Best for
- "How do I run Claude headless?"
- "Can I automate Claude workflows?"
- "How to use Claude in CI/CD?"
sunholo-data/ailang/.claude/skills/headless-runner/SKILL.md
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.
Decision brief
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.
Compatibility matrix
| Platform | Status | Evidence | What to check |
|---|---|---|---|
| Codex | Not declared | No explicit evidence | Portability before use |
| Claude Code | Declared | Source record | Install path and trigger |
| Cursor | Not declared | No explicit evidence | Portability before use |
| Gemini CLI | Not declared | No explicit evidence | Portability before use |
Installation
The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.
npx skills add https://github.com/sunholo-data/ailang --skill ".claude/skills/headless-runner"Inspect the Agent Skill "headless-runner" from https://github.com/sunholo-data/ailang/blob/9944e264e3b9043881978731dccd258f561082a3/.claude/skills/headless-runner/SKILL.md at commit 9944e264e3b9043881978731dccd258f561082a3. List every install step, command, network request, credential, file read/write, external action, and rollback step. Explain whether it fits my task. Do not install or execute anything until I approve.
Workflow
Review the “Quick Start” section in the pinned source before continuing.
Use for: Simple, one-off tasks
claude -p "Step 1" --output-format json step1.json ARTIFACT1=$(jq -r '.artifact' step1.json)
claude -p "Step 2 using $ARTIFACT1" --output-format json step2.json ARTIFACT2=$(jq -r '.artifact' step2.json)
claude -p "Step 3 using $ARTIFACT2" bash !/bin/bash
Permission review
The documentation asks the agent to run terminal commands or scripts.
Run headless command with automatic retry on failure.Evidence record
| Signal | Value | Evidence type | Meaning |
|---|---|---|---|
| Quality score | 93/100 | Computed | Documentation, specificity, maintenance, and trust rules |
| Repository stars | 33 | Source | Repository attention, not individual Skill quality |
| Compatibility | 1 platforms | Source | Declared in the catalog source record |
| Usage guide | automated source guide | Editorial | Generated or reviewed according to the visible evidence level |
Pinned source
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.
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.json and .claude/settings.local.json.claude/agents/ (all project agents).claude/skills/ (all project skills).claude/commands/Invoke this skill when user asks about:
# 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
# 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
# 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"
# .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
#!/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
#!/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
#!/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
scripts/test_headless.shTest headless mode works correctly with project configuration.
Usage:
.claude/skills/headless-runner/scripts/test_headless.sh
What it tests:
claude command is availablescripts/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:
Use for: Simple, one-off tasks
claude -p "Generate changelog from git log since v0.3.13"
Use for: Multi-step workflows where each step depends on previous
#!/bin/bash
set -euo pipefail
# Step 1
claude -p "Step 1" --output-format json > step1.json
ARTIFACT1=$(jq -r '.artifact' step1.json)
# Step 2 (uses Step 1 output)
claude -p "Step 2 using $ARTIFACT1" --output-format json > step2.json
ARTIFACT2=$(jq -r '.artifact' step2.json)
# Step 3
claude -p "Step 3 using $ARTIFACT2"
Use for: Multi-turn tasks that need context
#!/bin/bash
# Start conversation
RESULT=$(claude -p "Analyze codebase for tech debt" --output-format json)
SESSION_ID=$(echo "$RESULT" | jq -r '.session_id')
# Continue conversation with context
claude --resume $SESSION_ID "Focus on files over 800 lines"
claude --resume $SESSION_ID "Generate refactoring plan"
claude --resume $SESSION_ID "Estimate effort for top 3 items"
Use for: Independent tasks that can run concurrently
#!/bin/bash
# Start multiple tasks in parallel
claude -p "Task A" --output-format json > taskA.json &
PID_A=$!
claude -p "Task B" --output-format json > taskB.json &
PID_B=$!
claude -p "Task C" --output-format json > taskC.json &
PID_C=$!
# Wait for all to complete
wait $PID_A $PID_B $PID_C
# Aggregate results
jq -s '{taskA: .[0], taskB: .[1], taskC: .[2]}' taskA.json taskB.json taskC.json
Output formats:
--output-format text (default) - Human-readable--output-format json - For automation (includes session_id, status, cost)--output-format stream-json - For real-time progressConfiguration:
.claude/ configError handling:
if ! claude -p "..." ; then ...echo "$RESULT" | jq -e '.status == "success"'run_with_retry.sh script)Tool permissions:
--allowedTools "Read,Grep,Glob"--allowedTools "Bash,Read"--allowedTools "Bash,Read,Write,Edit"For complete details, see CLI Reference and Troubleshooting.
Build autonomous agents using headless Claude + AILANG messaging:
For complete autonomous agent patterns (task claiming, handoffs, error handling), see:
resources/agent_workflows.md - Autonomous agent patterns with messagingQuick example:
# Agent checks inbox for tasks
MESSAGES=$(ailang agent inbox --unread-only my-agent)
MESSAGE_ID=$(echo "$MESSAGES" | grep "ID:" | head -1 | awk '{print $2}')
# Claim task
ailang agent ack $MESSAGE_ID
# Process with headless Claude
RESULT=$(claude -p "Process task from inbox" --output-format json)
# On success: keep ack, send result
if [ "$(echo "$RESULT" | jq -r '.status')" = "success" ]; then
ailang agent send --to-user --from "my-agent" '{"status": "complete"}'
else
# On failure: return to queue
ailang agent unack $MESSAGE_ID
fi
See resources/agent_workflows.md for autonomous agent patterns with AILANG messaging system.
See resources/cli_reference.md for complete CLI flag documentation.
See resources/examples.md for comprehensive workflow examples.
See resources/troubleshooting.md for common issues and solutions.
This skill loads information progressively:
scripts/ directoryresources/ (detailed CLI reference, examples, troubleshooting)--output-format json → .cost field--resumeFrequently asked questions
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.
The source record exposes this install command: npx skills add https://github.com/sunholo-data/ailang --skill ".claude/skills/headless-runner". Inspect the command and pinned source before running it.
The pinned source record declares support for: claude code.
Static rules flagged exec-script in the source; the page lists the matching lines and excerpts.
Alternatives
sunholo-data/ailang
Run Codex in headless/programmatic mode for automation, CI/CD, and agent workflows. Use when user asks about headless mode, programmatic execution, scripting Codex, or automating Codex workflows.
yonatangross/orchestkit
Grade work that already exists and decide whether it can merge. Runs the project's current unit, integration, and E2E suites plus security scanning and type checking, scores every dimension 0-10, and returns a merge verdict with a VERIFIED-vs-CLAIMED evidence manifest. Writes no test files and edits no source. Use when verifying changes are ready to merge. Use /ork:cover instead when the tests still have to be written.
PramodDutta/qaskills
Gate RAG pipelines in CI with versioned golden eval sets, per-metric thresholds, baseline drift detection, and a build that fails when retrieval or answer quality regresses.
brucesongs/kali-claw
CAN/CAN-FD bus analysis, UDS diagnostics, IVI pentest, OBD-II exploitation, key fob replay/relay attacks, GNSS spoofing, EV charging station (ISO 15118), and connected vehicle red team operations.