Back to Examples
Run an Agent Headless in CI
Most terminal agents support a headless / print mode (-p) so you can run them non-interactively in CI for triage, fixes, or checks.
Workflow Patterns•Advanced•yaml
Example Code
# .github/workflows/agent-triage.yml
# Runs a coding agent non-interactively on new issues.
# Works the same way across Claude Code, Codex, and Grok Build —
# each exposes a headless "-p" / print mode for automation.
name: Agent triage
on:
issues:
types: [opened]
jobs:
triage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install agent
run: npm install -g @anthropic-ai/claude-code
# Grok Build: curl -fsSL https://x.ai/cli/install.sh | bash
# Codex CLI: npm install -g @openai/codex
- name: Run agent headless
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
# XAI_API_KEY for Grok Build, OPENAI_API_KEY for Codex
run: |
claude -p "Read AGENTS.md, then reproduce and root-cause the bug in
issue #${{ github.event.issue.number }}. Post findings as a comment.
Do NOT push code." \
--allowedTools "Read,Grep,Bash(gh issue comment:*)"
# Safety in CI: grant the narrowest tool/permission scope possible,
# never expose write/deploy access, and keep secrets in the CI vault.
When to use this
Most terminal agents support a headless / print mode (-p) so you can run them non-interactively in CI for triage, fixes, or checks.
Quick Info
Difficulty: Advanced
Language: yaml
Copy the block above and adapt it to your project.
Related Examples
Complete AGENTS.md for Next.js + TypeScript
A production-grade AGENTS.md used by real teams. Covers principles, skills, workflows, and review standards.
Real Grok Build Skill Definition (advanced-code-reviewer)
A complete, production-ready skill definition you can download and use.
Research → Implement → Review → Ship Workflow
A complete multi-step workflow used for feature development with agents.