The Currai Skill

Install the Currai agent skill so Claude Code or Cursor can instrument your app with traces, generations, and spans automatically.

The Currai Skill is an agent skill for AI coding tools like Claude Code and Cursor. Once installed, your coding agent knows how to wire Currai into an app the right way — the trace → observation model, the client singleton pattern, MCP tool wrapping, Vercel AI SDK integration, and the flush hygiene serverless needs. Ask it to "add tracing", "log my LLM calls", or "see token usage" and it produces instrumentation that matches Currai's conventions instead of guessing.

The skill is published at skills.sh and lives in the open-source curraiapp/skills repo.

Install the skill

Add the skill to your project with one command:

npx skills add https://github.com/curraiapp/skills --skill currai

This drops the skill's SKILL.md into your agent's skills directory, where it's discovered automatically — Claude Code and Cursor load it whenever a task involves observability or currai.

Then add the SDK to your app:

pnpm add currai

And set your keys (the SDKs are server-side — never ship the secret key to the browser):

CURRAI_PUBLIC_KEY=pk-lf-...
CURRAI_SECRET_KEY=sk-lf-...
# CURRAI_BASE_URL is optional — only set it if you self-host.

See Authentication for how to create keys.

What the skill teaches

The skill encodes Currai's recommended patterns so your agent gets them right the first time:

  • Client singleton — instantiate Currai once per process and stash it on globalThis so HMR and route handlers don't create duplicates.
  • Trace anatomy — one trace per request or agent turn, with sessionId and userId so the dashboard can group by conversation and user.
  • The observation hierarchygenerations (one LLM call, with model, modelParameters, and usage), spans (tool calls, retrieval, MCP connect/close), and events (point-in-time markers). Spans nest under generations via parentObservationId.
  • Error handling — end an observation with level: "ERROR" and a statusMessage on failure, rather than throwing and losing the record.
  • MCP tool wrapping — a drop-in instrumentTools helper that wraps every MCP tool's execute so each invocation becomes a child span automatically.
  • Vercel AI SDK integration — wire generation.end() and trace.update() into streamText's onFinish/onError.
  • Flush hygiene — always await currai.flushAsync() before a serverless function returns.

Using it

After the skill is installed, prompt your agent in plain language:

Add Currai tracing to my chat route.

The agent will create the client singleton, wrap the request in a trace, record the model call as a generation with token usage, wrap any tool calls as spans, and flush before returning. The result follows the same shape as Your first trace:

const trace = currai.trace({
  name: "chat-turn",
  sessionId,
  userId,
  input: { messages },
});

const generation = trace.generation({
  name: "openai.chat.completions",
  model: "gpt-4o-mini",
  input: messages,
});

// ...call the model...

generation.end({
  output: completion.choices[0].message,
  usage: {
    input: usage.inputTokens ?? null,
    output: usage.outputTokens ?? null,
    total: usage.totalTokens ?? null,
    unit: "TOKENS",
  },
});

trace.update({ output: text });

Next steps