/rudder-ai-events:rudder-ai-events-setupfrom rudder-ai-events
Onboards an app to RudderStack AI events (spec v0.4) by discovering LLM, chat, agent, browser and MCP surfaces, then drafting an ai-events.md plan. Use when adding @rudderstack/ai, rudderstack-ai or ai-sdk-go.
Ships in rudder-ai-events. 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.
Takes an existing app with LLM features to the standard RudderStack AI events (spec v0.4): one ai_user_prompt_created and one ai_response_received per answer, ai_user_action for feedback, and mcp_* events for MCP servers, through the app's existing RudderStack client. SDKs, each for chat, background agents and MCP servers: @rudderstack/ai (Node.js 24+, or Deno via npm compatibility), rudderstack-ai (Python 3.12+) and github.com/rudderlabs/ai-sdk-go (public Go modules, one per provider integration; the Go floor is the go line of the chosen version's go.mod). Use 0.8.0 / v0.4.0 or later (spec v0.4, with the migration check and recorders verify uses); resolve the latest in step 2.3 and never invent one. Other product events (non-AI features): rudder-code-first-instrumentation or rudder-design-first-instrumentation.
| Step | What | Who |
|---|---|---|
| 1. Discover | Find every AI surface, read-only | this skill |
| 2. Plan | Write ai-events.md, ask once, then stop for approval | this skill |
| 3. Instrument | Minimal code changes from the approved plan | rudder-ai-events-instrument |
| 4. Verify | Capture events locally, validate against the spec | rudder-ai-events-verify |
Resuming. If ai-events.md already exists at the repo root, read it, then before anything else: fetch and compare the branch with the default branch (git fetch, git log HEAD..origin/<default>) and, if it is behind, say so (the user decides whether to update it); re-resolve the latest SDK versions (step 2.3); re-check every entry under Dependencies and blockers. Correct the plan where any of these changed (an approved plan goes back to draft). Then status: approved goes to step 3; status: draft re-presents the plan (step 2.6).
Change nothing. Use Glob, Grep, Read and the read-only commands allowed above; do not run the app, install packages or read .env files. Patterns for every check: references/discovery.md.
references/discovery.md, "Install preflight".chat (a person waits for the answer, including Slack replies and one-shot buttons: generate, suggest, autofill, summarize, rewrite, translate, fix, planned with input_method: button and conversation_id set to the interaction ID, plus their accept, edit and reject handlers), background (cron, queue, webhook, Lambda, CLI script, automated Slack message with no person waiting, MCP Events run), client (browser chat UI on the RudderStack JavaScript SDK), mcp (each MCP server, and each endpoint that serves one). A UI call that fires on page load without a typed prompt is background. Note channel, attachments, streaming, thread pools, tool loops, per-item fan-out, and where each entry point already records its own failures, including best-effort generators that swallow an unparseable reply and return an empty result (they must end with a failure status). Every call site found goes in the plan. Recommend skipped for dev-only local CLI/REPL surfaces with no user identity in the batched questions (override any); instrument the rest unless blocked or the user opts out. Detect Claude Agent SDK session resume and its usage store, human-in-the-loop pauses (LangGraph interrupt(, Claude Agent SDK permission callbacks, OpenAI Agents SDK approvals: paused with pause_reason), plan repeated pauses with in-process or JSON snapshot resume, and estimate events per turn and run with sample_rates for high-volume MCP and per-call events (references/discovery.md, section 2). Answers and client copies stay unsampled by default.identify(), and the config library the app uses for flags (does it reload at runtime?). Also mobile RudderStack SDKs and AI events sent from Java, Ruby, PHP or raw HTTP: each is a surface with status: unsupported and its reason.track() calls about chats, prompts, answers, tokens or feedback; feedback/copy/retry handlers and whether their requests carry the answer and conversation IDs; accept/reject blocks. Search the wider names too (agent, tool, run, job, handoff, hitl, credit, generate, suggestion, confidence) and schema-generated emitters. Compare each legacy field by meaning, not name (field aliases and mapping rows: references/ai-events-md.md), run every breaking-change check there, and list the legacy fields that carry raw prompts, answers, feedback text, emails or file names.userId comes from today (path:line), account/workspace, and whether browser cookies reach it.ai-events.md at the repo root with status: draft, following references/ai-events-md.md exactly: ## What changes first, then the other sections with their exact headings in order, and every machine value in the Config yaml block (it wins when a section disagrees). One surfaces entry per surface found, including skipped, blocked and MCP ones; reference code by path plus symbol.capture_content: false. Classifier off. Scores off unless the app already computes them. identity_from_cookies: false without a browser.remove_after: null).client_events.switch_source; add a local legacy switch only when local legacy events exist.total_cost_usd is absent, a TODO goes at the price config, prices_missing goes under Known limits, and verify uses dummy prices. Claude Agent SDK reported cost needs no rates for new sessions; resumed sessions need a usage baseline choice (step 2.5). Never look up or suggest rates; the customer supplies their own.event_rules only for tools whose call is itself a product action. MCP: request_context on with the server's intents; declared tool events for tools that change data (no readOnlyHint); capability requests and MCP Events off; one wrap per endpoint with a distinct server name.none unless step 1.5 found a tool. When another exporter (Langfuse and the like) owns the OpenTelemetry provider, pass its trace ID as traceId / trace_id / TraceID rather than adding the SDK's span processor with linkTraceId: true (Node.js registerTracing throws when another global tracer provider is registered). Say so before approval.feat/ai-events when on the default branch.devEngines can fail npm view): npm view @rudderstack/ai version, pip index versions rudderstack-ai, go list -m -versions github.com/rudderlabs/ai-sdk-go, plus each Go integration module the plan uses (go list -m -versions github.com/rudderlabs/ai-sdk-go/rudderopenai): they carry their own tags, and each exact version goes into sdks[].extras. Use 0.8.0 / v0.4.0 or later. Go: read the go line of that version's go.mod as the toolchain floor. Node.js: an installed @rudderstack/rudder-sdk-node below 3.0.16 conflicts with the optional peer range; plan the core SDK upgrade. Release-age gate newer than the version: plan an exemption. Check the exact upgraded framework's own peers and every forced bump too. Use the latest published version from the registry; when the user names an unreleased exact target, record it as the plan target under Dependencies and blockers and sdks[].version, with a note that installation waits for publication. Raise every install blocker now, not after approval.other; background-only apps with the classifier off: [other]. Outcomes: the SDK default. MCP servers get their own list from tool names and descriptions (published in every tool schema: no sensitive categories). When the app already computes a category or outcome before the answer ends, propose reusing it (setIntent / setOutcome). One computed after the answer has ended (a summarizer, a later job) cannot reach the answer: a later setIntent is ignored once ai_response_received is sent. Plan it as a score on that answer instead: trackScore / track_score / TrackScore with the answer's interaction_id and conversation_id, evaluation_name naming the category (topic), score_label the value and evaluator: model or code (scores.evaluator: manual); it arrives as ai_interaction_scored, joined by interaction_id, not in the intent column. When the category is a function of the turn's prompt and answer alone, the classifier with the app's own classify function is the alternative: it runs after each successful answer and sends ai_interaction_classified (it needs prompt or answer text: promptText, or content capture for the answer).path:line) under one heading, "override any": surface kinds, channels, feature and task_name, units and child tasks, conversation and interaction ID sources, dev-only skipped recommendations, server repo/plan dependencies, switch source and server-first PR ordering, client copies, event rules, legacy mapping, every default above.references/discovery.md, section 6: entry point, caller, auth, current userId source, proposed source, tradeoff): identity where the table leaves a real choice, the intent and outcome lists, and anything the code cannot decide (a route with no auth, a job with no clear tenant). For resumed Claude Agent SDK sessions: persist snapshot (recommended), mark resumed with no durable baseline (cost needs registered prices when no cached baseline exists), or in-memory only (breaks across pods/restarts). For typed browser tracking: add client events to the catalog and use generated calls (recommended when codegen exists), or the raw helper where repo rules permit it. Write the answers into the draft.identity.open_questions must be empty before approval.## What changes first, in full; then each other section in a few lines, pointing at ai-events.md for detail. Ask: "Approve this plan as written?" In the same message, offer step 7 in one line. Only an unambiguous yes ("yes", "approved", "go ahead") sets status: approved. A yes while edits are pending is not approval: apply them, show only the diff, ask again. Never start step 3 on a draft.end_reason on shutdown or TTL; declare only those events and properties (no prompt_text / response_text while capture is off, no free-text fields the app never sets), with shapes from spec/ai-events-v0.4.schema.json. With unsupported senders (mobile, Java, Ruby, PHP, raw HTTP), offer it as their spec-only path: the tracking plan plus one sample payload per event they would send, so their hand-built events validate at the source. Use rudder-tracking-plans and rudder-cli-workflow if installed; otherwise point to the RudderStack CLI docs (https://www.rudderstack.com/docs/dev-tools/rudder-cli/). No answer or no: skip it. Run it after approval.ai-events.md to the file git rev-parse --git-path info/exclude prints (in a worktree .git is a file) when drafting it: instrument and verify resume from the working tree, while in history it drifts from the code. That file belongs to the repository, not the worktree: an ai-events.md is then ignored in every worktree of the repo, which is harmless but worth one line to the user. Git has no per-worktree exclude file (per-worktree core.excludesFile under extensions.worktreeConfig replaces the user's global ignore file), so do not work around it. Commit it only when the user asks or the repo already keeps design docs in-tree. Do not commit or push unless the user asks.Files the instrumentation typically touches (list the actual paths under Files to change):
| Change | Node.js | Python | Go |
|---|---|---|---|
| Install | package.json, lockfile; Deno: selected manifest (deno.json, deno.jsonc or package.json), configured lockfile if enabled (discover actual paths) | pyproject.toml or requirements*.txt, lockfile | go.mod, go.sum |
configure() and switches | the module that creates the RudderStack client | the same, or app startup (lifespan, AppConfig.ready) | rudderstackai.Configure where the analytics-go client is built |
| Wrapper / integration | where the model client or agent is constructed | the same | the same: rudderopenai.WithTracking(), ... |
| MCP server | each endpoint's server: wrapMcpServer | the same: wrap_mcp_server | the same: WrapMCPServer / ruddermcpgo.WrapServer |
| Identity middleware | the app/server setup file | ASGI app, Django settings, Flask factory | rudderstackai.Middleware around the handlers, or WithValues in each |
| Interaction or task | each chat route / job entry point | the same | the same: RunInteraction / RunTask |
| Feedback | each feedback endpoint, and the client request that calls it | the same | the same: TrackAction |
| Flush | the shutdown hook (shutdown()), or the end of a script/handler | the same | rudderstackai.Shutdown(ctx), then client.Close() |
| Browser | the page script that renders the chat and its buttons |
Hand off to rudder-ai-events-instrument with the approved plan, then to rudder-ai-events-verify. If either finds that something differs from the plan (an unsupported surface, different identity, a new endpoint change), update ai-events.md, set it back to draft and return to step 2.6. The same holds after approval for a route change or a file outside Files to change. Refreshing path / symbol references after code moves needs no re-approval.
aiInteraction / ai_interaction per user turn, one aiTask / ai_task per background run or planned child step; never one per conversation or per process.source: client and only what the browser saw; dashboards count answers from the server rows.client surface is then skipped.Tell the user the ones that apply before approval; record them in the plan's Known limits section and in Config known_limits by id. The list, with ids: references/ai-events-md.md, "Known limit ids".
.env files, key files or secret stores; record environment variable names only.ai-events.md.references/discovery.md: patterns for runtimes, libraries, install preflight, entry points (one-shot features, human-in-the-loop, volume), browser and mobile, legacy events, tracing, MCP endpoints, the identity table, intents.references/ai-events-md.md: the plan layout, ## What changes, a complete example, Config keys, known limit ids, field rules, breaking-change checks, legacy-event mapping and field aliases.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub rudderlabs/rudder-agent-skills --plugin rudder-ai-events3 skills in this plugin
/rudder-ai-events-instrumentAdds RudderStack AI events code from an approved ai-events.md plan: installs @rudderstack/ai, rudderstack-ai or ai-sdk-go, wraps model clients and MCP servers, opens interactions and tasks, wires feedback and browser events. Use when implementing an approved AI events plan./rudder-ai-events-verifyVerifies RudderStack AI events locally and checks a move from existing RudderStack events: validates captures against the v0.4 schema, joins, switches and legacy events. Use when testing AI events, comparing old and new tracking, or when AI or MCP events look wrong or missing.Other plugins' skills for the same job