Overview
Composable scripts let you build complex AI workflows from simple, reusable pieces. Chain scripts together like Unix commands, use dispatchers to orchestrate tool access, and leverage process isolation for clean multi-step pipelines.The --cc Flag
--cc is shorthand for --tool cc, which explicitly selects Claude Code as the backend tool. Since Claude Code is currently the only supported tool, --cc has no effect on its own — but it becomes meaningful when combined with other flags.
--cc alone does NOT grant tool access. You need --skip or --bypass for that.
The Dispatcher Pattern
Use--cc --skip to give the AI full access to Claude Code’s tools (shell commands, file operations, browser automation) during script execution. This creates a dispatcher — a script that can take real actions:
Why --cc --skip?
--cc: Selects Claude Code as the tool (explicit, for future compatibility)--skip: Shorthand for--dangerously-skip-permissions(grants full tool access)--live: Streams progress narration in real-time
- Run shell commands (
npm test,git status, etc.) - Read and write files
- Browse the web with
--chrome - Use all Claude Code tools without permission prompts
Example: Test Runner Dispatcher
Tradeoff: Tool Output Visibility
When Claude Code runs shell commands, subprocess output is captured internally (not streamed to your terminal). You won’t see livenpm test output scrolling by.
Solution: Use --live and prompt the AI to narrate progress:
Chaining Scripts Together
Connect scripts in Unix pipelines. Each script runs independently with clean process isolation:Process Isolation
AI Runner clears inherited environment variables between nested calls so each script starts fresh:.md script runs in isolation:
- No inherited
ANTHROPIC_MODELorANTHROPIC_SMALL_FAST_MODEL - No carried-over provider configuration (
CLAUDE_CODE_USE_BEDROCK, etc.) - No leaked session IDs or internal state
Child Scripts Should Be Simple
Best practice: Only the top-level dispatcher should use--cc. Child scripts in pipelines should be simple prompt mode:
- Multiple agentic loops
- Unpredictable execution order
- Debugging nightmares
Example: Multi-Stage Pipeline
dispatcher.md (top-level orchestrator):Long-Running Scripts
Scripts that take more than 30 seconds (browser automation, multi-step analysis, CI/CD pipelines) should always use--live:
Why --live Matters
Without --live:
- No output until the entire script completes
- No indication of progress
- Looks frozen for minutes
--live:
- Heartbeat while waiting for first response
- Real-time narration of progress
- Immediate feedback on what’s happening
Streaming at Turn Granularity
--live streams between tool calls, not during them. The AI’s text responses appear immediately, but tool execution (shell commands, file writes) completes before streaming continues.
Prompt for narration:
--live something to stream.
Output Redirection with --live
When stdout is redirected, --live separates narration from content:
- Intermediate turns (narration) stream to stderr
- The final turn is split at the first content marker (
---frontmatter or#heading) - Preamble text goes to stderr
- Content from the marker onward goes to stdout (the file)
- A summary line appears on stderr when complete
Quiet Mode for CI/CD
Suppress all narration for clean stdout-only output:--quiet:
- No status messages
- No narration
- No “Done” summary
- Only the final content goes to stdout
Composable Patterns Reference
Simple Chain
Dispatcher + Workers
Parallel Execution
Conditional Execution
Loop Over Inputs
Provider Selection in Pipelines
Each script in a pipeline can use a different provider:Security Considerations
Dispatcher scripts with--skip or --bypass have full system access. Follow these guidelines:
- Audit before running: Review dispatcher scripts that run commands or write files
- Restrict child scripts: Keep children read-only (no
--skip) - Use
--allowedToolsfor granular control: - Never pipe untrusted sources with
--skip:
Related Documentation
- Scripting Guide — Permission modes, variables, shebang basics
- Live Output — Streaming behavior and output redirection
- Configuration — Provider-specific model configuration