Source profileQuality 93/100Review permissions

sunholo-data/ailang/.agents/skills/headless-runner/SKILL.md

headless-runner

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.

Source repository stars
33
Declared platforms
1
Static risk flags
1
Last source update
2026-08-25
Source checked
2026-08-25

Decision brief

What it does: where it fits

Run Codex programmatically from scripts, CI/CD pipelines, and autonomous agent workflows. Headless mode automatically loads all project configuration (.Codex/ directory), giving you full access to skills, agents, hooks, and commands.

Best for

  • "How do I run Codex headless?"
  • "Can I automate Codex workflows?"
  • "How to use Codex in CI/CD?"

Not for

  • Tasks that require unconfirmed production actions or broad system permissions.
  • Environments where the pinned source and install steps cannot be inspected.

Compatibility matrix

Platform support, with evidence labels

PlatformStatusEvidenceWhat to check
CodexDeclaredSource recordInstall path and trigger
Claude CodeNot declaredNo explicit evidencePortability before use
CursorNot declaredNo explicit evidencePortability before use
Gemini CLINot declaredNo explicit evidencePortability before use
Open the compatibility checker

Installation

Inspect first. Install second.

The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.

Source-detected install commandSource
npx skills add https://github.com/sunholo-data/ailang --skill ".agents/skills/headless-runner"
Safe inspection promptEditorial

Inspect the Agent Skill "headless-runner" from https://github.com/sunholo-data/ailang/blob/9944e264e3b9043881978731dccd258f561082a3/.agents/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

What the source asks the agent to do

  1. 01

    Quick Start

    Review the “Quick Start” section in the pinned source before continuing.

    Review and apply the “Quick Start” source section.
  2. 02

    Workflow Patterns

    Use for: Simple, one-off tasks

    Use for: Simple, one-off tasksUse for: Multi-step workflows where each step depends on previousbash !/bin/bash set -euo pipefail
  3. 03

    Step 1

    Codex -p "Step 1" --output-format json step1.json ARTIFACT1=$(jq -r '.artifact' step1.json)

    Codex -p "Step 1" --output-format json step1.json ARTIFACT1=$(jq -r '.artifact' step1.json)
  4. 04

    Step 2 (uses Step 1 output)

    Codex -p "Step 2 using $ARTIFACT1" --output-format json step2.json ARTIFACT2=$(jq -r '.artifact' step2.json)

    Codex -p "Step 2 using $ARTIFACT1" --output-format json step2.json ARTIFACT2=$(jq -r '.artifact' step2.json)
  5. 05

    Step 3

    Codex -p "Step 3 using $ARTIFACT2" bash !/bin/bash

    Codex -p "Step 3 using $ARTIFACT2" bash !/bin/bash

Permission review

Static risk signals and limitations

Runs scripts

medium · line 192

The documentation asks the agent to run terminal commands or scripts.

Run headless command with automatic retry on failure.

Evidence record

Why each signal appears

EvidenceSourceComputedTestedEditorial
SignalValueEvidence typeMeaning
Quality score93/100ComputedDocumentation, specificity, maintenance, and trust rules
Repository stars33SourceRepository attention, not individual Skill quality
Compatibility1 platformsSourceDeclared in the catalog source record
Usage guideautomated source guideEditorialGenerated or reviewed according to the visible evidence level

Pinned source

Provenance and original SKILL.md

Repository
sunholo-data/ailang
Skill path
.agents/skills/headless-runner/SKILL.md
Commit
9944e264e3b9043881978731dccd258f561082a3
License
Apache-2.0
Collected
2026-08-25
Default branch
dev
View the original SKILL.md

Headless Runner

Run Codex programmatically from scripts, CI/CD pipelines, and autonomous agent workflows. Headless mode automatically loads all project configuration (.Codex/ directory), giving you full access to skills, agents, hooks, and commands.

Quick Start

Most common usage:

# Basic headless invocation (from project directory)
Codex -p "Your prompt here"

# With JSON output for programmatic parsing
Codex -p "Run eval baseline for v0.3.14" --output-format json

# Control tool access
Codex -p "Analyze failures" --allowedTools "Bash,Read,Grep"

# Multi-turn conversation
Codex -p "Start task" --output-format json > result.json
SESSION_ID=$(jq -r '.session_id' result.json)
Codex --resume $SESSION_ID "Continue with next step"

What gets loaded automatically:

  • .Codex/settings.json and .Codex/settings.local.json
  • .Codex/agents/ (all project agents)
  • .Codex/skills/ (all project skills)
  • ✅ Hooks configured in settings
  • ✅ Slash commands from .Codex/commands/
  • ✅ AGENTS.md project instructions

When to Use This Skill

Invoke this skill when user asks about:

  • "How do I run Codex headless?"
  • "Can I automate Codex workflows?"
  • "How to use Codex in CI/CD?"
  • "Programmatic Codex execution"
  • "Script Codex commands"
  • "Agent-to-agent communication"
  • "Automated eval runs"
  • "Scheduled Codex tasks"

Core Commands

Basic Invocation

# Text output (default)
Codex -p "Prompt here"

# JSON output with metadata
Codex -p "Prompt here" --output-format json
# Returns: {session_id, result, cost, duration, ...}

