PluginBench
Skill
Pass
Audit score 90

discover-analytics-patterns

amplitude/mcp-marketplace

Discover how your codebase instruments analytics events—SDK calls, patterns, and naming conventions.

What is discover-analytics-patterns?

Analyzes your repository to identify the concrete analytics tracking patterns, SDK calls, and naming conventions already in use. Run this before adding new analytics instrumentation to ensure consistency with existing code style and event/property naming standards.

  • Locates all analytics tracking call sites using SDK detection and custom wrapper discovery
  • Groups tracking calls by pattern (SDK type, method, argument structure) to identify reusable patterns
  • Extracts dominant event and property naming conventions from observed tracking code
  • Prioritizes customer directives from `.amplitude/instrumentation-agent-context.md` over inferred conventions
  • Outputs deduplicated patterns with file locations and generalized examples
  • Identifies custom analytics wrappers and distinguishes them from raw SDK calls

How to install discover-analytics-patterns

npx skills add https://github.com/amplitude/mcp-marketplace --skill discover-analytics-patterns
Prerequisites
  • Access to the codebase being analyzed
  • Optionally: `.amplitude/instrumentation-agent-context.md` file with customer directives (if conventions are pre-defined)
  • Optionally: Connected Amplitude MCP server for taxonomy reference (fallback to codebase grep if unavailable)
Claude Code
Cursor
Windsurf
Cline

How to use discover-analytics-patterns

  1. 1.Install the skill using the provided npm command
  2. 2.Run the skill on your repository to scan for existing analytics patterns
  3. 3.Review the output to understand current SDK usage, wrapper functions, and naming conventions
  4. 4.Use the identified patterns as a reference when writing new instrumentation code
  5. 5.Share the output with your team to align on analytics coding standards

Use cases

Good for
  • Before instrumenting new events, understand the existing tracking patterns to match code style
  • Onboard new engineers by showing them how analytics are actually implemented in the codebase
  • Audit analytics instrumentation consistency across a repository
  • Prepare context for the `instrument-events` skill to generate code in the correct style
  • Resolve naming convention questions ('Do we use snake_case or camelCase for events?')
Who it's for
  • Frontend and backend engineers adding analytics to existing codebases
  • Analytics engineers reviewing instrumentation consistency
  • Teams onboarding to Amplitude or migrating analytics implementations
  • Developers using Claude Code or Cursor with analytics instrumentation workflows

discover-analytics-patterns FAQ

What if my codebase uses multiple analytics SDKs or patterns?

The skill groups and documents each pattern separately, showing which files use which approach. This helps you understand the full landscape and choose which pattern to follow for new code.

Does this skill find events in test or mock files?

Test and mock files are excluded unless they are the only place a pattern appears. This keeps the output focused on production instrumentation patterns.

How does it handle custom analytics wrappers?

Custom wrappers (like `trackEvent()` or `useAnalytics()` hooks) are treated as distinct patterns from the underlying SDK, since engineers will use the wrapper directly rather than the raw SDK.

What if my naming conventions aren't consistent across the codebase?

The skill identifies the dominant convention and notes meaningful exceptions, giving you a clear picture of what to standardize on going forward.

Can I override the inferred conventions?

Yes—create `.amplitude/instrumentation-agent-context.md` in your repo root with explicit naming conventions and SDK preferences. These directives take precedence over all inferred patterns.

Full instructions (SKILL.md)

Source of truth, from amplitude/mcp-marketplace.


name: discover-analytics-patterns description: > 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

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

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.

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 forWhy
\.track\(Generic .track() method calls
ampli\.Ampli typed SDK calls (e.g. ampli.myEvent(...))
amplitude\.track|amplitude\.logEventDirect Amplitude SDK calls
sendEventCustom wrapper method names
from.*amplitude|import.*amplitude|require.*amplitudeImport statements
https://api2\.amplitude\.com/2/httpapiHTTP 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 event names and property names returned by the active taxonomy reader 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.