Headless Runner
БесплатноБез исполняемых скриптовНе проверенRun Claude Code in headless/programmatic mode for automation, CI/CD, and agent workflows. Use when user asks about headless mode, programmatic execution…
от majiayu000★ 31 звезда на GitHubОб этом скилле
Headless Runner
Run Claude Code programmatically from scripts, CI/CD pipelines, and autonomous agent workflows. Headless mode automatically loads all project configuration (.claude/ directory), giving you full access to skills, agents, hooks, and commands.
Quick Start
Most common usage:
# Basic headless invocation (from project directory)
claude -p "Your prompt here"
# With JSON output for programmatic parsing
claude -p "Run eval baseline for v0.3.14" --output-format json
# Control tool access
claude -p "Analyze failures" --allowedTools "Bash,Read,Grep"
# Multi-turn conversation
claude -p "Start task" --output-format json > result.json
SESSION_ID=$(jq -r '.session_id' result.json)
claude --resume $SESSION_ID "Continue with next step"
What gets loaded automatically:
- ✅
.claude/settings.jsonand.claude/settings.local.json - ✅
.claude/agents/(all project agents) - ✅
.claude/skills/(all project skills) - ✅ Hooks configured in settings
- ✅ Slash commands from
.claude/commands/ - ✅ CLAUDE.md project instructions
When to Use This Skill
Invoke this skill when user asks about:
- "How do I run Claude headless?"
- "Can I automate Claude workflows?"
- "How to use Claude in CI/CD?"
- "Programmatic Claude execution"
- "Script Claude commands"
- "Agent-to-agent communication"
- "Automated eval runs"
- "Scheduled Claude tasks"
Core Commands
Basic Invocation
# Text output (default)
claude -p "Prompt here"
# JSON output with metadata
claude -p "Prompt here" --output-format json
# Returns: {session_id, result, cost, duration, ...}
# Streaming JSON (for long-running tasks)
claude -p "Prompt here" --output-format stream-json
Tool Permissions
# Allow specific tools
claude -p "Task" --allowedTools "Bash,Read,Write"
# Allow all tools (use with caution)
claude -p "Task" --allowedTools "*"
# Permission mode for edits
claude -p "Task" --permission-mode acceptEdits
Multi-Turn Conversations
# Resume specific session
claude --resume SESSION_ID "Continue task"
# Continue most recent session
claude --continue "Next instruction"
# Extract session ID from JSON output
SESSION_ID=$(claude -p "Start" --output-format json | jq -r '.session_id')
claude --resume $SESSION_ID "Continue"
Common Use Cases
1. CI/CD Integration
# .github/workflows/eval-baseline.yml
- name: Run eval baseline
run: |
claude -p "Use eval-orchestrator agent to run baseline for ${{ github.ref_name }}" \
--output-format json \
--allowedTools "Bash,Read,Write" \
> eval_result.json
- name: Check for failures
run: |
FAILURES=$(jq -r '.failures' eval_result.json)
if [ "$FAILURES" -gt 0 ]; then
echo "::error::Eval baseline has $FAILURES failures"
exit 1
fi
2. Scheduled Analysis
#!/bin/bash
# cron_daily_check.sh - Run via cron daily
cd /path/to/project
# Check agent inbox
claude -p "Use agent-inbox skill to check for unread messages" \
--output-format json > inbox.json
# If messages exist, notify
UNREAD=$(jq -r '.unreadCount' inbox.json)
if [ "$UNREAD" -gt 0 ]; then
echo "Found $UNREAD unread agent messages"
# Send notification, create issue, etc.
fi
3. Agent-to-Agent Workflows
#!/bin/bash
# autonomous_sprint_cycle.sh
# Agent A: Create design doc
claude -p "Use design-doc-creator to document feature X" \
--output-format json > design.json
DESIGN_DOC=$(jq -r '.artifactPath' design.json)
# Agent B: Plan sprint from design
claude -p "Use sprint-planner to create plan from $DESIGN_DOC" \
--output-format json > plan.json
PLAN_FILE=$(jq -r '.planPath' plan.json)
# Agent C: Execute sprint
claude -p "Use sprint-executor to execute $PLAN_FILE" \
--output-format json > execution.json
4. Automated Testing
#!/bin/bash
# test_agent_quality.sh
# Run eval with specific model
claude -p "Use eval-orchestrator: run suite with gpt5-mini only" \
--output-format json > results.json
# Parse results
SUCCESS_RATE=$(jq -r '.successRate' results.json)
# Assert quality threshold
if (( $(echo "$SUCCESS_RATE < 0.75" | bc -l) )); then
echo "Agent quality below threshold: $SUCCESS_RATE"
exit 1
fi
Available Scripts
scripts/test_headless.sh
Test headless mode works correctly with project configuration.
Usage:
.claude/skills/headless-runner/scripts/test_headless.sh
What it tests:
- ✓
claudecommand is available - ✓ Project configuration loads (.claude/ directory)
- ✓ Skills are accessible
- ✓ Agents are accessible
- ✓ JSON output parses correctly
- ✓ Multi-turn sessions work
scripts/run_with_retry.sh <prompt> [max_retries]
Run headless command with automatic retry on failure.
Usage:
.claude/skills/headless-runner/scripts/run_with_retry.sh "Run eval baseline" 3
Features:
- Retries on transient failures
- Exponential backoff
- JSON output preserved
- Exit codes: 0 (success), 1 (permanen
Установить Headless Runner в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл Headless Runner?
Run Claude Code in headless/programmatic mode for automation, CI/CD, and agent workflows. Use when user asks about headless mode, programmatic execution, scripting Claude, or automating Claude workflows.
Как установить скилл Headless Runner?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл Headless Runner запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic