This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
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 changesnpm 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.
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 URLThis 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
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
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
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
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
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>;- 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
- 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
✅ 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.
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
{ "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" } ] } }