CLI wrapper for Claude to load default options from .env files
- Shell 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .env.example | ||
| claude | ||
| README.md | ||
Claude Wrapper Script
A bash wrapper for the Claude CLI that automatically loads default options from a .env file in your working directory.
Why?
Instead of typing the same flags every time you work in a service-specific folder:
cd ~/workspace/google-service
claude --chrome --dangerously-skip-permissions
You can set defaults once and just run:
cd ~/workspace/google-service
claude
Installation
Copy the claude script to a location in your PATH:
cp ~/workspace/claude/claude-wrapper/claude ~/.local/bin/claude
Or symlink it:
ln -s ~/workspace/claude/claude-wrapper/claude ~/.local/bin/claude
Make sure ~/.local/bin is in your $PATH. You can check with:
echo $PATH | grep -q "$HOME/.local/bin" && echo "✓ in PATH" || echo "✗ not in PATH"
Usage
Set Up Defaults
Create a .env file in your project/service directory:
cd ~/workspace/my-service
echo 'CLAUDE_FLAGS=--chrome --dangerously-skip-permissions' > .env
Run Claude
Now just run claude normally — it will automatically load flags from .env:
claude
# Equivalent to: claude --chrome --dangerously-skip-permissions
Override Defaults
Pass flags on the command line to override .env defaults:
# .env has: CLAUDE_FLAGS=--no-chrome
claude --chrome
# The wrapper passes: --no-chrome --chrome
# Result: --chrome wins (last flag takes precedence)
How It Works
- The wrapper looks for a
.envfile in your current working directory - Extracts the
CLAUDE_FLAGSvariable - Prepends those flags to any CLI arguments you pass
- Calls the real
claudecommand with the merged arguments
Since CLI args come last, they naturally override .env defaults.
Examples
Example 1: Google Service Setup
# ~/workspace/google-service/.env
CLAUDE_FLAGS=--chrome --dangerously-skip-permissions
Example 2: Multiple Flags with Quotes
# .env
CLAUDE_FLAGS=--chrome --model claude-opus-5 --timeout 300
Example 3: No Defaults
# If no .env file exists, wrapper just passes through to claude normally
Troubleshooting
"claude binary not found in PATH"
- Make sure your actual Claude CLI is installed and in your
$PATH - Check with:
which claude(should show the real binary, not the wrapper)
Flags aren't being picked up
- Verify the
.envfile exists in your working directory - Check the variable name is exactly
CLAUDE_FLAGS(case-sensitive) - Verify the format:
CLAUDE_FLAGS=value
The wrapper is being called instead of the real claude
- Make sure
~/.local/bin(where the wrapper lives) comes after the real Claude location in your$PATH - Or use an alias:
alias claude='command claude'to force the real binary
Notes
- The wrapper uses
CLAUDE_FLAGS(uppercase) as the variable name - Flags in
.envare space-separated, just like command-line arguments - Multi-word arguments should be quoted in
.envif needed - The wrapper preserves all shell escaping and quoting