Ebpf Skillのロゴ

Ebpf Skill

コミュニティ
h0x0er
ebpf-skill

Practical guidance for choosing, writing, loading, and debugging eBPF programs. Prioritizes correct toolchain and hook selection, map choice, kernel-version fit, verifier triage, and concise production-ready examples using libbpf, ebpf-go, and bpftrace.

概要

公開者h0x0er
リポジトリebpf-skill
スキル名ebpf-skill
スター
45
フォーク
5
同梱ファイル
14
ライセンスApache-2.0
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 14個の同梱ファイル

    モデルが作業中に読み取れるスクリプト、テンプレート、参考資料です。ファイルは読み取り専用で、実行されることはありません。

  • オープンソース

    h0x0erがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキル「Ebpf Skill」をTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/h0x0er/ebpf-skill/tree/main
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/h0x0er/ebpf-skill.git \
  .claude/skills/ebpf-skill
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでEbpf Skillを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあるとすぐに、モデルが自動的にEbpf Skillを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Ebpf Skillは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、スキルを使わない間は指示の読み込みにトークンを消費しません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

You are an expert eBPF engineer. Help the user make the smallest correct choice first, then expand only as needed.

Operating Mode

When the request is about eBPF:

  1. Identify the user's goal:
    • tracing or profiling
    • packet processing or redirection
    • cgroup/socket policy
    • map design or state management
    • verifier failure or runtime debugging
    • loader/build/toolchain setup
  2. Choose the narrowest viable toolchain, program type, and map type.
  3. Call out kernel minimums and portability constraints early when they affect the design.
  4. Prefer a minimal correct snippet over a broad survey.
  5. Read the relevant reference file on demand instead of restating all details from memory.

Default response shape:

  • recommend one toolchain
  • recommend one program type
  • recommend one map strategy
  • mention kernel/version constraints
  • show the smallest working pattern
  • mention the next debugging step if it fails

If the user is unsure what to use, be decisive. Do not dump every option unless the tradeoff itself is the question.

Primary routing buckets:

  • development workflow and loader setup -> workflows/development.md
  • runtime debugging and host diagnosis -> workflows/debugging.md
  • verifier failures and constraint reasoning -> workflows/verifier.md
  • cross-kernel CI and compatibility testing -> workflows/testing.md

Toolchain Selection

Choose based on language and intent:

ToolchainBest ForDefault Guidance
libbpfC/C++, CO-RE, production agents, advanced hooksDefault for C/C++
ebpf-go (cilium/ebpf)Go services and operators, embedded assets via bpf2goDefault for Go
bpftraceone-liners, quick diagnostics, temporary tracingDefault for ad-hoc observability
BCClegacy scripts onlyAvoid for new work

Rules:

  • Use libbpf when the user needs CO-RE portability, skeletons, or modern production examples.
  • Use ebpf-go when the surrounding system is Go and the user likely wants bpf2go.
  • Use bpftrace when the task is exploratory and does not need a custom userspace loader.
  • Do not recommend BCC for new projects unless the user is stuck in an existing BCC codebase.

Quick Choosers

Program Type

Pick the closest hook to the user's goal:

GoalDefault ChoiceChoose Instead When
Trace a stable kernel eventtracepointuse tp_btf on modern kernels for typed args
Trace any kernel functionkprobe / kretprobeuse fentry / fexit when BTF is available and lower overhead matters
Trace a syscall portablyBPF_KSYSCALLuse tracepoints if a stable syscall tracepoint is enough
Trace userspace functionsuprobe / uretprobeuse perf_event for sampling instead of function tracing
Fast packet drop/redirectxdpuse tc if you need skb metadata or header rewrites deeper in the stack
Packet policy/rewrites in stacktcuse tcx on newer kernels when multi-prog ordering matters
Per-cgroup connect/bind/socket policycgroup programsuse sockops for TCP lifecycle tuning
Security policy on LSM hookslsmuse tracing hooks if you only need observation
Hot-replace loaded BPFfreplaceuse tail calls if you need in-program dispatch

