headless-cli-agents
Build agentic systems using Claude CLI in headless mode or the Claude Agent SDK. Use when building automation pipelines, CI/CD integrations, multi-agent orchestration, or programmatic Claude interactions. Covers CLI flags (-p, --output-format), session management (--resume, --continue), Python SDK (claude-agent-sdk), custom tools, and agent loop patterns.
npx skills add majiayu000/claude-skill-registry --skill headless-cli-agents-cuba6112-skillfactory --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# Headless CLI Agents Build agentic systems using Claude Code CLI or the Claude Agent SDK. ## CLI Headless Mode Use `-p` flag for non-interactive execution: ```bash # Basic query claude -p "Explain this code" # With JSON output for parsing claude -p "Create a REST API" --output-format json # Streaming JSON for real-time output claude -p "Build a CLI app" --output-format stream-json # Restrict tools claude -p "Stage changes" --allowedTools "Bash,Read" --permission-mode acceptEdits ``` ### Output Formats | Format | Flag | Use Case | |--------|------|----------| | Text | (default) | Simple scripts | | JSON | `--output-format json` | Programmatic parsing | | Stream JSON | `--output-format stream-json` | Real-time streaming | JSON response includes: `session_id`, `total_cost_usd`, `duration_ms`, `num_turns`, `result`. ### Multi-Turn Sessions ```bash # Get session ID session_id=$(claude -p "Start review" --output-format json | jq -r '.session_id') # Continue conversation claude -p --resume "$session_id" "Now implement the plan" # Or continue most recent claude --continue "Add tests" ``` ### Key Flags | Flag | Purpose | |------|---------| | `-p, --print` | Non-interactive mode | | `--outp
- CLI Headless Mode
- Output Formats
- Multi-Turn Sessions
- Key Flags
- Python Agent SDK
- Basic Usage
- Custom Tools (In-Process MCP)
- ClaudeSDKClient Options
- Agent Loop Pattern
- Subagents
- Best Practices
- Integration Examples
- CI/CD Pipeline
- Multi-Step Workflow
Basic query claude -p "Explain this code" With JSON output for parsing claude -p "Create a REST API" --output-format json Streaming JSON for real-time output claude -p "Build a CLI app" --output-format stream-json Restrict tools claude -p "Stage changes" --allowedTools "Bash,Read" --permission-mode acceptEdits Get session ID Continue conversation
What does the headless-cli-agents skill do?
Build agentic systems using Claude CLI in headless mode or the Claude Agent SDK. Use when building automation pipelines, CI/CD integrations, multi-agent orchestration, or programmatic Claude interactions. Covers CLI flags (-p, --output-format), session management (--resume, --continue), Python SDK (claude-agent-sdk), custom tools, and agent loop patterns.
How do I install it?
Run `npx skills add majiayu000/claude-skill-registry --skill headless-cli-agents-cuba6112-skillfactory --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From majiayu000/claude-skill-registry, a repository with 534 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
