headless-mode
Guide for using Claude Code programmatically via CLI flags and SDKs. Use for automation, CI/CD pipelines, scripting, and building tools on top of Claude Code. Covers --print mode, output formats, session management, and SDK integration.
npx skills add majiayu000/claude-skill-registry --skill headless-mode-hgeldenhuys-claude-code-sdk --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 Mode Run Claude Code programmatically for automation, CI/CD, and scripting. ## Quick Reference | Mode | Command | Use Case | |------|---------|----------| | CLI (simple) | `claude -p "prompt"` | One-shot tasks, scripts | | CLI (structured) | `claude -p "prompt" --output-format json` | Parsing responses | | TypeScript SDK | `@anthropic-ai/claude-code` | Full programmatic control | | Python SDK | `claude-code-sdk` | Python automation | ## Core Concept The `-p` (or `--print`) flag runs Claude Code non-interactively. All CLI options work with `-p`, enabling automated workflows without human interaction. ```bash claude -p "Explain what this project does" ``` ## Essential Flags | Flag | Purpose | Example | |------|---------|---------| | `-p`, `--print` | Run non-interactively | `claude -p "query"` | | `--output-format` | Response format | `json`, `stream-json`, `text` | | `--allowedTools` | Auto-approve tools | `"Bash,Read,Edit"` | | `--max-turns` | Limit agent turns | `--max-turns 5` | | `--continue` | Continue last session | `claude -p "..." --continue` | | `--resume` | Resume specific session | `--resume $SESSION_ID` | ## Output Formats ### Text (Default) Plain text output
- Quick Reference
- Core Concept
- Essential Flags
- Output Formats
- Text (Default)
- JSON (Structured)
- Stream JSON (Real-time)
- Tool Auto-Approval
- Basic Approval
- Granular Bash Commands
- Skip All Permissions (Dangerous)
- Session Management
- Continue Last Session
- Resume Specific Session
claude -p "Explain what this project does" claude -p "Summarize auth.py" claude -p "Analyze this code" --output-format json claude -p "Generate report" --output-format stream-json claude -p "Fix the failing tests" --allowedTools "Bash,Read,Edit" claude -p "Create a commit for staged changes" \ claude -p "Deploy to staging" --dangerously-skip-permissions claude -p "Review this codebase" claude -p "Focus on the database layer" --continue claude -p "Summarize findings" --continue
What does the headless-mode skill do?
Guide for using Claude Code programmatically via CLI flags and SDKs. Use for automation, CI/CD pipelines, scripting, and building tools on top of Claude Code. Covers --print mode, output formats, session management, and SDK integration.
How do I install it?
Run `npx skills add majiayu000/claude-skill-registry --skill headless-mode-hgeldenhuys-claude-code-sdk --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.
