Skip to content

feat: forward extra args to the agent in ch run#19

Merged
xico42 merged 1 commit into
mainfrom
feat/pass-args
Jul 6, 2026
Merged

feat: forward extra args to the agent in ch run#19
xico42 merged 1 commit into
mainfrom
feat/pass-args

Conversation

@xico42

@xico42 xico42 commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Summary

ch run <agent> replaces the current shell with a registered agent, but it only ever launched that agent with its statically configured args. Passing a one-off argument at invocation time (e.g. picking a model for a single session) meant editing config first.

This adds the -- pass-through convention:

ch run <agent> -- <args>

Everything after -- is forwarded to the agent verbatim — each token as its own argv element, no shell re-parsing. Extra args are appended after the agent's configured args, so they also land after any -- already embedded in the agent's command string (e.g. ai-jail -- claude), reaching the real agent rather than the wrapper. Example:

ch run claude -- --model opus

Validation

cobra.ExactArgs(1) is replaced with a validator keyed on ArgsLenAtDash(): exactly one positional (the agent name) before --, any number after. A stray positional like ch run claude foo is rejected outright, and a bare flag without -- still errors as unknown — keeping codeherd's own flags distinct from the agent's flags.

Docs & tests

  • Documented in the command help (ch run --help) and the README Commands table + Agents section.
  • Design spec and implementation plan added under docs/superpowers/.
  • Six new tests in cmd/run_internal_test.go cover append order, landing after an embedded --, empty pass-through, and the three strict-validation rejections.
  • make check passes: coverage 81.9% (≥80%), integration tests, lint (0 issues), build.

🤖 Generated with Claude Code

ch run <agent> replaces the current shell with a registered agent, but it
only ever launched that agent with the arguments statically configured for
it. Handing the agent a one-off argument at invocation time — say, picking a
model for a single session — required editing config first. There was no way
to pass arguments through at the call site.

ch run <agent> -- <args> now forwards everything after -- to the agent
verbatim, each token as its own argv element with no shell re-parsing. The
extra args are appended after the agent's configured args, so they also land
after any -- already embedded in the agent's command string (for example
ai-jail -- claude): the arguments reach the real agent rather than the
wrapper in front of it. In practice, ch run claude -- --model opus runs
claude with --model opus tacked onto whatever the config already supplies.

Enforcing the -- convention replaces cobra.ExactArgs(1) with a validator
keyed on ArgsLenAtDash(): exactly one positional, the agent name, may appear
before --, and any number may follow. A stray positional such as
ch run claude foo is rejected outright rather than silently swallowed, and a
bare flag without -- still errors as unknown — keeping the boundary between
codeherd's own flags and the agent's flags unambiguous. The new usage is
documented in the command help and the README, alongside the design spec and
implementation plan under docs/superpowers.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@xico42 xico42 merged commit 185cf18 into main Jul 6, 2026
7 checks passed
@xico42 xico42 deleted the feat/pass-args branch July 6, 2026 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant