⌨️--max-turns Flag
Also known as claude --max-turns, Turn limit, CLAUDE_CODE_MAX_TURNS
It caps how many turns claude -p may take.
Think of it like
It is like a game where you get three tries, then you have to stop.
Example
Lucy's CI job asks Claude to fix lint errors. She sets --max-turns 10, so a run that cannot find a fix stops instead of using up the job's time.
Why it matters
A run with no end costs time and money. A cap puts a ceiling on both.
Definition
Example code
bash
claude -p --max-turns 3 "Fix the typo in README.md"Common mistake
Key takeaways
- 1Print mode only. With -p.
- 2No limit. Unless you set one.
- 3Too low. Stops work half done.