Companies are spending 44% of their AI tokens fixing bugs that AI generated (Entelligence AI, May 2026). CodeRabbit analyzed open-source PRs and found AI produces 1.7x more problems than human code.
I spent three days refactoring 20 minutes of agent-generated code last week. The architecture was fine on the surface — it compiled, tests passed, features worked. But underneath:
Error handling was catch (e) {} everywhere — swallowed silently
Temp files were created but never cleaned up (200MB of orphans in a week)
The agent used a method from v3 of a library. We're on v5. It doesn't exist.
No finally blocks anywhere — connections leaked on failure
Sound familiar? If you use Cursor, Claude Code, Codex, or Copilot for anything beyond boilerplate, you've seen this.
The Problem Is Specific to AI
These aren't random bugs. They're a pattern. AI agents optimize for "looks correct" and "passes the happy path." They systematically miss:
Failure modes — what happens when the network drops mid-request?
Orphaned resources — event listeners, connections, temp files never cleaned up
Edge cases — empty arrays, null inputs, Unicode, concurrent access
Hallucinated dependencies — imports that look right but don't exist
Architectural drift — agent ignores your project's patterns and reinvents
The Fix: A Skill That Forces Self-Audit
I built ai-debt-detector — a 98-line behavioral skill that makes the agent check its OWN output for these exact failure patterns after every code generation session.
It's not a linter. It's not a CI tool. It runs at write-time, inside your agent, before you even see the code.
Install (Cursor)
npx skills@latest add Adit-Jain-srm/skill-forge
Install (Claude Code)
/plugin marketplace add Adit-Jain-srm/skill-forge
/plugin install skill-forge@skill-forge
The skill activates automatically after code generation. It scans for:
catch (e) {} — swallowed errors (red flag)
Missing finally blocks when resources were opened
// TODO: handle error — AI's way of punting
Imports from paths that don't exist
Timeouts without cleanup
Connections opened but never returned to pool
It's Part of a Larger System
ai-debt-detector is one of 17 skills in skill-forge — a self-improving collection that also includes:
/prove-it — forces evidence before claiming "done"
/diagnose — systematic debugging loop (reproduce → minimise → fix)
/grill — prevents building the wrong thing
/error-resilience — retry patterns, circuit breakers, graceful degradation
/session-guard — prevents long-session corruption
101 tests passing, 0 validation warnings, MIT licensed. Works in Cursor, Claude Code, Codex CLI, Gemini CLI, and Copilot.
Try It
npx skills@latest add Adit-Jain-srm/skill-forge
Then write some code with your agent. The skill activates automatically and catches what you'd miss.
GitHub | MIT License | 17 skills | 101 tests
Top comments (0)