本コードベースにおけるアナリティクス(利用分析)トラッキング呼び出しが実際にどのように書かれているかを調査します。具体的なSDK(ソフトウェア開発キット)呼び出し、関数シグネチャ(関数の形式)、イベント送信に使用されるインポートパターンを特定します。 **次のような場合に使用:** - 新しいトラッキングを追加する前に既存のアナリティクス実装パターンを理解する必要があるとき - 「ここではイベントをどのように追跡していますか?」「アナリティクスの設定を見せてください」「このコードベースのアナリティクスパターンは何ですか?」といった質問が出ているとき - instrument-events(イベント計測)スキルやdiscover-event-surfaces(イベント対象領域の発見)スキルを実行する前に、従うべき正しいコーディングスタイルを知る必要があるとき **出力内容:** 各パターンについて、重複を除いた汎化された例とそのパターンが現れるファイルパス、さらにそれらの呼び出し箇所から推測されたイベント名とプロパティ(属性)の命名規則を表示します。 **重要:** アナリティクス計測コードを書く際は、必ず最初にこのスキルを使用してください。
Discovers how analytics tracking calls are actually written in this codebase — the concrete SDK calls, function signatures, and import patterns used to send events. Use this skill whenever you need to understand the existing analytics instrumentation patterns before adding new tracking, when someone asks "how do we track events here?", "show me the analytics setup", "what's the analytics pattern in this codebase?", or any time the instrument-events or discover-event-surfaces skills are about to run and you need to know the correct coding style to follow. Outputs a deduplicated list of patterns with generalized examples and the file paths where each pattern appears, plus the dominant event and property naming conventions inferred from those call sites. Always use this skill before writing any analytics instrumentation code.
このスキルの目的は、コードベース内でどのように分析イベント(ユーザー行動の追跡データ)を送信しているかという方法を把握することです。存在するイベントの種類を調べるのではなく、エンジニアがトラッキング呼び出しを実行するために使っている具体的なコードパターンを見つけます。
この出力によって、エンジニアは新しいイベントを既存コードベースと一貫性を保つ形で追加できるようになります。また、他のスキルに対して、このリポジトリでイベント名やプロパティ名(データ項目名)がどのように書かれているかを伝えることもできます。
このスキルで命名規則を決める際は、以下の優先順位を厳密に守ってください:
.amplitude/instrumentation-agent-context.md(およびそこで参照されているファイル)に記載されたお客様の指示 — 存在する場合、これが最優先です../taxonomy/SKILL.mdのtaxonomyスキル最初に、.amplitude/instrumentation-agent-context.md(リポジトリのルート、または計測対象のサブディレクトリ)があるかを確認してください。ファイルが存在する場合は、それと参照されているすべてのファイルを読んでください。記載されている命名規則、プロパティ基準、SDK/ラッパーパターンはすべてお客様の指示であり、以下で推測した内容よりも優先されます。これらを記録して、カバーされている部分の推測はスキップしてください。ファイルがない場合は、続行してください — instrument-eventsスキルがユーザーにファイル追加を促す責任を持っています。
利用可能なものに基づいて、2 つのアプローチを使い分けてください。
接続されたカタログを検査して、そのタクソノミー(分類体系)リーダーを使用してプロジェクトからサンプルのイベント名を取得します。リーダーがアドバタイズしているスキーマに従ってください。呼び出し元の帰属が可能な場合は、YAML フロントマターのnameを使ってこのスキルを識別します。結果を使用して、代表的な非システムプロダクトイベントをいくつか選んだら、そのイベント・プロパティ読み取り機能を使用して実際のプロパティ名を検査します。これが主要な命名参照になります。
[Amplitude]、[Guides-Surveys]、[Assistant]、[Experiment]などの角括弧で始まる Amplitude システム名からは、イベント名でもプロパティ名でも命名規則を推測しないでください。パターン検出からは除外してください。MCP のサンプルが Amplitude システム名で占められているか、十分な根拠がない場合は、命名規則の推測はコードベースにフォールバック(切り替え)してください。
その後、Grep を使用してコードベース内でサンプルの非システムイベント名を検索し、実際のトラッキング呼び出し箇所を見つけます。
Grep を使用してコードベース内でこれらのシグナルを検索してください。広く検索してから、あとで絞り込むことができます:
| 検索対象 | 理由 |
|---|---|
\.track\( |
汎用の .track()メソッド呼び出し |
ampli\. |
Ampli(型付き SDK)呼び出し(例:ampli.myEvent(...)) |
amplitude\.track|amplitude\.logEvent |
直接的な Amplitude SDK 呼び出し |
sendEvent |
カスタムラッパーメソッド名 |
from.*amplitude|import.*amplitude|require.*amplitude |
インポートステートメント(取り込み宣言) |
https://api2\.amplitude\.com/2/httpapi |
HTTP API 呼び出し |
また、カスタム分析ラッパーも積極的に探してください — コードベースは多くの場合、生の SDK をtrackEvent()、track()などのユーティリティ、またはuseAnalytics()やuseTracking()といった React フック(部品)でラップしています。Amplitude 内部を呼び出す関数を探すことで、これらを見つけることができます。各ラッパーを、基盤の SDK 呼び出しとは別のパターンとして扱ってください。結局のところamplitude.track()を呼び出していても関係ありません。ラッパーを使用するエンジニアは、生の SDK ではなくラッパーそのものを使用するため、より重要なパターンです。
ラッパーを探すには:Amplitude SDK をインポートするファイルを検索してから、コードベースの他の部分がトラッキングに使用するためにインポートして使用する関数またはフックをエクスポートしているかどうかを確認します。
テストファイル(.test.、.spec.、__tests__)とモックファイルは、そのパターンが唯一の登場箇所である場合を除き、除外してください。
2 つの呼び出し箇所が同じパターンである条件:
例えば、以下は同じパターンです:
amplitude.track('Page Viewed', { page: '/home' })
amplitude.track('Button Clicked', { label: 'signup' })
しかし以下は異なるパターンです — 常に分けてください:
amplitude.track('Page Viewed', { page: '/home' }) // 直接 SDK — パターン 1
ampli.pageViewed({ page: '/home' }) // Ampli 型付きメソッド — 異なるパターン
trackEvent('Page Viewed', { page: '/home' }) // カスタムラッパー — 別パターン
カスタムラッパーは、SDK に委譲していても、常に独立したパターンです。ラッパーパターンを文書化する際は、それが何をラップしているか(例:「amplitude.track()をラップするカスタムフック」)を明記して、エンジニアが階層構造を理解できるようにしてください。
以下の 2 つの規則を別々に決定してください:
event_naming_convention — 計測コード内のイベント名に使われる大文字小文字の表記、区切り文字、単語の順序、接頭辞、時制。例:Title Case、snake_case、[接頭辞] 動作、オブジェクト優先対動作優先property_naming_convention — イベントプロパティに使われる大文字小文字の表記、区切り文字、共通の接尾辞・接頭辞パターン。例:snake_case、camelCase、*_id、is_*、フラット構造対ネストされたオブジェクトこの優先順位を使用してください:
リポジトリ計測コンテキストを最初に確認。 ステップ 0 で読んだ.amplitude/instrumentation-agent-context.mdに明示的なイベント名またはプロパティ名の命名規則が記載されている場合、それが確定です — 記録して、それが指定する部分の推測はスキップしてください。ファイルが存在しないか、命名について記載がない場合のみ次に進んでください。
Amplitude MCP を次に確認。 アクティブなタクソノミーリーダーが返す観測済みのイベント名・プロパティ名(複数の代表的な非システムイベントから)が明確な支配的規則を示している場合、それを使用します。角括弧で始まる Amplitude システム名を命名根拠として使用しないでください。
コードベースを 3 番目に確認。 MCP のエビデンスが利用不可、乏しい、または矛盾している場合は、リポジトリ内の近くの実際のトラッキング呼び出し箇所から支配的な規則を推測します。コードベースに複数の規則が見られる場合は、支配的なものを指摘して、意味のある例外を注記してください。
タクソノミースキルを最後にフォールバック。 上記のすべてで十分に明確でない場合は、../taxonomy/SKILL.mdのtaxonomyスキルにフォールバックしてください。
推測しないでください。上記のソースを確認しても一方または両方の規則が不明確な場合は、明確にそう述べてください。
簡潔な規則セクションで始めてから、各ユニークなパターンをリストします。
event_naming_convention: "<リポジトリコンテキストファイルで指定されていれば、そうでなければ MCP、そうでなければコードベース、そうでなければタクソノミースキル、それでなければ '根拠が不足'>"
property_naming_convention: "<リポジトリコンテキストファイルで指定されていれば、そうでなければ MCP、そうでなければコードベース、そうでなければタクソノミースキル、それでなければ '根拠が不足'>"
その後、各ユニークなパターンについて、以下の形式でセクションを出力します:
<簡潔な説明名>説明:このパターンが行うこと、およびこのコードベースで通常使われる場面(例:「React フロントエンド全体でユーザーアクション追跡に使用」)
例(一般化した形):
// 必要なインポート
import { amplitude } from '@/lib/analytics'
// プレースホルダー名を含む代表的なトラッキング呼び出し
amplitude.track('Event Name', {
propertyOne: value,
propertyTwo: value,
})
関連パス:
src/path/to/file.tssrc/another/file.tsxパターンは最も一般的なもの(ファイルパスが最も多い)から最も一般的でないものへと並べてください。
2 つのパターンが常に一緒に使われる場合(例:インポート + 呼び出し)は、1 つの例で一緒に示してください。
どの検索戦略でもトラッキング呼び出しが見つからない場合は、明確にそう述べてください。ユーザーに対して、プロジェクトで Amplitude(または別の分析ライブラリ)がセットアップされているかを確認することを勧め、関連があれば他の分析ライブラリ(Segment、Mixpanel、PostHog など)を検索することを提案してください。
Your goal is to find out how this codebase sends analytics events — not which events exist, but the specific code patterns engineers use to fire a tracking call. This output helps engineers add new events that look consistent with the rest of the codebase. It should also tell downstream skills how event names and property names are typically written in code here.
When determining naming conventions in this skill, use the following sources in strict order of preference:
.amplitude/instrumentation-agent-context.md (and any files it references), if present — explicit conventions the customer wants followed, so they override everything below.taxonomy skill at ../taxonomy/SKILL.mdBefore anything else, check for .amplitude/instrumentation-agent-context.md
(repo root, or the subdirectory you're instrumenting). If it exists, read it and
any repo-relative files it references. Any naming conventions, property
standards, or SDK/wrapper patterns it states are customer directives — they
take precedence over everything you infer below; record them and skip inference
for whatever they cover. If it's absent, just continue — the instrument-events
skill owns prompting the user to add one.
Use two approaches based on what's available.
Inspect the connected catalog and use its current taxonomy reader to fetch a
sample of event names from the project. Follow only the reader's advertised
schema. When it supports caller attribution, identify this skill with the
name from its YAML frontmatter. Use those results to choose a few
representative non-system product events, then use its
event-property read capability to inspect real property names. This is your
primary naming reference.
Do not infer naming conventions from bracket-prefixed Amplitude system names
such as [Amplitude], [Guides-Surveys], [Assistant], [Experiment] for either events or properties. Exclude those from
pattern detection. If the MCP sample is dominated by Amplitude system names or otherwise does not provide enough evidence, fall back to codebase
inference for naming.
Then search the codebase for the sampled non-system event names using Grep to locate the actual tracking call sites.
Search the codebase for these signals using Grep. Cast a wide net — you can narrow down after:
| What to search for | Why |
|---|---|
\.track\( |
Generic .track() method calls |
ampli\. |
Ampli typed SDK calls (e.g. ampli.myEvent(...)) |
amplitude\.track|amplitude\.logEvent |
Direct Amplitude SDK calls |
sendEvent |
Custom wrapper method names |
from.*amplitude|import.*amplitude|require.*amplitude |
Import statements |
https://api2\.amplitude\.com/2/httpapi |
HTTP API calls |
Also actively look for custom analytics wrappers — a codebase often wraps the
raw SDK in a utility like trackEvent(), track(), or a React hook like
useAnalytics() or useTracking(). Search for these by looking for functions
that call into Amplitude internally. Treat each wrapper as its own pattern,
separate from the underlying SDK call, even if it ultimately calls
amplitude.track() underneath. Engineers who encounter the wrapper will use
it, not the raw SDK — so it's the more important pattern to document.
To find wrappers: search for files that import the Amplitude SDK, then check whether any of those files export a function or hook that other parts of the codebase import and use for tracking.
Exclude test files (.test., .spec., __tests__) and mock files unless they
are the only place a pattern appears.
Two call sites use the same pattern if they share the same:
For example, these are the same pattern:
amplitude.track('Page Viewed', { page: '/home' })
amplitude.track('Button Clicked', { label: 'signup' })
But these are different patterns — always keep them separate:
amplitude.track('Page Viewed', { page: '/home' }) // direct SDK — one pattern
ampli.pageViewed({ page: '/home' }) // Ampli typed method — different pattern
trackEvent('Page Viewed', { page: '/home' }) // custom wrapper — also a separate pattern
A custom wrapper is always its own pattern, even if it delegates to the SDK
underneath. When documenting a wrapper pattern, note what it wraps (e.g.,
"Custom hook wrapping amplitude.track()") so engineers understand the layering.
Resolve two conventions separately:
event_naming_convention — casing, separators, word order, prefixes, and
tense used for event names in instrumentation code. Examples: Title Case,
snake_case, [Prefix] Action, object-first vs action-first.property_naming_convention — casing, separators, and common suffix/prefix
patterns used for event properties. Examples: snake_case, camelCase,
*_id, is_*, flat keys vs nested objects.Use this precedence order:
.amplitude/instrumentation-agent-context.md (from Step 0) states an explicit
event or property naming convention, it wins outright — record it and skip
inference for whatever it specifies. Only fall through when the file is absent
or silent on naming.taxonomy skill at ../taxonomy/SKILL.md.Do not guess. If one or both conventions remain unclear even after checking those sources, say so explicitly.
Start with a short conventions section, then list each unique pattern.
event_naming_convention: "<from repo context file if it specifies one, else MCP if clear, else codebase, else taxonomy skill, or 'insufficient evidence'>"
property_naming_convention: "<from repo context file if it specifies one, else MCP if clear, else codebase, else taxonomy skill, or 'insufficient evidence'>"
Then, for each unique pattern, output a section in this format:
<short descriptive name>Description: What this pattern does and when it's typically used in this codebase (e.g., "Used throughout the React frontend for user action tracking").
Example (generalized):
// show the import(s) needed
import { amplitude } from '@/lib/analytics'
// show a representative tracking call with placeholder names
amplitude.track('Event Name', {
propertyOne: value,
propertyTwo: value,
})
Relevant paths:
src/path/to/file.tssrc/another/file.tsxList patterns from most common (most file paths) to least common.
If two patterns are always used together (e.g., an import + a call), show them together in one example.
If no tracking calls are found with any search strategy, say so clearly. Suggest that the user check whether Amplitude (or another analytics library) has been set up in the project, and offer to search for other analytics libraries (Segment, Mixpanel, PostHog, etc.) if relevant.
原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。