Dev.to AI 🤖 Ai 👁 0 📖 2 min read

A free Claude Code skill that audits your cron job before it bills you

Scheduling claude -p from cron is easy. Scheduling it so it can't silently bill an API key, overlap with itself, hang forever, or hammer a usage limit is where most setups fall short. I turned the checklist I use into a

Scheduling claude -p from cron is easy. Scheduling it so it can't silently bill an API key, overlap with itself,
hang forever, or hammer a usage limit is where most setups fall short. I turned the checklist I use into a
Claude Code skill: a plain markdown file Claude loads when you ask it to audit a scheduled run.

It is read-only. It reads your crontab and the script it calls, then reports PASS / FAIL with file:line and a fix.

The 10 checks

  1. API key leakage. If ANTHROPIC_API_KEY is set anywhere the cron job inherits it (script, sourced files, /etc/environment, VAR= lines in the crontab), claude may bill the API instead of your plan. Fix: unset ANTHROPIC_API_KEY ANTHROPIC_AUTH_TOKEN at the top of the script, unless API billing is intended.
  2. Overlap. No flock -n means a slow run plus the next tick gives you two agents editing the same files.
  3. Turn / time cap. --max-turns and timeout around the whole command.
  4. PATH. Cron's PATH is minimal; call claude by absolute path or set PATH.
  5. Working directory. Cron starts in $HOME; cd to the project first.
  6. Permissions. Headless runs can't answer prompts. Give a narrow settings file / --allowedTools, not a blanket Bash(*) or --dangerously-skip-permissions outside a sandbox.
  7. Output capture. Timestamped log for stdout and stderr, rotated or capped.
  8. Limit handling. On a usage-limit message, stop until reset instead of firing again next tick.
  9. Schedule sanity. Translate the expression to runs/day; more than ~8/day on a subscription is likely to hit limits.
  10. Reboot. @reboot or a systemd unit if it must survive restarts.

Install

Save the file as ~/.claude/skills/cron-preflight/SKILL.md, then ask Claude: "run cron-preflight on my crontab".
Free download (pay what you want, $0 is fine):
https://spikeyjr.gumroad.com/l/claude-code-cron-preflight

The output is a table, # | Check | Result | Where | Fix, and a one-line verdict. It never prints secret values
it finds; it writes <set> instead.

If you want the fixes already done

The free, MIT-licensed agent-autopilot-kit is a cron launcher that
passes all ten: flock, key stripping, turn cap, limit detection with a pause file, daily run cap, @reboot, logs.

There is also a paid pack of five more ops skills (session handoff, task slicing for short sessions, pre-publish secret
scan, log triage, changelog from git) for people running Claude Code across many short sessions:
https://spikeyjr.gumroad.com/l/claude-code-headless-skills

Disclosure: I maintain the repo and sell the paid pack; this post was drafted with AI assistance. Unofficial, not
affiliated with Anthropic.

📰 Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.