• 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

discover-analytics-patterns

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

本コードベースにおけるアナリティクス(利用分析)トラッキング呼び出しが実際にどのように書かれているかを調査します。具体的な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.

ユースケース
  • 既存のアナリティクス実装パターンを理解する必要があるとき
  • コードベースのイベントトラッキング方法を確認するとき
  • アナリティクス計測コードを書く前に従うべきスタイルを知るとき
本文(日本語訳)

discover-analytics-patterns

このスキルの目的は、コードベースが分析イベント(データ送信)をどのように送信しているかを明らかにすることです。どんなイベントが存在するかではなく、エンジニアが追跡呼び出しを実行するために使う具体的なコードパターンを見つけることが重要です。このスキルの出力は、他のスキルに対して、このコードベースでイベント名やプロパティ名がどのように書かれているかを示します。また、新しいイベントを追加する際に、既存のコードと一貫性を保つのに役立ちます。

このスキルで命名規約を決定する際は、以下の優先順位に従ってください:

  1. .amplitude/instrumentation-agent-context.md に含まれるお客様の指定内容(参照されるファイルも含む)— 最優先。お客様が従いたい明示的な規約であり、以下のすべてをオーバーライドします。
  2. Amplitude MCP サーバーから観測されたイベントとプロパティ
  3. コードベース内の実際の追跡呼び出しサイト
  4. ../taxonomy/SKILL.md にある taxonomyスキル

Step 0: リポジトリの計測コンテキストを読む

まず、.amplitude/instrumentation-agent-context.md(リポジトリのルート、または計測対象のサブディレクトリ)があるかを確認します。存在する場合は、それと参照されるすべてのリポジトリ相対ファイルを読みます。そこに記載されている命名規約、プロパティ標準、SDK/ラッパーパターンはお客様の指定内容であり、以下で推測したものより優先されます。記録し、それでカバーされている部分の推測はスキップしてください。ファイルが存在しない場合は、続行してください。ユーザーにこのファイルの追加を促すのは instrument-events スキルの責務です。


Step 1: 追跡呼び出しを見つける

利用可能なものに応じて、2つのアプローチを使い分けます。

Amplitude MCPが接続されている場合

manage_amp_events を action: "get" と kind: "event" で呼び出し、プロジェクトからイベント名のサンプルを取得します。入力スキーマが _client を受け入れる場合、このスキルが行うすべての manage_amp_events 呼び出しは、ツール引数にトップレベル引数 "_client": { "type": "skill", "skill_name": "discover-analytics-patterns" } を含める必須です。そうでない場合は _client を省略します。結果を使用して、代表的なシステム以外の製品イベントをいくつか選び、それらのイベントに対して get_properties を呼び出し、実際のプロパティ名を確認します。これが主要な命名参照になります。

[Amplitude]、[Guides-Surveys]、[Assistant]、[Experiment] のようにブラケット(角括弧)で始まる Amplitude システム名からは、イベントやプロパティのいずれについても命名規約を推測しないでください。それらはパターン検出から除外します。MCP サンプルが Amplitude システム名で占められているか、十分な証拠を提供していない場合は、コードベース推測を命名のフォールバックとして使用します。

その後、Grep を使用してコードベースをサンプリングされた非システムイベント名で検索し、実際の追跡呼び出しサイトを見つけます。

Amplitude MCPが利用できない場合(フォールバック)

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 呼び出し

また、カスタム分析ラッパーを積極的に探してください。コードベースは通常、raw SDK を trackEvent()、track() などのユーティリティ、または useAnalytics() や useTracking() などの React フックでラップします。Amplitude の内部を呼び出す関数を探すことで、これらを見つけます。各ラッパーを独自のパターンとして扱い、基礎となる SDK 呼び出しとは別にします。最終的に内部で amplitude.track() を呼び出す場合でも。ラッパーに遭遇するエンジニアは、raw SDK ではなくラッパーを使用するため、より重要なパターンです。

ラッパーを見つけるには:Amplitude SDK をインポートするファイルを検索してから、これらのファイルのいずれかが、コードベースの他の部分がインポートして追跡に使用する関数またはフックをエクスポートしているかを確認します。

テストファイル(.test.、.spec.、__tests__)とモックファイルは除外します。ただし、パターンが唯一の場所に表示される場合は除外しません。


Step 2: パターンでグループ化する

2つの呼び出しサイトが同じパターンを使用するのは、以下を共有する場合です:

  • 呼び出されるライブラリ/SDK/関数
  • メソッド名
  • 引数構造(イベント名またはプロパティが異なる場合でも)

例えば、これらは同じパターンです:

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() をラップするカスタムフック」)。エンジニアはレイヤー構造を理解できます。


Step 3: 命名規約を解決する

2つの規約を別々に解決します:

  • event_naming_convention — 計測コード内のイベント名に使用される大文字小文字、区切り文字、単語順、プレフィックス、時制。例: Title Case、snake_case、[Prefix] Action、オブジェクト優先かアクション優先か。
  • property_naming_convention — イベントプロパティに使用される大文字小文字、区切り文字、共通のサフィックス/プレフィックスパターン。例: snake_case、camelCase、*_id、is_*、フラットキーかネストされたオブジェクトか。

