runtime
CLAUDE.md1.9k starsChanged 2 days agoApache-2.0View on GitHub
This development guide applies to Codex, Claude Code, and OpenCode. Repository and review rules are shared through: E2B Infrastructure is the backend infrastructure powering E2B (e2b.dev), an open-source cloud platform for AI code interpreting. It provides sandboxed execution environments using Firecracker microVMs. Start with docs/ARCHITECTURE.md — it explains what each service does, how services interact (with diagrams of the core flows: sandbox creation, traffic routing, pause/resume, template builds), and the deployment topology. Reading it first is the fastest way to…
- Reads credentials
1 other project uses a version of this.
Trending
More talk lately.thin dataabout the whole repository
Most recently taken up by
- e2b-dev/infraword for word, first seen Nov 27, 2026
Who's talking about e2b-dev/runtime
- A Hacker News story“E2B Embed”Hacker News · Sep 30, 2026 · 1 points
- cocofhu/grasp“[方案评估] E2B 自托管沙箱接入:完整实测、预览兼容、OCI 与暂停快照设计”GitHub · Nov 4, 2026
- ClassiFinder/classifinder-engine“feat(patterns): weekly batch 2026-11-02 — 10 patterns (cerebras, dify, e2b, vercel blob, liveblocks, …”GitHub · Nov 2, 2026
- ClassiFinder/classifinder“feat(patterns): weekly batch 2026-11-02 — 10 patterns (cerebras, dify, e2b, vercel blob, liveblocks, …”GitHub · Nov 2, 2026
- ivanleomk/workspace-notes“Fix Lesson 06: Remove unmeasured latencies and correct vendor claims”GitHub · Oct 16, 2026
The biggest 5 of 12 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 12
Talked about on GitHub and Hacker News (12 times).
On GitHub · 11
- Nov 4, 2026[方案评估] E2B 自托管沙箱接入:完整实测、预览兼容、OCI 与暂停快照设计 — cocofhu/grasp0 reactions · 2 comments
- Nov 2, 2026feat(patterns): weekly batch 2026-11-02 — 10 patterns (cerebras, dify, e2b, vercel blob, liveblocks, chromatic, radar, keygen, growthbook, settlemint sat) — ClassiFinder/classifinder-engine0 reactions
- Nov 2, 2026feat(patterns): weekly batch 2026-11-02 — 10 patterns (cerebras, dify, e2b, vercel blob, liveblocks, chromatic, radar, keygen, growthbook, settlemint sat) — ClassiFinder/classifinder0 reactions
- Oct 16, 2026Fix Lesson 06: Remove unmeasured latencies and correct vendor claims — ivanleomk/workspace-notes0 reactions
- Oct 16, 2026Add Lesson 06: E2B's Open-Source Runtime Architecture — ivanleomk/workspace-notes0 reactions
6 more on GitHub
- Oct 8, 2026arch(sandbox): 外部沙箱接入设计稿——SandboxSessionProvider、ExecRequest(argv)、SandboxKey、fail-closed 模式(docs/32)/ External sandbox design — skaiy/wild_agentos0 reactions · 2 comments
- Oct 5, 2026[Bug]: Creation-time environment defaults missing after resume-time envd upgrade — e2b-dev/E2B0 reactions · 4 comments
- Sep 27, 2026test(runtime): 用真实虚拟机复现启停后进程退出恢复 — VeriInfra-Lab/sandproof0 reactions
- Sep 27, 2026feat(runtime)!: 为禁网沙箱加入宿主规则与资源归属核对 — VeriInfra-Lab/sandproof0 reactions
- Sep 21, 2026fix(orchestrator/nbd): require device quiescence before declaring a slot free — AdaAibaby/infra0 reactions
- Sep 21, 2026NBD device-release race + partscan noise: isDeviceFree predicate too weak, causes dmesg I/O errors — AdaAibaby/infra0 reactions
On Hacker News · 1
- Sep 30, 2026E2B Embed1 point
Other versions1 project uses a version of this.
Word for word · 1
- e2b-dev/infra★ 1.9k100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repositoryOne other file it gives its agents.
- AGENTS.mdAGENTS.md
The file
We split this CLAUDE.md into the rules it gives an agent
5 rules. About 0 are common, 0 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 14
Keep docs/ARCHITECTURE.md updated: if your change alters anything it describes (service responsibilities, ports, protocols, data stores, …
- Very specific: line 182
Unit tests: Use testify/assert and testify/require: require for checks that stop the test, assert for checks that let it continue
- Very specific: line 202
After editing proto files, run make generate/orchestrator and make generate/shared
- Very specific: line 207
Create: cd packages/api && make create-migration NAME=your-migration-name — this generates the file with a correct YYYYMMDDHHMMSS timestamp.
- Very specific: line 224
All services export OpenTelemetry traces/metrics/logs
≈ “Common” is an estimate: at least 1 in 5 of the 28,633 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
This development guide applies to Codex, Claude Code, and OpenCode. Repository and review rules are shared through:
@AGENTS.md
Project Overview
E2B Infrastructure is the backend infrastructure powering E2B (e2b.dev), an open-source cloud platform for AI code interpreting. It provides sandboxed execution environments using Firecracker microVMs.
Start with docs/ARCHITECTURE.md — it explains what each service does, how services interact (with diagrams of the core flows: sandbox creation, traffic routing, pause/resume, template builds), and the deployment topology. Reading it first is the fastest way to understand this repository.
Keep docs/ARCHITECTURE.md updated: if your change alters anything it describes (service responsibilities, ports, protocols, data stores, flows, deployment topology), update the document in the same change.
Common Development Commands
Setup & Environment
# Switch between environments (prod, staging, dev)
make switch-env ENV=staging
# Setup local development stack (PostgreSQL, Redis, ClickHouse, monitoring)
make local-infraBuilding & Testing
# Run all unit tests across packages
make test
# Run integration tests
make test-integration
# Build specific package
make build/api
make build/orchestrator
# Generate code (proto, SQL, OpenAPI)
make generate
# Format and lint code
make fmt
make lint
# Regenerate mocks
make generate-mocks
# Tidy go dependencies
make tidyRunning Services Locally
# From packages/api/
make run-local # Run API server on :3000
# From packages/orchestrator/
make run-local # Run orchestrator
make run-debug # Run with race detectorPackage-Specific Commands
# API: Generate OpenAPI code
cd packages/api && make generate
# Orchestrator: Generate proto + OpenAPI
cd packages/orchestrator && make generate
# DB: Run migrations
make migrate
# Run single test
cd packages/<package> && go test -v -run TestName ./path/to/packagePublishing Artifacts
# Build and upload all service images to your GCP project
make build-and-upload
# Build specific service
make build-and-upload/api
make build-and-upload/orchestratorArchitecture Overview
Service Communication Flow
Client → Client-Proxy → API (REST) ⟷ PostgreSQL
↓ ⟷ Redis
Orchestrator ⟷ ClickHouse
↓ (gRPC)
Firecracker VMs
↓
Envd (in-VM daemon)Core Services
API (packages/api/) - REST API using Gin framework
- Entry point:
main.go - Core logic:
internal/handlers/store.go(APIStore) - Authentication: API keys and OIDC auth provider JWTs
- OpenAPI code generation:
internal/api/*.gen.go - Port: 80
Orchestrator (packages/orchestrator/) - Firecracker microVM orchestration
- Entry point:
main.go - VM management:
pkg/sandbox/ - Firecracker integration:
pkg/sandbox/fc/ - Networking:
pkg/sandbox/network/ - Storage:
pkg/sandbox/nbd/(Network Block Device) - Template caching:
pkg/sandbox/template/ - Template building:
pkg/template/ - gRPC server:
pkg/server/ - Utilities:
cmd/clean-nfs-cache/,cmd/dummy-orchestrator/
Envd (packages/envd/) - In-VM daemon using Connect RPC
- Runs inside each Firecracker VM
- Process management API:
packages/envd/spec/process/process.proto - Filesystem API:
packages/envd/spec/filesystem/filesystem.proto - Port: 49983
pkg/version.gois release-please's: it is set from the Conventional Commits merged since the last envd release, so do not bump it by hand. A behavioral change ships under afeatorfixtype so a version exists for the orchestrator to gate on; comment or docs-only changes usedocs, which the changelog hides, and cut no release (choreandrefactorare visible and cut one)
Client Proxy (packages/client-proxy/) - Edge routing layer
- Service discovery via
packages/shared/pkg/servicediscovery - Request routing to orchestrators
- Redis-backed state management
Shared (packages/shared/) - Common utilities
- Proto definitions:
pkg/grpc/orchestrator/,pkg/grpc/envd/ - Telemetry:
pkg/telemetry/(OpenTelemetry) - Logging:
pkg/logger/(Zap + OTEL) - Database:
pkg/db/(ent ORM) - Models:
pkg/models/ - Storage:
pkg/storage/(GCS/S3 clients) - Feature flags:
pkg/featureflags/(LaunchDarkly)
Database (packages/api/internal/db/) - PostgreSQL layer
- Migrations:
migrations/*.sql(goose) - Queries:
queries/*.sql(sqlc) - Generated code:
queries/(pluspkg/auth/queries/)
Key Technologies
- go 1.27.4 with workspaces (
go.work) - Firecracker for microVM virtualization
- PostgreSQL for primary data (sqlc for queries)
- ClickHouse for analytics
- Redis for caching and state
- OpenTelemetry for observability (Grafana stack: Loki, Tempo, Mimir)
- gRPC/Connect RPC for service communication
- Gin (API), chi (Envd) for HTTP
Code Generation
The codebase uses several code generators:
- Protocol Buffers (
packages/orchestrator/generate.Dockerfile)- Generates:
packages/shared/pkg/grpc/*/ - Run:
make generate/orchestrator
- Generates:
- OpenAPI (
oapi-codegen)- Spec:
spec/openapi.yml - Generates: API handlers, types, specs
- Run:
make generate/api
- Spec:
- SQL (
sqlc)- Queries:
packages/api/internal/db/queries/*.sql - Generates: Type-safe DB code
- Run:
make generate/api
- Queries:
- Mocks (
mockery)- Config:
.mockery.yaml - Run:
make generate-mocks
- Config:
Testing Patterns
- Unit tests: Use
testify/assertandtestify/require:requirefor checks that stop the test,assertfor checks that let it continue - Database tests:
packages/api/internal/db/pkg/testutils.SetupDatabasegives each test its own database on the PostgreSQL serverPG_TEST_DATABASE_URLnames (see DEV-LOCAL.md) - Integration tests:
packages/api/integration/with shared test utilities - Mocking: Generated mocks in
mocks/directories - Race detection: Tests run with
-raceflag
Example test invocation:
# Single package
go test -race -v ./internal/handlers
# Specific test
go test -race -v -run TestCreateSandbox ./internal/handlersImportant Development Notes
Working with Proto/gRPC
- Proto files:
packages/envd/spec/process/,packages/envd/spec/filesystem/, orchestrator protos atpackages/orchestrator/*.proto - Shared protos:
packages/shared/pkg/grpc/ - After editing proto files, run
make generate/orchestratorandmake generate/shared
Database Migrations
- Migrations:
packages/api/internal/db/migrations/ - Schema:
packages/api/internal/db/schema/schema.sqldeclares what the migrations build; change it in the same commit as the migration. Migrations generated from it carry aCode generatedheader. - Create:
cd packages/api && make create-migration NAME=your-migration-name— this generates the file with a correctYYYYMMDDHHMMSStimestamp. Do NOT hand-create migration files; placeholder timestamps like120000/000000cause same-day version collisions and are rejected by the out-of-order-migrations CI check. - Apply:
make migrate(requires POSTGRES_CONNECTION_STRING) - Code generation:
make generate/api(regenerates sqlc code)
Environment Variables
- Local development defaults:
packages/<service>/.env.local; see DEV-LOCAL.md. - Self-hosting configuration: embed/compose/.env; see embed/README.md.
- Custom environment configs:
.env.<environment>, selected withmake switch-env ENV=<environment>.
Firecracker & VM Management
- Orchestrator requires sudo to run (Firecracker needs root)
- VM networking uses
iptablesand Linuxnetlink - Storage uses NBD (Network Block Device)
- Templates cached in GCS bucket (configurable via TEMPLATE_BUCKET_NAME)
- Kernel/Firecracker versions:
packages/fc-versions/
Observability
- All services export OpenTelemetry traces/metrics/logs
- Local stack includes Grafana + Loki + Tempo + Mimir
- Telemetry setup:
packages/shared/pkg/telemetry/ - Logger:
packages/shared/pkg/logger/(Zap with OTEL) - Log field and span attribute keys are lower snake_case (
transition_id; dots allowed, as insandbox.id); revive'sstring-formatrule enforces it - Profiling: API exposes pprof on
/debug/pprof/(seepackages/api/Makefileprofiler target)
CI/CD Workflows
.github/workflows/pull-request.yml- PR orchestrator (lint, OpenAPI, unit, arm64, integration).github/workflows/pr-tests.yml- Unit test shards.github/workflows/integration_tests.yml- Integration test suite
Architecture Patterns
- Service Isolation: Each service runs in containers with defined gRPC/HTTP interfaces
- Shared Libraries: Cross-cutting concerns (logging, telemetry, DB) in
packages/shared - Event-Driven: ClickHouse + Redis pub/sub for async operations
- Caching Strategy: Redis for templates, auth tokens, performance optimization
- Feature Flags: LaunchDarkly for gradual rollouts
- Graceful Shutdown: Services handle SIGTERM with context cancellation
- Health Checks: gRPC health protocol + HTTP health endpoints
Debugging
Logs
- Local: Docker logs in
make local-infra - Production: Grafana Loki
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

