This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
You are working on the Sentry JavaScript SDK, a critical production SDK used by thousands of applications. Follow these rules strictly.
CRITICAL: All changes must pass these checks before committing:
- Always run
yarn lint- Fix all linting issues - Always run
yarn test- Ensure all tests pass - Always run
yarn build:dev- Verify TypeScript compilation
yarn build- Full production build with package verificationyarn build:dev- Development build (transpile + types)yarn build:dev:watch- Development build in watch mode (recommended)yarn build:dev:filter <package>- Build specific package and dependenciesyarn build:types:watch- Watch mode for TypeScript types onlyyarn build:bundle- Build browser bundles only
yarn test- Run all unit tests
yarn lint- Run ESLint and Prettier checksyarn fix- Auto-fix linting and formatting issuesyarn lint:es-compatibility- Check ES compatibility
This repository uses Git Flow. See docs/gitflow.md for details.
- All PRs target
developbranch (NOTmaster) masterrepresents the last released state- Never merge directly into
master(except emergency fixes) - Avoid changing
package.jsonfiles ondevelopduring pending releases - Never update dependencies, package.json content or build scripts unless explicitly asked for
- When asked to do a task on a set of files, always make sure that all occurences in the codebase are covered. Double check that no files have been forgotten.
- Unless explicitly asked for, make sure to cover all files, including files in
src/andtest/directories.
- Features:
feat/descriptive-name - Releases:
release/X.Y.Z
This is a Lerna monorepo with 40+ packages in the @sentry/* namespace.
packages/core/- Base SDK with interfaces, type definitions, core functionalitypackages/types/- Shared TypeScript type definitions - this is deprecated, never modify this packagepackages/browser-utils/- Browser-specific utilities and instrumentationpackages/node-core/- Node Core SDK which contains most of the node-specific logic, excluding OpenTelemetry instrumentation.
packages/browser/- Browser SDK with bundled variantspackages/node/- Node.js SDK. All general Node code should go into node-core, the node package itself only contains OpenTelemetry instrumentation on top of that.packages/bun/,packages/deno/,packages/cloudflare/- Runtime-specific SDKs
- Framework packages:
packages/{framework}/(react, vue, angular, etc.) - Client/server entry points where applicable (nextjs, nuxt, sveltekit)
- Integration tests use Playwright (Remix, browser-integration-tests)
packages/replay-internal/- Session replay functionalitypackages/replay-canvas/- Canvas recording for replaypackages/replay-worker/- Web worker support for replaypackages/feedback/- User feedback integration
browser-integration-tests/- Playwright browser testse2e-tests/- End-to-end tests for 70+ framework combinationsnode-integration-tests/- Node.js integration teststest-utils/- Shared testing utilitiesbundle-analyzer-scenarios/- Bundle analysisrollup-utils/- Build utilities- GitHub Actions packages for CI/CD automation
- Uses Rollup for bundling (
rollup.*.config.mjs) - TypeScript with multiple tsconfig files per package
- Lerna manages package dependencies and publishing
- Vite for testing with
vitest
Each package typically contains:
src/index.ts- Main entry pointsrc/sdk.ts- SDK initialization logicrollup.npm.config.mjs- Build configurationtsconfig.json,tsconfig.test.json,tsconfig.types.jsontest/directory with corresponding test files
- Uses Volta for Node.js/Yarn version management
- Requires initial
yarn buildafteryarn installfor TypeScript linking - Integration tests use Playwright extensively
- Never change the volta, yarn, or package manager setup in general unless explicitly asked for
E2E tests are located in dev-packages/e2e-tests/ and verify SDK behavior in real-world framework scenarios.
E2E tests use Verdaccio, a lightweight npm registry running in Docker. Before tests run:
- SDK packages are built and packed into tarballs (
yarn build && yarn build:tarball) - Tarballs are published to Verdaccio at
http://127.0.0.1:4873 - Test applications install packages from Verdaccio instead of public npm
Every E2E test application needs an .npmrc file with:
@sentry:registry=http://127.0.0.1:4873
@sentry-internal:registry=http://127.0.0.1:4873
Without this file, pnpm installs from the public npm registry instead of Verdaccio, so your local changes won't be tested. This is a common cause of "tests pass in CI but fail locally" or vice versa.
Run the e2e skill.
-
Missing
.npmrc: Most common issue. Always verify the test app has the correct.npmrcfile. -
Stale tarballs: After SDK changes, must re-run
yarn build:tarball. -
Debugging tips:
- Check browser console logs for SDK initialization errors
- Use
debug: truein Sentry config - Verify installed package version: check
node_modules/@sentry/*/package.json
- Make sure to use volta for development. Volta is used to manage the node, yarn and pnpm version used.
- Make sure that PNPM support is enabled in volta. This means that the
VOLTA_FEATURE_PNPMenvironment variable has to be set to1. - Yarn, Node and PNPM have to be used through volta, in the versions defined by the volta config. NEVER change any versions unless explicitly asked to.
- Test specific package:
cd packages/{package-name} && yarn test - Build specific package:
yarn build:dev:filter @sentry/{package-name}
- Follow existing code conventions in each package
- Check imports and dependencies - only use libraries already in the codebase
- Look at neighboring files for patterns and style
- Never introduce code that exposes secrets or keys
- Follow security best practices
- ✅
yarn lint(fix all issues) - ✅
yarn test(all tests pass) - ✅
yarn build:dev(builds successfully) - ✅ Target
developbranch for PRs (notmaster)
IMPORTANT: When editing CLAUDE.md, also update .cursor/rules/sdk_development.mdc and vice versa to keep both files in sync.