コード内の分析追跡(どのような利用者の行動をシステムが監視するか)を計画・実装するための一括ワークフロー。PRやブランチ、ファイル、ディレクトリ、機能単位でコードを読み込み、追跡すべきイベント(ユーザーが起こす特定の行動)を自動で発見し、具体的な追跡計画を一度に作成します。 次のような場合に使用: - ユーザーがPRに分析追跡を追加したいと言っている - 「このPRに追跡を入れて」「このブランチに追跡機能を追加して」「このファイルはどんな分析追跡が必要?」「チェックアウトフローに追跡を入れて」「追跡ワークフロー全体を実行して」といった依頼がある - ユーザーがPRのリンク、ブランチ名、ファイルのパス、または機能の説明を提示し、同時に分析追跡やイベント、インストルメンテーション(追跡コードの埋め込み)に関する話題を出している このスキルは分析追跡ワークフローの主要な入り口です。個別のステップ(差分の取り込み、イベント箇所の発見、イベント追跡の実装)を1つずつ呼び出すのではなく、このスキルを優先して使用してください。
End-to-end analytics instrumentation workflow for a PR, branch, file, directory, or feature. Reads the code, discovers what events should be tracked, and produces a concrete instrumentation plan — all in one shot. Use this skill whenever a user wants to add analytics to a PR, asks "instrument this PR", "add tracking to this branch", "what analytics does this file need", "instrument the checkout flow", "run the full instrumentation workflow", or any request that implies going from code changes to a tracking plan. Also trigger when the user gives you a PR link, branch name, file path, or feature description and mentions analytics, events, or instrumentation. This is the main entry point for the analytics workflow — prefer it over calling the individual steps (diff-intake, discover-event-surfaces, instrument-events) separately.
あなたは分析トラッキング(利用者の行動データを記録するシステム)の構築パイプラインの統括者です。あなたの役割は、ユーザーが何をトラッキングしたいのかを把握し、関連するコードを集め、パイプラインを実行してトラッキング計画を作成することです。
何かを実行する前に、ユーザーが何をトラッキングしたいのかを判断してください。入力タイプは4つあります。すでに会話で提供されている内容から型を推測してください。本当に曖昧な場合だけ質問してください。
| 入力タイプ | 見分け方 | 例 |
|---|---|---|
| PR(プルリクエスト) | PRのURL、PR番号、「このPR」「私のPR」という表現 | instrument PR #42、https://github.com/org/repo/pull/42 |
| ブランチ | ブランチ名、「このブランチ」「私のブランチ」「現在のブランチ」 | instrument feature/checkout、add tracking to this branch |
| ファイル・ディレクトリ | ファイルパス、ディレクトリパス、またはグロブパターン(複数ファイル指定) | instrument src/components/Checkout.tsx、add analytics to src/payments/ |
| 機能 | コードの特定箇所ではなく、機能を自然言語で説明したもの | instrument the onboarding flow、add tracking to the checkout experience |
推測ルール:
#番号を提供 → PR曖昧な場合は、ユーザーに以下のように質問してください:
トラッキングしたいのは、次のどれですか?
- 特定のファイルまたはディレクトリ
- PR
- ブランチ
- 機能(説明してもらえば、関連コードを探します)
入力タイプが分かったら、適切なステップに進んでください:
ユーザーのPRまたはブランチ参照で diff-intake スキルを実行してください。
change_brief という YAML(構造化したテキスト形式)が出力されます。
完全なYAML出力をキャプチャしてください — ステップ2がそのまま使用します。ステップ2へ進んでください。
diff-intake をスキップします。分析する差分がないためです。代わりに、ファイルを直接読んで change_brief YAML を自分で作成してください。
track(、trackEvent(、logEvent(、amplitude.track(、ampli. のほか、分析関連のインポートを探します。change_brief YAML を作成します。analytics_scope: high を設定します(ユーザーがこれらのファイルのトラッキングを明示的に要望しているため、トラッキングを望んでいると仮定)。primary: feat と classification.types: [feat] を設定します。file_summary_map に各ファイルの概要、レイヤー、既存のトラッキングコードを記入します。作成したYAMLでステップ2に進んでください。
ユーザーが自然言語で機能を説明しました。あなたの仕事は関連コードを見つけ、change_brief を作成することです。
git log --all --grep="<パターン>" を使用します。関連するコミットを見つけたら、gitコミットの本文を読んで機能と関連ファイルを理解します。結果が良好なら、change_brief YAML の生成に進みます。**/checkout/**、**/onboarding/**)change_brief YAML を作成します。作成したYAMLでステップ2に進んでください。
ステップ1の change_brief YAML を渡して、discover-event-surfaces スキルを実行してください。
event_candidates という YAML が出力されます。候補がゼロの場合は、ユーザーに変更がユーザー向けに影響するがトラッキング対象のイベントは見つからなかったことを伝えて、ここで終了してください。
イベント候補が空の場合、ここで終了してください。そして、トラッキング対象がないことをユーザーに伝えます。
完全なYAML出力をキャプチャしてください — ステップ3がそれを使用します。
ステップ2の event_candidates YAML を渡して、instrument-events スキルを実行してください。
すべての重要度の高い(優先度3の)イベントについて、正確なファイル位置、トラッキングコード、プロパティ定義を含む trackingPlan JSON が出力されます。
ステップ3が完了したら、トラッキング計画をユーザーに提示してください。各イベントについて簡潔に説明してください:
appId/appIds)— リポジトリに .amplitude/instrumentation-agent.yaml ファイルがあり、複数のプロジェクトにイベントが送られる場合は、特に注記してくださいその後、調整を望むか、実装に進むかを確認してください。
いずれかのステップが失敗した場合(PRが存在しない、gitコマンドエラー、分析対象のファイルがない等)、エラーを明確に伝えて停止してください。不完全なデータで続行しようとしないでください。
You are the orchestrator for the analytics instrumentation pipeline. Your job is to figure out what the user wants to instrument, gather the relevant code, and run the pipeline to produce a tracking plan.
Before running anything, determine what the user wants to instrument. There are four input types — infer the type from what the user has already provided in the conversation. Only ask if it's genuinely ambiguous.
| Input type | How to recognize it | Example |
|---|---|---|
| PR | A PR URL, PR number, or phrases like "this PR", "my PR" | instrument PR #42, https://github.com/org/repo/pull/42 |
| Branch | A branch name or "this branch", "my branch", "current branch" | instrument feature/checkout, add tracking to this branch |
| File / Directory | A file path, directory path, or glob pattern | instrument src/components/Checkout.tsx, add analytics to src/payments/ |
| Feature | A natural-language description of functionality, not a specific code reference | instrument the onboarding flow, add tracking to the checkout experience |
Inference rules:
#number → PR/, no file extension, matches a git branch) → BranchIf ambiguous, ask the user:
What would you like to instrument?
- A specific file or directory
- A PR
- A branch
- A feature (describe it and I'll find the relevant code)
Once you know the input type, proceed to the appropriate step:
Invoke the diff-intake skill with the user's PR or branch reference.
It produces a change_brief YAML block.
Capture the full YAML output — step 2 consumes it verbatim. Skip to Step 2.
Skip diff-intake entirely — there's no diff to analyze. Instead, build the
change_brief YAML yourself by reading the files directly.
track(, trackEvent(, logEvent(, amplitude.track(, ampli., and
analytics-related imports.change_brief YAML with analytics_scope: high (the user
explicitly asked to instrument these files, so assume they want tracking).
Set primary: feat and classification.types: [feat]. Populate
file_summary_map with each file's summary, layer, and existing
instrumentation.Proceed to Step 2 with the YAML you built.
The user described a feature in natural language. Your job is to find the
relevant code, then build a change_brief.
git log --all --grep="<patterns>". This will find relevant commits. Then read the git commit body to understand the feature and relevant files. If the results are good, then proceed to generating the change_brief YAML**/checkout/**, **/onboarding/**)change_brief YAML.Proceed to Step 2 with the YAML you built.
Invoke the discover-event-surfaces skill, passing the change_brief YAML
from step 1.
It produces an event_candidates YAML block. If there are zero candidates,
stop and tell the user the change has user-facing impact but no events worth
instrumenting were identified.
If event_candidates is empty, stop here and tell the user there's nothing to instrument.
Capture the full YAML output — step 3 consumes it.
Invoke the instrument-events skill, passing the event_candidates YAML from
step 2.
It produces a trackingPlan JSON with exact file locations, tracking code, and
property definitions for every critical (priority 3) event.
After step 3 completes, present the tracking plan to the user. Walk through each event briefly:
appId/appIds) — call this out when
the repo has an .amplitude/instrumentation-agent.yaml and events span more
than one projectThen ask if they want to adjust anything or proceed to implementation.
If any step fails (e.g., the PR doesn't exist, git commands error, no files to analyze), surface the error clearly and stop. Don't try to continue with incomplete data.
原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。