Skip to content
BENIBIX Learn

--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

--max-turns sets how many turns claude -p may take before it stops. A turn is one round where Claude acts, such as running a tool, then reads what came back. There is no limit unless you set one. It keeps a run that is stuck from going round and round.

Example code

bash
claude -p --max-turns 3 "Fix the typo in README.md"
Stop after three turns at most.
--max-turns is the first of the three limits.

Common mistake

Setting it too low for a real task. A fix that needs ten steps stops at three, half done.

Key takeaways

  1. 1
    Print mode only. With -p.
  2. 2
    No limit. Unless you set one.
  3. 3
    Too low. Stops work half done.

Compare

Learn it properly