A DDEV addon that integrates Claude Code CLI into your DDEV environment.
gh), and ccusage in the DDEV web container~/.claude and ~/.config/gh directories into the containerGH_TOKEN and CLAUDE_CODE_OAUTH_TOKEN via a pre-start hookddev claude and ddev claude-auto commandsddev add-on get jamespublishlab/ddev-claude-code
ddev restart
npm install -g @anthropic-ai/claude-code or via claude.ai/install.sh)claude on your host at least once to initialize ~/.claudegh) authenticated on your host (gh auth login)# Run Claude Code interactively
ddev claude
# Run with arguments
ddev claude --help
ddev claude --version
# Run in autonomous mode (skips permission prompts)
ddev claude-auto "add unit tests for the auth module"
ddev claude --version # Claude Code CLI version
ddev exec gh --version # GitHub CLI version
ddev exec 'echo $GH_TOKEN' # Confirm token injection
The addon supports two authentication methods. The pre-start hook automatically captures tokens from your host and injects them into the container — no manual env var setup required.
Uses your Claude Pro/Max subscription allowance — no additional API costs.
Install Claude Code on your host:
npm install -g @anthropic-ai/claude-code
Run claude once to authenticate:
claude
This opens a browser window where you sign in with your Anthropic account. On completion, Claude saves your OAuth credentials (access token + refresh token) to ~/.claude/.credentials.json.
Install the addon and restart:
ddev add-on get jamespublishlab/ddev-claude-code
ddev restart
The pre-start hook reads the token from ~/.claude/.credentials.json and sets CLAUDE_CODE_OAUTH_TOKEN in the container automatically.
Note: OAuth access tokens expire after ~1 hour. Because
~/.claudeis volume-mounted into the container, Claude Code can auto-refresh using the refresh token stored in~/.claude/.credentials.json. If you experience auth failures during long sessions, runddev restartto re-capture a fresh token.
Uses per-token API billing — simpler but costs more than a subscription.
Get an API key from console.anthropic.com
Add it to .ddev/.env.tokens:
echo "ANTHROPIC_API_KEY=sk-ant-api03-..." >> .ddev/.env.tokens
Do not set both
ANTHROPIC_API_KEYandCLAUDE_CODE_OAUTH_TOKEN— they conflict and Claude will throw an auth error.
Restart: ddev restart
The addon also captures your host’s gh auth token for GitHub integration. Authenticate on your host first:
gh auth login
ddev exec 'echo $CLAUDE_CODE_OAUTH_TOKEN' # Should show your OAuth token
ddev exec 'echo $GH_TOKEN' # Should show your GitHub token
ddev claude --version # Should print version without auth errors
config.claude-code.yaml): Captures your host’s gh auth token and Claude OAuth token into .ddev/.env.tokensdocker-compose.claude-code.yaml): Mounts ~/.claude and ~/.config/gh into the container and loads .env.tokensweb-build/Dockerfile.claude-code): Installs gh, claude, and ccusage in the web container| File | Type | Purpose |
|---|---|---|
docker-compose.claude-code.yaml |
Project | Volume mounts + env_file |
config.claude-code.yaml |
Project | Pre-start hook for token capture |
web-build/Dockerfile.claude-code |
Project | Installs CLI tools |
commands/web/claude |
Global | ddev claude command |
commands/web/claude-auto |
Global | ddev claude-auto command |
ddev add-on remove claude-code
ddev restart
MIT