Best for
- Use this skill when debugging applications, investigating test failures, analyzing error reports, tracing runtime issues, or performing root cause analysis.
ArabelaTso/Skills-4-SE/skills/bug-localization/SKILL.md
Identify the precise location of bugs in source code, modules, and systems. Use this skill when debugging applications, investigating test failures, analyzing error reports, tracing runtime issues, or performing root cause analysis. Analyzes stack traces, error messages, failing tests, and code patterns to pinpoint buggy functions, classes, files, or modules with confidence rankings and supporting evidence.
Decision brief
Precisely identify the location of bugs in source code by analyzing error messages, stack traces, failing tests, and code patterns. Provides ranked suspect locations with confidence scores and evidence.
Compatibility matrix
| Platform | Status | Evidence | What to check |
|---|---|---|---|
| Codex | Not declared | No explicit evidence | Portability before use |
| Claude Code | Not declared | No explicit evidence | Portability before use |
| Cursor | Not declared | No explicit evidence | Portability before use |
| Gemini CLI | Not declared | No explicit evidence | Portability before use |
Installation
The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.
npx skills add https://github.com/ArabelaTso/Skills-4-SE --skill "skills/bug-localization"Inspect the Agent Skill "bug-localization" from https://github.com/ArabelaTso/Skills-4-SE/blob/4f38503747e0617504bce5329283ef837d375c09/skills/bug-localization/SKILL.md at commit 4f38503747e0617504bce5329283ef837d375c09. List every install step, command, network request, credential, file read/write, external action, and rollback step. Explain whether it fits my task. Do not install or execute anything until I approve.
Workflow
Collect all available information:
Collect all available information:
Understand what caused the error:
Identify likely buggy locations:
Assign confidence scores:
Permission review
No configured static risk pattern was detected
This is not proof of safety. Runtime behavior, indirect dependencies, and hidden external systems are outside the static scan.
Evidence record
| Signal | Value | Evidence type | Meaning |
|---|---|---|---|
| Quality score | 90/100 | Computed | Documentation, specificity, maintenance, and trust rules |
| Repository stars | 236 | Source | Repository attention, not individual Skill quality |
| Compatibility | 0 platforms | Source | Declared in the catalog source record |
| Usage guide | automated source guide | Editorial | Generated or reviewed according to the visible evidence level |
Pinned source
Precisely identify the location of bugs in source code by analyzing error messages, stack traces, failing tests, and code patterns. Provides ranked suspect locations with confidence scores and evidence.
Extract information from error sources:
Examine code for bug indicators:
Prioritize likely bug locations:
Provide actionable next steps:
Collect all available information:
From stack trace:
Traceback (most recent call last):
File "app.py", line 45, in process_order
total = calculate_total(items)
File "billing.py", line 23, in calculate_total
price = item['price'] * item['quantity']
KeyError: 'price'
Extract:
KeyError'price'billing.py:23app.py:45 → billing.py:23calculate_totalFrom failing test:
FAILED tests/test_auth.py::test_login_with_valid_credentials
AssertionError: assert False is True
Expected: User logged in successfully
Actual: Login failed with invalid credentials
Extract:
tests/test_auth.pytest_login_with_valid_credentialsUnderstand what caused the error:
For KeyError example:
For login test failure:
Identify likely buggy locations:
Primary suspects (KeyError):
1. billing.py:23 (95% confidence)
- Direct location of exception
- Line: price = item['price'] * item['quantity']
- Issue: No validation before dict access
2. app.py:40-45 (70% confidence)
- Calls calculate_total with items
- Possible: Items data structure incorrect
- Need to verify items content
3. Data source (50% confidence)
- Where items are created/loaded
- Possible: Missing field in data
- Check database schema or API response
Code locations to examine:
# billing.py:20-25 (Primary suspect)
def calculate_total(items):
total = 0
for item in items:
price = item['price'] * item['quantity'] # Line 23 - BUG HERE
total += price
return total
# app.py:40-45 (Secondary suspect)
def process_order(order_id):
order = get_order(order_id)
items = order.get('items', [])
total = calculate_total(items) # Line 45
return total
Assign confidence scores:
Ranking factors:
Example ranking:
Rank 1: billing.py:23 in calculate_total() - 95%
Evidence:
- Direct exception location
- No null/existence check before dict access
- Simple fix: Add key validation
Rank 2: app.py:45 in process_order() - 70%
Evidence:
- Calls buggy function
- items might be malformed
- Check: order.get('items') might return bad data
Rank 3: models.py:78 in get_order() - 50%
Evidence:
- Data source for items
- Possible missing fields in database
- Check: Database schema and migrations
Rank 4: api.py:112 in create_order() - 30%
Evidence:
- Creates order data
- Might not include all required fields
- Check: API contract validation
Guide debugging efforts:
Immediate actions:
billing.py:23itemitems contains at app.py:45Verification steps:
print(f"Item: {item}") before line 23Long-term fixes:
Error:
Traceback (most recent call last):
File "main.py", line 100, in run
result = processor.execute()
File "processor.py", line 45, in execute
data = self.transform(input_data)
File "processor.py", line 78, in transform
return data.upper()
AttributeError: 'NoneType' object has no attribute 'upper'
Analysis:
Stack trace (bottom to top):
1. processor.py:78 - data.upper() fails (EXCEPTION POINT)
2. processor.py:45 - self.transform(input_data) called
3. main.py:100 - processor.execute() triggered
Primary suspect: processor.py:78
- Directly referenced in error
- Calls .upper() on None
- Confidence: 95%
Secondary suspect: processor.py:45
- Passes input_data to transform
- input_data might be None
- Confidence: 80%
Tertiary suspect: main.py:100
- Initial call site
- Processor initialization might be wrong
- Confidence: 40%
Localization:
# processor.py:75-80 (PRIMARY SUSPECT - 95%)
def transform(self, data):
if data is None: # MISSING CHECK
return ""
return data.upper() # Line 78 - Bug location
# processor.py:43-46 (SECONDARY - 80%)
def execute(self):
input_data = self.get_input() # Might return None
data = self.transform(input_data) # Line 45
return self.process(data)
# main.py:98-101 (TERTIARY - 40%)
def run(self):
processor = Processor(config)
result = processor.execute() # Line 100
return result
Evidence:
AttributeError on line 78data is None.upper()Failing test:
def test_calculate_discount():
# Given
price = 100.0
discount_percent = 20.0
# When
result = calculate_discount(price, discount_percent)
# Then
assert result == 80.0 # FAILS: result is 120.0
Analysis:
Test expectation: 80.0
Actual result: 120.0
Difference: +40 (opposite direction)
Hypothesis:
- Expected: price - (price * discount / 100) = 100 - 20 = 80
- Actual: price + (price * discount / 100) = 100 + 20 = 120
- Likely bug: Using + instead of -
Localization:
# utils.py:15-20 (PRIMARY SUSPECT - 98%)
def calculate_discount(price, discount_percent):
discount_amount = price * (discount_percent / 100)
# Bug: Should be subtraction, not addition
return price + discount_amount # Line 18 - WRONG OPERATOR
# Should be: return price - discount_amount
Evidence:
Error:
IndexError: list index out of range
File "search.py", line 56, in find_median
median = sorted_list[len(sorted_list) / 2]
Analysis:
Error type: IndexError
Location: search.py:56
Expression: sorted_list[len(sorted_list) / 2]
Issues identified:
1. Division result might be float (Python 3)
2. Index calculation might be off-by-one
3. Empty list not handled
Confidence: 99% - obvious bug
Localization:
# search.py:52-58 (PRIMARY SUSPECT - 99%)
def find_median(numbers):
sorted_list = sorted(numbers)
# BUG 1: len() / 2 returns float in Python 3
# BUG 2: No empty list check
# BUG 3: Even-length list not handled
median = sorted_list[len(sorted_list) / 2] # Line 56
return median
# CORRECT VERSION:
def find_median(numbers):
if not numbers:
raise ValueError("Cannot find median of empty list")
sorted_list = sorted(numbers)
n = len(sorted_list)
mid = n // 2 # Integer division
if n % 2 == 0:
# Even length: average of middle two
return (sorted_list[mid - 1] + sorted_list[mid]) / 2
else:
# Odd length: middle element
return sorted_list[mid]
Evidence:
Bug report:
Issue: Users are seeing incorrect order totals
Expected: Total = sum of (price * quantity) for each item
Actual: Total is always just the price of the last item
Example:
Item 1: $10 × 2 = $20
Item 2: $15 × 1 = $15
Expected total: $35
Actual total: $15
Analysis:
Pattern: Total equals last item only
Hypothesis: Loop variable overwriting instead of accumulating
Suspects:
1. Total calculation loop (HIGH)
2. Item price calculation (LOW)
3. Database query (LOW)
Localization:
# orders.py:34-40 (PRIMARY SUSPECT - 90%)
def calculate_order_total(items):
total = 0
for item in items:
item_total = item.price * item.quantity
total = item_total # Line 38 - BUG: Should be +=
# Should be: total += item_total
return total
# Evidence:
# - total = item_total overwrites instead of adds
# - Result matches last item only
# - Classic accumulation bug
Fix:
def calculate_order_total(items):
total = 0
for item in items:
item_total = item.price * item.quantity
total += item_total # FIXED: Use +=
return total
Bug report:
Issue: Intermittent race condition
Symptom: Counter value incorrect under high load
Expected: counter = 1000 after 1000 increments
Actual: counter = 987 (varies)
Analysis:
Characteristics:
- Non-deterministic (varies each run)
- Happens under concurrent access
- Counter less than expected (lost updates)
Root cause: Race condition in increment operation
Localization:
# counter.py:15-20 (PRIMARY SUSPECT - 95%)
class Counter:
def __init__(self):
self.value = 0
def increment(self):
# BUG: Non-atomic read-modify-write
temp = self.value # Read
temp = temp + 1 # Modify
self.value = temp # Write
# Race condition: Another thread can modify between read and write
# Evidence:
# - Symptom matches race condition
# - No synchronization
# - Multiple threads accessing shared state
# FIX:
import threading
class Counter:
def __init__(self):
self.value = 0
self.lock = threading.Lock()
def increment(self):
with self.lock:
self.value += 1 # Atomic under lock
For large codebases, narrow down location:
1. Identify entry point and exception point
2. Find midpoint in call chain
3. Add logging/breakpoint at midpoint
4. Run to see if bug is before or after
5. Repeat on relevant half
Track variable values through execution:
1. Identify problematic variable (e.g., None value)
2. Trace backwards to find where it's set
3. Check each assignment point
4. Find where it becomes incorrect
Example:
# Trace None value backwards
data = transform(input) # 3. input is None, where from?
input = get_data(source) # 2. get_data returns None, why?
source = config.get('src') # 1. config.get returns None - BUG HERE
Compare working vs broken code:
1. Find a working version (git history)
2. Identify what changed
3. Focus on changed code
4. Bug likely in recent modifications
Form and test hypotheses:
1. List possible causes
2. For each, predict what evidence would prove it
3. Gather evidence (logging, debugging)
4. Eliminate hypotheses that don't match
5. Focus on remaining candidates
Indicators:
Indicators:
Indicators:
Indicators:
## Bug Localization Report
### Summary
[One-line description of the bug]
### Evidence
- Error type: [Exception/Assertion/Logic error]
- Error message: [Full message]
- Location: [File:line where error occurs]
- Test case: [Failing test if applicable]
### Primary Suspect (XX% confidence)
**Location:** [file:line]
**Function:** [function_name]
**Issue:** [Description of suspected bug]
**Evidence:**
- [Evidence item 1]
- [Evidence item 2]
**Code snippet:**
```[language]
[Relevant code with bug location marked]
Suspect 2 (XX% confidence) [Similar format]
Suspect 3 (XX% confidence) [Similar format]
[Brief description of how to fix]
[Other code that might be affected]
### Example Report
```markdown
## Bug Localization Report
### Summary
KeyError when calculating order total due to missing 'price' field in item dict
### Evidence
- Error type: KeyError
- Error message: KeyError: 'price'
- Location: billing.py:23 in calculate_total()
- Call chain: app.py:45 → billing.py:23
### Primary Suspect (95% confidence)
**Location:** billing.py:23
**Function:** calculate_total
**Issue:** No validation before accessing item['price']
**Evidence:**
- Direct exception location
- No null/existence check
- Simple dict access without safety
**Code snippet:**
```python
def calculate_total(items):
total = 0
for item in items:
price = item['price'] * item['quantity'] # ← BUG HERE
total += price
return total
Suspect 2 (70% confidence) Location: app.py:45 Function: process_order Issue: items data might be malformed Code:
items = order.get('items', [])
total = calculate_total(items) # Passes potentially bad data
Suspect 3 (50% confidence) Location: models.py:78 Function: get_order Issue: Database might be missing 'price' field
print(f"Item structure: {item}") before line 23def calculate_total(items):
total = 0
for item in items:
# Add validation
if 'price' not in item or 'quantity' not in item:
raise ValueError(f"Invalid item: {item}")
price = item['price'] * item['quantity']
total += price
return total
## Best Practices
1. **Start with evidence** - Don't guess, analyze error messages and traces
2. **Use confidence scores** - Quantify certainty, don't claim absolute knowledge
3. **Provide multiple suspects** - Bugs aren't always where they appear
4. **Show your reasoning** - Explain why each location is suspect
5. **Suggest verification** - How to confirm the bug location
6. **Consider context** - Recent changes, code complexity, bug history
7. **Think systematically** - Use data flow, control flow, and call graphs
8. **Prioritize** - Focus on highest-confidence locations first
9. **Be specific** - File:line precision, not just "somewhere in this module"
10. **Recommend next steps** - Debugging strategies, not just identification
Frequently asked questions
Precisely identify the location of bugs in source code by analyzing error messages, stack traces, failing tests, and code patterns. Provides ranked suspect locations with confidence scores and evidence.
The source record exposes this install command: npx skills add https://github.com/ArabelaTso/Skills-4-SE --skill "skills/bug-localization". Inspect the command and pinned source before running it.
Alternatives
mgiovani/cc-arsenal
Run the checks a GitHub Actions workflow would run, locally, when Actions is unavailable or out of quota. Parses .github/workflows/*.yml, extracts the jobs/steps that gate merges (lint, typecheck, test, build), translates them to local commands respecting the workflow's pinned node/python versions and env, executes them sequentially, and reports a parity table of what passed locally vs. what can't be replicated (service containers, secrets, matrix dimensions) and why. Activates on "CI quota", "A
synthetic-sciences/openscience
Comprehensive healthcare AI toolkit for developing, testing, and deploying machine learning models with clinical data. This skill should be used when working with electronic health records (EHR), clinical prediction tasks (mortality, readmission, drug recommendation), medical coding systems (ICD, NDC, ATC), physiological signals (EEG, ECG), healthcare datasets (MIMIC-III/IV, eICU, OMOP), or implementing deep learning models for healthcare applications (RETAIN, SafeDrug, Transformer, GNN).
narrative-io/narrative-skills-marketplace
Translate a fuzzy analytical question into a rigorous investigation plan. Interrogates the ask, grounds the plan in the available data dictionary, applies analytical best practices, and produces a structured brief of query specifications for a downstream query-writing skill. Plans, does not write SQL. Use when: "why did X drop", "is there a relationship between A and B", "who are our highest-value customers", "what's driving the change in Y", "investigate this trend", "design an analysis for", "
ZaxbyHub/opencode-swarm
Evidence-first investigation and full resolution of issues and bugs. Use when asked to investigate, trace, root-cause, reproduce, plan, fix, resolve, close, or prepare a PR for an issue, bug report, defect, regression, failing test, crash, or confusing runtime behavior. Drives intake, reproduction, reasoning-guided localization, no-gap fix planning, independent critic and implementation review, recurrence-class eradication, and invariant-aware PR-ready closure under a mandatory full-resolution c