Awesome-claude-code generate-bug-fix

Generates minimal, safe bug fixes for PHP 8.4. Provides fix templates for each bug category with DDD/Clean Architecture patterns.

install
source · Clone the upstream repo
git clone https://github.com/dykyi-roman/awesome-claude-code
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/dykyi-roman/awesome-claude-code "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/generate-bug-fix" ~/.claude/skills/dykyi-roman-awesome-claude-code-generate-bug-fix && rm -rf "$T"
manifest: skills/generate-bug-fix/SKILL.md
source content

Bug Fix Generator

Templates and patterns for generating minimal, safe bug fixes.

Fix Generation Principles

1. Minimal Change

  • Fix only what's broken
  • No refactoring
  • No "improvements"
  • No formatting changes

2. Safe Change

  • Preserve existing behavior
  • Maintain API contracts
  • Keep backward compatibility
  • Add, don't remove

3. Tested Change

  • Reproduction test first
  • Fix makes test pass
  • Existing tests still pass

Fix Templates by Category

CategoryPatternsSee
Null PointerGuard clause, Null object, Optional returntemplates.md
Logic ErrorCondition correction, Boolean inversion, Missing casetemplates.md
BoundaryEmpty check, Index bounds, Range validationtemplates.md
Race ConditionDatabase locking, Optimistic locking, Atomic operationtemplates.md
Resource LeakTry-finally, Higher-level API, Pool returntemplates.md
ExceptionSpecific catch, Exception chaining, Proper re-throwtemplates.md
Type SafetyStrict types, Type validation, Boundary coerciontemplates.md
SQL InjectionPrepared statement, Query buildertemplates.md
Infinite LoopIteration limit, Visited tracking, Depth limittemplates.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

  • Method signatures (unless required)
  • Return types (unless fixing wrong type)
  • Visibility modifiers
  • Class structure
  • Unrelated code

Commit Message Format

fix(<scope>): <short description>

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

Fixes #<issue-number>