この優先順位で使用します:

  1. リポジトリ計測コンテキストを最優先に。 .amplitude/instrumentation-agent-context.md(Step 0より)が明示的なイベントまたはプロパティ命名規約を述べている場合、それが最優先です。記録し、それが指定した部分の推測はスキップしてください。ファイルが存在しないか、命名について何も述べていない場合のみ、次に進みます。
  2. Amplitude MCPを2番目に。 観測された eventType 値といくつかの代表的なシステム以外のイベントの get_properties から返されたプロパティ名が明確な支配的規約を示している場合、それを使用します。ブラケット付き Amplitude システム名を命名証拠として使用しないでください。
  3. コードベースを3番目に。 MCP 証拠が利用できない、スパース、または矛盾している場合、リポジトリ内の近くの実際の追跡呼び出しサイトから支配的な規約を推測します。コードベースが複数の規約を示している場合、支配的なものを指摘し、意味のあるローカル例外を注記します。
  4. Taxonomy をフォールバックとして最後に。 上記のいずれも十分に明確でない場合、../taxonomy/SKILL.md の taxonomy スキルにフォールバックします。

推測しないでください。上記のソースをすべてチェックした後でも、1つまたは両方の規約が不明な場合は、明示的にそう述べてください。


Step 4: 出力

短い規約セクションから始まり、その後に各ユニークなパターンをリストします。

event_naming_convention: "<リポジトリコンテキストファイルが指定している場合、そうでなければ MCP が明確な場合、そうでなければコードベース、そうでなければ taxonomy スキル、または ' 証拠不足'>"
property_naming_convention: "<リポジトリコンテキストファイルが指定している場合、そうでなければ MCP が明確な場合、そうでなければコードベース、そうでなければ taxonomy スキル、または '証拠不足'>"

次に、各ユニークなパターンについて、この形式でセクションを出力します:


Pattern: <短い説明的な名前>

説明: このパターンが何をするか、このコードベースで通常どのような場合に使用されるか(例:「React フロントエンド全体でユーザーアクション追跡に使用」)。

例(一般化):

// 必要なインポートを表示
import { amplitude } from '@/lib/analytics'

// プレースホルダー名を使った代表的な追跡呼び出しを表示
amplitude.track('Event Name', {
  propertyOne: value,
  propertyTwo: value,
})

関連パス:

  • src/path/to/file.ts
  • src/another/file.tsx

パターンを最も一般的なもの(ファイルパスが最多)から最も一般的でないものの順にリストします。

2つのパターンが常に一緒に使用される場合(例:インポート+呼び出し)、1つの例でそれらを一緒に表示します。


Step 5: 結果がない場合

どの検索戦略でも追跡呼び出しが見つからない場合は、明確にそう述べてください。ユーザーに対して Amplitude(または別の分析ライブラリ)がプロジェクトでセットアップされているかどうかを確認することを提案し、関連する場合は他の分析ライブラリ(Segment、Mixpanel、PostHog など)を検索することを提案します。

原文(English)を表示

discover-analytics-patterns

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:

  1. Customer directives in .amplitude/instrumentation-agent-context.md (and any files it references), if present — explicit conventions the customer wants followed, so they override everything below.
  2. Events and properties observed from the Amplitude MCP server
  3. Real tracking call sites in the codebase
  4. The taxonomy skill at ../taxonomy/SKILL.md

Step 0: Read repo instrumentation context

Before 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.


Step 1: Find tracking calls

Use two approaches based on what's available.

If the Amplitude MCP is connected

Call manage_amp_events with action: "get" and kind: "event" to fetch a sample of event names from the project. If its input schema accepts _client, every manage_amp_events call made by this skill MUST include the top-level argument "_client": { "type": "skill", "skill_name": "discover-analytics-patterns" } in the tool arguments; otherwise, omit _client. Use those results to choose a few representative non-system product events, then call get_properties for those events 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.

If the Amplitude MCP is not available (fallback)

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.


Step 2: Group by pattern

Two call sites use the same pattern if they share the same:

  • Library/SDK/function being called
  • Method name
  • Argument structure (even if the event name or properties differ)

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.


Step 3: Resolve naming conventions

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:

  1. Repo instrumentation context first. If .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.
  2. Amplitude MCP second. If the observed eventType values and property names returned by get_properties for a few representative non-system events show a clear dominant convention, use that. Do not use bracket-prefixed Amplitude system names as naming evidence.
  3. Codebase third. If the MCP evidence is unavailable, sparse, or inconsistent, infer the dominant convention from nearby, real tracking call sites in the repository. If the codebase shows multiple conventions, call out the dominant one and note meaningful local exceptions.
  4. Taxonomy fallback last. If none of the above is clear enough, fall back to the taxonomy skill at ../taxonomy/SKILL.md.

Do not guess. If one or both conventions remain unclear even after checking those sources, say so explicitly.


Step 4: Output

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:


Pattern: <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.ts
  • src/another/file.tsx

List 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.


Step 5: Handle no results

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