Thank you for your interest in contributing to the Cloudflare Sandbox SDK! This guide will help you get started.
- Node.js 24+
- Bun (latest)
- Docker (for E2E tests)
- Git
-
Fork the repository to your GitHub account
-
Clone your fork:
git clone https://github.com/YOUR-USERNAME/sandbox-sdk.git cd sandbox-sdk -
Install dependencies:
npm install
-
Build the packages:
npm run build
-
Run tests:
npm test
-
Create a new branch for your changes:
git checkout -b feat/your-feature-name # or git checkout -b fix/your-bug-fix -
Make your changes following our coding standards (see CLAUDE.md)
-
Run code quality checks:
npm run check # Linting + type checking npm run fix # Auto-fix linting issues
-
Run tests:
npm test # Unit tests npm run test:e2e # E2E tests (requires Docker)
Follow the 7 rules for great commit messages:
- Separate subject from body with a blank line
- Limit the subject line to 50 characters
- Capitalize the subject line
- Do not end the subject line with a period
- Use the imperative mood ("Add feature" not "Added feature")
- Wrap the body at 72 characters
- Use the body to explain what and why vs. how
Example:
Add session isolation for concurrent executions
Previously, multiple concurrent exec() calls would interfere with each
other's working directories and environment variables. This adds proper
session management to isolate execution contexts.
Before submitting a PR, create a changeset if your change modifies any published packages:
npx changesetThis will interactively guide you through:
- Selecting which packages to include
- Choosing the semantic version bump (
patch,minor, ormajor) - Writing a description of your changes
Use semantic versioning:
patch: Bug fixes, minor improvementsminor: New features, non-breaking changesmajor: Breaking changes
The changeset bot will comment on your PR if a changeset is needed.
-
Push your branch to your fork:
git push origin feat/your-feature-name
-
Open a pull request from your fork to
cloudflare/sandbox-sdk:main -
Fill out the PR template with:
- Description of your changes
- Motivation and context
- How you tested the changes
- Screenshots (if applicable)
A maintainer will review your PR and may:
- Request changes
- Ask questions
- Suggest improvements
- Approve and merge
Please be patient and responsive to feedback. We aim to review PRs within a few days.
We use Biome for linting and formatting. Key guidelines:
- Use TypeScript for all code
- Avoid
anytype - define proper types - Write concise, readable code
- Add comments for complex logic
- Follow patterns in existing code
- Use the provided logger (
this.logger.info()) instead ofconsole.log()in production code
Located in packages/*/tests/:
- Test individual components in isolation
- Mock external dependencies
- Fast feedback loop
Run with: npm test
Located in tests/e2e/:
- Test full workflows against real Workers and containers
- Require Docker
- Share a single sandbox container for performance (~30s for full suite)
- Use sessions for test isolation
Run with: npm run test:e2e
# Run a single vitest E2E test file
npm run test:e2e:vitest -- -- tests/e2e/process-lifecycle-workflow.test.ts
# Run a specific vitest E2E test within a file
npm run test:e2e:vitest -- -- tests/e2e/git-clone-workflow.test.ts -t 'should handle cloning to default directory'
# Run browser E2E tests only (Playwright)
npm run test:e2e:browserNote: Use test:e2e:vitest when filtering tests. The test:e2e wrapper runs both vitest and browser tests sequentially but doesn't support argument passthrough.
See docs/E2E_TESTING.md for the complete guide on writing E2E tests.
- Write tests for new features
- Add regression tests for bug fixes
- Ensure tests are deterministic (no flaky tests)
- Use descriptive test names
- For E2E tests: use
getSharedSandbox()andcreateUniqueSession()for isolation
- Update README.md if you change public APIs
- Add JSDoc comments to public functions
- Update CLAUDE.md if you change architecture or conventions
- Open an issue for bug reports or feature requests
- Start a discussion for questions or ideas
- Check existing issues and discussions first
By contributing, you agree that your contributions will be licensed under the Apache License 2.0.