Generate bug fix

From dykyi-roman/awesome-claude-code · View interactive version

Generate bug fix is an AI agent skill from the GitHub repository dykyi-roman/awesome-claude-code. Generates minimal, safe bug fixes for PHP 8.4. Provides fix templates for each bug category with DDD/Clean Architecture patterns.

How to use this skill

Skill file

Bug Fix Generator

Templates and patterns for generating minimal, safe bug fixes.

Fix Generation Principles

1. Minimal Change

2. Safe Change

3. Tested Change

Fix Templates by Category

| Category | Patterns | See |

|----------|----------|-----|

| Null Pointer | Guard clause, Null object, Optional return | templates.md |

| Logic Error | Condition correction, Boolean inversion, Missing case | templates.md |

| Boundary | Empty check, Index bounds, Range validation | templates.md |

| Race Condition | Database locking, Optimistic locking, Atomic operation | templates.md |

| Resource Leak | Try-finally, Higher-level API, Pool return | templates.md |

| Exception | Specific catch, Exception chaining, Proper re-throw | templates.md |

| Type Safety | Strict types, Type validation, Boundary coercion | templates.md |

| SQL Injection | Prepared statement, Query builder | templates.md |

| Infinite Loop | Iteration limit, Visited tracking, Depth limit | templates.md |

Quick Reference

Null Pointer → Guard Clause

$entity = $this->repository->find($id);
if ($entity === null) {
    throw new EntityNotFoundException($id);
}

Logic Error → Condition Fix

// Wrong: if ($a > $b)
// Fixed: if ($a >= $b)

Boundary → Empty Check

if ($items === []) {
    throw new EmptyCollectionException();
}

Race Condition → Locking

$this->em->beginTransaction();
try {
    $entity = $this->repository->findWithLock($id);
    // ... modify ...
    $this->em->commit();
} catch (\Throwable $e) {
    $this->em->rollback();
    throw $e;
}

Resource Leak → Try-Finally

$resource = acquire();
try {
    return process($resource);
} finally {
    release($resource);
}

Fix Composition Rules

Order of Operations

  1. Add validation/guards at the top
  2. Make the minimal code change
  3. Keep existing code paths intact
  4. Add new exception types if needed

What NOT to Change

Commit Message Format

fix(<scope>): <short description>

<detailed description of what was wrong and how it's fixed>

Fixes #<issue-number>
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.