Back to Blog

Schedule Claude Code Sessions With launchd to Use Your Token Quota Automatically

Fazm Team··2 min read
claude-codelaunchdautomationschedulingmacos

Schedule Claude Code Sessions With launchd to Use Your Token Quota Automatically

Most Claude Code subscriptions come with a monthly token quota. Most people do not use all of it. Scheduled sessions let you put those tokens to work on tasks that run while you are away from your desk.

What to Automate

Good candidates for scheduled Claude Code sessions:

  • Automated PR reviews - scan open PRs every morning and leave review comments
  • Dependency updates - check for outdated packages and create update PRs weekly
  • Engagement stats - pull analytics from side projects and update dashboards
  • Code cleanup - run linting, fix warnings, and create cleanup PRs
  • Documentation sync - update docs when code changes are detected

These are tasks you would do manually but keep postponing. A scheduled agent does them consistently.

Setting Up launchd

Create a plist file in ~/Library/LaunchAgents/ that runs a shell script on a schedule. The script launches Claude Code in headless mode with a specific prompt:

The plist defines when to run (daily, hourly, weekly), and the script defines what to do. Keep each session focused on one task - a clear prompt with a specific goal works better than a broad "check everything" instruction.

Key Considerations

  • Session isolation - each scheduled session should work in its own directory or worktree to avoid conflicts with your active work
  • Timeouts - set a maximum duration so a stuck session does not run forever
  • Logging - redirect output to log files so you can review what happened
  • Error handling - the script should handle cases where Claude Code is unavailable or rate-limited
  • Token awareness - track how many tokens each scheduled task uses so you do not blow through your quota on low-priority tasks

The Mindset Shift

Scheduled agents turn Claude Code from an interactive tool into infrastructure. Instead of "I should review those PRs," it becomes "PRs get reviewed automatically every morning." The consistency alone makes it worthwhile - these are the tasks that slip through the cracks when done manually.

More on This Topic

Fazm is an open source macOS AI agent. Open source on GitHub.

Related Posts