|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +This is the **Cloudflare Workers SDK** monorepo containing tools and libraries for developing, testing, and deploying serverless applications on Cloudflare's edge network. The main components are Wrangler (CLI), Miniflare (local dev simulator), and Create Cloudflare (project scaffolding). |
| 8 | + |
| 9 | +## Development Commands |
| 10 | + |
| 11 | +**Package Management:** |
| 12 | + |
| 13 | +- Use `pnpm` - never use npm or yarn |
| 14 | +- `pnpm install` - Install dependencies for all packages |
| 15 | +- `pnpm build` - Build all packages (uses Turbo for caching) |
| 16 | + |
| 17 | +**Testing:** |
| 18 | + |
| 19 | +- `pnpm test:ci` - Run tests in CI mode |
| 20 | +- `pnpm test:e2e` - Run end-to-end tests (requires Cloudflare credentials) |
| 21 | + |
| 22 | +**Code Quality:** |
| 23 | + |
| 24 | +- `pnpm check` - Run all checks (lint, type, format) |
| 25 | +- `pnpm fix` - Auto-fix linting issues and format code |
| 26 | + |
| 27 | +**Working with Specific Packages:** |
| 28 | + |
| 29 | +- `pnpm run build --filter <package-name>` - Build specific package |
| 30 | +- `pnpm run test:ci --filter <package-name>` - Test specific package |
| 31 | + |
| 32 | +## Architecture Overview |
| 33 | + |
| 34 | +**Core Tools:** |
| 35 | + |
| 36 | +- `packages/wrangler/` - Main CLI tool for Workers development and deployment |
| 37 | +- `packages/miniflare/` - Local development simulator powered by workerd runtime |
| 38 | +- `packages/create-cloudflare/` - Project scaffolding CLI (C3) |
| 39 | + |
| 40 | +**Development & Testing:** |
| 41 | + |
| 42 | +- `packages/vitest-pool-workers/` - Vitest integration for testing Workers in actual runtime |
| 43 | +- `packages/chrome-devtools-patches/` - Modified Chrome DevTools for Workers debugging |
| 44 | + |
| 45 | +**Shared Libraries:** |
| 46 | + |
| 47 | +- `packages/pages-shared/` - Code shared between Wrangler and Cloudflare Pages |
| 48 | +- `packages/workers-shared/` - Code shared between Wrangler and Workers Assets |
| 49 | + |
| 50 | +**Build System:** |
| 51 | + |
| 52 | +- Turbo (turborepo) orchestrates builds across packages |
| 53 | +- TypeScript compilation with shared configs in `packages/workers-tsconfig/` |
| 54 | +- Dependency management via pnpm catalog system |
| 55 | + |
| 56 | +## Development Guidelines |
| 57 | + |
| 58 | +**Requirements:** |
| 59 | + |
| 60 | +- Node.js >= 20 |
| 61 | +- pnpm |
| 62 | + |
| 63 | +**Code Style:** |
| 64 | + |
| 65 | +- All significant changes require a changeset: `pnpm changeset` |
| 66 | + |
| 67 | +**Testing Standards:** |
| 68 | + |
| 69 | +- Unit tests with Vitest for all packages |
| 70 | +- Fixture tests in `/fixtures` directory for filesystem/Worker scenarios |
| 71 | +- E2E tests require real Cloudflare account credentials |
| 72 | +- Use `vitest-pool-workers` for testing actual Workers runtime behavior |
| 73 | + |
| 74 | +**Git Workflow:** |
| 75 | + |
| 76 | +- Clean commit history required before first review |
| 77 | +- Never commit without changesets for user-facing changes |
| 78 | +- PR template requirements: Remove "Fixes #..." line when no relevant issue exists, keep all checkboxes (don't delete unchecked ones) |
| 79 | + |
| 80 | +## Key Locations |
| 81 | + |
| 82 | +- `/fixtures` - Test fixtures and example applications |
| 83 | +- `/packages/wrangler/src` - Main Wrangler CLI source code |
| 84 | +- `/packages/miniflare/src` - Miniflare source |
| 85 | +- `/tools` - Build scripts and deployment utilities |
| 86 | +- `turbo.json` - Turbo build configuration |
| 87 | +- `pnpm-workspace.yaml` - Workspace configuration |
| 88 | + |
| 89 | +## Testing Strategy |
| 90 | + |
| 91 | +**Package-specific tests:** Most packages have their own test suites |
| 92 | +**Integration tests:** Use fixtures to test real-world scenarios |
| 93 | +**E2E tests:** Test against actual Cloudflare services (requires auth) |
| 94 | +**Workers runtime tests:** Use vitest-pool-workers for workerd-specific behavior |
| 95 | + |
| 96 | +Run `pnpm check` before submitting changes to ensure all quality gates pass. |
| 97 | + |
| 98 | +## Keeping CLAUDE.md up to date |
| 99 | + |
| 100 | +IMPORTANT. Whenever you discover or are told new information that would be relevant to future instances of Claude Code, include it in CLAUDE.md |
0 commit comments