diagnosing-bugs
Diagnosis loop for hard bugs and regressions. Use when the user says diagnose or debug this, or reports something broken, throwing, failing, or slow.
- License 许可
- MIT
- 最近更新
- 2026-11-01
- Stars
- ★ 5
- Forks
- 0
01 前言 Front Matter
- name
- diagnosing-bugs
- description
- Diagnosis loop for hard bugs and regressions. Use when the user says diagnose or debug this, or reports something broken, throwing, failing, or slow.
03 SKILL.md 正文
Diagnosing Bugs
A discipline for hard bugs. Skip phases only when explicitly justified.
When exploring, read docs/architecture.md (seam model + hydration lifecycle) for module vocabulary before forming hypotheses.
Feedback loops (prefer in order):
- Failing
bun test— co-locatedsrc/**/*.test.tsat the unit/codec/backend seam (fastest; no DOM) bun run test:dom—tests-dom/**/*.test.tsxforuseHydratedrerender / unmount-detach /useSyncExternalStorereactivity- Isolated storage-codec harness — construct a
PersistStorageover an in-memoryStateStorageand drivepersistSourceagainst a fake source to reproduce cross-tab / throttle / migrate paths without a real browser - Real backend in a DOM runner —
localStorage(sync) oridb-keyval(async) inside the vitest jsdom suite when the bug only shows against a real storage backend - Captured trace replay — a recorded
CrossTabStorageEventpayload or agetStatesequence replayed through the isolated harness
Phase 1 — Build a feedback loop
This is the skill. Spend disproportionate effort here. A tight pass/fail signal for this bug beats staring at code.
Done when you can name one command that is red-capable, deterministic, fast, and agent-runnable (bun test <file> or bun run test:dom -- <pattern>). No red-capable command → no Phase 2.
Phase 2 — Reproduce + minimise
Run the loop; shrink to the smallest scenario that still goes red. Every remaining element must be load-bearing — one codec, one backend, one source, one setState sequence.
Done when: minimal repro documented; non-load-bearing steps removed.
Phase 3 — Hypothesise
Generate 3–5 ranked, falsifiable hypotheses. Show the list to the user before testing. Bias toward the seams: sync-vs-async getItem branch, hydration gate ordering, throttle trailing edge, migrate version mismatch, cross-tab raw identity compare, codec encode/decode asymmetry.
Done when: user has seen ranked list before any fix attempt.
Phase 4 — Instrument
One variable at a time. Tag debug logs [DEBUG-xxxx] for cleanup. Perf bugs (write loop, cross-tab listener, hydrate read path): measure first, then bisect.
Done when: one hypothesis confirmed or all falsified with evidence.
Phase 5 — Fix + regression test
Regression test before the fix when a correct seam exists — co-locate under src/ (bun test) or tests-dom/ (test:dom) per the test matrix in docs/architecture.md. If no seam exists to test through, document that as an architectural finding (a shallow module worth deepening behind a smaller interface) and track it in docs/roadmap.md.
Done when: loop is green; regression test added or gap documented.
Phase 6 — Cleanup + post-mortem
Remove [DEBUG-...] logs, delete throwaway harnesses, state the winning hypothesis in the commit message. If prevention needs an architecture change, record specifics in docs/roadmap.md.
Done when: no debug sediment; commit message states root cause.
Reference
tracer-bullets·verify-after-each-step·harden-pr(lite on the fix commit)docs/architecture.md— seam model, hydration lifecycle, test matrix
04 同仓库更多 Skills
vue-persist
Gate Vue 3 UI on Persist hydration with useHydrated (shallowRef). Use in setup/effectScope when avoiding flash of default state on async backends.
svelte-store-persist
Gate Svelte store-based UI on Persist hydration with hydratedStore (Readable). Use for Svelte 3–4 or Svelte 5 apps that still use stores; runes UI → svelte-persist.
svelte-persist
Gate Svelte 5 runes UI on Persist hydration with hydratedRune (.current). Use for Svelte 5; for stores / Svelte 3–4 use svelte-store-persist.
solid-persist
Gate Solid UI on Persist hydration with useHydrated (Accessor). Use when avoiding flash of default state on async backends; read hydrated() in reactive scopes.
react-persist
Gate React UI on Persist hydration with useHydrated + toHydrationSignal. Use when avoiding flash of default state on async backends (IndexedDB), SSR snapshot true, or wiring HydrationSignal into React 18/19.
preact-persist
Gate Preact UI on Persist hydration with useHydrated (preact/compat useSyncExternalStore). Use when avoiding flash of default state on async backends or wiring HydrationSignal into Preact.