A DDEV addon for sandboxing Claude Code in professional team environments with built-in security features: URL allow list and .env protection.
ddev get agence-adeliom/ddev-claude-sandbox
ddev restart
ddev claude
Run commands that need environment variables from .env.local:
ddev agent-env php bin/console app:call-api
ddev agent-env printenv | grep API_KEY
Override defaults in .ddev/config.local.yaml:
web_environment:
# Disable URL allow list feature
- CLAUDE_URL_ALLOWLIST_ENABLED=false
# Disable .env protection
- CLAUDE_ENV_PROTECTION_ENABLED=false
# Customize protected files (comma-separated patterns)
- CLAUDE_PROTECTED_FILES=.env.local,.env.*.local,credentials.json
Then restart: ddev restart
| Variable | Default | Description |
|---|---|---|
CLAUDE_URL_ALLOWLIST_ENABLED |
true |
Auto-approve domains after first authorization |
CLAUDE_ENV_PROTECTION_ENABLED |
true |
Block Claude from reading .env files |
CLAUDE_PROTECTED_FILES |
.env.local,.env.*.local |
File patterns to protect |
URL Allow list/Disallow list - Control which domains Claude can access:
~/.claude/hooks/url-disallowlist-add.sh <domain>).ddev/claude/url-list.jsonEnvironment Protection - Keep secrets safe:
.env.local or other protected filesddev agent-env <command> when you need secrets loadedddev-claude-sandbox/
├── install.yaml # Addon manifest
├── config.claude-sandbox.yaml # DDEV hooks and environment
├── web-build/
│ └── Dockerfile.claude-sandbox
├── claude/
│ └── hooks/ # Security hooks (tracked by git)
├── commands/web/
│ ├── claude
│ └── agent-env
├── scripts/
│ ├── setup-claude.sh
│ └── generate-claude-settings.php
└── tests/
└── test.bats
This addon uses BATS (Bash Automated Testing System).
# macOS
brew install bats-core
brew tap kaos/shell
brew install bats-file bats-support
# Linux (apt)
apt install bats bats-assert bats-file bats-support
# All tests
bats ./tests/test.bats
# Exclude release tests (local development)
bats ./tests/test.bats --filter-tags '!release'
# Verbose output
bats ./tests/test.bats --show-output-of-passing-tests --verbose-run
| Test | Description |
|---|---|
install from directory |
Basic addon installation |
claude command is available |
Claude binary works |
agent-env command works |
Secrets wrapper executes |
setup script creates hook files |
Hooks generated correctly |
settings.json is generated |
Hook configuration created |
url allow list can be disabled |
Feature toggle works |
env protection can be disabled |
Feature toggle works |
claude config directory exists |
Config directory created |
protected files pattern is configurable |
Custom patterns work |
Tests run automatically via GitHub Actions on:
mainApache License 2.0