|
| 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 | +### Initial Setup |
| 8 | + |
| 9 | +```bash |
| 10 | +pnpm i # Install dependencies |
| 11 | +cp .env.example .env # Create environment file |
| 12 | +pnpm run docker # Start Docker services (Postgres, Redis, Clickhouse, Electric) |
| 13 | +pnpm run db:migrate # Run database migrations |
| 14 | +``` |
| 15 | + |
| 16 | +### Build Commands |
| 17 | + |
| 18 | +```bash |
| 19 | +pnpm run build --filter webapp && pnpm run build --filter trigger.dev && pnpm run build --filter @trigger.dev/sdk |
| 20 | +pnpm run build --filter "@trigger.dev/*" # Build all public packages |
| 21 | +pnpm run typecheck # Type check all packages |
| 22 | +``` |
| 23 | + |
| 24 | +### Development |
| 25 | + |
| 26 | +```bash |
| 27 | +pnpm run dev --filter webapp # Start webapp development server (port 3030) |
| 28 | +pnpm run dev --filter trigger.dev --filter "@trigger.dev/*" # Watch CLI and packages for changes |
| 29 | +``` |
| 30 | + |
| 31 | +### Testing |
| 32 | + |
| 33 | +```bash |
| 34 | +pnpm run test # Run all tests |
| 35 | +pnpm run test --filter webapp # Test webapp only |
| 36 | +pnpm run test --filter "@trigger.dev/*" # Test public packages |
| 37 | +pnpm run test --filter @internal/run-engine # Test internal packages |
| 38 | +``` |
| 39 | + |
| 40 | +## Architecture Overview |
| 41 | + |
| 42 | +### Monorepo Structure |
| 43 | + |
| 44 | +- **Apps**: Production services (`webapp`, `supervisor`) |
| 45 | +- **Packages**: Public npm packages (`@trigger.dev/sdk`, `trigger.dev` CLI, `@trigger.dev/core`) |
| 46 | +- **Internal Packages**: Shared internal code (database, run-engine, redis, clickhouse, tracing) |
| 47 | +- **References**: Testing and example projects (hello-world) |
| 48 | + |
| 49 | +### Key Components |
| 50 | + |
| 51 | +- **Webapp** (`apps/webapp`): Remix-based dashboard and API platform |
| 52 | +- **Run Engine** (`internal-packages/run-engine`): Task execution lifecycle management |
| 53 | +- **SDK** (`packages/trigger-sdk`): Main developer SDK (`@trigger.dev/sdk`) |
| 54 | +- **CLI** (`packages/cli-v3`): Development and deployment tool (`trigger.dev`) |
| 55 | +- **Database** (`internal-packages/database`): Prisma schema and client |
| 56 | + |
| 57 | +### Build System |
| 58 | + |
| 59 | +- **Turborepo** for build orchestration with dependency graph |
| 60 | +- **TypeScript 5.5.4** across all packages |
| 61 | +- **Vitest** for testing |
| 62 | +- **PNPM 8.15.5** workspace with locked version |
| 63 | + |
| 64 | +## Development Workflows |
| 65 | + |
| 66 | +### Making Changes to SDK/CLI |
| 67 | + |
| 68 | +1. Make changes in `packages/trigger-sdk` or `packages/cli-v3` |
| 69 | +2. Run `pnpm run dev --filter trigger.dev --filter "@trigger.dev/*"` to watch for changes |
| 70 | +3. Test in `references/v3-catalog` using `pnpm exec trigger dev` |
| 71 | +4. Restart trigger dev command to pick up CLI/SDK changes |
| 72 | + |
| 73 | +### Database Migrations |
| 74 | + |
| 75 | +1. Modify `internal-packages/database/prisma/schema.prisma` |
| 76 | +2. `cd internal-packages/database` |
| 77 | +3. `pnpm run db:migrate:dev:create` (creates migration file) |
| 78 | +4. `pnpm run db:migrate:deploy && pnpm run generate` |
| 79 | + |
| 80 | +### Adding Changesets |
| 81 | + |
| 82 | +```bash |
| 83 | +pnpm run changeset:add # Add changeset for version management |
| 84 | +``` |
| 85 | + |
| 86 | +### Testing Strategy |
| 87 | + |
| 88 | +- Unit tests with Vitest |
| 89 | +- Integration tests using testcontainers |
| 90 | +- E2E tests with Playwright |
| 91 | +- Manual testing via reference projects |
| 92 | + |
| 93 | +## Special Requirements |
| 94 | + |
| 95 | +### Prerequisites |
| 96 | + |
| 97 | +- Node.js 20.11.1 (enforced via .nvmrc) |
| 98 | +- pnpm 8.15.5 (via corepack enable) |
| 99 | +- Docker for local services |
| 100 | +- Protocol Buffers for gRPC |
| 101 | + |
| 102 | +### Environment Variables |
| 103 | + |
| 104 | +- `ENCRYPTION_KEY`: Generate with `openssl rand -hex 16` |
| 105 | +- Database runs on Docker at localhost:5432 |
| 106 | +- Webapp runs on port 3030 |
| 107 | + |
| 108 | +## Package Dependencies |
| 109 | + |
| 110 | +- Internal packages use `workspace:*` protocol |
| 111 | +- Shared TypeScript config and tooling |
| 112 | +- Patches in `patches/` directory for external dependencies |
| 113 | +- Build outputs cached by Turborepo |
0 commit comments