|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Development Commands |
| 6 | + |
| 7 | +### Build Commands |
| 8 | + |
| 9 | +- `yarn build` - Full production build with package verification |
| 10 | +- `yarn build:dev` - Development build (transpile + types) |
| 11 | +- `yarn build:dev:watch` - Development build in watch mode (recommended for development) |
| 12 | +- `yarn build:dev:filter <package>` - Build specific package and its dependencies |
| 13 | +- `yarn build:types:watch` - Watch mode for TypeScript types only |
| 14 | +- `yarn build:bundle` - Build browser bundles only |
| 15 | + |
| 16 | +### Testing |
| 17 | + |
| 18 | +- `yarn test` - Run all tests (excludes integration tests) |
| 19 | +- `yarn test:unit` - Run unit tests only |
| 20 | +- `yarn test:pr` - Run tests affected by changes (CI mode) |
| 21 | +- `yarn test:pr:browser` - Run affected browser-specific tests |
| 22 | +- `yarn test:pr:node` - Run affected Node.js-specific tests |
| 23 | + |
| 24 | +### Linting and Formatting |
| 25 | + |
| 26 | +- `yarn lint` - Run ESLint and Prettier checks |
| 27 | +- `yarn fix` - Auto-fix linting and formatting issues |
| 28 | +- `yarn lint:es-compatibility` - Check ES compatibility |
| 29 | + |
| 30 | +### Package Management |
| 31 | + |
| 32 | +- `yarn clean` - Clean build artifacts and caches |
| 33 | +- `yarn clean:deps` - Clean and reinstall all dependencies |
| 34 | + |
| 35 | +## Repository Architecture |
| 36 | + |
| 37 | +This is a Lerna monorepo containing 40+ packages in the `@sentry/*` namespace. Key architectural components: |
| 38 | + |
| 39 | +### Core Packages |
| 40 | + |
| 41 | +- `packages/core/` - Base SDK with interfaces, type definitions, and core functionality |
| 42 | +- `packages/types/` - Shared TypeScript type definitions (active) |
| 43 | +- `packages/browser-utils/` - Browser-specific utilities and instrumentation |
| 44 | + |
| 45 | +### Platform SDKs |
| 46 | + |
| 47 | +- `packages/browser/` - Browser SDK with bundled variants |
| 48 | +- `packages/node/` - Node.js SDK with server-side integrations |
| 49 | +- `packages/bun/`, `packages/deno/`, `packages/cloudflare/` - Runtime-specific SDKs |
| 50 | + |
| 51 | +### Framework Integrations |
| 52 | + |
| 53 | +- Framework packages follow naming: `packages/{framework}/` (react, vue, angular, etc.) |
| 54 | +- Each has client/server entry points where applicable (e.g., nextjs, nuxt, sveltekit) |
| 55 | +- Integration tests use Playwright (e.g., Remix, browser-integration-tests) |
| 56 | + |
| 57 | +### User Experience Packages |
| 58 | + |
| 59 | +- `packages/replay-internal/` - Session replay functionality |
| 60 | +- `packages/replay-canvas/` - Canvas recording support for replay |
| 61 | +- `packages/replay-worker/` - Web worker support for replay |
| 62 | +- `packages/feedback/` - User feedback integration |
| 63 | + |
| 64 | +### Build System |
| 65 | + |
| 66 | +- Uses Rollup for bundling with config files: `rollup.*.config.mjs` |
| 67 | +- TypeScript with multiple tsconfig files per package (main, test, types) |
| 68 | +- Lerna manages package dependencies and publishing |
| 69 | +- Vite for testing with `vitest` |
| 70 | + |
| 71 | +### Package Structure Pattern |
| 72 | + |
| 73 | +Each package typically contains: |
| 74 | + |
| 75 | +- `src/index.ts` - Main entry point |
| 76 | +- `src/sdk.ts` - SDK initialization logic |
| 77 | +- `rollup.npm.config.mjs` - Build configuration |
| 78 | +- `tsconfig.json`, `tsconfig.test.json`, `tsconfig.types.json` - TypeScript configs |
| 79 | +- `test/` directory with corresponding test files |
| 80 | + |
| 81 | +### Development Packages (`dev-packages/`) |
| 82 | + |
| 83 | +Separate from main packages, containing development and testing utilities: |
| 84 | + |
| 85 | +- `browser-integration-tests/` - Playwright browser tests |
| 86 | +- `e2e-tests/` - End-to-end tests for 70+ framework combinations |
| 87 | +- `node-integration-tests/` - Node.js integration tests |
| 88 | +- `test-utils/` - Shared testing utilities |
| 89 | +- `bundle-analyzer-scenarios/` - Bundle analysis |
| 90 | +- `rollup-utils/` - Build utilities |
| 91 | +- GitHub Actions packages for CI/CD automation |
| 92 | + |
| 93 | +### Key Development Notes |
| 94 | + |
| 95 | +- Uses Volta for Node.js/Yarn version management |
| 96 | +- Requires initial `yarn build` after `yarn install` for TypeScript linking |
| 97 | +- Integration tests use Playwright extensively |
| 98 | +- Native profiling requires Python <3.12 for binary builds |
| 99 | +- Bundle outputs vary - check `build/bundles/` for specific files after builds |
| 100 | + |
| 101 | +## Git Flow Branching Strategy |
| 102 | + |
| 103 | +This repository uses **Git Flow** branching model. See [detailed documentation](docs/gitflow.md). |
| 104 | + |
| 105 | +### Key Points |
| 106 | + |
| 107 | +- **All PRs target `develop` branch** (not `master`) |
| 108 | +- `master` represents the last released state |
| 109 | +- Never merge directly into `master` (except emergency fixes) |
| 110 | +- Automated workflow syncs `master` → `develop` after releases |
| 111 | +- Avoid changing `package.json` files on `develop` during pending releases |
| 112 | + |
| 113 | +### Branch Naming |
| 114 | + |
| 115 | +- Features: `feat/descriptive-name` |
| 116 | +- Releases: `release/X.Y.Z` |
| 117 | + |
| 118 | +## Code Quality Requirements |
| 119 | + |
| 120 | +**CRITICAL**: This is a production SDK used by thousands of applications. All changes must be: |
| 121 | + |
| 122 | +### Mandatory Checks |
| 123 | + |
| 124 | +- **Always run `yarn lint`** - Fix all linting issues before committing |
| 125 | +- **Always run `yarn test`** - Ensure all tests pass |
| 126 | +- **Run `yarn build`** - Verify build succeeds without errors |
| 127 | + |
| 128 | +### Before Any Commit |
| 129 | + |
| 130 | +1. `yarn lint` - Check and fix ESLint/Prettier issues |
| 131 | +2. `yarn test` - Run relevant tests for your changes |
| 132 | +3. `yarn build:dev` - Verify TypeScript compilation |
| 133 | + |
| 134 | +### CI/CD Integration |
| 135 | + |
| 136 | +- All PRs automatically run full lint/test/build pipeline |
| 137 | +- Failed checks block merging |
| 138 | +- Use `yarn test:pr` for testing only affected changes |
| 139 | + |
| 140 | +## Testing Single Packages |
| 141 | + |
| 142 | +To test a specific package: `cd packages/{package-name} && yarn test` |
| 143 | +To build a specific package: `yarn build:dev:filter @sentry/{package-name}` |
| 144 | + |
| 145 | +## Cursor IDE Integration |
| 146 | + |
| 147 | +For Cursor IDE users, see [.cursor/rules/sdk_development.mdc](.cursor/rules/sdk_development.mdc) for complementary development rules. |
0 commit comments