claude-code-containers
CLAUDE.md245 starsChanged 18 months agoMITView on GitHub
⚠️ Important: Always run npm run cf-typegen after making changes to wrangler.jsonc. This regenerates the TypeScript types and updates worker-configuration.d.ts to match your bindings and configuration. This is a Cloudflare Workers Container project that integrates Claude Code with GitHub for automated issue processing. It combines: - TypeScript Worker (src/index.ts) - Main request router and GitHub integration - Node.js Container (container_src/src/main.ts) - Containerized Claude Code environment running on port 8080 - Durable Objects - Two DO classes: GitHubAppConfigDO for encrypted credential…
The file
We split this CLAUDE.md into the rules it gives an agent
8 rules. About 0 are common, 1 is distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
7
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 13
⚠️ Important: Always run npm run cf-typegen after making changes to wrangler.jsonc.
- Distinctive: line 42
Default port 8080, 45-second sleep timeout
- Very specific: line 81
Run npm run cf-typegen to update TypeScript types
- Very specific: line 82
Check that worker-configuration.d.ts reflects your changes
- Very specific: line 83
Update your Env interface in TypeScript code if needed
- Very specific: line 127
Use console.log() for debugging - visible in wrangler dev and deployed logs
- Very specific: line 129
Use .dev.vars for local secrets (never commit this file)
- Very specific: line 130
Test with --remote flag to use actual Cloudflare resources during development
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 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 file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Development Commands
npm run dev # Start local development server (http://localhost:8787)
npm run deploy # Deploy to Cloudflare Workers
npm run cf-typegen # Generate TypeScript types after wrangler config changes⚠️ Important: Always run npm run cf-typegen after making changes to wrangler.jsonc. This regenerates the TypeScript types and updates worker-configuration.d.ts to match your bindings and configuration.
Wrangler CLI Commands
npx wrangler dev # Start local development (same as npm run dev)
npx wrangler dev --remote # Use remote Cloudflare resources
npx wrangler deploy # Deploy to production (same as npm run deploy)
npx wrangler login # Authenticate with Cloudflare
npx wrangler versions upload # Upload new version with preview URLTech Stack & Architecture
This is a Cloudflare Workers Container project that integrates Claude Code with GitHub for automated issue processing. It combines:
- TypeScript Worker (
src/index.ts) - Main request router and GitHub integration - Node.js Container (
container_src/src/main.ts) - Containerized Claude Code environment running on port 8080 - Durable Objects - Two DO classes:
GitHubAppConfigDOfor encrypted credential storage andMyContainerfor container management
Key Architecture Points
Request Flow:
- Worker receives requests and routes based on path
- GitHub webhooks trigger issue processing in Claude Code containers
- Container routes (
/container,/lb,/singleton,/error) for testing and load balancing - Setup routes (
/claude-setup,/gh-setup/*) handle API key configuration and GitHub app OAuth
Container Management:
- Extends
cf-containerslibrary'sContainerclass - Default port 8080, 45-second sleep timeout
- Lifecycle hooks:
onStart(),onStop(),onError() - Load balancing support across multiple container instances
- Contains Claude Code SDK (
@anthropic-ai/claude-code) and GitHub API client (@octokit/rest)
GitHub Integration:
- Uses GitHub App Manifests for one-click app creation
- Each deployment gets isolated GitHub app with dynamic webhook URLs
- OAuth flow:
/gh-setup→ GitHub →/gh-setup/callback→/gh-setup/install - Webhook processing:
/webhooks/githubhandles push, pull_request, issues, installation events - Encrypted credential storage using AES-256-GCM in Durable Objects
Configuration Files
wrangler.jsonc- Workers configuration with container bindings and Durable ObjectsDockerfile- Multi-stage build with Node.js, Python, Git, and Claude Code CLIworker-configuration.d.ts- Auto-generated types (runnpm run cf-typegenafter config changes).dev.vars- Local environment variables (not committed to git)container_src/package.json- Container dependencies including Claude Code SDK
Key Wrangler Configuration Patterns
{
"compatibility_date": "2025-05-23", // Controls API behavior and features
"nodejs_compat": true, // Enable Node.js API compatibility
"vars": { // Environment variables
"ENVIRONMENT": "development"
},
"durable_objects": { // Durable Object bindings
"bindings": [
{ "name": "MY_CONTAINER", "class_name": "MyContainer" },
{ "name": "GITHUB_APP_CONFIG", "class_name": "GitHubAppConfigDO" }
]
}
}After modifying bindings or vars in wrangler.jsonc:
- Run
npm run cf-typegento update TypeScript types - Check that
worker-configuration.d.tsreflects your changes - Update your
Envinterface in TypeScript code if needed
Development Patterns
Key Endpoints:
/claude-setup- Configure Claude API key/gh-setup- GitHub app creation and setup/gh-status- Check configuration status/webhooks/github- GitHub webhook processor/container/*- Basic container functionality/lb/*- Load balancing across 3 containers/singleton/*- Single container instance/error/*- Test container error handling
Environment Variables:
- Container receives issue context and GitHub credentials from Worker
- Configure base environment in
wrangler.jsoncvars section - Sensitive data (API keys, tokens) stored encrypted in Durable Objects
Cloudflare Workers Best Practices
Worker Code Structure
export interface Env {
MY_CONTAINER: DurableObjectNamespace;
GITHUB_APP_CONFIG: DurableObjectNamespace;
// Add other bindings here
ENVIRONMENT?: string;
}
export default {
async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
// Worker logic here
return new Response("Hello World");
},
} satisfies ExportedHandler<Env>;Resource Bindings
- Durable Objects: Access via
env.MY_CONTAINER.get(id) - Environment Variables: Access via
env.VARIABLE_NAME - KV/D1/R2: Configure in wrangler.jsonc, access via env bindings
Development Tips
- Use
console.log()for debugging - visible inwrangler devand deployed logs - Workers must start within 400ms - keep imports and initialization lightweight
- Use
.dev.varsfor local secrets (never commit this file) - Test with
--remoteflag to use actual Cloudflare resources during development
Current Implementation Status
✅ Completed:
- GitHub App Manifest setup and OAuth flow
- Secure credential storage in Durable Objects with AES-256-GCM encryption
- Basic webhook processing infrastructure with signature verification
- Container enhancement with Claude Code SDK and GitHub API integration
- Issue detection and routing to Claude Code containers
🔧 In Progress:
- End-to-end issue processing with Claude Code analysis and solutions
- Pull request creation from Claude's code modifications
- Enhanced error handling and progress monitoring
Important: Containers are a Beta feature - API may change. The cf-containers library version is pinned to 0.0.7.
Project Architecture Summary
This project creates an automated GitHub issue processor powered by Claude Code:
- Setup Phase: Configure Claude API key and GitHub app via web interface
- Issue Processing: GitHub webhooks trigger containerized Claude Code analysis
- Solution Implementation: Claude Code analyzes repositories and implements solutions
- Result Delivery: Solutions are delivered as GitHub comments or pull requests
Key Integration Points:
src/handlers/github_webhook.ts- Main webhook entry pointsrc/handlers/github_webhooks/issues.ts- Issue-specific processingcontainer_src/src/main.ts- Claude Code execution environment- Durable Objects for persistent, encrypted storage of credentials and state
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.

