/ship-pipeline:analytics-instrumentationfrom ship-pipeline
PostHog event taxonomy and instrumentation review - object_verb naming, flat property schemas, identify/reset/group calls, PII exclusion, LLM usage events, a starter dashboard set (activation, retention, feature funnel), and a per-feature checklist. Use when instrumenting a new feature, auditing existing PostHog events, or setting up analytics for a new product, e.g. "add tracking", "what events should we fire", "review our PostHog events", "is there PII in analytics".
Ships in ship-pipeline. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
The usual failure is not "we didn't track it". It is "we tracked it inconsistently": three naming styles mean every dashboard needs a translation layer, and PII slips into event properties because nobody reviewed the payload. Fix the naming up front and make the PII check a standing item.
object_verbLowercase snake_case, object first, past-tense verb, so related events sort together:
project_created
project_deleted
project_shared
subscription_started
subscription_upgraded
subscription_canceled
llm_query_submitted
llm_query_failed
Avoid: verb-first names (created_project), intent-free names (button_clicked - name the outcome, e.g. project_export_clicked), and versioned event names (project_created_v2 - version a property instead).
Identify the user as soon as they are known (signup and every login), before feature flag evaluation or conversion events. identify() links the earlier anonymous events to the person:
posthog.identify(user.id, { // stable internal ID, never the email
email: user.email, // person properties: the one place PII may go, if needed at all
plan: user.plan,
created_at: user.createdAt,
});
On logout call posthog.reset(), or the next user on the same device inherits this person and their groups.
Group calls for multi-user accounts, so usage and retention can be sliced by account:
posthog.group('company', company.id, { name: company.name, member_count: company.memberCount });
PostHog allows at most 5 group types per project, and an event can belong to only one group of each type. Pick group types deliberately.
Event properties - flat, consistently typed, minimal:
posthog.capture('project_created', {
project_id: project.id,
template_used: project.templateId ?? null,
source: 'dashboard_button', // where the action was triggered
});
No PII in capture() properties: no email, name, phone, address, IP, free-text user input, or raw form values. If PII is needed at all, it goes in person properties via identify(). Treat this as a hard rule and audit every new capture() call against it.
LLM usage events. Record cost and performance, not prompt or response content, unless there is an explicit, disclosed reason. PostHog's LLM analytics uses the $ai_generation event:
posthog.capture('$ai_generation', {
$ai_trace_id: traceId,
$ai_model: response.model, // take the model ID from the API response, don't hard-code it
$ai_provider: 'anthropic',
$ai_input_tokens: usage.input_tokens,
$ai_output_tokens: usage.output_tokens,
$ai_latency: latencySeconds,
feature: 'project_assistant', // custom properties are allowed alongside
});
PostHog's provider SDK wrappers send this event automatically; prefer them over hand-written capture where available, and check their privacy-mode setting so content is not stored.
Starter dashboards - build these first for any new product or major feature:
object_verb_failed event exists if the action can fail visiblycapture()rg -n "posthog\.capture\(|\.capture\(\s*['\"]" --type ts --type js (ripgrep's ts type includes .tsx; adjust for server SDKs and other languages).email, name, phone, address, ip) or that pass raw user input.^[a-z]+(_[a-z]+)+$ or not object-first. Propose renames with a migration note; renames break historical dashboards.identify() runs on signup and login, and reset() on logout.Show: the implemented taxonomy (event names and properties), a PostHog query or screenshot of the new events arriving with correct properties, and the PII search output showing it came back clean - not just an assertion.
reset() on logout on shared devices.capture() properties in production: stop. It needs a fix plus a possible deletion of historical events; escalate to the project owner instead of only patching forward.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub stylusnexus/agent-plugins --plugin ship-pipeline16 skills in this plugin
/api-designREST conventions for Next.js App Router route handlers — resource naming, versioning, cursor pagination, one error envelope, Zod request/response validation, status-code rules, OpenAPI generated from Zod, and response scrubbing (no secrets, hashes, or other users' data). Use when asked to "design an API route", "add a new endpoint", "review this route handler", "fix our error responses", or "generate API docs"./backup-verifyConfirm database backups exist AND actually restore, by enumerating Neon branch snapshots / Supabase scheduled backups / pg_dump artifacts, restoring into a scratch branch, running smoke queries, and recording timestamped evidence. Use before any risky migration or production mutation, and on a monthly cadence regardless./cdfUse when the user types /cdf or $cdf, or asks for issue numbers "comma-delimited". Output any list of GitHub issues as one plain comma-separated line of numbers, nothing else added./db-migration-safetyWrite or review Prisma and Supabase database migrations safely using the expand-contract pattern, idempotent SQL, and batched backfills. Use when adding/changing columns or tables, writing a migration PR, or reviewing one before merge — especially against Neon Postgres or Supabase in production./db-truthGround every database claim in the live database. Repo-agnostic — pre-work verification before any spec, plan, or code that touches tables (schema shape, M2M vs scalar, RLS/permissions, function properties), and post-apply verification that migrations actually landed (ledger, object existence, type regen). Defers to a repo-local db-truth skill when one exists. Use BEFORE designing anything DB-touching and AFTER every migration apply./deployPromote the integration branch to production as one authorized batch. Repo-agnostic — detects the repo's branch names, merge strategy, and release tooling from its own history, and defers to any repo-local runbook. Freezes the source commit, proves the live artifact matches it, records migration, publish, smoke, and rollback evidence, and closes only issues proved shipped. Use when ready to push to production.