Error prevention strategies for AI-assisted development. Use when working with Claude to minimize hallucinations, incomplete solutions, and wasted tokens. Enforces "trust but verify" workflow.
Resources
1Install
npx skillscat add peterbamuhigire/skills-web-dev/ai-error-prevention Install via the SkillsCat registry.
Required Plugins
Superpowers plugin: MUST be active for all work using this skill. Use throughout the entire build pipeline โ design decisions, code generation, debugging, quality checks, and any task where it offers enhanced capabilities. If superpowers provides a better way to accomplish something, prefer it over the default approach.
AI Error Prevention in Software Development
Overview
This skill teaches you to prevent errors BEFORE they happen when working with Claude to generate code. It focuses on minimizing wasted tokens, catching Claude's mistakes early, and ensuring production-ready output.
Documentation Structure (Tier 2 Deep Dives):
- ๐ prevention-strategies.md - The 7 prevention strategies with detailed examples
- ๐ failure-modes.md - Common Claude failures and how to prevent them
- ๐ app-specific-prevention.md - Prevention for MADUUKA, MEDIC8, BRIGHTSOMA, DDA
When to Use This Skill
Always use when:
- Working with Claude to generate code
- Building software with AI assistance
- Want to minimize wasted tokens on wrong solutions
- Need to catch Claude's mistakes early
- Developing production-ready code with AI
This skill prevents errors BEFORE they happen.
The Core Problem
Traditional vs AI-Assisted Development
Traditional Development:
You write code โ Code fails โ You debug โ You fix
AI-Assisted Development:
You ask Claude โ Claude generates code โ Code might be:
โโ Perfect โ
โโ Partially wrong (hallucination)
โโ Missing edge cases
โโ Insecure
โโ Inefficient
โโ Doesn't match your spec
YOU MUST: Verify, test, catch mistakes, know when to trust/distrustWhy Claude Can Fail
1. HALLUCINATION - Invents facts/APIs/methods that don't exist
2. INCOMPLETE SOLUTIONS - Solves 80%, misses the 20%
3. MISUNDERSTANDING - Misunderstood your requirement
4. OUTDATED KNOWLEDGE - Knows old way, not new way
5. CONTEXT LIMITS - Forgot earlier context
6. LAZY SOLUTIONS - Simplest answer, not best answer
7. WRONG ASSUMPTIONS - Assumes constraints you didn't mentionThe 7 Prevention Strategies (Quick Reference)
๐ See prevention-strategies.md for complete details with examples.
Strategy 1: Verification-First
Rule: NEVER accept code without verification
Claude generates โ YOU STOP โ Check:
โก Matches requirement?
โก Imports exist?
โก Obvious bugs?
โก Edge cases?
โก Secure?
โ Pass? Use it | Fail? Ask Claude to fixStrategy 2: Test-Driven Validation
Rule: Test Claude's code IMMEDIATELY
Claude generates โ YOU WRITE TESTS:
โก Happy path
โก Boundary cases
โก Edge cases
โก Error cases
โก Security cases
โ Tests pass? Good | Tests fail? FixStrategy 3: Specification Matching
Rule: Make Claude review against spec
You have SPEC โ Claude generates โ ASK CLAUDE:
"Check this against requirements. Does it:
โก Requirement 1?
โก Requirement 2?
โก Requirement 3?"
โ Gaps found? Fix | No gaps? CompleteStrategy 4: Incrementalism
Rule: Break big requests into small steps
โ DON'T: Ask for complete feature (Claude gets 50% right)
โ DO: Break into steps:
Step 1: Data model โ VERIFY โ
Step 2: Core function โ VERIFY โ
Step 3: Edge cases โ VERIFY โ
Step 4: Error handling โ VERIFY โ
Step 5: Integration โ VERIFY โEach step: 10-20 lines, easy to verify
Strategy 5: Dual Approach
Rule: Ask Claude to solve problem TWO ways
Ask Claude: "Solve problem X"
โ Claude gives Solution A
Ask Claude (new message): "Solve problem X differently"
โ Claude gives Solution B
COMPARE:
If A == B โ Probably correct
If A โ B โ One might be wrong
โ Ask Claude: "Compare. Which is better?"Strategy 6: Fallback Code
Rule: Keep simple backup implementation
Claude generates: Complex optimized solution
YOU ALSO WRITE: Simple naive solution (Plan B)
try {
return claudeSolution(); // Try Claude's
} catch {
return simpleFallback(); // Use backup
}Strategy 7: Documentation Validation
Rule: If Claude can't explain it, code might be wrong
Claude generates โ YOU ASK:
"Document this:
1. What it does
2. Inputs (with types)
3. Outputs (format)
4. Possible errors
5. Edge cases
6. Usage examples"
If Claude explains clearly โ Probably correct
If Claude struggles โ Code might be wrongCommon Claude Failure Modes (Summary)
๐ See failure-modes.md for detailed prevention strategies.
Failure Mode 1: Incomplete Understanding
Problem: Claude implements basic version, misses critical parts
Prevention: Ask for COMPLETE spec first, verify before implementingFailure Mode 2: Wrong Pattern/Approach
Problem: Claude chooses suboptimal approach
Prevention: Provide context (data patterns, usage, constraints)Failure Mode 3: Hallucinated Libraries
Problem: Claude suggests library that doesn't exist
Prevention: Verify library exists (docs URL, version, install command)Failure Mode 4: Misunderstood Requirement
Problem: Claude implements something different
Prevention: Provide examples and scenariosFailure Mode 5: Lazy Solution
Problem: Claude gives simplest answer, misses edge cases
Prevention: Explicitly demand edge case handling with test casesAI Development Error Prevention Framework
Complete Workflow:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ PHASE 1: REQUEST PREPARATION โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โก Use Clear Task pattern โ
โ โก Include specific constraints โ
โ โก Ask for structured output โ
โ โก Show examples โ
โ โก Break into small steps โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ PHASE 2: CLAUDE GENERATES โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ PHASE 3: IMMEDIATE VERIFICATION โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โก VERIFY: Match spec? โ
โ โก READ: Imports exist? โ
โ โก CHECK: Obvious bugs? โ
โ โก ASK: "Document this" โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ PHASE 4: TESTING โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โก Write tests (happy, edge, error) โ
โ โก Run tests โ
โ โก If fails โ Back to Claude โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ PHASE 5: QUALITY CHECKS โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โก SECURITY: Vulnerabilities? โ
โ โก PERFORMANCE: Bottlenecks? โ
โ โก EDGE CASES: All handled? โ
โ โก ERROR HANDLING: Clear messages? โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ PHASE 6: ITERATION (if needed) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ If ANY check fails: โ
โ โ Specific feedback to Claude โ
โ โ Claude fixes โ
โ โ Return to Phase 3 โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ PHASE 7: ACCEPTANCE โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ All checks passed โ USE CODE โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโApp-Specific Prevention (Summary)
๐ See app-specific-prevention.md for complete checklists.
MADUUKA (Franchise ERP)
High-Risk: Multi-tenancy, pricing, inventory, payments
Prevention:
โก Explicitly require tenant isolation
โก Provide pricing formulas with examples
โก Test edge cases (discounts, taxes, stock)
โก Verify tenant_id in ALL queriesMEDIC8 (Healthcare)
High-Risk: HIPAA, medication interactions, dosage calculations
Prevention:
โก List HIPAA requirements explicitly
โก Provide medication interaction rules
โก Show dosage formulas with examples
โก MANUAL REVIEW before productionBRIGHTSOMA (Education)
High-Risk: Curriculum alignment, grading fairness
Prevention:
โก Provide curriculum reference
โก Show grading rubric
โก Define difficulty criteria
โก Human review of first batchDDA (Database Tool)
High-Risk: Schema compliance, data integrity
Prevention:
โก Provide full schema
โก Show realistic data examples
โก Test referential integrity
โก Backup before runningThe Golden Rule
TRUST BUT VERIFY
โ Trust Claude's speed
โ Trust Claude's knowledge
โ Trust Claude to explain
โ Don't trust without verification
โ Don't skip testing
โ Don't assume it's secure
โ Don't use without understanding
YOUR JOB: Skeptical, test, verify
CLAUDE'S JOB: Generate, explain, fixAcceptance Checklist
Before accepting ANY code from Claude:
โก REQUIREMENTS
โก Matches all requirements
โก Handles edge cases
โก Error cases handled
โก VERIFICATION
โก Imports/libraries exist
โก No hallucinated APIs
โก Parses without errors
โก TESTING
โก Happy path tested
โก Edge cases tested
โก Error cases tested
โก All tests passing
โก SECURITY
โก No SQL injection
โก No XSS
โก No exposed secrets
โก Input validation present
โก QUALITY
โก Readable
โก Documented
โก Follows patterns
โก No performance issues
โก EXPLANATION
โก Claude can explain it
โก Edge cases explained
โก Assumptions documented
โก Usage examples provided
โก INTEGRATION
โก Works with existing code
โก No conflicts
โก Error handling integrated
โก Logging presentIf ALL checked โ Accept
If ANY unchecked โ Back to Claude
Token Waste Prevention
How This Skill Saves Tokens:
WITHOUT prevention:
Request โ Wrong code โ Discover later โ Fix โ Still wrong โ Fix again
TOKENS WASTED: 4-5x
WITH prevention:
Request (clear spec) โ Generate โ Verify immediately โ Fix once
TOKENS USED: 1-2x
SAVINGS: 50-75% fewer tokensBest Practices:
โ Be specific (prevents misunderstanding)
โ Verify immediately (catch errors early)
โ Specific feedback (faster fixes)
โ Small steps (easier to verify)
โ Test each step (no cascading errors)Integration with Other Skills
Use this skill WITH:
orchestration-best-practices- Structure in generated codeai-error-handling- Validation after preventionai-assisted-development- Prevent errors across multiple agentsprompting-patterns-reference- Better requests = fewer errors
Workflow:
1. AI-ERROR-PREVENTION (this) โ Request correctly, verify immediately
2. ORCHESTRATION-BEST-PRACTICES โ Ensure code structure
3. AI-ERROR-HANDLING โ Final validation layers
4. AI-ASSISTED-DEVELOPMENT โ Coordinate multiple agents
Result: Minimal errors, maximum efficiency, lowest token wasteSummary
Core Concept: Prevent errors BEFORE they happen by changing HOW you interact with Claude
The 7 Strategies:
- Verification-First
- Test-Driven Validation
- Specification Matching
- Incrementalism
- Dual Approach
- Fallback Code
- Documentation Validation
5 Common Failures:
- Incomplete Understanding
- Wrong Pattern
- Hallucinated Libraries
- Misunderstood Requirement
- Lazy Solution
Result: 50-75% fewer tokens wasted, higher quality code, faster development
Next Steps:
- ๐ Read prevention-strategies.md for detailed strategy examples
- ๐ Read failure-modes.md for failure prevention
- ๐ Read app-specific-prevention.md for your app's checklist
- Apply to your next Claude request!
Related Skills:
orchestration-best-practices/- Code structure enforcementai-error-handling/- Validation after generationai-assisted-development/- Multi-agent coordinationprompting-patterns-reference.md- Better promptsencoding-patterns-into-skills.md- Creating pattern-enforcing skills
Last Updated: 2026-02-07
Line Count: ~481 lines (compliant)