
rubber-ducking
by calvyntwh
SKILL.md
name: rubber-ducking description: Logic validation by verbalization. Translate code to plain English to catch semantic errors. Use before running complex logic or when debugging "it should work" failures. license: MIT
Rubber Ducking (The Logic Validator)
"By the time you've explained the problem to the duck, you've often solved it yourself." - The Pragmatic Programmer (1999)
When to Use
- Before Running: When you have written complex logic (loops, conditionals, state machines).
- Debugging: When "it should work" but produces wrong output.
- Code Review: When reviewing your own generated code before presenting it.
The Protocol: Explain It to the Duck
Constraint: You must be able to explain the code in plain English. If you cannot, you do not understand it.
1. Identify the Block
Select the complex code segment. Focus on:
if/elsechainsfor/whileloops- Business logic calculations
- State transitions
2. Translate to English
Write a plain English sentence for each logical step.
Example:
for i in range(len(arr) - 1):
if arr[i] > arr[i + 1]:
arr[i], arr[i + 1] = arr[i + 1], arr[i]
Translation:
- "We iterate through the array, stopping one element before the end."
- "If the current element is greater than the next element..."
- "...we swap them."
3. Goal Alignment Check (CRITICAL)
Compare your English description to the User's stated goal.
| User Goal | Your Translation | Match? | Action |
|---|---|---|---|
| "Sort the array" | "We swap adjacent elements if out of order" | ✅ Partial | This is Bubble Sort. Correct, but inefficient. Note limitation. |
| "Find the maximum" | "We swap adjacent elements..." | ❌ No | STOP. The code does not achieve the goal. Rewrite. |
4. The Verdict
- If Match: Proceed to run/save the code.
- If Mismatch: Do NOT run. Fix the logic first. The translation revealed the bug.
Example: The Off-By-One Bug
User Goal: "Reverse the array in place."
Code:
def reverse(arr):
for i in range(len(arr) // 2):
arr[i], arr[len(arr) - i] = arr[len(arr) - i], arr[i]
return arr
Translation (Ducking):
- "Iterate through the first half of the array."
- "Swap element at
iwith element atlen(arr) - i."
Goal Check:
- Problem:
arr[len(arr) - i]wheni=0isarr[len(arr)]→ IndexError! - Fix: Should be
arr[len(arr) - 1 - i].
Result: Bug caught before running. No runtime error wasted.
Resources
Score
Total Score
Based on repository quality metrics
SKILL.mdファイルが含まれている
ライセンスが設定されている
100文字以上の説明がある
GitHub Stars 100以上
3ヶ月以内に更新がある
10回以上フォークされている
オープンIssueが50未満
プログラミング言語が設定されている
1つ以上のタグが設定されている
Reviews
Reviews coming soon