Problem Description
I'm using claude-code-router (CCR), a proxy tool that routes Claude Code requests to different AI models and providers. However, opcode currently doesn't support integration with CCR due to the following limitations:
- Hardcoded
claude command: opcode directly calls the claude binary without allowing customization
- Environment variable whitelist: The code (
src-tauri/src/commands/claude.rs) only inherits specific environment variables (PATH, HOME, NODE_*, etc.) and filters out critical ones needed by CCR like:
ANTHROPIC_BASE_URL
CLAUDE_CODE_MAX_OUTPUT_TOKENS
MAX_THINKING_TOKENS
Current Workaround Attempts
I tried creating a wrapper script to intercept claude calls, but ran into issues:
- Direct call + environment variables: Doesn't work because CCR's managed authentication requires going through
ccr code command
- Wrapper calling
ccr code: Creates infinite loop (claude → ccr code → claude → ...)
Proposed Solutions
Option 1: Custom Claude Binary Path (Recommended)
Add a setting in opcode UI to specify a custom Claude Code launch command:
UI Example:
Settings → General → Claude Code Command
[ccr code ] (default: claude)
Implementation:
// In src-tauri/src/commands/claude.rs
let claude_command = get_custom_claude_command().unwrap_or("claude".to_string());
let mut cmd = Command::new(claude_command);
Option 2: Custom Environment Variables
Add a setting to specify additional environment variables:
UI Example:
Settings → Advanced → Custom Environment Variables
┌──────────────────────────────────────────────┐
│ ANTHROPIC_BASE_URL=https://my-proxy.com/ │
│ CLAUDE_CODE_MAX_OUTPUT_TOKENS=20000 │
└──────────────────────────────────────────────┘
Implementation:
// In create_command_with_env()
let custom_envs = get_custom_environment_variables();
for (key, value) in custom_envs {
cmd.env(key, value);
}
Option 3: Whitelist Configuration
Allow users to extend the environment variable whitelist via config file or UI.
Use Cases
This feature would benefit users who:
- Use CCR to route requests to different AI models (e.g., Gemini, DeepSeek, Ollama)
- Run Claude Code through custom proxy servers
- Need to set custom API endpoints for enterprise deployments
- Want to modify Claude Code behavior via environment variables
Related Code
The relevant code is in src-tauri/src/commands/claude.rs:
fn create_command_with_env() {
// Current whitelist only includes:
if key == "PATH" || key == "HOME" || key == "USER" || key == "SHELL"
|| key == "LANG" || key == "LC_ALL" || key.starts_with("LC_")
|| key == "NODE_PATH" || key == "NVM_DIR" || key == "NVM_BIN"
|| key == "HOMEBREW_PREFIX" || key == "HOMEBREW_CELLAR"
{
// Only these variables are inherited
}
}
Additional Context
Expected Behavior
After implementing one of the proposed solutions, users should be able to:
- Configure opcode to use
ccr code instead of claude
- Pass custom environment variables to Claude Code
- Successfully integrate opcode with CCR and similar proxy tools
Thank you for considering this feature! opcode is an excellent tool, and this enhancement would make it compatible with the broader Claude Code ecosystem.
Problem Description
I'm using claude-code-router (CCR), a proxy tool that routes Claude Code requests to different AI models and providers. However, opcode currently doesn't support integration with CCR due to the following limitations:
claudecommand: opcode directly calls theclaudebinary without allowing customizationsrc-tauri/src/commands/claude.rs) only inherits specific environment variables (PATH, HOME, NODE_*, etc.) and filters out critical ones needed by CCR like:ANTHROPIC_BASE_URLCLAUDE_CODE_MAX_OUTPUT_TOKENSMAX_THINKING_TOKENSCurrent Workaround Attempts
I tried creating a wrapper script to intercept
claudecalls, but ran into issues:ccr codecommandccr code: Creates infinite loop (claude→ccr code→claude→ ...)Proposed Solutions
Option 1: Custom Claude Binary Path (Recommended)
Add a setting in opcode UI to specify a custom Claude Code launch command:
UI Example:
Implementation:
Option 2: Custom Environment Variables
Add a setting to specify additional environment variables:
UI Example:
Implementation:
Option 3: Whitelist Configuration
Allow users to extend the environment variable whitelist via config file or UI.
Use Cases
This feature would benefit users who:
Related Code
The relevant code is in
src-tauri/src/commands/claude.rs:Additional Context
ccr code --model <model> "prompt"instead ofclaude "prompt"Expected Behavior
After implementing one of the proposed solutions, users should be able to:
ccr codeinstead ofclaudeThank you for considering this feature! opcode is an excellent tool, and this enhancement would make it compatible with the broader Claude Code ecosystem.