Skip to main content
ClaudeWave
Skill355 repo starsupdated today

claude-code-headless

Claude Code Headless Mode enables programmatic execution of Claude Code through CLI and scripts without interactive UI, supporting structured output formats (JSON, stream-JSON) and permission management for automation workflows. Use this skill for CI/CD pipelines, server-side scripting, batch processing, and integration with external tools requiring machine-readable responses and automated permission handling.

Install in Claude Code
Copy
git clone --depth 1 https://github.com/aiskillstore/marketplace /tmp/claude-code-headless && cp -r /tmp/claude-code-headless/skills/0xdarkmatter/claude-code-headless ~/.claude/skills/claude-code-headless
Then start a new Claude Code session; the skill loads automatically.

SKILL.md

# Claude Code Headless Mode

Run Claude Code from scripts without interactive UI.

## Quick Start

```bash
# Basic headless execution
claude -p "Explain this code" --allowedTools "Read,Grep"

# JSON output for parsing
claude -p "List files" --output-format json

# Continue conversation
claude -p "Start analysis" --output-format json > result.json
session=$(jq -r '.session_id' result.json)
claude --resume "$session" "Now fix the issues"
```

## Essential CLI Options

| Flag | Description |
|------|-------------|
| `-p`, `--print` | Non-interactive (headless) mode |
| `--output-format` | text, json, stream-json |
| `-r`, `--resume` | Resume by session ID |
| `-c`, `--continue` | Continue most recent session |
| `--allowedTools` | Comma-separated allowed tools |
| `--disallowedTools` | Comma-separated denied tools |
| `--mcp-config` | Path to MCP server config JSON |
| `--verbose` | Enable verbose logging |
| `--append-system-prompt` | Add to system prompt |

## Permission Modes

| Mode | Flag | Effect |
|------|------|--------|
| Default | (none) | Prompt for permissions |
| Accept edits | `--permission-mode acceptEdits` | Auto-accept file changes |
| Bypass | `--permission-mode bypassPermissions` | Skip all prompts |

## Output Formats

### Text (default)
```bash
claude -p "Hello"
# Outputs: Human-readable response
```

### JSON
```bash
claude -p "Hello" --output-format json
```
```json
{
  "type": "result",
  "subtype": "success",
  "result": "Hello! How can I help?",
  "session_id": "abc123",
  "total_cost_usd": 0.001,
  "duration_ms": 1234,
  "num_turns": 1
}
```

### Stream-JSON
```bash
claude -p "Hello" --output-format stream-json
# Real-time JSONL output for each message
```

## Common Patterns

### Script with tool restrictions
```bash
claude -p "Analyze the codebase" \
  --allowedTools "Read,Grep,Glob" \
  --disallowedTools "Write,Edit,Bash"
```

### CI/CD integration
```bash
claude -p "Review this PR diff" \
  --permission-mode acceptEdits \
  --output-format json \
  --append-system-prompt "Focus on security issues"
```

### Multi-turn automation
```bash
session=$(claude -p "Start task" --output-format json | jq -r '.session_id')
claude --resume "$session" "Continue with step 2"
claude --resume "$session" "Finalize and report"
```

## Error Handling

```bash
result=$(claude -p "Task" --output-format json)
if [[ $(echo "$result" | jq -r '.is_error') == "true" ]]; then
    echo "Error: $(echo "$result" | jq -r '.result')" >&2
    exit 1
fi
```

## Official Documentation

- https://code.claude.com/docs/en/headless - Headless mode reference
- https://code.claude.com/docs/en/settings - Settings and permissions

## Additional Resources

- `./references/cli-options.md` - Complete CLI flag reference
- `./references/output-formats.md` - Output format schemas
- `./references/integration-patterns.md` - CI/CD and scripting examples

---

**See Also:** `claude-code-hooks` for automation events, `claude-code-debug` for troubleshooting
jira-safeSkill

Implement SAFe methodology in Jira. Use when creating Epics, Features, Stories with proper hierarchy, acceptance criteria, and parent-child linking.

jira-workflowSkill

Orchestrate Jira workflows end-to-end. Use when building stories with approvals, transitioning items through lifecycle states, or syncing task completion with Jira.

chinese-learning-assistantSkill

HSK4級レベルから流暢さを目指す学習者向け。中国語表現の使用場面・自然さを分析し、作文を「ネイティブらしい流暢な表現」に改善。bilibili等のコンテンツ理解とネイティブとの会話をサポート。実際の用例をWeb検索で提示

frontend-dev-guidelinesSkill

Next.js 15 애플리케이션을 위한 프론트엔드 개발 가이드라인. React 19, TypeScript, Shadcn/ui, Tailwind CSS를 사용한 모던 패턴. Server Components, Client Components, App Router, 파일 구조, Shadcn/ui 컴포넌트, 성능 최적화, TypeScript 모범 사례 포함. 컴포넌트, 페이지, 기능 생성, 데이터 페칭, 스타일링, 라우팅, 프론트엔드 코드 작업 시 사용.

skill-developerSkill

Claude Code 스킬, 훅, 에이전트, 명령어를 생성하고 관리하기 위한 메타 스킬. 새 스킬 생성, 스킬 트리거 설정, 훅 설정, Claude Code 인프라 관리 시 사용.

sitemapkitSkill

Discover and extract sitemaps from any website using SitemapKit. Use this skill whenever the user wants to find pages on a website, get a list of URLs from a domain, audit a site's structure, crawl a sitemap, check what pages exist on a site, or do anything involving sitemaps or site URL discovery — even if they don't explicitly say "sitemap". Requires the sitemapkit MCP server configured with a valid SITEMAPKIT_API_KEY.

create-prSkill

GitHubのプルリクエスト(PR)を作成する際に使用します。変更のコミット、プッシュ、PR作成を含む完全なワークフローを日本語で実行します。「PRを作って」「プルリクエストを作成」「pull requestを作成」などのリクエストで自動的に起動します。

create-svg-from-promptSkill

Generate an SVG of a user-requested image or scene