-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat(pai.ts): Passthrough unknown CLI flags to claude #985
Description
Problem
pai.ts has a manual arg parser (switch/case) that only handles known flags (-m, -l, -r, --safe, etc.). Unknown flags starting with - are silently dropped, and unknown positional args error with "Unknown command."
This prevents users from combining PAI with Claude Code's native flags. For example:
pai -l --plugin-dir ~/Projects/boxie --mcp-config ~/.claude/mcp-profiles/boxie.jsonCurrently: --plugin-dir and --mcp-config are silently ignored, and ~/Projects/boxie causes error("Unknown command").
Proposed Solution
Change the default case in the arg parser to collect unknown flags and pass them through to the claude command:
// Before
default:
if (!arg.startsWith("-")) {
error(`Unknown command: ${arg}. Use 'k help' for usage.`);
}
// After
default:
if (arg.startsWith("-")) {
passthrough.push(arg);
if (i + 1 < args.length && !args[i + 1].startsWith("-")) {
passthrough.push(args[++i]);
}
} else {
error(`Unknown command: ${arg}. Use 'k help' for usage.`);
}Then spread passthrough into the args array before spawn():
if (options.passthrough?.length) {
args.push(...options.passthrough);
}Use Case
PAI is meant to extend Claude Code, not restrict it. Users should be able to pass any valid claude flag through pai without PAI needing to enumerate every possible flag. This is especially important for:
--plugin-dir— loading plugins per-session--mcp-config— loading MCP server profiles per-session--model— overriding the default model- Any future Claude Code flags that PAI doesn't need to know about
Implementation
I've implemented this in my fork and can open a PR if desired. The change is ~16 lines across 4 locations in pai.ts.
🤖 Generated with Claude Code