.agents/skills/add-ai-integration/SKILL.md
Add a new AI provider integration to the Sentry JavaScript SDK. Use when contributing a new AI instrumentation (OpenAI, Anthropic, Vercel AI, LangChain, etc.) or modifying an existing one.
npx skillsauth add getsentry/sentry-javascript add-ai-integrationInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Does the AI SDK have native OpenTelemetry support?
|- YES -> Does it emit OTel spans automatically?
| |- YES (like Vercel AI) -> Pattern 1: OTel Span Processors
| +- NO -> Pattern 2: OTel Instrumentation (wrap client)
+- NO -> Does the SDK provide hooks/callbacks?
|- YES (like LangChain) -> Pattern 3: Callback/Hook Based
+- NO -> Pattern 4: Client Wrapping
If an AI SDK only works in one runtime, code lives exclusively in that runtime's package. Do NOT add it to packages/core/.
packages/node/src/integrations/tracing/{provider}/packages/cloudflare/src/integrations/tracing/{provider}.tspackages/browser/src/integrations/tracing/{provider}/packages/core/src/tracing/{provider}/ with runtime-specific wrappersgen_ai.invoke_agent — parent/pipeline spans (chains, agents, orchestration)gen_ai.chat, gen_ai.generate_text, etc. — child spans (actual LLM calls)packages/core/src/tracing/ai/)gen-ai-attributes.ts — OTel Semantic Convention attribute constants. Always use these, never hardcode.utils.ts — setTokenUsageAttributes(), getTruncatedJsonString(), truncateGenAiMessages(), buildMethodPath()startSpan(), set attributes from responsestartSpanManual(), accumulate state via async generator or event listeners, set GEN_AI_RESPONSE_STREAMING_ATTRIBUTE: true, call span.end() in finally blockparams.stream === trueopenai/streaming.ts (async generator), anthropic-ai/streaming.ts (event listeners)setTokenUsageAttributes()invoke_agent): Accumulate from children using event processor (see vercel-ai/)Use when: SDK emits OTel spans automatically (Vercel AI)
add{Provider}Processors() in packages/core/src/tracing/{provider}/index.ts — registers spanStart listener + event processorcallWhenPatched() optimization in packages/node/src/integrations/tracing/{provider}/index.ts — defers registration until package is importedpackages/cloudflare/src/integrations/tracing/{provider}.ts — no OTel, call processors immediatelyReference: packages/node/src/integrations/tracing/vercelai/
Use when: SDK has no native OTel support (OpenAI, Anthropic, Google GenAI)
instrument{Provider}Client() in packages/core/src/tracing/{provider}/index.ts — Proxy to wrap client methods, create spans manuallyinstrumentation.ts: Patch module exports, wrap client constructor. Check _INTERNAL_shouldSkipAiProviderWrapping() for LangChain compatibility.index.ts: Export integration function using generateInstrumentOnce() helperReference: packages/node/src/integrations/tracing/openai/
Use when: SDK provides lifecycle hooks (LangChain, LangGraph)
create{Provider}CallbackHandler() — implement SDK's callback interface, create spans in callbacksinstrumentation.ts: Auto-inject callbacks by patching runnable methods. Disable underlying AI provider wrapping.Reference: packages/node/src/integrations/tracing/langchain/
Mandatory for Node.js AI integrations. OTel only patches when the package is imported (zero cost if unused).
getAutoPerformanceIntegrations() in packages/node/src/integrations/tracing/index.ts — LangChain MUST come firstgetOpenTelemetryInstrumentationToPreload() for OTel-based integrationspackages/node/src/index.ts: integration function + options typedev-packages/node-integration-tests/suites/tracing/{provider}/dev-packages/cloudflare-integration-tests/suites/tracing/{provider}/dev-packages/browser-integration-tests/suites/tracing/ai-providers/{provider}/sendDefaultPii for recordInputs/recordOutputsSEMANTIC_ATTRIBUTE_SENTRY_ORIGIN = 'auto.ai.{provider}' (alphanumerics, _, . only)utils.tsgen_ai.invoke_agent for parent ops, gen_ai.chat for child opsgetAutoPerformanceIntegrations() in correct order (Node.js)getOpenTelemetryInstrumentationToPreload() (Node.js with OTel)packages/node/src/integrations/tracing/vercelai/packages/node/src/integrations/tracing/openai/packages/node/src/integrations/tracing/langchain/When in doubt, follow the pattern of the most similar existing integration.
development
Upgrade OpenTelemetry instrumentations across the Sentry JavaScript SDK. Use when bumping OTel instrumentation packages to their latest versions.
development
Upgrade a dependency in the Sentry JavaScript SDK. Use when upgrading packages, bumping versions, or fixing security vulnerabilities via dependency updates.
development
Triage GitHub issues with codebase research and actionable recommendations
testing
Scan agent skills for security issues. Use when asked to "scan a skill", "audit a skill", "review skill security", "check skill for injection", "validate SKILL.md", or assess whether an agent skill is safe to install. Checks for prompt injection, malicious scripts, excessive permissions, secret exposure, and supply chain risks.