Bug Fix Knowledgeのロゴ

Bug Fix Knowledge

コミュニティ
dykyi-roman
bug-fix-knowledge

Bug fix knowledge base. Provides bug categories, symptoms, fix patterns, and minimal intervention principles for PHP 8.4 projects.

Add to TypingMind

概要

公開者dykyi-roman
リポジトリawesome-claude-code
スキル名bug-fix-knowledge
スター
98
フォーク
25
同梱ファイル
指示のみ
ライセンスMIT
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 指示だけで完結

    モデルに必要なものはすべて指示に含まれているため、別途同期するファイルはありません。

  • オープンソース

    dykyi-romanがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキル「Bug Fix Knowledge」をTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/dykyi-roman/awesome-claude-code/tree/master/skills/bug-fix-knowledge
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/dykyi-roman/awesome-claude-code.git /tmp/awesome-claude-code
mkdir -p .claude/skills
cp -r /tmp/awesome-claude-code/skills/bug-fix-knowledge .claude/skills/bug-fix-knowledge
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでBug Fix Knowledgeを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあるとすぐに、モデルが自動的にBug Fix Knowledgeを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Bug Fix Knowledgeは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、スキルを使わない間は指示の読み込みにトークンを消費しません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

Bug Fix Knowledge Base

Comprehensive knowledge for diagnosing and fixing bugs in PHP applications following DDD, CQRS, and Clean Architecture patterns.

Bug Categories and Symptoms

1. Logic Errors

Symptoms:

  • Incorrect output for valid input
  • Wrong branch taken in conditionals
  • Inverted boolean logic
  • Off-by-one errors in loops
  • Missing edge case handling

Common Causes:

  • > instead of >=, && instead of ||
  • Negation errors (!$condition vs $condition)
  • Loop boundary mistakes (< count vs <= count)
  • Missing break in switch statements

Fix Pattern:

php
// Before: Logic error
if ($amount > $limit) { // Should be >=
    throw new LimitExceededException();
}

// After: Fixed
if ($amount >= $limit) {
    throw new LimitExceededException();
}

2. Null Pointer Issues

Symptoms:

  • "Call to a member function on null"
  • "Cannot access property on null"
  • Unexpected null returns
  • Missing null checks after optional operations

Common Causes:

  • Repository returning null for non-existent entity
  • Optional relationships not checked
  • Nullable parameters not validated
  • Method chaining on potentially null objects

Fix Pattern:

php
// Before: Null pointer risk
$user = $this->userRepository->find($id);
$email = $user->getEmail(); // Crashes if user is null

// After: Safe with null check
$user = $this->userRepository->find($id);
if ($user === null) {
    throw new UserNotFoundException($id);
}
$email = $user->getEmail();

// Alternative: Null coalescing
$email = $user?->getEmail() ?? throw new UserNotFoundException($id);

3. Boundary Issues

Symptoms:

  • Array index out of bounds
  • Empty collection access
  • String index errors
  • Numeric overflow/underflow

Common Causes:

  • Accessing first/last element without checking emptiness
  • Loop index exceeding array size
  • Integer overflow in calculations
  • Missing bounds validation

Fix Pattern:

php
// Before: Boundary issue
$firstItem = $items[0]; // Crashes if empty

// After: Safe boundary check
if ($items === []) {
    throw new EmptyCollectionException('items');
}
$firstItem = $items[0];

// Alternative: Using first() with default
$firstItem = $items[0] ?? throw new EmptyCollectionException('items');

4. Race Conditions

Symptoms:

  • Intermittent failures
  • Data corruption under load
  • Lost updates
  • Duplicate records

Common Causes:

  • Check-then-act without locking
  • Shared mutable state
  • Missing database transactions
  • Concurrent file access

Fix Pattern:

php
// Before: Race condition
if (!$this->repository->exists($id)) {
    $this->repository->save($entity); // Another process might insert between check and save
}

// After: Atomic operation with locking
$this->lockManager->acquire("entity:$id");
try {
    if (!$this->repository->exists($id)) {
        $this->repository->save($entity);
    }
} finally {
    $this->lockManager->release("entity:$id");
}

// Alternative: Database-level uniqueness
// Use UNIQUE constraint + INSERT ... ON DUPLICATE KEY

5. Resource Leaks

Symptoms:

  • Memory exhaustion over time
  • "Too many open files"
  • Database connection pool exhaustion
  • Slow performance degradation

Common Causes:

  • Unclosed file handles
  • Missing database connection release
  • Event listeners not removed
  • Circular references preventing GC

Fix Pattern:

php
// Before: Resource leak
$handle = fopen($path, 'r');
$content = fread($handle, filesize($path));
// Missing fclose()

// After: Proper resource management
$handle = fopen($path, 'r');
try {
    $content = fread($handle, filesize($path));
} finally {
    fclose($handle);
}

// Better: Use high-level functions
$content = file_get_contents($path);

6. Exception Handling Issues

Symptoms:

  • Silent failures
  • Generic error messages
  • Lost exception context
  • Swallowed exceptions

Common Causes:

  • Empty catch blocks
  • Catching too broad exception types
  • Not re-throwing after logging
  • Missing exception chaining

Fix Pattern:

php
// Before: Swallowed exception
try {
    $this->service->process($data);
} catch (Exception $e) {
    // Silent failure - bug hidden
}

// After: Proper exception handling
try {
    $this->service->process($data);
} catch (ValidationException $e) {
    throw new ProcessingFailedException(
        "Failed to process data: {$e->getMessage()}",
        previous: $e
    );
}

7. Type Issues

Symptoms:

  • "Type error: Argument must be of type X, Y given"
  • Unexpected type coercion
  • String/int confusion
  • Array/object mismatch

Common Causes:

  • Missing strict_types declaration
  • Implicit type casting
  • Mixed types from external sources
  • Legacy code without type hints

Fix Pattern:

php
// Before: Type issue
function calculate($amount) { // No type hint
    return $amount * 1.1; // Fails if string passed
}

// After: Strict typing
declare(strict_types=1);

function calculate(float $amount): float {
    return $amount * 1.1;
}

8. SQL Injection

Symptoms:

  • Security vulnerabilities
  • Unexpected query results
  • Data corruption
  • Authentication bypass

Common Causes:

  • String concatenation in queries
  • Missing parameter binding
  • Unvalidated user input in queries
  • Dynamic table/column names

Fix Pattern:

php
// Before: SQL injection vulnerability
$query = "SELECT * FROM users WHERE email = '$email'";

// After: Parameterized query
$query = "SELECT * FROM users WHERE email = :email";
$stmt = $pdo->prepare($query);
$stmt->execute(['email' => $email]);

9. Infinite Loops

Symptoms:

  • Application hangs
  • 100% CPU usage
  • Request timeouts
  • Memory exhaustion

Common Causes:

  • Missing or unreachable exit condition
  • Iterator not advancing
  • Recursive call without base case
  • Circular dependencies in processing

Fix Pattern:

php
// Before: Potential infinite loop
while ($item = $queue->pop()) {
    $this->process($item);
    // If process() adds items back to queue, infinite loop
}

// After: Safe with limit
$maxIterations = 10000;
$iterations = 0;
while ($item = $queue->pop()) {
    if (++$iterations > $maxIterations) {
        throw new MaxIterationsExceededException($maxIterations);
    }
    $this->process($item);
}

Minimal Intervention Principles

1. Single Responsibility Fix

  • Fix ONLY the bug, nothing else
  • No refactoring while fixing
  • No "while I'm here" improvements
  • Keep the diff minimal

2. Preserve Behavior

  • Existing tests must pass
  • API contracts must not change
  • Side effects must be preserved (if intentional)
  • Error messages format should match

3. Backward Compatibility

  • Public method signatures unchanged
  • Return types unchanged
  • Exception types unchanged
  • Event payloads unchanged

4. Test First

  • Write failing test that reproduces bug
  • Fix should make test pass
  • No fix without reproduction test

Fix Validation Checklist

Before applying a fix, verify:

  1. Reproduction Test Exists

    • Test fails without fix
    • Test passes with fix
    • Test covers edge cases
  2. Minimal Change

    • Only affected code changed
    • No unrelated refactoring
    • No formatting changes
  3. No Regressions

    • All existing tests pass
    • No new warnings
    • Performance not degraded
  4. Code Quality

    • No new code smells
    • SOLID principles respected
    • DDD patterns maintained
  5. Documentation

    • PHPDoc updated if needed
    • CHANGELOG entry added
    • Issue linked in commit

DDD-Specific Bug Patterns

Domain Layer Bugs

  • Value Object validation bypass
  • Entity invariant violation
  • Aggregate boundary crossing
  • Domain Event lost

Application Layer Bugs

  • Use Case not transactional
  • Command/Query mixing
  • Missing authorization check
  • Event handler not idempotent

Infrastructure Layer Bugs

  • Repository returning detached entity
  • Cache invalidation missing
  • Message not acknowledged
  • Connection not released

Quick Reference: Fix by Error Message

Error MessageLikely BugQuick Fix
"Call to member function on null"Null pointerAdd null check
"Undefined array key"Boundary issueCheck array_key_exists
"Type error: Argument X"Type issueAdd type validation
"Maximum execution time"Infinite loopAdd iteration limit
"Allowed memory exhausted"Resource leakClose resources in finally
"Integrity constraint violation"Race conditionAdd locking/transaction
"Cannot modify readonly property"Immutability violationCreate new instance

よくある質問

AIスキル「Bug Fix Knowledge」では何ができますか?

Bug fix knowledge base. Provides bug categories, symptoms, fix patterns, and minimal intervention principles for PHP 8.4 projects.

TypingMindでBug Fix Knowledgeを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Bug Fix Knowledgeはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにBug Fix Knowledgeをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/dykyi-roman/awesome-claude-code/tree/master/skills/bug-fix-knowledgeを貼り付けてください。TypingMindがSKILL.mdを読み込み、チャットごとに有効にできるスキルとしてインストールします。

Bug Fix Knowledgeを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストの内容がこのスキルの用途に合ったときに、このスキルを読み込めます。

Bug Fix Knowledgeで使えるAIモデルの数に制限はありますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもBug Fix Knowledgeを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Bug Fix Knowledge」は無料ですか?

はい。dykyi-romanがMITライセンスのもとでGitHubに公開しています。ご利用のAIプロバイダーに支払うのは、使用したトークンの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