rudder-ai-events-instrument

rudder-ai-events-instrument is a skill for Claude Code from rudderlabs/rudder-agent-skills. It costs 68 tokens per session (2,484 once invoked), scanned A, original, MIT.

An implementation guide that adds RudderStack AI event tracking from an approved `ai-events.yaml` plan. It provides recipes for Node.js, Python, and Go, including model clients, MCP servers, feedback, and browser events.

In plain words
What is it for?
Use it to install the relevant SDK, wrap AI or MCP code, connect feedback and browser events, and run checks after each changed surface.
Why use it?
It keeps tracking changes limited to the approved surfaces and prevents code from being added from an unfinished plan. It also requires exact SDK versions for the event specification being used.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Part of the rudder-ai-events plugin — 3 skills shipped together

Good fit Use it to install the relevant SDK, wrap AI or MCP code, connect feedback and browser events, and run checks after each changed surface.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/rudderlabs/rudder-agent-skills/rudder-ai-events-instrument
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add rudderlabs/rudder-agent-skills --skill rudder-ai-events-instrument
Clone the repo
git clone --depth 1 https://github.com/rudderlabs/rudder-agent-skills

Made for: Claude Code.

Or install rudder-ai-events, the plugin that ships this one along with the rest of its 3 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for rudder-ai-events-instrument

