How I use Claude Code's -p flag to run autonomous AI sessions without any human intervention
Dev.to AI
•
Generative AI
The --print ( -p ) flag in Claude Code is the most underrated feature for building autonomous AI agents. Most people use Claude Code interactively. But with -p, you can run fully headless sessions where Claude: Reads files, writes code, executes commands Has access to the full tool suite (Bash, Read, Write, Edit, Glob, Grep) Works within a budget cap ( --max-budget-usd ) Outputs its entire work log to stdout Here's exactly how I use it to run a developer tools business automatically. The basic pattern claude \ -p "You are an autonomous agent. Execute these tasks.