@rules/routing.md
Claude Code Skill
Defaults
| Parameter | Default |
|---|
| Model selection | Use Claude Code CLI default unless the user explicitly asks for |
| Effort | Use CLI default unless the user explicitly asks for |
| Permission mode | --permission-mode default
|
| Headless mode | / |
| CI / scripted run | Add so the call ignores local hooks, plugins, MCP, and CLAUDE.md |
| Resume target | () for the latest session in the current directory; () for a session by ID or display name |
Do NOT ask the user for model or effort unless explicitly requested.
Routing
Use this skill when the request actually needs the
CLI or a separate Claude Code session.
- Read rules/routing.md before building a command when the request might be out of scope.
- Route away to direct editing or another skill when the user wants generic writing, documentation cleanup, or local edits without needing the CLI itself.
Examples
Positive triggers:
- "Use Claude Code to review this repository and summarize the risks."
- "Run in print mode and analyze this architecture."
- "Continue the last Claude Code session and ask it to finish the patch."
- "Resume the claude session and apply the next fix."
- "Use so this CI step does not pick up local hooks."
Negative triggers:
- "Rewrite this runbook for readability."
- "Create a new skill for our repo."
Boundary trigger:
- "Research Claude Code permissions and tell me what they do."
Use this skill only if the user wants the CLI involved; otherwise route to research or direct documentation work.
Critical: Print Mode
Always use
/
for non-interactive Claude Code runs. Positional prompts without
start the interactive REPL instead, so a script that omits
will hang waiting for a TTY.
bash
# Non-interactive (headless / SDK)
claude --permission-mode default -p "your prompt here"
# Interactive REPL (initial prompt only — does NOT exit)
claude "your prompt here"
is the canonical SDK/CI entrypoint. The CLI was previously called "headless mode"; the
flag is unchanged.
Bare Mode for CI and Scripts
Add
for any scripted or CI invocation. It skips auto-discovery of hooks, skills, plugins, MCP servers, auto memory, and CLAUDE.md so the call returns the same result on every machine. Bare mode also skips the OAuth keychain, so it requires
,
, or an
passed through
.
bash
ANTHROPIC_API_KEY=$KEY claude --bare -p "Summarize the diff" --allowedTools "Read"
For pipelines that need a long-lived OAuth token instead of an API key, generate one with
and export it as
(note: bare mode does NOT read
— use
or
when
is set).
Running a Task
Read references/recipes.md for concrete command recipes before changing permission modes, resuming a session, restricting tools, or adding extra directories.
Permission Mode Selection
Six modes are supported. Pick the loosest mode the task safely allows.
| Flag | When to use |
|---|
--permission-mode default
| General Claude Code usage with normal approval prompts |
| Read-only analysis or planning with no file changes or shell execution |
--permission-mode acceptEdits
| The user explicitly wants Claude Code to write files (also auto-approves common filesystem commands like , , ) |
| Long autonomous tasks where prompt fatigue matters; a server-side classifier blocks risky actions but does not replace review |
--permission-mode dontAsk
| Locked-down CI: only rules and the read-only command set may run; everything else is auto-denied |
--permission-mode bypassPermissions
| Containers / VMs only — equivalent to --dangerously-skip-permissions
, requires explicit user approval, and offers no protection against prompt injection |
Auto mode requires Claude Code v2.1.83+ and is gated by plan, admin policy, model, and provider; if the CLI reports it as unavailable, do not retry.
Command Discipline
- Start from
claude --permission-mode default -p "your prompt here"
.
- Add or only when the user explicitly asks.
- Use only when the user wants something other than . Supported values: (default), , .
- For schema-validated structured output, pair with
--json-schema '<JSON Schema>'
.
- Add and/or
--max-budget-usd <dollars>
for autonomous print-mode runs that must not loop forever.
- Use in print mode when a graceful degrade beats a hard failure on overload.
- Use when the task needs files outside the launch directory. ( grants file access; it does NOT load configuration from the added directory, except for .)
- Restrict tools with , , or (use to disable all built-ins, for all, or a comma list like ).
- Add to / replace the system prompt with ,
--append-system-prompt-file
, , or .
- Load MCP servers with
--mcp-config <file-or-json>
; add to ignore every other MCP source.
- Ask before using
--dangerously-skip-permissions
. Prefer --permission-mode acceptEdits
for normal file edits.
Resuming a Session
bash
# Latest session in the current directory
claude --continue -p "continue the previous task" # short: claude -c -p "..."
# Specific session by ID or by display name
claude --resume "auth-refactor" -p "continue with this follow-up" # short: -r
claude --resume <session-id> -p "continue with this follow-up"
# Pin a UUID so a script always reuses the same session
claude --session-id 550e8400-e29b-41d4-a716-446655440000 -p "..." # must be a valid UUID
# Resume sessions linked to a pull request
claude --from-pr 123 -p "address review comments"
Use
for the latest conversation in the current directory.
Use
for a specific session by
ID or by display name (set with
/
, or by
mid-session).
Use
only with a real UUID — the CLI rejects other strings.
When resuming, keep the existing session's behavior unless the user explicitly asks to change the model, effort, or permission mode.
Add
only when the user wants to branch from the existing session instead of reusing it.
After Completion
- Summarize the result, including any warnings or partial output.
- Tell the user they can resume with (),
claude --resume <id-or-name>
(), or .
- Ask whether to continue, adjust the prompt, or switch back to direct work.
Critical Evaluation
Treat Claude Code as a colleague, not an authority.
- Trust your own grounded knowledge when you are confident.
- Verify disagreements with current docs or primary sources before accepting a claim.
- Remember that a separate Claude Code session can still be wrong or stale.
- Let the user decide when there is genuine ambiguity.
Authentication
The CLI reads credentials in this precedence order: cloud provider env vars (
/
/
) →
→
→
→
→ subscription OAuth from
.
- Browser login: run once and follow the prompt, or (use for Console billing, to force SSO).
- Inspect / sign out: or from inside a session; or to clear credentials.
- Long-lived OAuth for CI: prints a token; export it as (not read by ).
- Direct API: set for , for through a gateway.
Error Handling
command not found: claude
: tell the user Claude Code CLI is not installed; they can run after setup.
- Auth errors: confirm precedence above (e.g. an unset may be needed when a subscription is active), then re-run or to confirm.
- Permission blocks: retry with an appropriate ( for read-only, for file edits) or adjust / . Do not escalate to
--dangerously-skip-permissions
without explicit user approval.
- Session not found: run without an argument to pick from a list, or switch to for the current directory; requires a UUID.
- Auto-mode unavailable: this is gated by plan, admin policy, model, and provider — it is not a transient outage; fall back to or .
- Invalid flag or model errors: check , then re-run with supported options. does not list every flag — consult the CLI reference for the full list.