用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/UitbreidenOS/UitKit --skill debug命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Guidelines and instructions for Agent execution state rollback rules
Guidelines and instructions for Agent execution step counters limits
Guidelines and instructions for Agent execution timeout limits setups
基于 SOC 职业分类
正在显示 SKILL.md
| name | debug |
| description | Systematic bug isolation: reproduce, hypothesise, narrow, fix, verify — for any language or error type |
1. REPRODUCE — make the bug happen reliably
2. HYPOTHESISE — form a specific, testable theory
3. NARROW — eliminate what can't be the cause
4. FIX — change one thing at a time
5. VERIFY — confirm the fix and check for regressions
Never skip step 1. If you can't reproduce it, you can't verify the fix.
# Turn a vague "it crashes sometimes" into a deterministic test case
def test_reproduces_bug():
# Exact inputs that trigger the bug
result = function_under_test(specific_input_that_fails)
assert result == expected # this should FAIL right now
Questions to answer:
git bisect to find the commit)Bad hypothesis: "Something's wrong with the database" Good hypothesis: "The query returns null when the user has no orders, and we're not handling the null case on line 47"
A good hypothesis is:
# Add temporary print/log statements to find where things go wrong
def process_payment(order):
print(f"[DEBUG] order: {order}") # is this right?
total = calculate_total(order)
print(f"[DEBUG] total: {total}") # is this right?
result = charge_card(order.card, total)
print(f"[DEBUG] charge result: {result}") # is this right?
return result
Binary search approach: if a function has 100 lines and you don't know where the bug is:
# Bad: fixing 3 things at once
# - Changed the query
# - Added null check
# - Updated the cache TTL
# Now you don't know which fix worked
# Good: fix one thing, run tests, commit if green, then fix next
The fix should be the smallest change that makes the test pass. If your fix is more than 10 lines, consider whether you're fixing the root cause or just masking the symptom.
# The test that reproduced the bug should now pass
def test_reproduces_bug():
result = function_under_test(specific_input_that_fails)
assert result == expected # now GREEN
# Add this test to the test suite so the bug never regresses
NullPointerException / AttributeError / TypeError:
# Add type guard before the crash
print(type(obj), repr(obj)) # what is it actually?
assert obj is not None, f"Expected User, got {obj!r}"
Off-by-one:
# Print boundary values
print(f"len={len(items)}, index={index}, range={range(start, end)}")
Race condition / async bug:
import asyncio
# Add sleep to exaggerate timing
await asyncio.sleep(0.1) # does this make the bug more or less likely?
"Works locally, fails in CI":
# Check for environment differences
env | sort > local-env.txt
# Compare with CI env variables
# Common causes: timezone, locale, file paths, missing env vars
Regression — worked before, broken now:
# Find the commit that broke it
git bisect start
git bisect bad HEAD
git bisect good v1.2.0
# Run your reproducer on each bisect step
# git bisect good / git bisect bad until it finds the culprit commit
Flaky test (passes sometimes, fails sometimes):
# Run 20 times to force it to fail consistently
for i in {1..20}; do pytest tests/test_flaky.py -x && echo "pass $i" || echo "FAIL $i" && break; done
/debug
Error: {paste the full error message and stack trace}
Code: {paste the function or file, or give the path}
Reproduction: {exact steps / input that triggers it}
What I've tried: {what you've already ruled out}
Expected: {what should happen}
Actual: {what actually happens}
Traceback (most recent call last):
File "app.py", line 42, in process_order ← outermost caller
total = calculate_total(order)
File "billing.py", line 17, in calculate_total ← intermediate
return sum(item.price for item in order.items)
File "billing.py", line 17, in <genexpr> ← innermost — READ THIS FIRST
AttributeError: 'NoneType' object has no attribute 'price'
Always start from the bottom of a stack trace. The top is where execution began; the bottom is where it crashed.
Error:
KeyError: 'user_id'
File "api/auth.py", line 34, in get_current_user
return User.get(session['user_id'])
Debug session with Claude:
print(session) before line 34 → reveals session = {}session['user_id'] = user.id is there. Check middleware — session.clear() is called on every request due to a misconfigured CORS handlersession.clear() call