Agent self correction

From majiayu000/claude-skill-registry-data · View interactive version

Agent self correction is an AI agent skill from the GitHub repository majiayu000/claude-skill-registry-data. Protocols for the agent to autonomously detect failures, analyze root causes, and attempt recovery strategies before requesting user intervention.

How to use this skill

Skill file

Agent Self-Correction

[Context: Errors and roadblocks are inevitable. An efficient agent does not stop at the first sign of failure; it analyzes the error, adjusts its approach, and retries. This skill defines the cognitive loop for autonomous self-correction.]

1. Core Principles

2. Step-by-Step Implementation

Phase 1: Failure Detection & Analysis

When a tool returns an error or a check fails:

  1. Stop: Do not proceed to the next step of the plan.
  2. Read: Analyze the error message thoroughly.
  1. Hypothesize: Formulate a hypothesis for the fix.

Phase 2: autonomous Recovery Loop

  1. Attempt 1 (Quick Fix): Address the obvious error (e.g., install missing package, fix typo).
  2. Verify: Run the verification command (e.g., npm run build or pytest).
  3. Attempt 2 (Alternative Approach): If Attempt 1 fails, try a different distinct strategy (e.g., switch library, rewrite logic).
  4. Attempt 3 (Simplify): Reduce complexity or scope to isolate the issue.

Phase 3: Escalation

If Attempt 3 fails:

  1. Gather Context: Collect error logs and the 3 failed attempts.
  2. Propose solution: Present the user with the situation and a proposed manual intervention or request for clarification.

3. Templates & Examples

Internal Monologue for Debugging

ERROR DETECTED: [Error Message]
ANALYSIS: The error implies [Cause].
HYPOTHESIS: If I change [X] to [Y], it should resolve.
ACTION: Applying fix [X->Y].

Self-Correction Checklist

4. Common Pitfalls

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.