A macOS sandbox - sandbox-exec wrapper for Claude Code that provides secure, isolated execution environment with automatic package manager detection and comprehensive configuration options.
- π What is claudebox?
- π Requirements
- β‘ Quick Start
- π Commands
- π οΈ Installation
- βοΈ Configuration
- π Features
- π Usage Examples
- π Security Model
- π Troubleshooting
- π§ How It Works
β οΈ Limitations- π Security Details
- π License
- π€ Contributing
- π Support
claudebox runs Claude Code inside a macOS sandbox to provide an additional layer of security by:
- Restricting file system access to project directories only
- Blocking access to sensitive directories (
~/Documents,~/Desktop,~/.ssh, etc.) - Allowing only necessary system resources and package manager paths
- Providing configurable process limits
- macOS 10.7+ with
sandbox-executility - Claude Code - Anthropic's official Claude CLI
- Xcode Command Line Tools (for
sandbox-exec)
# Make executable and run Claude Code in current directory
chmod +x claudebox
./claudebox
# Or install globally
sudo cp claudebox /usr/local/bin/
claudebox| Command | Description |
|---|---|
claudebox |
Generate profile + run Claude Code (default) |
claudebox run [...args] |
Same as default, pass arguments to Claude |
claudebox generate |
Build sandbox profile only |
claudebox profile |
Print path to generated profile |
claudebox validate |
Validate generated sandbox profile |
claudebox help |
Show help and examples |
All standard Claude Code commands work within the sandbox:
claudebox run --dangerously-skip-permissions- yolo mode
git clone <repository-url>
cd claudebox
chmod +x claudebox
./claudeboxsudo cp claudebox /usr/local/bin/
claudebox./install.sh| Variable | Description | Default |
|---|---|---|
CLAUDEBOX_VERBOSE |
Enable debug output (1 to enable) |
0 |
CLAUDEBOX_DRY_RUN |
Show what would be executed (1 to enable) |
0 |
CLAUDEBOX_CONFIG |
Path to custom config file | ~/.claudeboxrc |
Create ~/.claudeboxrc to customize behavior:
# Example ~/.claudeboxrc
ULIMIT_PROCESSES=2048
VERBOSE=1
# Add custom environment variables here- Homebrew (ARM:
/opt/homebrew, Intel:/usr/local/Homebrew) - User binaries (
~/.local) - Node Version Manager (
~/.nvm) - Fast Node Manager (
~/.fnm) - nodenv (
~/.nodenv) - Nix (
/nix/store)
- Automatic cleanup of temporary files
- Path validation and sanitization
- Environment validation before execution
- Sandbox profile validation
- Path caching: Detection results cached for 1 hour
- Parallel detection: Efficient package manager discovery
- Minimal overhead: Only validates when necessary
- Verbose logging: Detailed debug information
- Dry-run mode: Preview what would be executed
- Profile validation: Verify sandbox configuration
- Configuration support: Customizable via files and environment
# Run Claude Code with default settings
claudebox
# Run with specific arguments
claudebox run --help# Enable verbose output
CLAUDEBOX_VERBOSE=1 claudebox
# Show what would be executed without running
CLAUDEBOX_DRY_RUN=1 claudebox# Generate profile only
claudebox generate
# Show profile location
claudebox profile
# Validate generated profile
claudebox validate# Use custom config file
CLAUDEBOX_CONFIG=/path/to/custom.conf claudebox
# Combine multiple options
CLAUDEBOX_VERBOSE=1 CLAUDEBOX_DRY_RUN=1 claudebox run --version- β Project directory: Full read/write access to current working directory
- β
System binaries:
/usr,/bin,/sbin,/System - β Package managers: Detected paths for npm, pip, cargo, etc.
- β
Temp directories:
/tmpand system temp folders - β
Claude config:
~/.claudeand~/.claude.json - β
IDE configs:
.vscode,.cursor,.vim,.config(read-only) - β Networking: Full network access for API calls
- β Personal directories:
~/Documents,~/Desktop,~/Downloads - β Media folders:
~/Pictures,~/Movies,~/Music - β Sensitive configs:
~/.ssh,~/.aws,~/.gnupg,~/.kube - β System modifications: Cannot modify system files
Claude command not found
# Check if Claude is installed
which claude
# If not, install Claude first
# then run claudeboxPermission denied on temp directory
# Check temp directory permissions
ls -la $TMPDIR
# or
ls -la /tmpSandbox profile validation fails
# Check profile with verbose mode
CLAUDEBOX_VERBOSE=1 claudebox validate
# Or inspect the generated profile
claudebox profile
cat $(claudebox profile)Enable comprehensive debugging:
CLAUDEBOX_VERBOSE=1 CLAUDEBOX_DRY_RUN=1 claudeboxThis will show:
- Environment validation steps
- Package path detection
- Profile generation process
- What would be executed
claudebox creates a dynamic macOS sandbox profile for each project using Apple's sandbox-exec utility. Here's the process:
flowchart TD
A[claudebox] --> B[Detect package managers]
B --> C[Generate sandbox profile]
C --> D[Run Claude Code in sandbox environment]
D --> E[Cleanup]
- Scans for package managers (Homebrew, npm, nvm, fnm, nodenv, Nix)
- Detects system architecture (Apple Silicon vs Intel)
- Validates sandbox-exec availability and permissions
- Caches detection results for 1 hour to improve performance
- Creates a temporary sandbox profile using template-based replacement
- Injects detected package manager paths into the profile
- Adds project directory with full read/write/execute permissions
- Configures allowed system resources and blocked sensitive directories
- Validates the generated profile using
sandbox-exec -f profile true - Launches Claude Code within the sandbox with restricted permissions
- Automatically cleans up temporary files on exit
- macOS only: Requires Apple's
sandbox-executility (not available on Linux/Windows) - macOS 10.7+: Sandbox technology requires Lion or later
- Command-line tools: Requires Xcode Command Line Tools for
sandbox-exec
- Network restrictions: Some advanced networking features may be limited
- System modifications: Cannot install system-wide packages or modify system files
- Hardware access: Limited access to hardware resources and peripherals
- Inter-process communication: Restricted communication with other processes
- Cache limitations: Package manager detection cache may become stale (1-hour TTL)
- Slow first run: Initial package manager detection can take several seconds
- Path conflicts: May not detect custom package manager installations
- Profile validation: Some edge cases may cause sandbox profile validation to fail
claudebox leverages macOS's built-in Application Sandbox technology - sandbox-exec, which provides:
- Kernel-level isolation: Restrictions enforced at the kernel level
- Principle of least privilege: Only grants necessary permissions
- Resource limitations: Controls CPU, memory, and file descriptor usage
- Network filtering: Allows outbound connections while blocking unnecessary access
Allowed Paths:
βββ Project directory (full access)
βββ /usr, /bin, /sbin, /System (read/execute)
βββ Package manager paths (read/execute)
βββ ~/.claude* (read/write for config)
βββ IDE configs (read-only)
βββ /tmp, /var/tmp (temporary files)
Blocked Paths:
βββ ~/Documents, ~/Desktop, ~/Downloads
βββ ~/Pictures, ~/Movies, ~/Music
βββ ~/.ssh, ~/.aws, ~/.gnupg, ~/.kube
βββ /etc (system configuration)
βββ Other user directories
- Process limit: Configurable via
ULIMIT_PROCESSES(default varies by system) - Memory constraints: Inherits system memory limits
- CPU throttling: No artificial CPU restrictions applied
- Signal handling: Standard signal handling within sandbox boundaries
MIT License
- Fork the repository
- Create a feature branch
- Make your improvements
- Test thoroughly with
CLAUDEBOX_VERBOSE=1 - Submit a pull request
For issues or questions:
- Enable verbose mode:
CLAUDEBOX_VERBOSE=1 claudebox - Check the generated profile:
claudebox validate - Review the security model above
- Open an issue with debug output
sandbox-exec. It will not work on Linux or Windows systems.