CLI-Router
CLI-Router is a Python command-line orchestrator for AI coding tools. It routes ordered workflow stages across external CLIs such as Claude Code, Codex, Hermes, Grok, and local model tools.
The router is intentionally programmatic and non-intelligent: it loads configured commands, renders prompt templates, captures stdout/stderr, extracts configured output, writes artifacts such as PLAN.md, and records run artifacts.
Install
pip install cli-router
For CLI usage, pipx is recommended:
pipx install cli-router
From a local checkout:
python -m pip install -e .
Commands
cli-router --help
cli-router
cli-router tui
cli-router plan "Add a health check endpoint"
cli-router run "Add a health check endpoint"
cli-router run "Add a health check endpoint" --stages planner,review,coder
cli-router implement
cli-router implement --stages coder,review
cli-router check
cli-router config show
cli-router tools list
cli-router tools test claude-planner
cli-router runs
cli-router runs show 2026-07-07T14-22-10
Running cli-router with no subcommand opens the interactive TUI. plan runs the planner stage and writes PLAN.md. run runs all enabled workflow stages in configured order. implement runs enabled post-planner stages using the existing plan file. --stages selects specific stage IDs and runs them in the order provided, including stages that are disabled by default.
runs lists previous run artifact directories from defaults.run_dir, newest first. runs show <id> prints the saved manifest summary for one run and lists the artifact files present. <id> may be a unique prefix of the timestamp directory name.
tui opens a main menu:
- Prompt: enter a prompt and run the enabled workflow.
- Workflow: select, reorder, and run stages.
- Stage configuration: select stages, edit prompts, and choose model configs.
- Model Config: add providers/model configs and edit provider, model, and effort metadata.
On first run, if no config exists, the TUI asks which providers to enable. Built-in choices include codex, claude, hermes, and grok. The default workflow uses the first selected provider, and CLI-Router writes the generated config to ~/.cli-router/config.yaml.
Navigation is consistent across the TUI:
- Up/Down arrows move the cursor.
- Enter opens or runs the selected action.
bgoes back to the main menu from submenus.qquits the TUI.- Esc cancels the current screen, picker, or text entry.
- Ctrl+C cancels immediately and exits with code
130.
The workflow screen uses a checkbox selector in the left column and shows each stage prompt:
- Up/Down arrows move the cursor.
- Space toggles a stage between
☑selected and☐skipped. uanddreorder the current stage.iinserts a stage from the stage library after the current stage.xremoves the current stage from the workflow.- Enter runs the checked stages in the displayed order.
Stage prompts use these official variables:
[user prompt]: the request entered through the Prompt menu.[previous stage output]: the final extracted output of the immediately preceding stage (empty for the first stage).[all stage outputs]: the final outputs of every completed stage so far, each labeled with its stage id.[plan file]: the path to the workflow plan file (PLAN.md).
When stages run, those display variables are converted to CLI-Router's internal placeholders. In Stage configuration, the stage-prompt editor keeps this variable legend visible, supports multiline prompts with Enter, and saves with Ctrl+D.
Configuration
CLI-Router looks for config in this order:
./cli-router.yaml./.cli-router.yaml~/.cli-router/config.yaml~/.config/cli-router/config.yaml- Built-in defaults
The TUI persists first-run setup and TUI edits to ~/.cli-router/config.yaml. Project-local config files still take precedence when present.
Minimal example:
version: 1
defaults:
plan_file: PLAN.md
run_dir: .cli-router/runs
stop_on_failure: true
tui_verbosity: condensed
log_dir: ~/.cli-router/logs
log_level: INFO
tools:
claude-planner:
type: claude
timeout_seconds: 60
command:
- claude
- -p
- --permission-mode
- plan
- --output-format
- json
- "{prompt}"
output:
format: json
extract: result
codex-coder:
type: codex
timeout_seconds: 120
command:
- codex
- --ask-for-approval
- never
- exec
- "{prompt}"
output:
format: text
grok-coder:
type: grok
timeout_seconds: 120
command:
- grok
- --single
- "{prompt}"
output:
format: text
codex-reviewer:
type: codex
timeout_seconds: 120
command:
- codex
- --ask-for-approval
- never
- exec
- "{prompt}"
output:
format: text
stage_library:
- id: coder
tool: codex-coder
input_template: |
Please implement the plan in {plan_path}.
Original user request:
{user_prompt}
- id: qa
tool: codex-reviewer
input_template: |
Review the changes against {plan_path}.
Original user request:
{user_prompt}
- id: summary
tool: codex-reviewer
input_template: |
Summarize the workflow outcome for {user_prompt}.
workflows:
default:
stages:
- id: planner
tool: claude-planner
fallback_tools:
- codex-planner
input_template: |
You are the planning model for a coding-agent handoff.
User request:
{user_prompt}
Inspect this repository and produce a concrete implementation plan.
Do not edit files.
Write the plan in Markdown.
output_file: PLAN.md
- id: coder
tool: codex-coder
input_template: |
Please implement the plan in {plan_path}.
Original user request:
{user_prompt}
- id: review
tool: codex-reviewer
enabled: false
input_template: |
Review the changes against {plan_path}.
Original user request:
{user_prompt}
Command args and templates support {prompt}, {user_prompt}, and {plan_path} placeholders.
Workflow stages are modular:
stagesorder is execution order forcli-router run.stage_libraryis an optional top-level list of reusable stage templates that the TUI can insert into a workflow.- Inserting a template whose ID already exists auto-suffixes the new workflow stage, for example
coderbecomescoder-2, so artifacts remain distinct. enabled: falsekeeps a stage out of defaultrunandimplementexecution.--stages review,coderselects stages explicitly and controls their order.cli-router tuiprovides an interactive main menu with Prompt first. The workflow screen has checkbox selection, stage ordering, stage-library insertion, selected-stage removal, and a Prompt column that previews each stage prompt.- The TUI stage configuration screen lets users select a stage with Up/Down, press Enter to edit its prompt, and choose its Model Config from a picker. The stage-prompt editor keeps the official variable legend visible, supports multiline prompts with Enter, and saves with Ctrl+D.
Aadds a custom stage,Iinserts from the stage library, andXremoves the selected stage. Changes persist to~/.cli-router/config.yamlwhen the TUI is operating on the generated or user-level config. Project-local configs are left unchanged. - The TUI calls configured tools "Model Configs" and lets users add providers/model configs or edit provider, model, and effort metadata. Runtime command configuration remains in YAML.
- Model Config rows are edited with
E; Enter does not start editing. Provider, model, and effort are selected with arrow-key pickers. - Esc cancels the active TUI screen, picker, or text entry without applying partial changes. Ctrl+C cancels from any TUI screen, picker, or text entry and exits with code
130. - When a workflow starts from Prompt or Workflow, the TUI immediately shows a "Running workflow" panel and streams condensed stage progress while external tools execute.
- By default, the TUI collapses verbose thinking blocks and unified diffs, then prints a compact summary with the run artifact directory. Set
defaults.tui_verbosity: fullto restore the raw stdout/stderr dump. - Model options are discovered through the provider CLI when possible with stdin closed and a short timeout, then fall back to built-in known model names. Codex discovery uses
codex debug modelsand reads the returned model catalog, and Grok discovery usesgrok models. Claude currently uses a static fallback list because Claude Code does not expose an equivalent model catalog command. - TUI stage prompts use official bracket variables:
[user prompt],[previous stage output],[all stage outputs], and[plan file]. Unknown bracket variables are rejected. - A stage with
output_filewrites its extracted output to that file. - A stage with
updates_plan: truemakes later{plan_path}placeholders point to itsoutput_file.
When a stage command fails, CLI-Router records stdout/stderr and classifies common failures. Usage-limit messages such as provider quota, rate-limit, or 429 errors are reported as usage-limit failures. Authentication failures such as provider login errors are reported as auth_required and include the provider's first error line. Commands can set timeout_seconds; timed-out commands are recorded with exit code 124. A stage can define fallback_tools to try alternate configured tools in order after a failed primary tool.
Artifacts
Each run writes artifacts under .cli-router/runs/:
.cli-router/runs/2026-07-07T14-22-10/
run.yaml
planner.stdout
planner.stderr
planner.extracted.md
coder.stdout
coder.stderr
Inspect previous runs from the CLI:
cli-router runs
cli-router runs list
cli-router runs show 2026-07-07T14-22-10
Each run manifest records workflow start/finish timestamps, total duration, per-stage attempt durations, subprocess durations, byte counts, failure kind, and retry count. cli-router runs show <id> prints the saved durations.
Diagnostic logs are written to ~/.cli-router/logs/ by default:
cli-router.log: rotating structured text log with workflow and stage lifecycle events.metrics.jsonl: one JSON object per run for aggregate analysis.
Set defaults.log_dir to store these files somewhere else, and defaults.log_level to change verbosity.
Development
python -m pip install -e .
python -m pytest
Build and check a release locally:
python -m pip install --upgrade build twine
python -m build
python -m twine check dist/*
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cli_router-0.3.0.tar.gz.
File metadata
- Download URL: cli_router-0.3.0.tar.gz
- Upload date:
- Size: 163.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b8e827c3916b46a40b5486fd3eebe039e53765d47cf31afd807e3c991f0fb3f
|
|
| MD5 |
01aa37d791804371f537480861cb782a
|
|
| BLAKE2b-256 |
1037736020f451043876b4d995462258675cf0ed9dc1604786e85b722251acbb
|
Provenance
The following attestation bundles were made for cli_router-0.3.0.tar.gz:
Publisher:
publish.yml on coolrazor007/cli-router
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cli_router-0.3.0.tar.gz -
Subject digest:
3b8e827c3916b46a40b5486fd3eebe039e53765d47cf31afd807e3c991f0fb3f - Sigstore transparency entry: 2165135295
- Sigstore integration time:
-
Permalink:
coolrazor007/cli-router@82fdb60034d148a40c72d73387075f35a40e1a1c -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/coolrazor007
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@82fdb60034d148a40c72d73387075f35a40e1a1c -
Trigger Event:
release
-
Statement type:
File details
Details for the file cli_router-0.3.0-py3-none-any.whl.
File metadata
- Download URL: cli_router-0.3.0-py3-none-any.whl
- Upload date:
- Size: 54.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cdeb86c9731e65d323bef6acce17a353e898131f588e2b9602b0e76c16f83d84
|
|
| MD5 |
f88e3decd657d55588fb7412f5b63913
|
|
| BLAKE2b-256 |
b6a876a9a83393e116e36dba089785141dddd561096121ef0687a32cce94fbad
|
Provenance
The following attestation bundles were made for cli_router-0.3.0-py3-none-any.whl:
Publisher:
publish.yml on coolrazor007/cli-router
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cli_router-0.3.0-py3-none-any.whl -
Subject digest:
cdeb86c9731e65d323bef6acce17a353e898131f588e2b9602b0e76c16f83d84 - Sigstore transparency entry: 2165135302
- Sigstore integration time:
-
Permalink:
coolrazor007/cli-router@82fdb60034d148a40c72d73387075f35a40e1a1c -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/coolrazor007
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@82fdb60034d148a40c72d73387075f35a40e1a1c -
Trigger Event:
release
-
Statement type: