archived/skills/debug-headless/SKILL.md
Debug Claude Code or Gemini CLI in headless mode with full output capture.
npx skillsauth add nicsuzor/academicops debug-headlessInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Run Claude Code or Gemini CLI non-interactively with output and debug log capture.
# Run headless session
cd /path/to/project && claude -p "your prompt" --output-format json --model haiku
# Find the session file (most recent)
ls -lt ~/.claude/projects/-home-<user>-<project>/*.jsonl | head -1
# Generate readable transcript
cd $AOPS && uv run python scripts/session_transcript.py /path/to/session.jsonl
claude -p "prompt" --output-format json --model haiku 2>&1 | head -200
Key flags:
-p "prompt" - Non-interactive mode with prompt--output-format json - Structured output for parsing--model haiku - Faster/cheaper for testing (or sonnet for complex)--dangerously-skip-permissions - Skip permission prompts (use carefully)Sessions are stored at: ~/.claude/projects/-<path-with-dashes>/<uuid>.jsonl
# List recent sessions for a project
ls -lt ~/.claude/projects/-home-nic-src-academicOps/*.jsonl | head -5
# Find session by prompt content
grep -l "your prompt text" ~/.claude/projects/-home-nic-src-*/*.jsonl
cd $AOPS && uv run python scripts/session_transcript.py /path/to/session.jsonl
Output: Creates two files in $ACA_DATA/sessions/claude/:
*-full.md - Complete transcript with all tool results*-abridged.md - Compact view without tool output detailsUse the transcript - don't grep raw JSONL. The full transcript contains:
### Hook: EventName: ToolName ✓ - Hook execution markers### Subagent: type (description) - Inline subagent conversations## Subagent Transcripts - Orphan/warmup agents at endWhat to look for:
| Debug Question | Look In Transcript |
| --------------------- | ------------------------------------------------------------------ |
| Did custodiet fire? | ### Hook: PostToolUse entries + Task(subagent_type="custodiet" |
| What hooks ran? | All ### Hook: headings show event + tool |
| Where did it fail? | Search for ERROR, failed, exit [1-9] |
| What did subagent do? | ### Subagent: sections show full conversation |
| What was injected? | SessionStart hook content at beginning |
Custodiet threshold: Fires every ~5 "action" tool calls.
Skipped tools (don't count toward threshold):
Read, Glob, Grep, mcp__memory__retrieve_memoryParallel vs Sequential: Tools called in parallel (same turn) may count differently than sequential calls across multiple turns.
Use the full transcript to verify hooks:
| Hook | What to Check in Transcript |
| ---------------- | ----------------------------------------------- |
| SessionStart | First content block has AXIOMS.md/HEURISTICS.md |
| UserPromptSubmit | ### Hook: UserPromptSubmit ✓ after user turn |
| PostToolUse | ### Hook: PostToolUse: ToolName ✓ entries |
| Stop | No ✗ (exit N) markers on hooks |
Hook status indicators:
✓ = exit 0 (success)✗ (exit N) = non-zero exit (error)Hook not executing:
# Check settings.json configuration
cat ~/.claude/settings.json | jq '.hooks'
# Check hook file exists
ls -la $AOPS/hooks/*.py | head -10
Session exits with code 1:
sys.exit(0) for advisory messages| Tool | Headless Flag | Debug Flag | Auto-approve |
| ----------- | ------------- | ---------- | -------------------------------- |
| Claude Code | -p | -d | --dangerously-skip-permissions |
| Gemini CLI | (positional) | -d | -y / --yolo |
data-ai
Canonical session close — commit, push, PR, release_task, reflection blocks, handover. Use /dump for emergency bail (no commit/PR/reflection).
data-ai
Emergency session bail — fast resume task + short handover, no commit/PR/reflection. For when you (or the user) need a clean context now. Use /end-session for canonical close.
data-ai
Daily note lifecycle — compose and maintain a factual daily note. Reports the state of the day; does not prioritise or recommend. SSoT for daily note structure.
testing
Launder supervisor/worker task-log output into a Nic-facing narrative — what happened, where things are headed, and what (if anything) is genuinely his to decide. Never relays raw process detail (worker IDs, thread pointers, log paths) or verbatim task-log stream-of-consciousness.