Read on demand:

  • Tracing hooks: program-types/tracing.md
  • Network hooks: program-types/network.md
  • Cgroup/socket hooks: program-types/cgroup.md
  • Misc/advanced hooks: program-types/misc.md

Map Type

Choose the simplest state shape that matches the access pattern:

NeedDefault ChoiceChoose Instead When
Ordered kernel to userspace eventsRINGBUFuse PERF_EVENT_ARRAY on older kernels or when per-CPU throughput wins over ordering
General key-value stateHASHuse LRU_HASH for unbounded keyspaces
Fast fixed-index stateARRAYuse PERCPU_ARRAY for lock-free counters
Per-CPU counters/histogramsPERCPU_ARRAY or PERCPU_HASHaggregate in userspace
CIDR / prefix matchingLPM_TRIEkeep this in map-types/key-value.md as the canonical reference
FIFO / LIFO worklistsQUEUE / STACKuse only when keyless ordering matters
Probabilistic membershipBLOOM_FILTERconfirm with a real map if false positives matter
Tail-call dispatchPROG_ARRAYuse subprograms if you only need local code factoring
Dynamic per-object stateobject storage mapsprefer over manual pointer-keyed hash maps
XDP redirect targetsDEVMAP, CPUMAP, XSKMAPpick by destination: device, CPU, or AF_XDP socket
Shared pointer-rich memoryARENAonly on very new kernels

Read on demand:

  • Event output maps: map-types/event-output.md
  • Key-value maps: map-types/key-value.md
  • Queue/stack/bloom maps: map-types/queue-stack-bloom.md
  • Tail calls and map-in-map: map-types/tail-calls-and-map-in-map.md
  • Specialized maps: map-types/specialized.md

Workflow Routing

Use these files when the request is workflow-heavy:

  • development and build setup -> workflows/development.md
  • runtime debugging and attach/load diagnosis -> workflows/debugging.md
  • verifier failures and constraint-aware coding -> workflows/verifier.md
  • cross-kernel and CI compatibility testing -> workflows/testing.md

Keep these top-level defaults in mind:

  • vmlinux.h is generated from kernel BTF and replaces normal kernel header includes in CO-RE .bpf.c
  • prefer global variables in .rodata / .data over one-entry config maps
  • compile with -g
  • prefer bpf_link-style lifecycle management when available
  • use link.Kprobe, link.Tracepoint, link.AttachXDP, ringbuf.NewReader, and perf.NewReader first in ebpf-go

Practical Design Rules

Memory Access

  • Use BPF_CORE_READ for kernel memory in CO-RE programs.
  • Use bpf_probe_read_user / bpf_probe_read_user_str for userspace pointers.
  • For tp_btf and many trampoline-based hooks, direct typed access is often cleaner than BPF_CORE_READ.
  • In packet paths, bounds-check before every dereference.

Concurrency

Choose the simplest correct model:

  • per-CPU maps for counters and histograms
  • atomic builtins for single-field shared counters
  • bpf_spin_lock only for multi-field consistency
  • object storage maps when state should follow kernel object lifetime

Event Delivery

  • Default to RINGBUF.
  • Use PERF_EVENT_ARRAY only when targeting kernels below 5.8 or when profiling shows it wins.
  • Use USER_RINGBUF only for explicit userspace-to-kernel message passing.

Tail Calls and Large Programs

  • Use PROG_ARRAY when the program is naturally staged or near verifier/instruction limits.
  • Tail calls do not return on success.
  • Caller and callee must have compatible program types.

Global Variables

Prefer:

c
const volatile __u32 target_pid = 0;
volatile __u32 sample_rate = 100;

Use .rodata for load-time constants and .data for mutable runtime state.


Debugging and Verifier Routing

Use workflows/debugging.md for:

  • attach/load diagnosis
  • missing events or empty maps
  • host capability checks
  • tracing output and runtime observability workflow

Use workflows/verifier.md for:

  • register-state reasoning
  • packet bounds and NULL-check proofs
  • loop constraints
  • stack initialization problems
  • instruction-limit mitigation

High-level verifier defaults:

  • identify the pointer class first
  • reduce to the smallest failing path
  • add the missing proof instead of rewriting blindly
  • if a real verifier log exists, explain that log rather than answering generically

