rudder-ai-events-instr…
Adds RudderStack AI events code from an approved ai-events.md plan: installs @rudderstack/ai, rudderstack-ai or ai-sdk-go, wraps…
Derives tracking plans from existing codebase types and structures. Use when instrumenting an existing product that wasn't well-instrumented or restructuring existing tracking.
Claude Code
$ npx -y skills add rudderlabs/rudder-agent-skills --skill rudder-code-first-instrumentation --agent claude-code
Codex
$ npx skills add rudderlabs/rudder-agent-skills --skill rudder-code-first-instrumentation -a codex -y
Cursor
$ npx skills add rudderlabs/rudder-agent-skills --skill rudder-code-first-instrumentation -a cursor -y
Gemini CLI
$ npx skills add rudderlabs/rudder-agent-skills --skill rudder-code-first-instrumentation -a gemini-cli -y
GitHub Copilot
$ npx skills add rudderlabs/rudder-agent-skills --skill rudder-code-first-instrumentation -a github-copilot -y
OpenCode
$ npx skills add rudderlabs/rudder-agent-skills --skill rudder-code-first-instrumentation -a opencode -y
Windsurf
$ npx skills add rudderlabs/rudder-agent-skills --skill rudder-code-first-instrumentation -a windsurf -y
name: rudder-code-first-instrumentation description: Derives tracking plans from existing codebase types and structures. Use when instrumenting an existing product that wasn't well-instrumented or restructuring existing tracking. allowed-tools: "Bash(rudder-cli *), Read, Write, Edit"
This skill guides instrumentation planning for **existing products** where you derive tracking plans from the codebase's existing types and structures.
| Scenario | Use This Skill? | |----------|-----------------| | Existing product needs instrumentation | Yes | | Codebase has domain types (enums, interfaces) you want to track | Yes | | Restructuring messy existing tracking | Yes | | Building new feature, events not yet defined | No — use `rudder-design-first-instrumentation` | | LLM chat, AI agent or MCP server usage | No — use `rudder-ai-events-setup` (standard AI events via the AI SDKs) |
When a product already exists, the code contains valuable type information:
Deriving tracking plans from code types:
> "If I say plan, that cannot mean many things. It's the plan. I have to be specific."
┌─────────────────────────────────────────────────────────────────────┐
│ CODE-FIRST INSTRUMENTATION │
└─────────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────┐
│ 1. DISCOVER │ ← Identify domain types in codebase
│ CODE TYPES │
└────────┬────────┘
▼
┌─────────────────┐
│ 2. MAP TYPES │ ← Translate code types to tracking plan types
│ TO YAML │
└────────┬────────┘
▼
┌─────────────────┐
│ 3. IDENTIFY │ ← What user actions should be tracked?
│ EVENTS │
└────────┬────────┘
▼
┌─────────────────┐
│ 4. BUILD │ ← Create YAML referencing the types
│ TRACKING │
│ PLAN │
└────────┬────────┘
▼
┌─────────────────┐
│ 5. VERIFY │ ← TypeScript compilation validates alignment
└────────┬────────┘
▼
┌─────────────────┐
│ 6. TEST & APPLY │ ← Verify in dev workspace, apply to prod
└─────────────────┘Scan the codebase for domain types that should flow through to analytics.
| Type Category | Examples | Tracking Plan Equivalent | |---------------|----------|-------------------------| | Enums | `BillingPlan`, `UserRole`, `Region` | Property with enum config | | String unions | `type Status = 'active' \| 'inactive'` | Property with enum config | | Interfaces | `Product`, `Workspace`, `User` | Custom type | | Constants | `PLAN_TYPES`, `REGIONS` | Property enum values |
# Find enums in TypeScript codebase
grep -r "enum " --include="*.ts" --include="*.tsx" src/
# Find type unions
grep -r "type.*=" --include="*.ts" src/ | grep "|"
# Find interfaces that might be tracked
grep -r "interface.*{" --include="*.ts" src/types/// Found in src/types/workspace.ts
enum BillingPlan {
FREE = 'free',
STARTER = 'starter',
GROWTH = 'growth',
ENTERPRISE = 'enterprise',
}
enum Region {
US = 'us',
EU = 'eu',
}
// Found in src/types/transformation.ts
type TransformationLanguage = 'javascript' | 'python';
// Found in src/types/audience.ts
enum ConditionGroupType {
AND = 'and',
OR = 'or',
AUDIENCE = 'audience',
}Translate discovered code types to tracking plan YAML.
// Code
enum BillingPlan {
FREE = 'free',
STARTER = 'starter',
GROWTH = 'growth',
ENTERPRISE = 'enterprise',
}# Tracking plan property
version: "rudder/v1"
kind: "property"
metadata:
name: "properties"
spec:
name: "billing_plan"
type: "string"
description: "Organization billing plan"
config:
enum:
- "free" # Exact match to BillingPlan.FREE
- "starter" # Exact match to BillingPlan.STARTER
- "growth" # Exact match to BillingPlan.GROWTH
- "enterprise" # Exact match to BillingPlan.ENTERPRISE// Code type TransformationLanguage = 'javascript' | 'python';
# Tracking plan property
version: "rudder/v1"
kind: "property"
metadata:
name: "properties"
spec:
name: "transformation_language"
type: "string"
description: "Programming language of transformation"
config:
enum:
- "javascript"
- "python"// Code
interface Product {
id: string;
name: string;
price: number;
category: ProductCategory;
}# Tracking plan custom type
version: "rudder/v1"
kind: "custom-type"
metadata:
name: "custom-types"
spec:
name: "ProductType"
type: "object"
description: "Product information from catalog"
config:
properties:
- property: "urn:rudder:property/product_id"
required: true
- property: "urn:rudder:property/product_name"
required: true
- property: "urn:rudder:property/product_price"
required: true
- property: "urn:rudder:property/product_category"
required: trueThe tracking plan **must** use the exact string values from the code:
// If code uses lowercase
enum Region {
US = 'us', // lowercase
EU = 'eu',
}
// YAML must match
config:
enum:
- "us" # NOT "US"
- "eu" # NOT "EU"Wi
A Claude Code plugin marketplace and Agent Skills collection that teaches your AI coding agent how to drive every programmatic RudderStack surface — CLI, MCP server, Terraform, Profiles, and AI events — with the right preflight checks, commands, and recovery
Adds RudderStack AI events code from an approved ai-events.md plan: installs @rudderstack/ai, rudderstack-ai or ai-sdk-go, wraps…
Onboards an app to RudderStack AI events, including moving existing RudderStack LLM, chat or agent events to them: discovers…
Verifies RudderStack AI events locally and checks a move from existing RudderStack events: validates captures against the v0.3…
Installs and authenticates rudder-cli. Use when installing rudder-cli, setting up rudder cli, rudder-cli command not found, or…
Validates, previews, and applies RudderStack resource changes via YAML specs. Use when iterating on RudderStack resources with…
Imports existing RudderStack workspace resources into YAML files for git-based management. Use when importing existing…
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…
Ask which skill or flow fits your situation. A router over the skills in this repo.