Agent skill · AI & Agents

claude-code-automation

Run Claude Code programmatically in headless mode or via bidirectional stream-json protocol. Use when building agents, automating Claude, running headless Claude, implementing multi-turn conversations, or integrating Claude CLI into applications.

majiayu000github.com/majiayu000GitHub ↗
claude-codeMIT
Install
npx skills add majiayu000/claude-skill-registry --skill claude-code-automation --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 2
SKILL.md size: 5 KB
Bundled scripts: none
Path: skills/agent/claude-code-automation/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 534
Language: HTML

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

From the SKILL.md

# Claude Code Automation This skill covers running Claude Code programmatically - either one-shot with `--print` or multi-turn with the bidirectional stream-json protocol. ## Quick Reference | Mode | Use Case | Key Flags | |------|----------|-----------| | Headless (`--print`) | One-shot tasks, background agents | `--print --verbose --output-format stream-json` | | Bidirectional | Multi-turn conversations, persistent sessions | `--input-format stream-json --output-format stream-json --verbose` | ## Headless Mode (`--print`) For one-shot execution without interactive prompts. ### Essential Flags ```bash claude --print \ --verbose \ # REQUIRED with stream-json --output-format stream-json \ --model sonnet \ --permission-mode bypassPermissions \ # Enable file writes --append-system-prompt "context here" # Inject dynamic context ``` ### Critical Gotchas 1. **`--verbose` is required** with `stream-json` output - without it, Claude exits silently with status 1 2. **File writes silently fail** without `--permission-mode bypassPermissions` 3. **Session hooks don't run** in `--print` mode - no SessionStart/SessionEnd 4. **`--append-system-prompt` is ephemeral** - NOT re-applied on `--resume`

What's inside
Steps it walks through
  1. Quick Reference
  2. Headless Mode (--print)
  3. Essential Flags
  4. Critical Gotchas
  5. Rust Implementation
  6. Bidirectional Protocol
  7. Starting a Session
  8. Message Types
  9. Critical Gotcha: controlresponse
  10. Rust Session Pattern
  11. Reading JSONL Transcripts
  12. When to Use Which
Ships with 1 file
  • metadata.json
Commands it runs
claude --print \
claude --input-format stream-json --output-format stream-json --verbose
Extract specific fields with jq
jq -r 'select(.type == "user") | .message.content' file.jsonl | head -20
Python for complex extraction
python3 -c "
import json
for line in open('file.jsonl'):
obj = json.loads(line)
if obj.get('type') == 'user':
More from claude-skill-registry
All skills →
About this skill
What does the claude-code-automation skill do?

Run Claude Code programmatically in headless mode or via bidirectional stream-json protocol. Use when building agents, automating Claude, running headless Claude, implementing multi-turn conversations, or integrating Claude CLI into applications.

How do I install it?

Run `npx skills add majiayu000/claude-skill-registry --skill claude-code-automation --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.

Keep going