# Streaming JSON (for long-running tasks)
Codex -p "Prompt here" --output-format stream-json

Tool Permissions

# Allow specific tools
Codex -p "Task" --allowedTools "Bash,Read,Write"

# Allow all tools (use with caution)
Codex -p "Task" --allowedTools "*"

# Permission mode for edits
Codex -p "Task" --permission-mode acceptEdits

Multi-Turn Conversations

# Resume specific session
Codex --resume SESSION_ID "Continue task"

# Continue most recent session
Codex --continue "Next instruction"

# Extract session ID from JSON output
SESSION_ID=$(Codex -p "Start" --output-format json | jq -r '.session_id')
Codex --resume $SESSION_ID "Continue"

Common Use Cases

1. CI/CD Integration

# .github/workflows/eval-baseline.yml
- name: Run eval baseline
  run: |
    Codex -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
Codex -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
Codex -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
Codex -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
Codex -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
Codex -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:

.Codex/skills/headless-runner/scripts/test_headless.sh

What it tests:

  • Codex command is available
  • ✓ Project configuration loads (.Codex/ 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:

.Codex/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 (permanent failure), 2 (retries exhausted)

Workflow Patterns

Pattern 1: Single Command

Use for: Simple, one-off tasks

Codex -p "Generate changelog from git log since v0.3.13"

Pattern 2: Sequential Pipeline

Use for: Multi-step workflows where each step depends on previous

#!/bin/bash
set -euo pipefail

# Step 1
Codex -p "Step 1" --output-format json > step1.json
ARTIFACT1=$(jq -r '.artifact' step1.json)

# Step 2 (uses Step 1 output)
Codex -p "Step 2 using $ARTIFACT1" --output-format json > step2.json
ARTIFACT2=$(jq -r '.artifact' step2.json)

# Step 3
Codex -p "Step 3 using $ARTIFACT2"

Pattern 3: Conversation Session

Use for: Multi-turn tasks that need context

#!/bin/bash

# Start conversation
RESULT=$(Codex -p "Analyze codebase for tech debt" --output-format json)
SESSION_ID=$(echo "$RESULT" | jq -r '.session_id')

# Continue conversation with context
Codex --resume $SESSION_ID "Focus on files over 800 lines"
Codex --resume $SESSION_ID "Generate refactoring plan"
Codex --resume $SESSION_ID "Estimate effort for top 3 items"

Pattern 4: Parallel Execution

Use for: Independent tasks that can run concurrently

#!/bin/bash

# Start multiple tasks in parallel
Codex -p "Task A" --output-format json > taskA.json &
PID_A=$!

Codex -p "Task B" --output-format json > taskB.json &
PID_B=$!

Codex -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

Quick Tips

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 progress

Configuration:

  • Runs from project directory → auto-loads .Codex/ config
  • No special flags needed for skills/agents/commands

Error handling:

  • Always check exit codes: if ! Codex -p "..." ; then ...
  • Validate JSON: echo "$RESULT" | jq -e '.status == "success"'
  • Use retry with backoff (see run_with_retry.sh script)

Tool permissions:

  • Analysis: --allowedTools "Read,Grep,Glob"
  • Testing: --allowedTools "Bash,Read"
  • Development: --allowedTools "Bash,Read,Write,Edit"

For complete details, see CLI Reference and Troubleshooting.

AILANG Agent Integration

Build autonomous agents using headless Codex + AILANG messaging:

For complete autonomous agent patterns (task claiming, handoffs, error handling), see:

Quick 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 Codex
RESULT=$(Codex -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

Resources

Agent Workflows (NEW!)

See resources/agent_workflows.md for autonomous agent patterns with AILANG messaging system.

CLI Reference

See resources/cli_reference.md for complete CLI flag documentation.

Examples

See resources/examples.md for comprehensive workflow examples.

Troubleshooting

See resources/troubleshooting.md for common issues and solutions.

Progressive Disclosure

This skill loads information progressively:

  1. Always loaded: This SKILL.md file (YAML frontmatter + core workflows)
  2. Execute as needed: Scripts in scripts/ directory
  3. Load on demand: resources/ (detailed CLI reference, examples, troubleshooting)

Notes

  • Requires: Codex CLI installed and in PATH
  • Context window: Be mindful of token limits for large prompts
  • Costs: Track with --output-format json.cost field
  • Concurrency: Multiple headless sessions can run in parallel
  • State: Each invocation is stateless unless using --resume

Frequently asked questions

What to verify before installation and use

What does the headless-runner source document cover?

Run Codex programmatically from scripts, CI/CD pipelines, and autonomous agent workflows. Headless mode automatically loads all project configuration (.Codex/ directory), giving you full access to skills, agents, hooks, and commands.

How do I install headless-runner?

The source record exposes this install command: npx skills add https://github.com/sunholo-data/ailang --skill ".agents/skills/headless-runner". Inspect the command and pinned source before running it.

Which Agent platforms does the source record declare?

The pinned source record declares support for: codex.

Which permission-related actions were detected?

Static rules flagged exec-script in the source; the page lists the matching lines and excerpts.

Alternatives

Compare before choosing