Skip to main content
bash TV

Claude Code Headless (claude -p) in CI: Exit 0 Isn't a Pass

TestMu AI (Formerly LambdaTest)

45 views5 Dec 2026

YouTube

Claude Code headless (claude -p) exits 0 when the agent finishes, not when your app works. Here's how to run it in CI and let a real browser test decide. Claude Code headless mode runs the agent with no terminal UI: pass -p, it prints the result and exits with a status code. That code only says the run finished. In 90 seconds we lock the run down with four CI flags, parse its JSON output, then add Kane CLI from TestMu AI (formerly LambdaTest) as a separate judge: a natural-language objective with an assert, run in a real browser, whose own exit code sets the GitHub Actions job status. Chapters 00:00 claude -p exited 0, checkout broken · Step 1: headless mode (-p) 00:16 Step 2: lock it down (--bare, --allowedTools, dontAsk, caps, JSON) 00:34 The exit-0 trap · Step 3: a Kane CLI browser test as the judge 00:57 Step 4: gate GitHub Actions on the Kane CLI step 01:15 The Separate-Judge checklist + install Commands shown claude -p "Find and fix the bug in auth.py" --allowedTools "Read,Edit,Bash" claude --bare -p "$TASK" --allowedTools "Read,Edit" --permission-mode dontAsk --max-turns 15 --max-budget-usd 2 --output-format json claude -p "Summarize this project" --output-format json | jq -r '.result' kane-cli run "click 'Buy Pro', assert the total due today shows '$19.00'" --url http://localhost:3000 --agent --headless kane-cli run "$OBJECTIVE" --url http://localhost:3000 --name claude-headless-gate --agent --headless --timeout 300 --username "$LT_USERNAME" --access-key "$LT_ACCESS_KEY" npm install -g @testmuai/kane-cli Kane CLI exit codes: 0 passed · 1 did not pass (or upload failed) · 2 did not start, no credits used · 3 timeout or cancelled. Flag behaviour checked against Anthropic's Claude Code docs on Dec 5, 2026. Full guide (flags table, permissions, subscription vs API key, the full GitHub Actions workflow): https://www.testmuai.com/blog/claude-code-headless/ Kane CLI: https://www.testmuai.com/kane-cli/ Kane CLI in CI/CD (docs): https://www.testmuai.com/support/docs/kane-cli-cicd/ #ClaudeCode #KaneCLI #CICD

Join the discussion

Have something to add?

Sign in to reply, follow this thread, and earn XP when your answer helps someone.