スキル一覧に戻る
calvyntwh

rubber-ducking

by calvyntwh

0🍴 0📅 2026年1月20日
GitHubで見るManusで実行

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/else chains
  • for/while loops
  • 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:

  1. "We iterate through the array, stopping one element before the end."
  2. "If the current element is greater than the next element..."
  3. "...we swap them."

3. Goal Alignment Check (CRITICAL)

Compare your English description to the User's stated goal.

User GoalYour TranslationMatch?Action
"Sort the array""We swap adjacent elements if out of order"✅ PartialThis is Bubble Sort. Correct, but inefficient. Note limitation.
"Find the maximum""We swap adjacent elements..."❌ NoSTOP. 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):

  1. "Iterate through the first half of the array."
  2. "Swap element at i with element at len(arr) - i."

Goal Check:

  • Problem: arr[len(arr) - i] when i=0 is arr[len(arr)]IndexError!
  • Fix: Should be arr[len(arr) - 1 - i].

Result: Bug caught before running. No runtime error wasted.

Resources

スコア

総合スコア

55/100

リポジトリの品質指標に基づく評価

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

0/5
タグ

1つ以上のタグが設定されている

0/5

レビュー

💬

レビュー機能は近日公開予定です