self-debug

Generate an evidence-based workflow to recover from AI agent looping and drift.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/Pyl-Tech/stream-coding --skill self-debug
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: self-debug
Source: https://github.com/Pyl-Tech/stream-coding/tree/main/.agents/skills/self-debug
Command: npx skills add https://github.com/Pyl-Tech/stream-coding --skill self-debug

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Self-debug prevents wasted retries by helping an AI agent recognize looping or drifting, capture the exact failure state, diagnose the likely agent-level cause, and perform the smallest recovery step before escalating.

Core Features & Use Cases

  • Loop and drift detection: Triggers when retries repeat 3+ times, token burn occurs, or context drifts away from the objective.
  • Structured failure capture: Freezes task state with required fields like last successful step and repeated pattern observed.
  • Pattern-based diagnosis + minimal recovery: Selects the most likely agent failure pattern, verifies world state, shrinks scope, runs one discriminating check, then reports outcome.
  • User escalation guardrail: Avoids repeating the same recovery cycle and escalates with a Self-Debug Report when blocked after one cycle.

Quick Start

Use this skill when you notice the agent is looping by running /self-debug and generating a Self-Debug Report with capture, diagnosis, one minimal recovery action, and final escalation if still blocked.

Frequently Asked Questions about self-debug

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I stop an AI coding agent from looping and burning tokens?▼

To stop an AI coding agent from looping and burning tokens, you need an evidence-based debugging workflow that detects repeated tool calls, freezes the failure state, and applies a minimal recovery step before escalating. This prevents wasted retries when the agent gets stuck rather than the code being incorrect.

What is context drift in AI-assisted coding and how do I recover from it?▼

Context drift in AI-assisted coding occurs when the agent loses sight of the original objective. To recover, you capture the exact failure state, classify whether the agent or the spec failed, select a diagnosis pattern, and run a single discriminating check to verify the world state before proceeding.

When should I use a self-debug workflow for agent failure recovery?▼

You should use a self-debug workflow for agent failure recovery when retries repeat three or more times, token burn occurs, or context drifts away from the objective. It applies specifically when the agent is stuck rather than the code or specification being incorrect.

How do I diagnose whether my AI agent or my code spec is causing repeated failures?▼

To diagnose whether your AI agent or code spec is causing repeated failures, you classify the failure mode by capturing the last successful step and the repeated pattern observed. This structured failure capture distinguishes agent-level looping from actual specification errors.

What is the best way to prevent an AI coding agent from repeating the same failed recovery cycle?▼

The best way to prevent an AI coding agent from repeating the same failed recovery cycle is to enforce an escalation guardrail that allows only one minimal recovery action. If still blocked, the agent outputs a structured report instead of retrying to avoid infinite loops.

Does this debugging workflow require any external dependencies or specific components?▼

This debugging workflow requires no external dependencies or specific components to function. It operates as a standalone process within AI-assisted coding environments to detect looping, capture failure state, and produce structured reports for escalation.