Fix — Sửa bug
Phân tích và sửa bug tự động. Tuân thủ nguyên tắc: tìm root cause TRƯỚC, fix SAU. Tự động detect loại bug và chọn strategy phù hợp.Cập nhật bộ claudekit mới: Các lệnh
/fix:test, /fix:ui, /fix:ci, /fix:types, /fix:hard, /fix:fast, /fix:logs, /fix:parallel đã bỏ. Thay bằng /fix (auto-route theo mô tả), /investigate (iron law: no fix without root cause), /verify (confirm fix works). Xem cấu trúc skill mới để biết đầy đủ.Cú pháp
Luồng hoạt động bên trong
Khi bạn gõ/fix "API returns 500 when creating order", đây là 6 bước xảy ra:
1
Bước 1: Scout (BẮT BUỘC — không bao giờ skip)
Kích hoạt
ck:scout skill HOẶC spawn 2-3 Explore subagents song song.
Mục tiêu: hiểu codebase TRƯỚC khi đưa ra giả thuyết.- Tìm: affected files, dependencies, related tests, recent changes (git log)
- Đọc
./docsnếu chưa quen project
Step 1: Scouted — 12 files mapped, 5 dependencies, 3 tests found2
Bước 2: Diagnose (BẮT BUỘC — không bao giờ skip)
Phân tích root cause có hệ thống. KHÔNG đoán.
- Ghi lại pre-fix state: error messages, failing test output, stack traces
- Kích hoạt
ck-debugskill (systematic debugging + root cause tracing) - Kích hoạt
ck:sequential-thinking— hình thành giả thuyết qua lý luận - Spawn
Exploreagents song song test từng giả thuyết - Nếu 2+ giả thuyết sai → tự động kích hoạt
ck:problem-solving - Tạo diagnosis report: confirmed root cause, evidence chain
Step 2: Diagnosed — Root cause: missing Site relation in Prisma include, Evidence: stack trace line 423
Bước 3: Complexity Assessment
Phân loại độ phức tạp trước khi chọn workflow:
4
Bước 4: Fix Implementation
Implement fix dựa trên diagnosis findings.
Fix ROOT CAUSE, không fix triệu chứng.
Minimal changes, follow patterns hiện có.
5
Bước 5: Verify + Prevent (BẮT BUỘC)
- Verify: Chạy ĐÚNG commands từ pre-fix state. So sánh output.
- Regression test: Thêm/update test cho issue vừa fix. Test PHẢI fail nếu bỏ fix.
- Prevention gate: Thêm defense-in-depth nếu applicable.
- Parallel verification: Typecheck + lint + build + test chạy song song.
Step 5: Verified — before: HTTP 500, after: HTTP 201, 2 tests added, 1 guard added6
Bước 6: Finalize (BẮT BUỘC)
- Report summary: confidence score, root cause, changes, files, prevention
docs-managersubagent cập nhật./docs/- Hỏi user commit qua
git-managersubagent - Viết journal entry
Hard Gate: KHÔNG được đề xuất hay implement fix trước khi hoàn thành Bước 1-2 (Scout + Diagnose). Fix triệu chứng là THẤT BẠI. Tìm root cause trước.
Ví dụ thực tế
- Input
- Output
So sánh với chat trực tiếp
Khi nào dùng / không dùng
Quy trình Fix chính
/fix "mô tả" — Intelligent Routing & Auto-Fix
Tự động detect loại bug từ mô tả, chạy scout + diagnose + fix + verify:
type,typescript,error TS→ TypeScript fixui,layout,responsive,css→ UI/CSS fixgithub actions,ci/cd,build failed→ CI/CD analysis + fixtest,jest,failing test→ Test fixlogs,error logs,stack trace→ Log analysis + fixrace condition,concurrent,complex→ Deep analysis + brainstorm- Default → Auto-detect based on codebase context
/investigate "mô tả" — Iron Law: Find Root Cause FIRST
Phá vỡ assumption, tìm root cause trước khi fix bất kỳ thứ gì.
- Bắt buộc scout (understand codebase)
- Bắt buộc diagnose (find evidence chain)
- NO fix until root cause confirmed
/verify — Confirm Fix Works
Chạy tests, typecheck, linting, build → xác nhận fix không gây lỗi mới:
/fix hoặc manual fix, cần xác nhận không gây regression.
Lưu ý & Best Practices
Sai lầm phổ biến:
- Fix triệu chứng thay vì root cause → bug quay lại tuần sau
- Không viết regression test → same bug tái phát khi refactor
- Skip
/investigatecho bugs phức tạp → fix sai hướng - Không chạy
/verifysau khi fix → regression bugs lọt vào production
Tips từ team:
- Bugs phức tạp? Dùng
/investigateTRƯỚC/fix - Luôn kết thúc bằng
/verify— xác nhận fix không gây lỗi mới - Viết test reproduce bug — đảm bảo fix đúng chỗ
- Nếu bug quay lại → dùng
/investigateđể tìm root cause thực sự
Quy trình fix khuyên dùng
1
Investigate (nếu nghi ngờ root cause)
2
Fix
3
Verify
Chi tiết lệnh Fix (Accordion)
/fix — Intelligent auto-routing & fix
/fix — Intelligent auto-routing & fix
Prefix: Skill auto-detects từ keywords và codebase context:
/fix "bug description"Tự động detect loại bug từ mô tả, chạy scout → diagnose → fix → verify. Không bao giờ fix mà không biết root cause.- TypeScript errors → typecheck + fix type definitions
- UI/layout issues → CSS analysis + responsive fix
- CI/CD failures → GitHub Actions logs analysis
- Test failures → test code + source code diagnosis
- Performance → profiling + optimization
- Complex bugs → deep analysis + architecture review
/investigate — Iron law: root cause FIRST
/investigate — Iron law: root cause FIRST
Prefix: Output: Detailed diagnosis report + root cause + evidence (NO code changes).Khi dùng:
/investigate "bug description"Phá vỡ assumptions, tìm confirmed root cause không implement fix.- Bắt buộc scout (hiểu codebase)
- Bắt buộc diagnose (tìm evidence chain)
- Report root cause + evidence
- Bugs phức tạp, không chắc root cause
- Cần deep understanding trước fix
- Multiple hypotheses, need evidence-based confirmation
/verify — Confirm fix works
/verify — Confirm fix works
Prefix: Output:
/verifyChạy tests, typecheck, linting, build → so sánh before/after.- Test results (number passed/failed)
- Type check: strict mode pass?
- Linting: warnings/errors?
- Build: successful?
- Regression check: new failures introduced?
/fix hoặc manual code changes, xác nhận không gây regression.