feat: Claude Configuration Injection for Docker Sandboxes #243
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Claude Configuration Injection for Docker Sandboxes
Summary
Enables Claude Code to work with full functionality inside Docker containers by automatically injecting user-level configuration files, custom tools, and MCP server environment variables from the host system.
What This PR Adds
1. User-Level Configuration Injection
~/.claude/CLAUDE.md→/home/vibekit/.claude/CLAUDE.md~/.claude/{agents,commands,scripts}/*→/home/vibekit/.claude/*/./.claude/{agents,commands,scripts}/*→/workspace/.claude/*/Why: User's personal coding standards and custom workflow tools now work inside containers
2. MCP Environment Variable Injection
.mcp.jsonfor${ENV_VAR}patternsBRAVE_API_KEY,ANTHROPIC_API_KEY)Security: Only explicitly referenced env vars are passed—no blind credential exposure
3. Project MCP Server Support
extractProjectMcpServers()function extracts MCP servers from project.mcp.json4. Auto-Executable Scripts
chmod +xfor.shfiles and scripts in/commands/,/scripts/directories5. Non-Root User Execution
vibekituser (not root)Why: Prevents permission issues when editing files created inside container
Technical Implementation
Method: Base64-encoded injection script mounted into container
:ro) for securityGraceful Degradation: Silently skips injection if config files don't exist—no errors, no crashes
Files Changed
packages/cli/src/sandbox/docker-sandbox.js(+190 lines)injectClaudeFiles()- File injection logicinjectEnvironmentVariables()- MCP env var extractionextractEnvVarsFromMcpConfig()- Recursive env var pattern matchingcreateFileInjectionScript()- Base64-encoded script generationpackages/cli/src/auth/claude-auth-helper.js(+53 lines)extractProjectMcpServers()- Project-level MCP server extractiongenerateClaudeSettings()- Merge host + project MCP serverspackages/cli/Dockerfile(+23/-4 lines)/root/to/home/vibekit//home/vibekit/.claudedirectoryCommits
921a975- feat(docker): add Claude configuration and credential injection support3101ed2- fix(auth): sanitize MCP server logging to avoid exposing configuration details38c0a39- fix(docker): automatically set executable permissions for injected scriptsTesting
.mcp.json.claude/commands/and.claude/scripts/Before This PR
Claude Code works in containers but:
CLAUDE.md(loses personal coding preferences).claude/{agents,commands,scripts}After This PR
Security Notes
.mcp.jsonare injected:ro)