[FEATURE] Headless/batch mode for automated benchmarks and CI

Resolved 💬 3 comments Opened Apr 19, 2026 by jerrythomas Closed Apr 21, 2026

Summary

There is no way to programmatically start a Claude Code session with a predefined prompt, let it execute autonomously, and capture structured results. This blocks automated benchmarks, regression tests, and A/B comparisons of different configurations.

Use Case

Benchmarking AI-assisted development tools:

  1. Define 5 test tasks ("add a feature", "fix a bug", "refactor a module")
  2. Run each task twice: once with tool X enabled, once without
  3. Compare: turns, corrections, outcome, time
  4. Report: "Tool X improved FTR by 15% but added 8% more tokens"

CI integration:

  • "Run these 5 tasks on every PR, fail if FTR drops below 80%"
  • Reproducible evaluation across different model versions or configurations

Today this requires manually running sessions and recording results by hand.

Proposed Solution

claude --headless \
  --prompt "Fix the null pointer exception in src/parser.rs" \
  --max-turns 20 \
  --output-json session-result.json

Output:

{
  "session_id": "...",
  "outcome": "completed",
  "turns": 8,
  "tokens_in": 24000,
  "tokens_out": 8000,
  "duration_seconds": 45,
  "files_modified": ["src/parser.rs"],
  "tools_used": ["search", "Read", "Edit"],
  "corrections": 0
}

Alternatives considered

  • claude -p "prompt" exists but is single-turn, not agentic
  • Recording manual sessions works but doesn't scale and introduces human variance
  • claude-code-action runs in CI but doesn't return structured metrics

Impact

This unlocks:

  • Automated quality benchmarks for AI-assisted development tools
  • A/B testing of prompt strategies, skills, or configurations
  • CI gating on AI session quality
  • Reproducible evaluation for researchers comparing AI coding assistants

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