/agent-skills:setup-browser-sdk-sourcemapsfrom agent-skills
Configures build-time JavaScript sourcemap upload to Datadog via bundler plugins (esbuild, Rollup, Rspack, Vite, webpack) so RUM and Error Tracking show un-minified stack traces with git metadata.
Ships in agent-skills. 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.
None: SKILL.md is the whole skill.
Adds build-time sourcemap upload to a frontend project using the Datadog build plugin. Sourcemaps are uploaded as part of the build, so every deploy ships un-minified stack traces to RUM and Error Tracking. Git metadata is attached automatically, which links errors back to source files.
Follow steps 1-7 in order.
Before starting any work: Create exactly 7 todo items — one per step below. Do not begin implementation until all 7 todos are created. Do not compress or merge steps.
Never invent a value. Three fields (service, releaseVersion, minifiedPathPrefix) must
match how the app is actually deployed. If you cannot read a value from the repo, stop and ask the
user. Do not write a placeholder, a TODO, or a guessed hostname.
In scope: projects built by esbuild, Rollup, Rspack, Vite, or webpack — including meta-frameworks
that expose one of these directly in their own config file (e.g. Remix/React Router v7+ framework
mode, SvelteKit, Nuxt via vite.config.ts/nuxt.config.ts's vite: key). If Step 1's config-file
search below finds a real bundler config, the meta-framework sitting on top of it does not change
anything — wire the plugin into that config file exactly as normal.
Out of scope: Next.js and Turbopack specifically. Unlike the meta-frameworks above, Next.js does
not expose a plain webpack/Turbopack config surface the plugin can hook into — it has no Next.js
or Turbopack integration at all. For those, use the datadog-ci sourcemaps upload CLI in a
postbuild script instead — do not attempt to thread the webpack plugin through next.config.js.
If a project uses some other meta-framework not listed here and Step 1 finds no plain bundler config file to edit, stop and ask rather than guessing whether it's supported.
Search for a bundler config file:
find . -maxdepth 1 \( -name "vite.config.*" -o -name "rollup.config.*" -o -name "webpack.config.*" -o -name "rspack.config.*" -o -name "esbuild.config.*" \) 2>/dev/null
grep -l -E "\"(vite|rollup|webpack|@rspack/core|esbuild)\"" package.json
Use find, not ls with these glob patterns directly — in zsh, an ls invocation with multiple
glob patterns aborts with no matches found the moment any one pattern fails to match, even with
2>/dev/null appended, because the failure happens during shell word-expansion before ls ever
runs. find does its own pattern matching internally, so it works identically in bash and zsh and
correctly returns nothing (not an error) when no bundler config exists.
Map the result:
| Config file | Bundler | Package to install | Named export |
|---|---|---|---|
vite.config.{js,ts,mjs} | Vite | @datadog/vite-plugin | datadogVitePlugin |
webpack.config.{js,ts,mjs} | webpack | @datadog/webpack-plugin | datadogWebpackPlugin |
rollup.config.{js,ts,mjs} | Rollup | @datadog/rollup-plugin | datadogRollupPlugin |
rspack.config.{js,ts,mjs} | Rspack | @datadog/rspack-plugin | datadogRspackPlugin |
| esbuild build script | esbuild | @datadog/esbuild-plugin | datadogEsbuildPlugin |
Supported bundler versions:
| Bundler | Supported range |
|---|---|
| esbuild | any |
| Rollup | >= 3 < 5 |
| Rspack | 1.x or 2.x |
| Vite | >= 5 <= 8 |
| webpack | >= 5 < 6 |
Stop and ask the user if: no bundler config is found, more than one is found (monorepo — ask which app to instrument), Next.js or Turbopack is detected (out of scope, see above), or the bundler version is outside the supported range.
The plugin will not build without these three. Read them from the repo; ask the user for anything you cannot read.
service — must equal the service passed to datadogRum.init(). Datadog matches uploaded
sourcemaps to incoming errors on this value. A mismatch means the sourcemaps upload successfully
and are never used.
grep -rn "datadogRum.init" --include="*.ts" --include="*.tsx" --include="*.js" --include="*.jsx" -A 15
If the grep finds no datadogRum.init() call anywhere, stop: this skill only adds sourcemap
upload to an existing RUM setup, it does not instrument RUM itself. Tell the user Browser RUM
needs to be set up first, then re-run this skill.
If datadogRum.init() has no service, stop and tell the user: sourcemaps cannot be matched
without it, and it must be added to the RUM init first.
releaseVersion — must be exactly the version passed to datadogRum.init(), because
Datadog matches uploads to errors on that string. Copy it as written: version: '1.4.2' means
releaseVersion: '1.4.2', and if it reads a variable, read the same variable. Don't swap in a
commit SHA or CI variable that datadogRum.init() doesn't use, even if it looks like a better
version: it won't match. Leave datadogRum.init() as it is. Can be set here, or once at the top
level as metadata.version. If both are set and differ, the build fails with
sourcemaps.releaseVersion must match metadata.version when both are configured.
minifiedPathPrefix — the URL prefix the built JS is served from. Must be a full URL or start
with /, otherwise the build fails with
sourcemaps.minifiedPathPrefix must be a valid URL or start with '/'.
Worked example: if dist/main.js is served at https://example.com/static/main.js, then
minifiedPathPrefix is https://example.com/static/ or /static/. If JS is served from the
server root, / is valid.
This is the field most often wrong, and it cannot be derived from the bundler config alone. Before asking the user, check the repo for how it actually deploys:
base/publicPath/baseURL config first — if set, that already
answers the question..github/workflows/*.yml, .gitlab-ci.yml, vercel.json, netlify.toml, wrangler.toml,
Dockerfile. If the deploy step ships the bundler's output directory verbatim (e.g.
pages deploy ./dist, netlify deploy --dir=build), the prefix is the URL that directory's root
is served from (/ when it's deployed at the server root). Don't add asset subfolders like
Vite's assets/: the plugin appends each file's path inside the output directory, so /assets/
would upload /assets/assets/index-*.js._routes.json / _redirects, Netlify _redirects, Vercel rewrites in vercel.json. If any
exist, re-derive the prefix from the rewrite rule instead of the raw build output path.Do not write a placeholder, a TODO, or a guessed hostname even after checking all of the above.
npm install --save-dev @datadog/<bundler>-plugin@^3
Use the project's package manager: yarn add -D, pnpm add -D, or bun add -d. If you add the
dependency to package.json by hand instead, its version is "^3.0.0". Version 2 does not read
DATADOG_API_KEY from the environment, so with the config from step 5 the build succeeds and
nothing is ever uploaded.
This is the most common silent failure. The plugin uploads whatever .map files the build
produces. If the bundler is not configured to emit them it finds nothing, logs only a
No sourcemaps to upload warning, and the build still succeeds. Nothing appears in Datadog and
there is no error to explain why.
These are bundler-native settings, not plugin options. The Datadog build plugin does not set them and does not document them.
| Bundler | Setting |
|---|---|
| webpack | devtool: 'source-map' |
| Rspack | devtool: 'source-map' |
| Vite | build.sourcemap: true |
| Rollup | output.sourcemap: true |
| esbuild | sourcemap: true |
Add the setting if it is missing. If the project deliberately disables sourcemaps in production,
stop and raise it with the user — hidden sourcemaps served publicly is a real concern, and the
plugin uploads then deletes nothing, so the .map files still ship unless the deploy strips them.
Register the plugin first in the plugins array — the plugin's own README recommends this
across all five bundlers for complete build reporting.
Do not put the API key in the config file. The plugin (version 3 or later, see step 3) reads
DATADOG_API_KEY (or DD_API_KEY) from the environment, and the environment takes precedence
over the config value. Leaving it out keeps credentials out of version control.
Vite (vite.config.js):
import { defineConfig } from 'vite';
import { datadogVitePlugin } from '@datadog/vite-plugin';
export default defineConfig({
build: { sourcemap: true },
plugins: [
datadogVitePlugin({
errorTracking: {
sourcemaps: {
service: 'my-service',
releaseVersion: '1.4.2',
minifiedPathPrefix: '/static/',
},
},
}),
],
});
webpack (webpack.config.js):
const { datadogWebpackPlugin } = require('@datadog/webpack-plugin');
module.exports = {
devtool: 'source-map',
plugins: [
datadogWebpackPlugin({
errorTracking: {
sourcemaps: {
service: 'my-service',
releaseVersion: '1.4.2',
minifiedPathPrefix: '/static/',
},
},
}),
],
};
Rspack (rspack.config.js) — same as webpack, with datadogRspackPlugin from
@datadog/rspack-plugin.
Rollup (rollup.config.js):
import { datadogRollupPlugin } from '@datadog/rollup-plugin';
export default {
output: { sourcemap: true },
plugins: [
datadogRollupPlugin({
errorTracking: {
sourcemaps: {
service: 'my-service',
releaseVersion: '1.4.2',
minifiedPathPrefix: '/static/',
},
},
}),
],
};
esbuild (build script):
const { datadogEsbuildPlugin } = require('@datadog/esbuild-plugin');
require('esbuild').build({
sourcemap: true,
plugins: [
datadogEsbuildPlugin({
errorTracking: {
sourcemaps: {
service: 'my-service',
releaseVersion: '1.4.2',
minifiedPathPrefix: '/static/',
},
},
}),
],
});
Replace every value with the ones collected in step 2. Do not leave 'my-service', '1.4.2' or
'/static/' in place.
Optional sub-options, only if the user asks:
| Option | Default | Effect |
|---|---|---|
dryRun | false | Documented to do everything except the upload — do not rely on this for safety, see step 7 |
bailOnError | false | Fail the build on the first upload error |
maxConcurrency | 20 | Concurrent uploads |
The upload needs an API key. No application key is required.
| Variable | Purpose |
|---|---|
DATADOG_API_KEY or DD_API_KEY | Required. Without it the upload fails with No authentication token provided. |
DATADOG_SITE or DD_SITE | Required for non-US1 orgs. Defaults to datadoghq.com. Use datadoghq.eu, us3.datadoghq.com, us5.datadoghq.com, ap1.datadoghq.com, ap2.datadoghq.com, ddog-gov.com as appropriate. |
Set these as CI/build secrets. Never write the key to a committed file.
Check the repo for what actually executes the build command (the build script) before asking —
that is where the secret needs to be injected, which is not always the same as the eventual
hosting target. A GitHub Actions workflow can run the build and then deploy the output to
Cloudflare Pages/Netlify/Vercel/S3 as a separate step; in that case the secret goes on the
workflow, not the host.
| Signal found in repo | Where the build actually runs | Where to add the secret |
|---|---|---|
.github/workflows/*.yml with a build/install step | GitHub Actions | Repo Settings → Secrets and variables → Actions |
.gitlab-ci.yml | GitLab CI | Settings → CI/CD → Variables |
vercel.json, or no CI file and deployed via Vercel's own build | Vercel | Project Settings → Environment Variables |
netlify.toml, or no CI file and deployed via Netlify's own build | Netlify | Site Settings → Environment variables |
Dockerfile/docker-compose.yml with no CI workflow calling it | Docker, wherever the image is built | Depends on the deploy pipeline — ask |
Confirm the detected provider with the user rather than assuming — a repo can have leftover config from a provider it no longer uses. If nothing matches, stop and ask where the build runs.
Git metadata is attached automatically. enableGit is a top-level option that defaults to true,
so there is nothing to switch on — only something to avoid breaking. Do not set it unless step 7
turns up the specific error below.
Do not rely on dryRun: true to test safely. It is documented to "do everything except the
upload," but this is not trustworthy — at least one real published plugin version ignores the flag
entirely and makes the live, authenticated upload anyway. Treat dryRun as unverified for safety
purposes; it may or may not actually skip the network call in whatever version is installed.
First check the installed version: npm ls @datadog/<bundler>-plugin (or your package manager's
equivalent) must show 3.x or later. If it shows 2.x, go back to step 3. Version 2 never reads
DATADOG_API_KEY from the environment, so the build below looks exactly the same, and the real
upload in CI never happens either.
The only way to test discovery that is actually guaranteed not to upload anything: make sure
DATADOG_API_KEY/DD_API_KEY are not set anywhere in the environment the build runs in —
check for this explicitly, a key left over from unrelated local tooling (e.g. a personal
datadog-ci setup) counts and will be picked up silently. With no key reachable, the plugin cannot
authenticate no matter what dryRun does. Then run a normal production build (no dryRun needed):
No sourcemaps to upload, step 4 is not correct — the plugin found no .map files.
This check happens locally before any network call, regardless of credentials.No authentication token provided instead (you may also see
git-metadata warnings), steps 4 and 5 are correct. The build still exits 0: the plugin found the
sourcemaps and only skipped the upload because no key was reachable, which is the expected,
safe outcome when none is set.Only move on to testing the real upload path once that passes, and only deliberately — this is a live action, not a verification step to run casually. Confirm with the user, explicitly, which key will be used:
DATADOG_API_KEY (and DATADOG_SITE if not US1) exported in the shell for this test.If the build fails with Error: No git remotes available: the build environment has no git
remote, which is common in shallow CI clones and container builds. Two options, in order of
preference: make the git remote available in the build (better — keeps the error-to-source
linking), or set enableGit: false at the top level of the plugin config to disable git
collection entirely.
datadogWebpackPlugin({
enableGit: false,
errorTracking: { sourcemaps: { /* ... */ } },
})
Confirm end to end: trigger an error in the deployed app and check that the stack trace in Datadog Error Tracking is un-minified.
service or releaseVersion different from the values in datadogRum.init(). The upload
succeeds and the sourcemaps are never matched to any error. This is silent.minifiedPathPrefix from the output directory instead of the served URL. dist/ is not
a URL prefix.apiKey in the committed config file instead of the build environment.enableGit: true because a ticket said to "enable git". It is already the default;
setting it changes nothing.releaseVersion and metadata.version to different values, which fails the build.npm ls @datadog/<bundler>-plugin)plugins arrayservice matches datadogRum.init()'s servicereleaseVersion matches datadogRum.init()'s versionminifiedPathPrefix is a full URL or starts with /, and matches where JS is servedDATADOG_API_KEY (and DATADOG_SITE if not US1) set in the build environmentNo authentication token provided), not No sourcemaps to upload — do not use dryRun for
this check, see step 7What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub datadog-labs/agent-skills --plugin agent-skills78 skills in this plugin
/agent-observability-auto-experimentRun an iterative code-improvement hill-climb against real Datadog LLM-Obs data, locally, with Claude Code as the agent. Establishes a baseline eval, makes one focused change, re-scores with the same harness, keeps the change if it improves the score in the goal's direction (labeling within-noise gains tentative), and repeats. This is the skill published as "Autoresearch" in Datadog Agent Observability. Use when the user says "run an auto experiment", "run autoresearch", "hill-climb this code", "iteratively improve X and measure the delta", "optimize this prompt/file against my traces", "auto-optimize against LLM-Obs", or wants the local equivalent of the auto_experiments worker. Works from an ml_app, a dataset_id, an annotation_queue_id (a queue of human-labelled interactions), a list of trace_ids, or (by exception) a local dataset file. The corpus and its val/test splits live in Datadog LLM-Obs Datasets, created once per run with a timestamp in their names./agent-observability-build-eval-from-annotationsFit a Datadog LLM-Obs evaluator to human labels. Takes an annotation queue, works out where in the trace the labelled property actually lives, drafts an LLM-judge that predicts the human label, scores that judge against the already-labelled rows with a metric agreed with the user, then hill-climbs it — inspect the errors, make one focused change, re-score, keep it only if it beats the best — for a bounded number of iterations, and finally publishes the winner to Datadog as a DISABLED evaluator (not a Datadog draft — a real evaluator with `enabled: false`). Use when the user says "build an eval from my annotations", "build an evaluator from the annotation queue", "turn my annotations into an evaluator", "learn an evaluator from my labels", "fit a judge to the annotation queue", "auto-label", "auto labelling", "automate this annotation queue", "scale up my human labels", or wants the rest of a queue graded the way the humans graded the first rows. Needs an annotation queue with at least two classes present in the human labels (e.g. one true and one false for a boolean)./agent-observability-eval-bootstrapBootstrap evaluators from production traces — by default propose online LLM-judge evaluators and, after you confirm, create them in Datadog as disabled drafts (never auto-enabled); on request emit Python SDK code or a framework-agnostic JSON spec instead. Use when user says "bootstrap evaluators", "generate evaluators", "create evals from traces", "eval bootstrap", "write evaluators", "build eval suite", "publish evaluators", or wants to generate BaseEvaluator/LLMJudge code or online judge configs from production LLM trace data. Works with ml_app and optional RCA report or failure hypothesis./agent-observability-eval-pipelineEnd-to-end Agent Observability pipeline for an instrumented ml_app — classify production traces, root-cause failures, bootstrap evaluators, then (optionally) sample + publish a dataset, generate + run an experiment, and analyze results. Six narrated phases with a standardized banner and a "continue" checkpoint between each. Pure orchestration over the agent-observability sub-skills (`agent-observability-session-classify`, `agent-observability-trace-rca`, `agent-observability-eval-bootstrap`, `agent-observability-experiment-bootstrap`, `agent-observability-experiment-analyzer`). Use when user says "run the eval pipeline", "go from traces to evals", "bootstrap evals end to end", "classify then RCA then bootstrap", "build an eval set from scratch", "onboard me to datasets and experiments", "walk me through experiments", "I have an ml_app, now what", "Agent Observability onboarding", "guided experiment setup", "from traces to experiments", or wants a deterministic, narrated tour from production data through evaluators, datasets, and experiments. Stop early with `--stop-after <phase>` to short-circuit at evaluators or dataset, or resume mid-flow with `--start-at <phase>`./agent-observability-experiment-analyzerAnalyze LLM experiment results. Handles single or comparative experiments, exploratory or Q&A modes. Use when user says "analyze experiment", "compare experiments", "analyze against baseline", or provides one or two experiment IDs for analysis./agent-observability-experiment-bootstrapBootstrap a reproducible LLM Observability experiment through the Python ddtrace SDK or the Node dd-trace SDK. Use for experiment, dataset, evaluator, benchmark, regression, or LLM-as-a-judge scaffolding. The legacy Python invocation remains supported.Other plugins' skills for the same job