README.md
[![agentmods](https://agentmods.dev/badge/skills/rudderlabs/rudder-agent-skills/rudder-ai-events-instrument/github.svg)](https://agentmods.dev/skills/rudderlabs/rudder-agent-skills/rudder-ai-events-instrument)
Your own site
<a href="https://agentmods.dev/skills/rudderlabs/rudder-agent-skills/rudder-ai-events-instrument"><img src="https://agentmods.dev/badge/skills/rudderlabs/rudder-agent-skills/rudder-ai-events-instrument/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for rudder-ai-events-instrument

Your own site · 80×15
<a href="https://agentmods.dev/skills/rudderlabs/rudder-agent-skills/rudder-ai-events-instrument"><img src="https://agentmods.dev/badge/skills/rudderlabs/rudder-agent-skills/rudder-ai-events-instrument.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 68 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,484 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00068 $0.02484
Opus 5.5 $0.00027 $0.00994
Sonnet 5.5 $0.00014 $0.00497
Haiku 4.5 $0.00007 $0.00248

Measured yesterday against content hash 30f59a93330f, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

rudder-ai-events-instrument scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/rudder-ai-events/skills/rudder-ai-events-instrument/SKILL.md · 80 lines

How it starts

The opening of the file, as written. The whole thing — 80 lines — stays where its author put it; the contents beside it link to each section on GitHub.

RudderStack AI Events Instrumentation

Turns the approved plan into the smallest reviewable diff, for AI events spec v0.3. Recipes with exact code: references/node.md, references/python.md, references/go.md, references/client-events.md. Each recipe names the SDK examples that show the same change end to end.

Preconditions

  1. ai-events.yaml exists at the repo root with metadata.status: approved. Missing or draft: stop and run rudder-ai-events-setup; never instrument from an unapproved plan.
  2. Every surface you are about to change has status: instrument. Skip the rest (skipped, blocked, unsupported).
  3. Apart from ai-events.yaml, the working tree is clean, or the user agreed to mix changes. Work on a branch if the user uses them.
  4. The SDK release that ships spec v0.3 exists for each language in the plan (<VERSION> in the recipe files). If it does not, stop: never install 0.4.0 (spec v0.2) for a v0.3 plan, or a branch or pseudo-version.

Order of changes

Do one surface at a time; after each, run the app's type check or tests if it has them.

  1. Install the SDK in each sdks[].path with an exact pin, using the repo's package manager:

    npm install --save-exact @rudderstack/ai@<VERSION>
    uv add "rudderstack-ai[<extras from the plan>]==<VERSION>"   # e.g. rudderstack-ai[anthropic]==<VERSION>
    go get github.com/rudderlabs/ai-sdk-go@<VERSION>           # plus one module per provider: .../rudderopenai@<VERSION>, ...
    

    <VERSION> is the plan's sdks[].version, the release that ships spec v0.3 for that language. Other managers: section 1 of the recipe files. Never add a version range, and never bump the app's own LLM libraries. Add @rudderstack/[email protected] / rudder-sdk-python==2.1.9 only when the plan says client: new.

  2. Configure once in a module that runs before the first request or job: next to the RudderStack client, at module level, works when the app imports it at startup. configure({ analytics }) with the existing client (Go: rudderstackai.Configure(rudderstackai.WithAnalytics(client), ...)), plus the spec.config keys that are configure() options (Node.js camelCase, Go With* options). intents / outcomes go only into the classifier. captureContent stays false unless the plan says otherwise.

  3. Wrap the model client or add the framework integration at its construction site, per the surface's integration. Call sites keep working unchanged.

  4. Chat surfaces: identity middleware (aiContextMiddleware, withAiContext, AIContextMiddleware, Django/Flask middleware; Go: rudderstackai.WithValues(ctx, ContextValues{Request: r, ...})) or request / cookies on the interaction; then one aiInteraction / ai_interaction / RunInteraction per user turn at the entry point. Wrap only the model-call part of the handler when the rest (history, legacy event, response) needs its result. Pass userId, conversationId, feature, surface, and interactionId when the plan's interaction_id_source is client (validated UUID) or app. Streams: return them from the callback or bind() them (Go: read them inside the RunInteraction function). Always return the ID the interaction used to the client.

  5. Feedback endpoints (the plan's surfaces[].feedback): trackAction / track_action with interactionId, conversationId, surface and the action type; the browser sends its own copy too (step 8); opt_out: [server_feedback] means serverFeedback: false / server_feedback=False in configure(), not deleting the call; when the plan lists request_changes, extend the client request and the endpoint to carry those IDs. Keep the endpoint's existing behaviour; do not copy placeholder user IDs ('anonymous') from legacy code.

  6. Background surfaces: one aiTask / ai_task / RunTask per run at the job's entry point with task_name, trigger_source (plus trigger_event_id for mcp_event), a stable scoped conversationId, accountId / onBehalfOf from the plan, and no user ID; one child task per planned child_tasks entry. Python thread pools: propagate(fn).

  7. MCP servers (type: mcp): one wrapMcpServer / wrap_mcp_server / rudderstackai.WrapMCPServer (go-sdk) / ruddermcpgo.WrapServer (mcp-go) call where the server is built, before it connects (for a server factory, inside the factory), with the plan's identify mapping, request_context intents, declared tool events and capability requests. Tools stay untouched. Distinct servers need distinct names: state is per server name, per process.

  8. Flush: add the SDK's flush() to the existing shutdown hook for servers (keep the existing client flush); before return/exit for scripts, cron jobs and serverless handlers (a top-level task flushes itself). Node.js and Python flush() is bounded (10 s per client) and returns false on timeout, never throws. Go: rudderstackai.Flush(0), then client.Close() on analytics-go.

  9. Client surface: a trackAi helper on the existing rudderanalytics instance, the interaction_id sent with each chat request, then the events listed in client_events in their UI handlers. By default that includes the client copies of the prompt and answer and of feedback (source: client), sent alongside the server's, never sampled, and carrying only what the browser saw; click-through is ai_user_action with action_type: clicked_through.

  10. Optional config from the plan only: eventRules, classifier (the app's own client and model; intents without other), scores (trackScore / track_score or the evaluator hook), prices (with tier, long-context and server-tool options when listed), toolBreakdown, and trace_id per the plan's tracing: Node.js and Python fill it from the first OpenTelemetry span in the interaction when the SDK's span processor is registered (registerTracing / register_tracing); Go needs WithTraceIDFrom(rudderotel.TraceID); another tool passes traceId / trace_id / TraceID, which always wins.

  11. Legacy events: leave each old track() call as it is, wrapped in the plan's flag, defaulting on.

  12. Refresh references: update path / symbol entries in ai-events.yaml that moved; this keeps status: approved.

Read the full file on GitHub · 80 lines

Files

What ships with it

4 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 80 lines · 68 tokens per session scan A 30f59a93330f

Subscribe to this mod's changes

rudder-ai-events-instrument is a skill published in the GitHub repository rudderlabs/rudder-agent-skills (19 stars, last pushed today), licensed MIT. It adds 68 tokens to every session and 2,484 once invoked, about $0.0003 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-10-20.

Related

Other skills, from other repositories

scientific-figure-prompt-compiler

Transform concise scientific or technical descriptions into structured visual specifications and high-quality image-generation prompts. Use for scientific figures, technical diagrams, system architectures, mechanisms, workflows, spatial models, timelines, layered systems, and information-dense visuals. Model-agnostic…

basejb/skills · 72 tokens

seo-optimizer

Search Engine Optimization specialist for content strategy, technical SEO, keyword research, and ranking improvements. Use when optimizing website content, improving search rankings, conducting keyword analysis, or implementing SEO best practices. Expert in on-page SEO, meta tags, schema markup, and Core Web Vitals.

basejb/skills · 60 tokens

ai-collab-evaluator

A review of Claude Code session logs against four hiring criteria for working with AI: how you handle, use, and question AI, and how you weigh trade-offs.

basejb/skills · 169 tokens

learning-companion

A guided learning tool that turns official documents or other sources into lasting study notes through five stages, including explanation, recall, reflection, and next steps.

basejb/skills · 134 tokens

oss-tour

A guided method for learning an unfamiliar open-source repository in layers, from the whole project to folders and core modules. An open-source repository is a publicly available code project whose source can be inspected.

basejb/skills · 106 tokens

image-optimizer

An image-processing tool that converts images to WebP, an image format that can reduce file size while preserving visual quality. It handles individual images, groups of images, and whole directories.

basejb/skills · 43 tokens