debug_logic_buglisted
Install: claude install-skill feralbureau/luminy
# debug_logic_bug
Logic bugs are the hardest class of bugs to find because the program runs — it just does the wrong thing. There's no error message to guide you. You have to reason about what the code *should* do versus what it *actually* does, and find where they diverge.
## The Fundamental Approach: Binary Search on the Truth
The code produces a wrong result. That wrong result was computed somewhere. Your job is to find the earliest point in the computation where the value becomes incorrect. The most efficient way to do this is binary search:
1. Find the output (wrong value).
2. Find the input (correct value at the start).
3. Check the midpoint — is the value correct there?
4. If correct at midpoint: the bug is in the second half. If wrong at midpoint: the bug is in the first half.
5. Repeat until you've isolated a single function or operation that corrupts the value.
This is faster than reading every line top-to-bottom, especially in large codebases.
## Step 1: Write Down What You Expect
Before reading any code, write down (or say aloud) exactly what you expect:
- What is the input?
- What should the output be?
- What's the actual output?
This sounds obvious but it's often skipped. If you can't state the expected output precisely, you can't find the bug.
**Example:**
```
Input: order with 3 items at $10, $20, $30 = $60, coupon code SAVE10 (10% off)
Expected: $54.00
Actual: $60.00 (discount not applied)
```
## Step 2: Add Observation Points
Add logging/print sta