[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7B2RJZ1AVNDX2AKPAT6T3YN":3,"skill-same:01M7B2RJZ1AVNDX2AKPAT6T3YN":54},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":25,"commitSha":26,"skillDirectory":27,"forksCount":28,"repositoryHtmlUrl":29,"repositoryHomepageUrl":6,"ownerHtmlUrl":30,"ownerBlogUrl":31,"ownerDescription":32,"updatedAt":33,"install":34,"resources":47},"01M7B2RJZ1AVNDX2AKPAT6T3YN","analytics-instrumentation-check",null,"Audit a feature, branch, or PR diff for analytics instrumentation coverage. Verifies that every state-changing action (server action, BullMQ processor, domain entity create\u002Fupdate\u002Fdelete, paywall\u002Fbilling transition) fires a typed `trackServerEvent` or `tracker.track*` call. Use proactively before opening a PR, during code review, or whenever a new feature is added under apps\u002Fweb\u002Fapp, apps\u002Fai\u002Fsrc\u002Fmodules, or apps\u002Fsync\u002Fsrc\u002Fmodules. The CI gate (typed event names) prevents untyped events from shipping but does NOT prevent uninstrumented actions from shipping — this skill closes that gap. Trigger phrases: 'is this tracked', 'audit instrumentation', 'check analytics coverage', 'are we tracking X', 'instrumentation review'.","gethamster\u002Fskills","gethamster","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F215697643?v=4","01M7B2R6PGB3SDZZ71E0WE2S74","Hamster","01M7B2R6Q21HWJRXZZWB78BNDG",4,"MIT","https:\u002F\u002Fgithub.com\u002Fgethamster\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002F.experimental\u002Fanalytics-instrumentation-check\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: analytics-instrumentation-check\ndescription: \"Audit a feature, branch, or PR diff for analytics instrumentation coverage. Verifies that every state-changing action (server action, BullMQ processor, domain entity create\u002Fupdate\u002Fdelete, paywall\u002Fbilling transition) fires a typed `trackServerEvent` or `tracker.track*` call. Use proactively before opening a PR, during code review, or whenever a new feature is added under apps\u002Fweb\u002Fapp, apps\u002Fai\u002Fsrc\u002Fmodules, or apps\u002Fsync\u002Fsrc\u002Fmodules. The CI gate (typed event names) prevents untyped events from shipping but does NOT prevent uninstrumented actions from shipping — this skill closes that gap. Trigger phrases: 'is this tracked', 'audit instrumentation', 'check analytics coverage', 'are we tracking X', 'instrumentation review'.\"\nversion: \"1.0.0\"\n---\n\n# Analytics Instrumentation Check\n\n## What this skill is for\n\nThe CI gate enforces that any event passed to `trackServerEvent` is in the typed catalog (`packages\u002Fanalytics\u002Fsrc\u002Fevent-types.ts`). It does NOT enforce that an event fires when a state-changing action runs. A developer can ship a new server action that mutates the database and fires no event, and `pnpm typecheck` will pass.\n\nThis skill closes the coverage gap. Given a diff, branch, or directory, it:\n\n1. Detects every **state-changing action** introduced or touched.\n2. For each action, looks for a `trackServerEvent` \u002F `tracker.track*` \u002F `analytics.trackEvent` call in the same code path.\n3. Classifies each action as **instrumented**, **missing**, **ambiguous**, or **intentionally untracked**.\n4. Produces a reviewer-ready report so the missing instrumentation is fixed before the feature ships.\n\nThe brief that introduced the CI gate explicitly framed this as the manual half of enforcement. The gate ensures shipped events are typed; this skill ensures shipped actions are tracked.\n\n## When to apply\n\nApply this skill when:\n\n- A user asks for an instrumentation audit before a PR (\"is this tracked?\", \"do we fire an event for X?\", \"audit analytics coverage on this branch\").\n- A user is reviewing a PR that touches `apps\u002Fweb\u002Fapp\u002F**\u002F_lib\u002Fserver\u002F`, `apps\u002Fai\u002Fsrc\u002Fmodules\u002F**`, `apps\u002Fsync\u002Fsrc\u002Fmodules\u002F**`, or `apps\u002Fhorde-v2\u002Fsrc\u002Fdelivery\u002F**`.\n- A new domain entity (brief, task, blueprint, skill, method, connection, plan, alignment vote) is being created or mutated by code introduced in the diff.\n- The user mentions a feature being \"ready to ship\" or \"ready for review\" and you can see uninstrumented mutation paths.\n\n## When NOT to apply\n\n- Read-only queries, repository getters, list endpoints — these are never expected to fire events.\n- Changes to existing **typed** events (event-name renames, property-shape edits) — that work belongs in the catalog, not in instrumentation coverage.\n- Webhook-receipt code that only acks (`200 OK`) without acting — instrumentation belongs in the consumer that processes the queued job, not the controller that enqueues.\n- Unit-test files, fixtures, mocks (`*.spec.ts`, `*.test.ts`, `__tests__\u002F**`).\n- Backfill scripts in `apps\u002Fweb\u002Fsupabase\u002Fscripts\u002F` — those are one-off runs and have their own audit-log mechanism via `backfill-script-creator`.\n\nIf the user's request fits one of these, say so explicitly and stop.\n\n## Required inputs\n\nThe skill needs ONE of:\n\n1. **A diff range** — `origin\u002Fdev...HEAD`, `HEAD~3...HEAD`, or a path to a saved diff (`\u002Ftmp\u002Ffoo-diff.txt`). Most common case.\n2. **A PR number** — fetched via `gh pr diff \u003Cnumber>`.\n3. **A directory or file list** — for example `apps\u002Fweb\u002Fapp\u002Fhome\u002F[account]\u002Fbriefs\u002F_lib\u002Fserver\u002F` after a feature lands but before instrumentation is verified.\n\nIf none is provided, ask the user which scope to audit. Do not guess.\n\n## Workflow\n\n### 1. Bound the scope\n\nPick the input form (diff \u002F PR \u002F paths) and produce a list of changed files. Exclude:\n\n- `*.spec.ts`, `*.test.ts`, files under `__tests__\u002F`\n- `*.md`, `*.json` (except for analytics dashboard configs in `apps\u002Fai\u002Fscripts\u002F`, see Pitfalls)\n- `packages\u002Fanalytics\u002F**` itself (we're auditing consumers, not the library)\n- `*.sql`, `*.config.ts`, `*.config.mjs`\n\nFor a diff, get the file list:\n\n```bash\ngit diff --name-only origin\u002Fdev...HEAD \\\n  | grep -vE '\\.(spec|test)\\.ts$|^__tests__\u002F|\\.(md|json|sql)$|^packages\u002Fanalytics\u002F'\n```\n\n### 2. Load the live event catalog\n\nBefore scanning for instrumentation, extract the authoritative event name list from `event-types.ts` so the search patterns are never stale:\n\n```bash\n# Pull every quoted string from EventPropertiesMap — one event name per line\ngrep -oP \"(?\u003C=')\\b[A-Z][^']+(?=')\\s*:\" \\\n  packages\u002Fanalytics\u002Fsrc\u002Fevent-types.ts \\\n  | sed \"s\u002F[[:space:]]*:\u002F\u002F\"\n```\n\nThis gives you the full catalog as it exists right now (e.g. `Brief Created`, `Task Completed`, `Integration Connected`, …). Use it as the `\u003CEVENTS>` list in the grep below.\n\nOnce you have the list, build a single-pass ripgrep that scans every `trackServerEvent` call site and checks whether the literal string matches a catalog entry:\n\n```bash\n# Replace \u003CEVENTS> with the pipe-joined list from the command above,\n# e.g. \"Brief Created|Task Completed|Integration Connected|...\"\nrg -n \"trackServerEvent\\s*\\(\\s*['\\\"](\u003CEVENTS>)['\\\"]\" \\\n  apps\u002F packages\u002F \\\n  --type ts \\\n  --glob '!*.spec.ts' --glob '!*.test.ts'\n```\n\nThis tells you, for every call site in scope, which catalog event it fires. Cross-referencing this against the state-changing actions you find in step 3 is how you identify gaps.\n\n> If `grep` is too noisy on `EventPropertiesMap`, you can alternatively extract names with:\n> \n> ```bash\n> grep -oP \"(?\u003C=: )[A-Z][^:']+\" packages\u002Fanalytics\u002Fsrc\u002Fevent-types.ts | sort -u\n> ```\n\n### 4. Detect state-changing actions\n\nRun each pattern below across the scoped files. The four patterns map to the brief's definition of \"state-changing action\":\n\n| # | Pattern | Detection (ripgrep) | Where it lives |\n| --- | --- | --- | --- |\n| 1 | Server action (Next.js) | `rg -n \"enhanceAction\\(\" \u003Cfiles>` | `apps\u002Fweb\u002Fapp\u002F**\u002F_lib\u002Fserver\u002F*-actions.ts`, `apps\u002Fweb\u002Fapp\u002F**\u002F_lib\u002Fserver\u002Fserver-actions.ts` |\n| 2 | BullMQ processor \u002F consumer | `rg -n \"@Processor\\(\\ | extends WorkerHost\\ |\n| 3 | Domain-entity mutation | `rg -nP \"\\.from\\('(briefs?\\ | tasks?\\ |\n| 4 | Direct write through an admin client | `rg -n \"getSupabaseServerAdminClient\\(\\)\" \u003Cfiles>` (then narrow to the surrounding mutation) | Rare; deserves extra scrutiny |\n\nFor each match, record:\n\n- **File path + line number**\n- **Enclosing function\u002Fhandler name** (`enhanceAction(...)` factory, NestJS method, etc.)\n- **Mutation table** (for pattern 3) or **queue name** (for pattern 2)\n- **Action verb** (insert \u002F update \u002F delete \u002F upsert) — this hints at the canonical event\n\n### 5. Find the instrumentation, if any\n\nFor each detected action, search the same enclosing function\u002Fhandler for a tracking call. Search ~50 lines before and after the mutation, not just the line itself — analytics calls are often after the mutation on the success path or in a `try`\u002F`catch` block:\n\n```bash\n# Adjust line range to enclosing function boundaries\nrg -n \"trackServerEvent\\(\\|tracker\\.track\\|analytics\\.trackEvent\\(\\|trackHordeEvent\\(\\|trackConnectionEvent\\(\\|trackFlushEvent\\(\\|trackRelayEvent\\(\\|trackSyncEvent\\(\" \u003Cfile>\n```\n\nIf a call is found, capture:\n\n- **Event name** passed (string literal — the gate guarantees it's typed)\n- **Distance from the mutation** (lines)\n- **Whether it's on the success path** (after `if (error) throw`) or unconditional\n\n### 6. Match action → expected event\n\nUse the canonical mapping below to decide whether the fired event matches the action. If multiple events would be reasonable, the call is **instrumented** as long as one fits.\n\n| Action verb | Table \u002F entity | Expected event(s) |\n| --- | --- | --- |\n| insert | `briefs` | `Brief Created`, `Brief Created From PRD`, `First Brief Created` |\n| update | `briefs` | `Brief Updated`, `Brief Status Changed` |\n| delete | `briefs` | `Brief Deleted` |\n| insert | `tasks` | `Task Created`, `First Task Created`, `Subtask Created` |\n| update | `tasks` | `Task Updated`, `Task Status Changed`, `Task Completed`, `Task Assigned`, `Task Assigned to Coding Agent` |\n| delete | `tasks` | `Task Deleted` |\n| insert | `blueprints` table or `document` (type=blueprint) | `Blueprint Created`, `Blueprint Imported`, `Blueprint Duplicated` |\n| update | same | `Blueprint Updated` |\n| delete | same | `Blueprint Deleted` |\n| insert | `skills` | `Skill Imported`, `Skill Imported From Repo`, `Skill Uploaded` |\n| update | same | `Skill Activated`, `Skill Deactivated` |\n| delete | same | `Skill Deleted` |\n| insert | `methods` table or `document` (type=method) | `Method Created` |\n| update | same | `Method Updated` |\n| delete | same | `Method Deleted` |\n| insert | `context_connections` | `OAuth Started`, `Integration Connected`, `Integration Reauthorized` |\n| update | same (status fields) | `Integration Disconnected`, `Integration Resync Triggered` |\n| delete | same | `Integration Disconnected` |\n| insert | `alignment_votes` | `Alignment Vote Submitted`, `First Alignment Vote` |\n| insert \u002F update | `subscriptions` | `Subscription Created`, `Subscription Updated`, `Subscription Deleted` |\n| BullMQ processor | sync queue | `Sync Run Started`, `Sync Run Completed`, `Sync Run Failed` |\n| BullMQ processor | horde delivery | `Horde Delivery Started`, `Horde Delivery Completed`, `Horde Delivery Failed` |\n\nThe full catalog is in `packages\u002Fanalytics\u002Fsrc\u002Fevent-types.ts`. You already extracted it in step 2 — use that list rather than the static table when the entity name isn't listed here.\n\n### 7. Classify each action\n\nUse four categories:\n\n- ✅ **Instrumented** — a typed event fires on the success path of the action.\n- ⚠️ **Missing** — no event fires anywhere in the enclosing handler. Action verb + table point at a canonical event the team would expect.\n- ❓ **Ambiguous** — an event fires but doesn't match the action verb (e.g., a `Brief Updated` event when the code is doing a delete), OR the mutation is wrapped behind a service method whose instrumentation we can't see from this diff alone, OR the action is a multi-step transaction where one event covers several mutations.\n- 🔒 **Intentionally untracked** — the mutation is internal (audit log, system retry, idempotency-key write, dedup pass) and a dashboard event would be noise. Flag with a one-line justification so the reviewer can override.\n\n### 8. Cross-check downstream\n\nFor each ✅ instrumented action, also verify:\n\n- The event name is in `EventPropertiesMap` (the gate already enforces this, but double-check in case of a `Parameters\u003Ctypeof trackServerEvent\u003C...>>[1]` cast bypassing the type system at the call site).\n- The call is wrapped against failure (`.catch(() => …)` or `try\u002Fcatch`) so analytics never blocks business logic.\n- `account_id` is in the property bag (or auto-injected from ALS).\n\nFor each ⚠️ missing action, suggest the canonical event from the table in step 4 plus the minimal property shape to fire.\n\n### 9. Produce the report\n\nOutput a markdown table the reviewer can paste into a PR comment. Format:\n\n```\n### Analytics Instrumentation Check — `feature\u002F\u003Cbranch>`\n\n**Scope:** \u003CN> files changed, \u003CM> state-changing actions detected.\n\n| Status | File:Line | Action | Expected event | Found | Notes |\n|--------|-----------|--------|----------------|-------|-------|\n| ✅ | apps\u002Fweb\u002Fapp\u002F...\u002Fbriefs.actions.ts:147 | insert briefs | Brief Created | `Brief Created` | success-path call |\n| ⚠️ | apps\u002Fweb\u002Fapp\u002F...\u002Ftasks.actions.ts:88 | update tasks (status→done) | Task Completed | none | suggest `Task Completed` |\n| ❓ | apps\u002Fai\u002Fsrc\u002Fmodules\u002F...\u002Fservice.ts:215 | insert briefs | Brief Created | none in this file | check `BriefsService` repository call site |\n| 🔒 | apps\u002Fai\u002Fsrc\u002Fmodules\u002F...\u002Faudit.ts:42 | insert audit_logs | — | n\u002Fa | internal audit table, no dashboard event needed |\n\n**Summary:** \u003CX> instrumented · \u003CY> missing · \u003CZ> ambiguous · \u003CW> intentionally untracked.\n**Verdict:** \u003Cship \u002F fix-the-Y-missing-actions-first \u002F spot-check-the-Z-ambiguous>.\n```\n\nIf everything is green, say so explicitly with one line per action so the reviewer doesn't have to re-derive coverage.\n\n## Detection patterns reference\n\nThe full grep recipes, including how to handle wrapper functions and helper services, live in [references\u002Fdetection-patterns.md](references\u002Fdetection-patterns.md). Read it when:\n\n- A pattern is matching too aggressively (e.g., flagging repository getters).\n- A custom helper wrapper (`updateBriefStatus(...)` that internally calls `trackServerEvent`) is hiding instrumentation from the surface scan.\n- The diff touches multi-tenant code where the action verb is conditional on a flag.\n\n## Pitfalls (catalogued from real bugs)\n\n1. **Repository methods are not state-changing actions for this skill.** A `BriefsRepository.update(...)` method should NOT be flagged. The action is the *caller* — the server action or service method that decides to update. Repositories are infrastructure; instrumentation lives at the boundary that owns the business decision.\n\n2. **A wrapper helper can own the instrumentation.** `apps\u002Fai\u002Fsrc\u002Fmodules\u002Fcontext-connections\u002Fcontext-connections.service.ts` has `trackConnectionEvent(...)` that fans out to typed connection events. If a service uses such a wrapper, the action is instrumented even though the surface grep won't show `trackServerEvent` directly. Add wrapper names to the search list:\n\n```\ntrackServerEvent | tracker.track | analytics.trackEvent | trackHordeEvent\n   | trackConnectionEvent | trackFlushEvent | trackRelayEvent | trackSyncEvent\n```\n\n3. **One event can cover multiple mutations in a transaction.** `createBriefAndStartConversationAction` may insert into `briefs`, `documents`, and `thread_items` in one server action and fire one `Brief Created` event. That's correct — don't flag the documents\u002Fthread_items writes as missing. The action's *intent* is creating a brief; the other writes are mechanism.\n\n4. **Sync engine writes are queue-internal.** Inbound webhook receipt only fires `Sync Webhook Received`; the actual entity mutations happen in the inbound consumer which fires `Sync Run Started\u002FCompleted\u002FFailed`. Don't double-count by demanding events at both the controller and the consumer for the same logical run.\n\n5. **Horde delivery has a different envelope.** `trackHordeEvent` auto-injects user_id, account_id, brief_id, sandbox_id from ALS + active span. Don't flag a Horde call site as missing `account_id` in the property bag — the helper adds it.\n\n6. **`enhanceAction` does NOT auto-instrument.** It validates input and runs auth, but does not fire any analytics event. Every `enhanceAction(...)` is a candidate state-changing action to audit.\n\n7. **Mixpanel dashboard configs reference event names.** `apps\u002Fai\u002Fscripts\u002Fgenerate-mixpanel-config.ts` and `apps\u002Fai\u002Fscripts\u002Fmixpanel-dashboard-config.json` hold dashboard funnel definitions keyed on event names. If the diff renames or drops an event, these configs must be updated in the same PR — otherwise the dashboard breaks silently. Include them in step 1's file scope when the diff modifies `event-types.ts` or removes a `trackServerEvent` call.\n\n8. **Server actions can delegate to a NestJS service via fetch \u002F `apps\u002Fai`.** A `apps\u002Fweb` server action that POSTs to `apps\u002Fai` and lets the API instrument the event is correctly instrumented — but the proof lives in the API, not the diff. Flag as ❓ ambiguous and ask the user to confirm the API side fires the event.\n\n9. **`enhanceAction` with `auth: false` and a `schema` only** — these are sometimes idempotency receivers (e.g., a metric ingest endpoint). They aren't always state-changing in the catalog sense. Inspect the body before flagging.\n\n10. **The gate probe in `server-analytics.test.ts` deliberately fires `'Bogus Event'`** to keep the typed-overload-removal honest. That's not a missing instrumentation — it's the test of the gate itself.\n\n## Anti-patterns\n\n- **Don't auto-fix.** This skill produces a report. Adding events without a human deciding the canonical name is how the catalog accumulates noise (see `Anonymous Event` \u002F `Orphan Event` in the data-platform-progress decision log).\n- **Don't flag every mutation.** Repositories, audit logs, idempotency-key writes, dedup passes are legitimately untracked. Use the 🔒 category liberally — false positives erode reviewer trust faster than false negatives.\n- **Don't suggest events that aren't in the catalog.** If the canonical event would be new, say so and point the reviewer at `event-types.ts` to add it. Don't invent names.\n- **Don't run this skill on `dev` or `main`.** It's a per-feature audit. Running it across the whole repo produces a report no one will read.\n- **Don't substitute for the gate.** This skill is coverage; the gate is type safety. Both must pass independently.\n\n## Output: what to give the user\n\nAfter the audit, deliver:\n\n1. **The classification table** (step 7 format) so the reviewer can scan in 30 seconds.\n2. **A one-line verdict** — ship, fix the ⚠️ missing actions first, or spot-check the ❓ ambiguous ones.\n3. **For each ⚠️ missing action: a copy-pasteable instrumentation snippet** with the canonical event name and the minimal property shape from `event-types.ts`. Don't write the code into the file — give the reviewer something to commit deliberately.\n4. **For each ❓ ambiguous action: the specific question** the reviewer needs to answer (e.g. \"Does `BriefsService.archive()` instrument `Brief Status Changed`? Open the file at line N and check.\").\n\n## What this skill is NOT\n\n- A linter — there is no auto-fix, no machine-readable output, no CI integration. It runs in conversation.\n- A replacement for the catalog — adding new typed events still goes through `packages\u002Fanalytics\u002Fsrc\u002Fevent-types.ts` per `packages\u002Fanalytics\u002FCLAUDE.md`.\n- A coverage threshold gate — the goal is informed review, not 100% mechanical coverage. The 🔒 category exists precisely because not every mutation deserves an event.\n\n## References\n\n| File | When to read |\n| --- | --- |\n| [references\u002Fdetection-patterns.md](references\u002Fdetection-patterns.md) | When the surface grep is producing false positives or missing wrapper-helper instrumentation. Contains the full ripgrep recipes plus AST-grep alternatives for tricky cases. |\n| `packages\u002Fanalytics\u002Fsrc\u002Fevent-types.ts` | The source of truth for valid event names. Always grep this before suggesting a canonical event. |\n| `packages\u002Fanalytics\u002FCLAUDE.md` | Adding a new event to the catalog. Step-by-step \"if you hit a type wall\" guidance. |\n| `docs\u002Farchitecture\u002Fdata-platform-summary.md` | Why this skill exists. Background on the gate, the brief, and what \"we'll instrument later\" was costing the team. |\n","# Analytics Instrumentation Check\n\n## What this skill is for\n\nThe CI gate enforces that any event passed to `trackServerEvent` is in the typed catalog (`packages\u002Fanalytics\u002Fsrc\u002Fevent-types.ts`). It does NOT enforce that an event fires when a state-changing action runs. A developer can ship a new server action that mutates the database and fires no event, and `pnpm typecheck` will pass.\n\nThis skill closes the coverage gap. Given a diff, branch, or directory, it:\n\n1. Detects every **state-changing action** introduced or touched.\n2. For each action, looks for a `trackServerEvent` \u002F `tracker.track*` \u002F `analytics.trackEvent` call in the same code path.\n3. Classifies each action as **instrumented**, **missing**, **ambiguous**, or **intentionally untracked**.\n4. Produces a reviewer-ready report so the missing instrumentation is fixed before the feature ships.\n\nThe brief that introduced the CI gate explicitly framed this as the manual half of enforcement. The gate ensures shipped events are typed; this skill ensures shipped actions are tracked.\n\n## When to apply\n\nApply this skill when:\n\n- A user asks for an instrumentation audit before a PR (\"is this tracked?\", \"do we fire an event for X?\", \"audit analytics coverage on this branch\").\n- A user is reviewing a PR that touches `apps\u002Fweb\u002Fapp\u002F**\u002F_lib\u002Fserver\u002F`, `apps\u002Fai\u002Fsrc\u002Fmodules\u002F**`, `apps\u002Fsync\u002Fsrc\u002Fmodules\u002F**`, or `apps\u002Fhorde-v2\u002Fsrc\u002Fdelivery\u002F**`.\n- A new domain entity (brief, task, blueprint, skill, method, connection, plan, alignment vote) is being created or mutated by code introduced in the diff.\n- The user mentions a feature being \"ready to ship\" or \"ready for review\" and you can see uninstrumented mutation paths.\n\n## When NOT to apply\n\n- Read-only queries, repository getters, list endpoints — these are never expected to fire events.\n- Changes to existing **typed** events (event-name renames, property-shape edits) — that work belongs in the catalog, not in instrumentation coverage.\n- Webhook-receipt code that only acks (`200 OK`) without acting — instrumentation belongs in the consumer that processes the queued job, not the controller that enqueues.\n- Unit-test files, fixtures, mocks (`*.spec.ts`, `*.test.ts`, `__tests__\u002F**`).\n- Backfill scripts in `apps\u002Fweb\u002Fsupabase\u002Fscripts\u002F` — those are one-off runs and have their own audit-log mechanism via `backfill-script-creator`.\n\nIf the user's request fits one of these, say so explicitly and stop.\n\n## Required inputs\n\nThe skill needs ONE of:\n\n1. **A diff range** — `origin\u002Fdev...HEAD`, `HEAD~3...HEAD`, or a path to a saved diff (`\u002Ftmp\u002Ffoo-diff.txt`). Most common case.\n2. **A PR number** — fetched via `gh pr diff \u003Cnumber>`.\n3. **A directory or file list** — for example `apps\u002Fweb\u002Fapp\u002Fhome\u002F[account]\u002Fbriefs\u002F_lib\u002Fserver\u002F` after a feature lands but before instrumentation is verified.\n\nIf none is provided, ask the user which scope to audit. Do not guess.\n\n## Workflow\n\n### 1. Bound the scope\n\nPick the input form (diff \u002F PR \u002F paths) and produce a list of changed files. Exclude:\n\n- `*.spec.ts`, `*.test.ts`, files under `__tests__\u002F`\n- `*.md`, `*.json` (except for analytics dashboard configs in `apps\u002Fai\u002Fscripts\u002F`, see Pitfalls)\n- `packages\u002Fanalytics\u002F**` itself (we're auditing consumers, not the library)\n- `*.sql`, `*.config.ts`, `*.config.mjs`\n\nFor a diff, get the file list:\n\n```bash\ngit diff --name-only origin\u002Fdev...HEAD \\\n  | grep -vE '\\.(spec|test)\\.ts$|^__tests__\u002F|\\.(md|json|sql)$|^packages\u002Fanalytics\u002F'\n```\n\n### 2. Load the live event catalog\n\nBefore scanning for instrumentation, extract the authoritative event name list from `event-types.ts` so the search patterns are never stale:\n\n```bash\n# Pull every quoted string from EventPropertiesMap — one event name per line\ngrep -oP \"(?\u003C=')\\b[A-Z][^']+(?=')\\s*:\" \\\n  packages\u002Fanalytics\u002Fsrc\u002Fevent-types.ts \\\n  | sed \"s\u002F[[:space:]]*:\u002F\u002F\"\n```\n\nThis gives you the full catalog as it exists right now (e.g. `Brief Created`, `Task Completed`, `Integration Connected`, …). Use it as the `\u003CEVENTS>` list in the grep below.\n\nOnce you have the list, build a single-pass ripgrep that scans every `trackServerEvent` call site and checks whether the literal string matches a catalog entry:\n\n```bash\n# Replace \u003CEVENTS> with the pipe-joined list from the command above,\n# e.g. \"Brief Created|Task Completed|Integration Connected|...\"\nrg -n \"trackServerEvent\\s*\\(\\s*['\\\"](\u003CEVENTS>)['\\\"]\" \\\n  apps\u002F packages\u002F \\\n  --type ts \\\n  --glob '!*.spec.ts' --glob '!*.test.ts'\n```\n\nThis tells you, for every call site in scope, which catalog event it fires. Cross-referencing this against the state-changing actions you find in step 3 is how you identify gaps.\n\n> If `grep` is too noisy on `EventPropertiesMap`, you can alternatively extract names with:\n> \n> ```bash\n> grep -oP \"(?\u003C=: )[A-Z][^:']+\" packages\u002Fanalytics\u002Fsrc\u002Fevent-types.ts | sort -u\n> ```\n\n### 4. Detect state-changing actions\n\nRun each pattern below across the scoped files. The four patterns map to the brief's definition of \"state-changing action\":\n\n| # | Pattern | Detection (ripgrep) | Where it lives |\n| --- | --- | --- | --- |\n| 1 | Server action (Next.js) | `rg -n \"enhanceAction\\(\" \u003Cfiles>` | `apps\u002Fweb\u002Fapp\u002F**\u002F_lib\u002Fserver\u002F*-actions.ts`, `apps\u002Fweb\u002Fapp\u002F**\u002F_lib\u002Fserver\u002Fserver-actions.ts` |\n| 2 | BullMQ processor \u002F consumer | `rg -n \"@Processor\\(\\ | extends WorkerHost\\ |\n| 3 | Domain-entity mutation | `rg -nP \"\\.from\\('(briefs?\\ | tasks?\\ |\n| 4 | Direct write through an admin client | `rg -n \"getSupabaseServerAdminClient\\(\\)\" \u003Cfiles>` (then narrow to the surrounding mutation) | Rare; deserves extra scrutiny |\n\nFor each match, record:\n\n- **File path + line number**\n- **Enclosing function\u002Fhandler name** (`enhanceAction(...)` factory, NestJS method, etc.)\n- **Mutation table** (for pattern 3) or **queue name** (for pattern 2)\n- **Action verb** (insert \u002F update \u002F delete \u002F upsert) — this hints at the canonical event\n\n### 5. Find the instrumentation, if any\n\nFor each detected action, search the same enclosing function\u002Fhandler for a tracking call. Search ~50 lines before and after the mutation, not just the line itself — analytics calls are often after the mutation on the success path or in a `try`\u002F`catch` block:\n\n```bash\n# Adjust line range to enclosing function boundaries\nrg -n \"trackServerEvent\\(\\|tracker\\.track\\|analytics\\.trackEvent\\(\\|trackHordeEvent\\(\\|trackConnectionEvent\\(\\|trackFlushEvent\\(\\|trackRelayEvent\\(\\|trackSyncEvent\\(\" \u003Cfile>\n```\n\nIf a call is found, capture:\n\n- **Event name** passed (string literal — the gate guarantees it's typed)\n- **Distance from the mutation** (lines)\n- **Whether it's on the success path** (after `if (error) throw`) or unconditional\n\n### 6. Match action → expected event\n\nUse the canonical mapping below to decide whether the fired event matches the action. If multiple events would be reasonable, the call is **instrumented** as long as one fits.\n\n| Action verb | Table \u002F entity | Expected event(s) |\n| --- | --- | --- |\n| insert | `briefs` | `Brief Created`, `Brief Created From PRD`, `First Brief Created` |\n| update | `briefs` | `Brief Updated`, `Brief Status Changed` |\n| delete | `briefs` | `Brief Deleted` |\n| insert | `tasks` | `Task Created`, `First Task Created`, `Subtask Created` |\n| update | `tasks` | `Task Updated`, `Task Status Changed`, `Task Completed`, `Task Assigned`, `Task Assigned to Coding Agent` |\n| delete | `tasks` | `Task Deleted` |\n| insert | `blueprints` table or `document` (type=blueprint) | `Blueprint Created`, `Blueprint Imported`, `Blueprint Duplicated` |\n| update | same | `Blueprint Updated` |\n| delete | same | `Blueprint Deleted` |\n| insert | `skills` | `Skill Imported`, `Skill Imported From Repo`, `Skill Uploaded` |\n| update | same | `Skill Activated`, `Skill Deactivated` |\n| delete | same | `Skill Deleted` |\n| insert | `methods` table or `document` (type=method) | `Method Created` |\n| update | same | `Method Updated` |\n| delete | same | `Method Deleted` |\n| insert | `context_connections` | `OAuth Started`, `Integration Connected`, `Integration Reauthorized` |\n| update | same (status fields) | `Integration Disconnected`, `Integration Resync Triggered` |\n| delete | same | `Integration Disconnected` |\n| insert | `alignment_votes` | `Alignment Vote Submitted`, `First Alignment Vote` |\n| insert \u002F update | `subscriptions` | `Subscription Created`, `Subscription Updated`, `Subscription Deleted` |\n| BullMQ processor | sync queue | `Sync Run Started`, `Sync Run Completed`, `Sync Run Failed` |\n| BullMQ processor | horde delivery | `Horde Delivery Started`, `Horde Delivery Completed`, `Horde Delivery Failed` |\n\nThe full catalog is in `packages\u002Fanalytics\u002Fsrc\u002Fevent-types.ts`. You already extracted it in step 2 — use that list rather than the static table when the entity name isn't listed here.\n\n### 7. Classify each action\n\nUse four categories:\n\n- ✅ **Instrumented** — a typed event fires on the success path of the action.\n- ⚠️ **Missing** — no event fires anywhere in the enclosing handler. Action verb + table point at a canonical event the team would expect.\n- ❓ **Ambiguous** — an event fires but doesn't match the action verb (e.g., a `Brief Updated` event when the code is doing a delete), OR the mutation is wrapped behind a service method whose instrumentation we can't see from this diff alone, OR the action is a multi-step transaction where one event covers several mutations.\n- 🔒 **Intentionally untracked** — the mutation is internal (audit log, system retry, idempotency-key write, dedup pass) and a dashboard event would be noise. Flag with a one-line justification so the reviewer can override.\n\n### 8. Cross-check downstream\n\nFor each ✅ instrumented action, also verify:\n\n- The event name is in `EventPropertiesMap` (the gate already enforces this, but double-check in case of a `Parameters\u003Ctypeof trackServerEvent\u003C...>>[1]` cast bypassing the type system at the call site).\n- The call is wrapped against failure (`.catch(() => …)` or `try\u002Fcatch`) so analytics never blocks business logic.\n- `account_id` is in the property bag (or auto-injected from ALS).\n\nFor each ⚠️ missing action, suggest the canonical event from the table in step 4 plus the minimal property shape to fire.\n\n### 9. Produce the report\n\nOutput a markdown table the reviewer can paste into a PR comment. Format:\n\n```\n### Analytics Instrumentation Check — `feature\u002F\u003Cbranch>`\n\n**Scope:** \u003CN> files changed, \u003CM> state-changing actions detected.\n\n| Status | File:Line | Action | Expected event | Found | Notes |\n|--------|-----------|--------|----------------|-------|-------|\n| ✅ | apps\u002Fweb\u002Fapp\u002F...\u002Fbriefs.actions.ts:147 | insert briefs | Brief Created | `Brief Created` | success-path call |\n| ⚠️ | apps\u002Fweb\u002Fapp\u002F...\u002Ftasks.actions.ts:88 | update tasks (status→done) | Task Completed | none | suggest `Task Completed` |\n| ❓ | apps\u002Fai\u002Fsrc\u002Fmodules\u002F...\u002Fservice.ts:215 | insert briefs | Brief Created | none in this file | check `BriefsService` repository call site |\n| 🔒 | apps\u002Fai\u002Fsrc\u002Fmodules\u002F...\u002Faudit.ts:42 | insert audit_logs | — | n\u002Fa | internal audit table, no dashboard event needed |\n\n**Summary:** \u003CX> instrumented · \u003CY> missing · \u003CZ> ambiguous · \u003CW> intentionally untracked.\n**Verdict:** \u003Cship \u002F fix-the-Y-missing-actions-first \u002F spot-check-the-Z-ambiguous>.\n```\n\nIf everything is green, say so explicitly with one line per action so the reviewer doesn't have to re-derive coverage.\n\n## Detection patterns reference\n\nThe full grep recipes, including how to handle wrapper functions and helper services, live in [references\u002Fdetection-patterns.md](references\u002Fdetection-patterns.md). Read it when:\n\n- A pattern is matching too aggressively (e.g., flagging repository getters).\n- A custom helper wrapper (`updateBriefStatus(...)` that internally calls `trackServerEvent`) is hiding instrumentation from the surface scan.\n- The diff touches multi-tenant code where the action verb is conditional on a flag.\n\n## Pitfalls (catalogued from real bugs)\n\n1. **Repository methods are not state-changing actions for this skill.** A `BriefsRepository.update(...)` method should NOT be flagged. The action is the *caller* — the server action or service method that decides to update. Repositories are infrastructure; instrumentation lives at the boundary that owns the business decision.\n\n2. **A wrapper helper can own the instrumentation.** `apps\u002Fai\u002Fsrc\u002Fmodules\u002Fcontext-connections\u002Fcontext-connections.service.ts` has `trackConnectionEvent(...)` that fans out to typed connection events. If a service uses such a wrapper, the action is instrumented even though the surface grep won't show `trackServerEvent` directly. Add wrapper names to the search list:\n\n```\ntrackServerEvent | tracker.track | analytics.trackEvent | trackHordeEvent\n   | trackConnectionEvent | trackFlushEvent | trackRelayEvent | trackSyncEvent\n```\n\n3. **One event can cover multiple mutations in a transaction.** `createBriefAndStartConversationAction` may insert into `briefs`, `documents`, and `thread_items` in one server action and fire one `Brief Created` event. That's correct — don't flag the documents\u002Fthread_items writes as missing. The action's *intent* is creating a brief; the other writes are mechanism.\n\n4. **Sync engine writes are queue-internal.** Inbound webhook receipt only fires `Sync Webhook Received`; the actual entity mutations happen in the inbound consumer which fires `Sync Run Started\u002FCompleted\u002FFailed`. Don't double-count by demanding events at both the controller and the consumer for the same logical run.\n\n5. **Horde delivery has a different envelope.** `trackHordeEvent` auto-injects user_id, account_id, brief_id, sandbox_id from ALS + active span. Don't flag a Horde call site as missing `account_id` in the property bag — the helper adds it.\n\n6. **`enhanceAction` does NOT auto-instrument.** It validates input and runs auth, but does not fire any analytics event. Every `enhanceAction(...)` is a candidate state-changing action to audit.\n\n7. **Mixpanel dashboard configs reference event names.** `apps\u002Fai\u002Fscripts\u002Fgenerate-mixpanel-config.ts` and `apps\u002Fai\u002Fscripts\u002Fmixpanel-dashboard-config.json` hold dashboard funnel definitions keyed on event names. If the diff renames or drops an event, these configs must be updated in the same PR — otherwise the dashboard breaks silently. Include them in step 1's file scope when the diff modifies `event-types.ts` or removes a `trackServerEvent` call.\n\n8. **Server actions can delegate to a NestJS service via fetch \u002F `apps\u002Fai`.** A `apps\u002Fweb` server action that POSTs to `apps\u002Fai` and lets the API instrument the event is correctly instrumented — but the proof lives in the API, not the diff. Flag as ❓ ambiguous and ask the user to confirm the API side fires the event.\n\n9. **`enhanceAction` with `auth: false` and a `schema` only** — these are sometimes idempotency receivers (e.g., a metric ingest endpoint). They aren't always state-changing in the catalog sense. Inspect the body before flagging.\n\n10. **The gate probe in `server-analytics.test.ts` deliberately fires `'Bogus Event'`** to keep the typed-overload-removal honest. That's not a missing instrumentation — it's the test of the gate itself.\n\n## Anti-patterns\n\n- **Don't auto-fix.** This skill produces a report. Adding events without a human deciding the canonical name is how the catalog accumulates noise (see `Anonymous Event` \u002F `Orphan Event` in the data-platform-progress decision log).\n- **Don't flag every mutation.** Repositories, audit logs, idempotency-key writes, dedup passes are legitimately untracked. Use the 🔒 category liberally — false positives erode reviewer trust faster than false negatives.\n- **Don't suggest events that aren't in the catalog.** If the canonical event would be new, say so and point the reviewer at `event-types.ts` to add it. Don't invent names.\n- **Don't run this skill on `dev` or `main`.** It's a per-feature audit. Running it across the whole repo produces a report no one will read.\n- **Don't substitute for the gate.** This skill is coverage; the gate is type safety. Both must pass independently.\n\n## Output: what to give the user\n\nAfter the audit, deliver:\n\n1. **The classification table** (step 7 format) so the reviewer can scan in 30 seconds.\n2. **A one-line verdict** — ship, fix the ⚠️ missing actions first, or spot-check the ❓ ambiguous ones.\n3. **For each ⚠️ missing action: a copy-pasteable instrumentation snippet** with the canonical event name and the minimal property shape from `event-types.ts`. Don't write the code into the file — give the reviewer something to commit deliberately.\n4. **For each ❓ ambiguous action: the specific question** the reviewer needs to answer (e.g. \"Does `BriefsService.archive()` instrument `Brief Status Changed`? Open the file at line N and check.\").\n\n## What this skill is NOT\n\n- A linter — there is no auto-fix, no machine-readable output, no CI integration. It runs in conversation.\n- A replacement for the catalog — adding new typed events still goes through `packages\u002Fanalytics\u002Fsrc\u002Fevent-types.ts` per `packages\u002Fanalytics\u002FCLAUDE.md`.\n- A coverage threshold gate — the goal is informed review, not 100% mechanical coverage. The 🔒 category exists precisely because not every mutation deserves an event.\n\n## References\n\n| File | When to read |\n| --- | --- |\n| [references\u002Fdetection-patterns.md](references\u002Fdetection-patterns.md) | When the surface grep is producing false positives or missing wrapper-helper instrumentation. Contains the full ripgrep recipes plus AST-grep alternatives for tricky cases. |\n| `packages\u002Fanalytics\u002Fsrc\u002Fevent-types.ts` | The source of truth for valid event names. Always grep this before suggesting a canonical event. |\n| `packages\u002Fanalytics\u002FCLAUDE.md` | Adding a new event to the catalog. Step-by-step \"if you hit a type wall\" guidance. |\n| `docs\u002Farchitecture\u002Fdata-platform-summary.md` | Why this skill exists. Background on the gate, the brief, and what \"we'll instrument later\" was costing the team. |\n",{"name":5,"version":24,"description":7},"1.0.0","main","fe3bb1476c3ec23d8a366eac0fa8cd9f0852360a","skills\u002F.experimental\u002Fanalytics-instrumentation-check",0,"https:\u002F\u002Fgithub.com\u002Fgethamster\u002Fskills","https:\u002F\u002Fgithub.com\u002Fgethamster","https:\u002F\u002Ftryhamster.com","We're building the AI-native future of work, unlocking the promised acceleration for your whole team, from idea to impact.","2026-11-05 11:33:33",{"source":8,"skillName":5,"commands":35,"prompt":45,"zipAvailable":46},[36,39,42],{"tool":37,"command":38},"npx","npx skills add gethamster\u002Fskills --skill analytics-instrumentation-check",{"tool":40,"command":41},"bunx","bunx skills add gethamster\u002Fskills --skill analytics-instrumentation-check",{"tool":43,"command":44},"pnpm","pnpm dlx skills add gethamster\u002Fskills --skill analytics-instrumentation-check","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fgethamster\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002F.experimental\u002Fanalytics-instrumentation-check\u002FSKILL.md",true,[48],{"path":49,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":52,"sourceHtmlUrl":53},"references\u002Fdetection-patterns.md","REFERENCE","参考文档",8081,"https:\u002F\u002Fgithub.com\u002Fgethamster\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002F.experimental\u002Fanalytics-instrumentation-check\u002Freferences\u002Fdetection-patterns.md",[55,62,69,76,83,90],{"skillNo":56,"name":57,"nameZh":6,"description":58,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":59,"categories":60,"keywords":61,"publishedAt":19},"01M7B5MWYW0KE251276S56KQDZ","writing-waterfall-requirements-documents","Write a waterfall requirements document: elicit, structure and review testable, traceable requirements, then baseline the specification before design.","https:\u002F\u002Fgithub.com\u002Fgethamster\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fwriting-waterfall-requirements-documents\u002FSKILL.md",[],[],{"skillNo":63,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":66,"categories":67,"keywords":68,"publishedAt":19},"01M7B5MRCXWWPKREPB1CHQ7H90","writing-vision-and-values-statements","Write a V2MOM vision a reader can test and a ranked list of values that settles real tradeoffs, so the rest of the document has a clear anchor.","https:\u002F\u002Fgithub.com\u002Fgethamster\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fwriting-vision-and-values-statements\u002FSKILL.md",[],[],{"skillNo":70,"name":71,"nameZh":6,"description":72,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":19},"01M7B5MKH2CH22YZAHQW3080VQ","writing-system-prompts-for-claude","Write Claude prompts and CLAUDE.md files that supply exact inputs, scope the task, and define done so the first attempt can be checked.","https:\u002F\u002Fgithub.com\u002Fgethamster\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fwriting-system-prompts-for-claude\u002FSKILL.md",[],[],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":19},"01M7B5ME1Y3X9RNRKP5HKHKACZ","writing-page-specific-website-copy","Website copywriting by page type: write homepage, landing page, pricing page and feature page copy that fits each page's visitor and single job.","https:\u002F\u002Fgithub.com\u002Fgethamster\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fwriting-page-specific-website-copy\u002FSKILL.md",[],[],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":19},"01M7B5M8MQNM8MN8PYH6BVWJ2B","writing-internal-press-releases","How to write an internal press release: the one-page working backwards press release that opens a PR\u002FFAQ document before anything is built.","https:\u002F\u002Fgithub.com\u002Fgethamster\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fwriting-internal-press-releases\u002FSKILL.md",[],[],{"skillNo":91,"name":92,"nameZh":6,"description":93,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":94,"categories":95,"keywords":96,"publishedAt":19},"01M7B5M3P3YH1XF37R8PWXXSBK","writing-email-sequences-that-sell","Email sequence copywriting for nurture and sales: give each email one job, write clear subject lines, and close with one specific call to action.","https:\u002F\u002Fgithub.com\u002Fgethamster\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fwriting-email-sequences-that-sell\u002FSKILL.md",[],[]]