Skip to content
BENIBIX Learn

CLAUDE_CODE_MAX_RETRIES

AI⌨️ Claude CodeConfiguration

Also known as CLAUDE_CODE_MAX_RETRIES environment variable

It sets how many times a failed request is tried again.

Think of it like

It is like how many times you knock on a door. Then you give up and leave.

Example

Jack's CI should fail fast, not wait through ten retries. He sets 3, and a broken run ends quickly.

Why it matters

Retries ride out short outages, but too many can make a script hang for a long time.

Definition

CLAUDE_CODE_MAX_RETRIES sets how many times Claude Code tries a failed API request again. The default is 10. It can stop sooner when the API says it is overloaded. If you set a fallback model, Claude Code moves to that model in place of showing the error.

Example code

bash
export CLAUDE_CODE_MAX_RETRIES=3
claude -p "Run the checks"
Give up sooner in a script.

Common mistake

Raising it to wait through a long outage. There is a separate watchdog variable built for that.

Key takeaways

  1. 1
    Default 10. Tries again.
  2. 2
    Stops sooner. When overloaded.
  3. 3
    Fallback model. Switches instead.