Skip to content

Commit 0bc038c

Browse files
badlogicclaude
andcommitted
Add --claude-binary parameter to specify custom Claude Code CLI path
- Add --claude-binary option to claude-bridge CLI for specifying custom Claude Code binary location - Update findClaudeExecutable to accept custom path parameter - Add parameter validation and helpful error messages - Enhanced OpenAI client error handling with more detailed error information 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent ab424b2 commit 0bc038c

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

apps/claude-bridge/src/cli.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ interface ClaudeArgs {
4040
patchClaude?: boolean | undefined;
4141
debug?: boolean | undefined;
4242
trace?: boolean | undefined;
43+
claudeBinary?: string | undefined;
4344
claudeArgs: string[];
4445
}
4546

@@ -54,6 +55,7 @@ interface ParsedArgs {
5455
maxRetries?: number | undefined;
5556
maxOutputTokens?: number | undefined;
5657
logDir?: string | undefined;
58+
claudeBinary?: string | undefined;
5759
patchClaude?: boolean | undefined;
5860
debug?: boolean | undefined;
5961
claudeArgs: string[];
@@ -132,6 +134,7 @@ OPTIONS:
132134
--maxRetries <num> Maximum number of retries for failed requests
133135
--max-output-tokens <num> Maximum output tokens (overrides provider defaults)
134136
--log-dir <dir> Directory for log files (default: .claude-bridge)
137+
--claude-binary <path> Path to Claude Code CLI binary (default: auto-detect)
135138
--patch-claude Patch Claude binary to disable anti-debugging checks
136139
--debug Enable debug logging (requests/responses to .claude-bridge/)
137140
--trace Spy mode: log all Claude ↔ Anthropic communication (implies --debug)
@@ -313,6 +316,11 @@ function parseArguments(argv: string[]): ParsedArgs {
313316
args.logDir = argv[++i];
314317
}
315318
i++;
319+
} else if (arg === "--claude-binary") {
320+
if (i + 1 < argv.length && argv[i + 1] !== undefined) {
321+
args.claudeBinary = argv[++i];
322+
}
323+
i++;
316324
} else if (arg === "--patch-claude") {
317325
args.patchClaude = true;
318326
i++;
@@ -447,7 +455,15 @@ function resolveToJsFile(filePath: string): string {
447455
}
448456
}
449457

450-
function findClaudeExecutable(): string {
458+
function findClaudeExecutable(customPath?: string): string {
459+
if (customPath) {
460+
console.log(`🔍 Using custom Claude binary: ${customPath}`);
461+
if (!fs.existsSync(customPath)) {
462+
console.error(`❌ Custom Claude binary not found: ${customPath}`);
463+
process.exit(1);
464+
}
465+
return resolveToJsFile(customPath);
466+
}
451467
try {
452468
let claudePath = require("child_process")
453469
.execSync("which claude", {
@@ -559,7 +575,7 @@ function runClaudeWithBridge(args: ClaudeArgs): number {
559575
}
560576
}
561577

562-
let claudeExe = findClaudeExecutable();
578+
let claudeExe = findClaudeExecutable(args.claudeBinary);
563579
if (!claudeExe) {
564580
console.error("❌ Claude CLI not found in PATH");
565581
console.error("❌ Please install Claude Code CLI first");
@@ -644,6 +660,7 @@ async function main(argv: string[] = process.argv) {
644660
model: "claude-3-5-sonnet-20241022", // dummy, ignored in trace mode
645661
trace: true,
646662
debug: true, // trace implies debug
663+
claudeBinary: parsedArgs.claudeBinary,
647664
claudeArgs: parsedArgs.claudeArgs,
648665
// All other flags ignored in trace mode
649666
});
@@ -679,6 +696,7 @@ async function main(argv: string[] = process.argv) {
679696
patchClaude: parsedArgs.patchClaude || false,
680697
debug: parsedArgs.debug || false,
681698
trace: parsedArgs.trace || false,
699+
claudeBinary: parsedArgs.claudeBinary,
682700
claudeArgs: parsedArgs.claudeArgs,
683701
});
684702

0 commit comments

Comments
 (0)