Claude Code Headless Mode Guides and Tutorials
13 guides about Headless, newest first. The first one published was “Why Claude Code Stops Mid-Automation (and How to Fix It)”. Last updated .
· 14 min read
Claude Code Hooks Not Working: 8 Fixes and a Debug Script
Claude Code hooks not working? Fix settings location, JSON, matchers, exit codes, permissions and claude -p, then log every payload with a debug script.
· 17 min read
Claude Code PreToolUse Hook: Copy-Paste Block Scripts
Claude Code PreToolUse hook guide: exact JSON input, allow/deny/ask output, exit codes, error fixes, copy-paste scripts that block risky headless runs.
· 17 min read
Claude Code Stop Hook: Block Early Exit Without Loops
Claude Code stop hook guide: block early exit until tests pass, cap retries with stop_hook_active and a counter, and fix JSON validation errors.
· 17 min read
Claude Code MCP Servers: Setup, Config & Cron-Safe Template
Claude Code MCP servers: add, configure, and remove them, pick a scope, run them safely in cron jobs with permission rules, timeouts, and failure checks.
· 15 min read
CLAUDE.md Best Practices: A Template for Unattended Agents
CLAUDE.md best practices for headless and scheduled Claude Code runs: a ready template, the --bare trap, and rules that stop overnight agents stalling.
· 18 min read
Claude Code on VPS: systemd Setup That Survives Reboots
Run Claude Code on a VPS unattended: install on Ubuntu or Hostinger, store a token safely, schedule jobs with systemd timers, and harden SSH and firewall.
· 19 min read
Claude Code Stuck on Compacting Conversation: Cron Watchdog
Claude Code stuck on compacting conversation? Why it hangs in headless and cron runs, the real auto-compact defaults, and a watchdog script that recovers.
· 16 min read
Claude Code Permissions Best Practices: Headless Template
Claude Code permissions best practices for unattended runs: a settings.json allow/deny template, mode picks, and pre-flight checks so overnight jobs finish.
· 10 min read
Claude Code Rate Limit Reached: Retry Setup for Cron Jobs
Claude Code rate limit reached? Tell a 429 throttle from a plan or spend cap, read the retry-after headers, and set safe auto-retries for headless cron jobs.
· 10 min read
Claude Code: How to See Token Usage (and Reduce It)
Claude Code how to see token usage: run /usage in a session, read total_cost_usd from headless JSON runs, check the Console Usage page, and set cost alerts.
· 10 min read
Claude Code Cron Job Setup: Run Automations Overnight
Claude Code cron job setup: auth tokens, PATH, working directory, permissions, locks and log rotation, so overnight claude -p runs don't fail silently.
· 13 min read
Claude Code Checkpoints: How Rollback Works in Automations
How Claude Code checkpoints work in headless jobs (claude -p, Agent SDK): enable file checkpointing, save UUIDs, roll back runs, and know rewind's limits.
· 9 min read
Why Claude Code Stops Mid-Automation (and How to Fix It)
Why does Claude Code stop running headless automations? Map the turn, budget, timeout and permission triggers in claude -p runs, plus a fix checklist.