• Projects
  • Service
  • About
  • branding.bz
  • Podcast
  • Tips
  • FAQ
  • Recruit
  • Download
  • Contact
  • branding.bz(ブランド構築SaaS)
  • DESIGN NOW(デザインメディア)
  • X
  • LinkedIn
  • Spotify
  • Facebook

213-0011 神奈川県川崎市高津区久本3-6-7-303

© 2026 ID INC. All rights reserved

claude-skills/スキル
SKILLOfficialmonitoring

add-analytics-instrumentation

プラグイン
amplitude
ソース
GitHub で見る ↗
説明

コード内の分析追跡(どのような利用者の行動をシステムが監視するか)を計画・実装するための一括ワークフロー。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.

ユースケース
  • PRやブランチに分析追跡を追加したい
  • ファイルやディレクトリに必要な追跡を確認する
  • 機能単位でイベント追跡を計画する
  • 追跡ワークフロー全体を実行する
本文(日本語訳)

add-analytics-instrumentation

あなたは分析トラッキング(利用者の行動データを記録するシステム)の構築パイプラインの統括者です。あなたの役割は、ユーザーが何をトラッキングしたいのかを把握し、関連するコードを集め、パイプラインを実行してトラッキング計画を作成することです。

パイプラインの流れ

ステップ0:ユーザーの意図を把握する

何かを実行する前に、ユーザーが何をトラッキングしたいのかを判断してください。入力タイプは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

推測ルール:

  • ユーザーがURLまたは#番号を提供 → PR
  • スラッシュを含む、ファイル拡張子がない、gitブランチのような名前に見える → ブランチ
  • ディスク上に存在するパス(ファイルまたはディレクトリ) → ファイル・ディレクトリ
  • 上記のいずれにも当てはまらず、説明的な内容 → 機能
  • 以前のメッセージにPRリンク、ブランチ名、ファイルパスがすでに含まれている場合は、それを使う(再度は聞かない)

曖昧な場合は、ユーザーに以下のように質問してください:

トラッキングしたいのは、次のどれですか?

  1. 特定のファイルまたはディレクトリ
  2. PR
  3. ブランチ
  4. 機能(説明してもらえば、関連コードを探します)

入力タイプが分かったら、適切なステップに進んでください:

  • PR またはブランチ → ステップ1へ(diff-intake スキル)
  • ファイル・ディレクトリ → ステップ1a へ(直接ファイル読み込み)
  • 機能 → ステップ1b へ(機能検索)

ステップ1:diff-intake スキル(PR またはブランチ)

ユーザーのPRまたはブランチ参照で diff-intake スキルを実行してください。

change_brief という YAML(構造化したテキスト形式)が出力されます。

完全なYAML出力をキャプチャしてください — ステップ2がそのまま使用します。ステップ2へ進んでください。

ステップ1a:直接ファイル読み込み(ファイル・ディレクトリ)

