[FEATURE] Proactive Pattern-Matching After Bug Fixes
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
Summary:
When Claude fixes a bug, it should automatically search for similar patterns in the codebase and fix all instances in one go, rather than fixing each occurrence reactively as it fails.
Proposed Solution
Proposed Addition to System Instructions:
After fixing any bug, proactively search for similar patterns:
- Immediately use Grep/Glob to find functions with a similar structure
- Check if the same bug exists in multiple places
- Fix all instances in a single commit
- Explain what you searched for and what you found
Example triggers:
- Fixed a recursive function → search for other recursive functions
- Fixed SQL injection → search for other SQL queries
- Fixed race condition → search for other concurrent operations
- Fixed array mutation → search for other array modifications
- Fixed cache invalidation → search for other cache operations
Don't wait for the user to ask, "Are there other places with this bug?" - find them proactively.
Benefits:
- Reduces debugging cycles (one fix instead of multiple versions)
- Catches bugs before they manifest
- Demonstrates thoroughness and systematic thinking
- Saves user time
Impact:
In our case, this would have saved an entire debug → fix → test → deploy cycle. For production systems, catching all instances of a bug pattern in one pass could prevent customer-facing failures.
Alternative Solutions
Right now, I ask for it to do it every time.
Priority
High - Significant impact on productivity
Feature Category
Performance and speed
Use Case Example
While debugging a WordPress plugin, Claude fixed this bug in delete_element_recursive():
// BEFORE (broken):
foreach ($elements as $index => $element) {
...
$this->delete_element_recursive($element['elements'], $id); // ❌ Passes copy
}
// AFTER (fixed):
foreach ($elements as $index => $element) {
...
$this->delete_element_recursive($elements[$index]['elements'], $id); // ✅ Passes reference
}
Root cause: Classic PHP pass-by-value bug - $element is a copy, so $element['elements'] is also a copy. Modifications to the copy get discarded.
After fixing this in v1.5.8, Claude committed and moved on.
What should have happened:
Claude should have immediately searched for the same pattern:
Search for similar recursive patterns
grep -n "foreach.as.element\)" *.php
grep -n "->._element.\(\$element\[" *.php
This would have found extract_element() with the same bug one function away. Instead, it was fixed a version later (v1.5.9) only after I asked, "Do we need to fix this anywhere else?"
Additional Context
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