Run popular AI code agents (Claude Code, Codex, Gemini CLI) in headless or non-interactive mode for automation, scripting, and programmatic execution...
This skill provides instructions for running popular AI code agents in headless (non-interactive) mode, enabling automation, scripting, and programmatic execution without user interaction.
As an expert in your assigned roles, you must announce your actions before performing them using the following format:
As a {Role} [and {Role}, ...], I will {action description}
This communication pattern ensures transparency and allows for human-in-the-loop oversight at key decision points.
Follow these steps to run an AI code agent in headless mode:
Determine which AI code agent to run in headless mode. Route to the appropriate reference file:
references/claude-code.mdreferences/codex.mdreferences/gemini-cli.md<agent-name> --help to discover available flags for non-interactive/headless mode. Look for flags like --print, --non-interactive, --batch, --yes, --auto-approve, or similarAs a DevOps Engineer, verify the agent is installed:
# Claude Code
claude --version
# Codex
codex --version
# Gemini CLI
gemini --version
If not installed, use the dev-swarm-install-ai-code-agent skill.
Each agent supports different headless modes:
| Agent | Mode | Use Case |
|---|---|---|
| Claude Code | --print |
Print output and exit (piping) |
| Codex | exec |
Non-interactive execution |
| Gemini CLI | Positional prompt | One-shot execution |
Important: Headless mode typically requires bypassing permission prompts.
| Agent | Permission Flag | Security Note |
|---|---|---|
| Claude Code | --dangerously-skip-permissions |
Bypasses all prompts |
| Codex | --ask-for-approval never |
Auto-approve all actions |
| Gemini CLI | --yolo |
Auto-accept all actions |
Security Warning: Only use these flags in trusted, sandboxed environments.
Refer to the agent-specific reference file for detailed command syntax and examples.
Quick Reference (Minimal Commands):
# Claude Code (headless)
claude --print --dangerously-skip-permissions "your prompt here"
# Codex (headless)
codex --ask-for-approval never --sandbox workspace-write exec "your prompt here"
# Gemini CLI (headless)
gemini --yolo --sandbox "your prompt here"
Configure output format based on your needs:
See agent-specific reference files for output format options.
Issue: Agent hangs waiting for input
Issue: Command not found
Issue: Permission denied errors
Issue: Output parsing fails
--output-format json) for reliable parsing