diff-intake をスキップします。分析する差分がないためです。代わりに、ファイルを直接読んで change_brief YAML を自分で作成してください。

  1. 入力を解決する。 ディレクトリの場合は、その中のすべてのソースファイルを探します(テスト、設定、ロックファイル、生成されたコードは除外)。単一ファイルの場合は、それを使用します。
  2. 各ファイルを読み、その役割をまとめます — 実装の詳細ではなく、ユーザー向けの動作に重点を置いてください。
  3. 既存のトラッキングコードをスキャンします。diff-intake と同じパターンを使用:track(、trackEvent(、logEvent(、amplitude.track(、ampli. のほか、分析関連のインポートを探します。
  4. change_brief YAML を作成します。analytics_scope: high を設定します(ユーザーがこれらのファイルのトラッキングを明示的に要望しているため、トラッキングを望んでいると仮定)。primary: feat と classification.types: [feat] を設定します。file_summary_map に各ファイルの概要、レイヤー、既存のトラッキングコードを記入します。

作成したYAMLでステップ2に進んでください。

ステップ1b:機能検索(機能)

ユーザーが自然言語で機能を説明しました。あなたの仕事は関連コードを見つけ、change_brief を作成することです。

  1. gitコミット履歴を検索して関連コミットを見つけてください。git log --all --grep="<パターン>" を使用します。関連するコミットを見つけたら、gitコミットの本文を読んで機能と関連ファイルを理解します。結果が良好なら、change_brief YAML の生成に進みます。
  2. コードベースを検索して、説明された機能に関連するファイルを見つけてください。以下を組み合わせて使用します:
    • 機能説明からのキーワード検索(コンポーネント名、ルートパス、関数名、ドメイン用語)
    • 可能性の高いファイルパスでのグロブ検索(例:**/checkout/**、**/onboarding/**)
    • ルート定義、ナビゲーション設定、またはインデックスファイルを読んでエントリーポイントを見つける
  3. change_brief YAML を作成します。

作成したYAMLでステップ2に進んでください。

ステップ2:discover-event-surfaces スキル

ステップ1の change_brief YAML を渡して、discover-event-surfaces スキルを実行してください。

event_candidates という YAML が出力されます。候補がゼロの場合は、ユーザーに変更がユーザー向けに影響するがトラッキング対象のイベントは見つからなかったことを伝えて、ここで終了してください。

イベント候補が空の場合、ここで終了してください。そして、トラッキング対象がないことをユーザーに伝えます。

完全なYAML出力をキャプチャしてください — ステップ3がそれを使用します。

ステップ3:instrument-events スキル

ステップ2の event_candidates YAML を渡して、instrument-events スキルを実行してください。

すべての重要度の高い(優先度3の)イベントについて、正確なファイル位置、トラッキングコード、プロパティ定義を含む trackingPlan JSON が出力されます。

結果を提示する

ステップ3が完了したら、トラッキング計画をユーザーに提示してください。各イベントについて簡潔に説明してください:

  • 何をトラッキングし、なぜそれが重要か
  • どのAmplitude プロジェクト(アナリティクスツール)に送られるか(appId/appIds)— リポジトリに .amplitude/instrumentation-agent.yaml ファイルがあり、複数のプロジェクトにイベントが送られる場合は、特に注記してください
  • トラッキングコードの配置場所(ファイル+関数)
  • 送信されるプロパティ(データ項目)

その後、調整を望むか、実装に進むかを確認してください。

エラー処理

いずれかのステップが失敗した場合(PRが存在しない、gitコマンドエラー、分析対象のファイルがない等)、エラーを明確に伝えて停止してください。不完全なデータで続行しようとしないでください。

原文(English)を表示

add-analytics-instrumentation

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.

Pipeline

Step 0: Capture intent

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:

  • If the user provided a URL or #number → PR
  • If the user provided something that looks like a branch name (contains /, no file extension, matches a git branch) → Branch
  • If the user provided a path that exists on disk (file or directory) → File / Directory
  • If none of the above match and the input is descriptive → Feature
  • If the conversation already contains a PR link, branch name, or file path from earlier messages, use that instead of asking again

If ambiguous, ask the user:

What would you like to instrument?

  1. A specific file or directory
  2. A PR
  3. A branch
  4. A feature (describe it and I'll find the relevant code)

Once you know the input type, proceed to the appropriate step:

  • PR or Branch → go to Step 1 (diff-intake)
  • File / Directory → go to Step 1a (direct file read)
  • Feature → go to Step 1b (feature search)

Step 1: diff-intake skill (PR or Branch)

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.

Step 1a: Direct file read (File / Directory)

Skip diff-intake entirely — there's no diff to analyze. Instead, build the change_brief YAML yourself by reading the files directly.

  1. Resolve the input. If a directory, find all source files in it (skip tests, config, lock files, generated code). If a single file, just use that.
  2. Read each file and summarize what it does — focus on user-facing behavior, not implementation details.
  3. Scan for existing instrumentation using the same patterns as diff-intake: track(, trackEvent(, logEvent(, amplitude.track(, ampli., and analytics-related imports.
  4. Build the 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.

Step 1b: Feature search (Feature)

The user described a feature in natural language. Your job is to find the relevant code, then build a change_brief.

  1. Search git commit history to find related commits. Use 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
  2. Search the codebase for files related to the described feature. Use a combination of:
    • Grep for keywords from the feature description (component names, route paths, function names, domain terms)
    • Glob for likely file paths (e.g., **/checkout/**, **/onboarding/**)
    • Read route definitions, navigation configs, or index files to find entry points
  3. Build the change_brief YAML.

Proceed to Step 2 with the YAML you built.

Step 2: discover-event-surfaces

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.

Step 3: instrument-events

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.

Presenting the result

After step 3 completes, present the tracking plan to the user. Walk through each event briefly:

  • What it tracks and why it matters
  • Which Amplitude project(s) it routes to (appId/appIds) — call this out when the repo has an .amplitude/instrumentation-agent.yaml and events span more than one project
  • Where the tracking call goes (file + function)
  • What properties it sends

Then ask if they want to adjust anything or proceed to implementation.

Error handling

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 による自動翻訳です。