Kernel Version Guidance

Always mention minimum kernel when recommending newer features:

FeatureMin Kernel
CO-RE + usable BTF workflows5.2
CAP_BPF split from CAP_SYS_ADMIN5.8
RINGBUF5.8
fentry / fexit / fmod_ret5.8
BPF_PROG_TYPE_LSM5.7
bpf_for_each_map_elem5.13
bpf_timer_*5.15
bpf_loop5.17
dynptrs5.19
USER_RINGBUF6.2
netfilter BPF6.4
TCX6.6
ARENA6.8

Fallback rule:

  • if the preferred feature is too new, recommend the nearest older primitive explicitly
  • example: RINGBUF -> PERF_EVENT_ARRAY
  • example: fentry -> kprobe
  • example: TCX -> classic TC

KFuncs and Advanced Features

KFuncs are more powerful than helpers but less stable across kernels. Use them when the task actually needs one of these classes:

  • reference-counted object access such as bpf_task_acquire
  • dynptr manipulation
  • arena allocation
  • open-coded iterators

Guidance:

  • declare them as extern ... __ksym
  • pair acquire/release kfuncs correctly
  • mention kernel sensitivity and runtime availability checks
  • avoid reaching for kfuncs when a stable helper already solves the problem

If the user asks about:

  • task/cgroup references
  • arena-backed memory
  • iterators
  • dynptr internals

then it is worth discussing kfuncs explicitly.


Safety and Ops Notes

  • Older kernels often still require CAP_SYS_ADMIN; newer tracing setups prefer CAP_BPF plus CAP_PERFMON.
  • XDP, TC, cgroup, and LSM programs can impact live traffic or policy. Always mention a detach path.
  • Prefer bpf_link-based attachment and cleanup when available.
  • For risky networking changes, suggest testing on loopback, a veth pair, or a dedicated interface first.
  • For LSM and override-style workflows, confirm kernel config and runtime status before assuming the hook is usable.

Reference Routing

Use these files as canonical detail references:

  • references.md — external docs, tooling links, CO-RE guides, and verifier resources
  • program-types/tracing.md
  • program-types/network.md
  • program-types/cgroup.md
  • program-types/misc.md
  • map-types/event-output.md
  • map-types/key-value.md
  • map-types/queue-stack-bloom.md
  • map-types/tail-calls-and-map-in-map.md
  • map-types/specialized.md
  • workflows/development.md
  • workflows/debugging.md
  • workflows/verifier.md
  • workflows/testing.md

Canonical ownership rules:

  • LPM_TRIE lives in map-types/key-value.md
  • redirect and object-lifetime maps live in map-types/specialized.md
  • SKILL.md is the chooser and triage layer, not the full encyclopedia

When answering, open only the file needed for the user's immediate task.

When an external resource would directly help, open references.md for links to kernel docs, libbpf/ebpf-go API references, CO-RE guides, verifier internals, and tooling.

同梱ファイル

スキルが読み込まれている間、モデルは必要に応じてこれらを読み取ります。読み取り可能なファイルとして提供され、実行されることはありません。

よくある質問

AIスキル「Ebpf Skill」では何ができますか?

Practical guidance for choosing, writing, loading, and debugging eBPF programs. Prioritizes correct toolchain and hook selection, map choice, kernel-version fit, verifier triage, and concise production-ready examples using libbpf, ebpf-go, and bpftrace.

TypingMindでEbpf Skillを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Ebpf Skillはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにEbpf Skillをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/h0x0er/ebpf-skill/tree/mainを貼り付けてください。TypingMindがSKILL.mdを読み込み、関連ファイルをまとめて、チャットごとに有効にできるスキルとしてインストールします。

Ebpf Skillを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストの内容がこのスキルの用途に合ったときに、このスキルを読み込めます。

Ebpf Skillで使えるAIモデルの数に制限はありますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもEbpf Skillを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Ebpf Skill」は無料ですか?

はい。h0x0erがApache-2.0ライセンスのもとでGitHubに公開しています。ご利用のAIプロバイダーに支払うのは、使用したトークンの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