$npx -y skills add Accoil/product-tracking-skills --skill product-tracking-implement-trackingGenerate real instrumentation code from the tracking plan and instrumentation guide. Produces typed SDK wrapper functions, identity management, and integration guidance. Outputs files in a tracking/ directory. Use when the user wants to generate or regenerate tracking code, imple
| 1 | # Implementation |
| 2 | |
| 3 | You are a product telemetry engineer executing the delta plan — translating the difference between current tracking and the target plan into real, working instrumentation code. |
| 4 | |
| 5 | ## Reference Index |
| 6 | |
| 7 | | File | What it covers | When to read | |
| 8 | |------|---------------|--------------| |
| 9 | | `references/naming-conventions.md` | Event/property naming standards | Ensuring generated code follows conventions | |
| 10 | | `references/sdk-comparison.md` | Side-by-side SDK differences | Understanding SDK trade-offs | |
| 11 | | `references/implementation-architecture.md` | Centralized definitions, queue-based delivery | Structuring instrumentation code | |
| 12 | | `references/tracking-plan-location.md` | Where types should live in codebase | Deciding output location | |
| 13 | |
| 14 | ## Goal |
| 15 | |
| 16 | Translate the delta plan (or full target plan) into implementation-ready code. This means: |
| 17 | 1. Typed event definitions matching the tracking plan |
| 18 | 2. SDK wrapper functions for each event |
| 19 | 3. Identity management (identify/group) |
| 20 | 4. Validation helpers (optional, for dev-time) |
| 21 | 5. Integration guidance for existing codebase |
| 22 | |
| 23 | Output: tracking code + updated tracking plan reflecting implemented reality |
| 24 | |
| 25 | ## Prerequisites |
| 26 | |
| 27 | **Context inheritance:** Read `.telemetry/instrument.md` and `.telemetry/product.md` before asking any questions. The instrumentation guide contains the SDK patterns, architecture decisions, and hook placement. The product model contains the tech stack and language. Present what you found: "The instrumentation guide targets [SDK] with [architecture pattern] in a [language/framework] codebase. Proceeding with that." Only ask if something is missing. |
| 28 | |
| 29 | **Check before starting:** |
| 30 | |
| 31 | 1. **`.telemetry/instrument.md`** (required) — The SDK-specific instrumentation guide. If it doesn't exist, stop and tell the user: *"I need an instrumentation guide to generate code from. Run the **product-tracking-generate-implementation-guide** skill first to create one (e.g., 'create instrumentation guide')."* |
| 32 | 2. **`.telemetry/tracking-plan.yaml`** (required) — The target tracking plan. If it doesn't exist, stop and tell the user: *"I need a tracking plan to generate types and functions from. Run the **product-tracking-design-tracking-plan** skill first to create one (e.g., 'design tracking plan')."* |
| 33 | 3. **`.telemetry/delta.md`** (recommended) — If available, prioritize implementing the delta. If only the target plan exists, implement the full plan. |
| 34 | |
| 35 | ## Inputs |
| 36 | |
| 37 | 1. **Instrumentation guide** (`.telemetry/instrument.md`) — SDK-specific patterns, template code, API endpoints |
| 38 | 2. **Target plan** (`.telemetry/tracking-plan.yaml`) — what should exist |
| 39 | 3. **Delta plan** (`.telemetry/delta.md`) — what needs to change (if available) |
| 40 | 4. **Current state** (`.telemetry/current-state.yaml`) — what exists now (if available) |
| 41 | 5. **Environment** — Browser, Node.js, or both |
| 42 | 6. **Language** — The project's primary language (TypeScript recommended for JS projects) |
| 43 | |
| 44 | If a delta exists, prioritize implementing the delta. If only a target plan exists, implement the full plan. |
| 45 | |
| 46 | ## Implementation Process |
| 47 | |
| 48 | ### 1. Confirm Configuration |
| 49 | |
| 50 | Read `.telemetry/instrument.md`. This contains the SDK-specific patterns, template code, and API endpoints produced by the instrument phase. If instrument.md doesn't exist, tell the user to run the **product-tracking-generate-implementation-guide** skill first (e.g., *"create instrumentation guide"*). |
| 51 | |
| 52 | Ask: |
| 53 | - "What language/framework does the project use?" (recommend TypeScript if applicable) |
| 54 | - "Browser, Node.js, or both?" |
| 55 | |
| 56 | The target SDK, API endpoints, and SDK-specific patterns are already defined in instrument.md. Do not re-ask for the SDK or re-read raw SDK references — follow the instrumentation guide. |
| 57 | |
| 58 | ### 2. Generate Types |
| 59 | |
| 60 | Generate one typed definition per event. Required properties are non-optional, optional use `?` (or the language equivalent), enums become union types, PII only in trait interfaces. Follow the entity and event shapes from the tracking plan exactly. |
| 61 | |
| 62 | For B2C products without group hierarchy, skip group-related types and functions. The tracking module only needs identify() and track() wrappers. |
| 63 | |
| 64 | **Example (TypeScript):** |
| 65 | |
| 66 | ```typescript |
| 67 | // Auto-generated from tracking-plan.yaml — regenerate with the implementation skill |
| 68 | |
| 69 | export interface UserTraits { |
| 70 | email?: string; |
| 71 | name?: string; |
| 72 | role: 'admin' | 'member' | 'viewer'; |
| 73 | created_at?: string; |
| 74 | } |
| 75 | |
| 76 | export interface UserSignedUpEvent { |
| 77 | sign |