debugging v1.0.0 · Updated Apr 15, 2026 · by Justin Adams

Error Escalation (3-Strike Rule)

Stops Claude Code from spinning on errors — after 3 varied attempts at a problem, the agent surfaces the issue in plain language instead of burning tokens.

Claude Code
$ curl -fsSL https://www.cendis.ai/library/skill/error-escalation-3x/install | sh

What it does

Sets a hard limit on how many times Claude Code can retry a failing approach before escalating to the human. Each retry must vary the approach — no identical retries. After 3 failed attempts, the agent stops and explains what it tried, what failed, and what it recommends.

When to use it

  • In any project where you pay per token (every retry costs money)
  • When working with a non-technical product owner who can’t debug alongside the agent
  • In CI/CD debugging where the agent might loop on environment issues
  • Anytime you’ve watched an AI agent spin for 10 minutes on the same error

How it works

Add to your CLAUDE.md:

## Error Escalation

- Try to self-resolve up to 3 attempts on any problem. Vary your approach each time.
- After 3 failed attempts, surface the problem in plain language: what you tried,
  what failed, and what you recommend next.
- Never spin silently. If you're stuck, say so early rather than wasting tokens.

The agent will:

  1. Attempt to solve the problem (attempt 1)
  2. If that fails, try a different approach (attempt 2)
  3. If that fails, try yet another approach (attempt 3)
  4. If still failing, stop and report:
    • What the problem is
    • What 3 approaches were tried
    • Why each failed
    • A recommended next step

Example escalation output

## Stuck: migration failing on CI

**Attempt 1:** Ran `drizzle-kit migrate` with direct connection string → timeout after 30s
**Attempt 2:** Switched to pooler URL with `?sslmode=require` → SSL handshake error
**Attempt 3:** Added `?pgbouncer=true&connection_limit=1` → connected but permission denied on schema

**Diagnosis:** The CI database user likely doesn't have DDL permissions. This is an infrastructure issue, not a code issue.

**Recommended next step:** Check the CI database user's role and grant `CREATE` permission on the target schema, or use a migration-specific user with elevated privileges.

Why it matters

AI agents are optimistic by default — they’ll keep trying variations of the same approach, burning context window and tokens, without recognizing that the problem is outside their control. The 3-strike rule converts silent spinning into actionable information.