ワンクリックで
bug-fix
Structured bug fixing workflow with root cause analysis and regression prevention. Triggers: BF, 修 bug, fix bug, debug, 除錯, 錯誤, error, 問題, issue, 修復, fix, 故障, fault, 異常, exception, 失敗, failure, 不能用, broken, 壞掉.
メニュー
Structured bug fixing workflow with root cause analysis and regression prevention. Triggers: BF, 修 bug, fix bug, debug, 除錯, 錯誤, error, 問題, issue, 修復, fix, 故障, fault, 異常, exception, 失敗, failure, 不能用, broken, 壞掉.
Deep comprehensive code audit across quality, security, architecture compliance, test coverage, and documentation sync. Triggers: AUDIT, 審計, audit, 全面審查, deep review, 深度審查, 健檢, health check, 程式碼審計, codebase audit, 完整檢查, full check.
Check health, freshness, and consistency of all Skills, copilot-instructions.md, chatmodes, and bylaws. Triggers: SHC, health, 健康檢查, skill check, freshness, 翻新, 過期, stale, 檢查 skill, instruction check, audit skills, 技能檢查.
Auto-update CHANGELOG.md following Keep a Changelog format. Triggers: CL, changelog, 變更, 版本, version, 更新日誌, whatsnew, release notes, 發布說明, 變更紀錄, history, 歷史, 更新紀錄, 新功能, new features, breaking changes.
Proactively detect and execute code refactoring to maintain DDD architecture and code quality. Triggers: RF, refactor, 重構, 拆分, split, 模組化, modularize, 太長, cleanup, 整理, clean, 優化, optimize, extract, 提取, simplify, 簡化, 複雜度, complexity, 重組, reorganize, 改善, improve.
Complete code review workflow for PR/MR with multiple reviewers and automated checks. Triggers: PRW, 審查流程, review workflow, PR review, MR review, pull request, merge request, 程式碼審查流程, full review, 完整審查.
Comprehensive code review checking quality, security, and best practices. Triggers: CR, review, 審查, 檢查, check, 看一下, PR, code review, 品質, inspect, 檢視, 看看, 幫看, lint, quality check, 品質檢查, pull request, merge request, MR, diff, 程式碼審查.
| name | bug-fix |
| description | Structured bug fixing workflow with root cause analysis and regression prevention. Triggers: BF, 修 bug, fix bug, debug, 除錯, 錯誤, error, 問題, issue, 修復, fix, 故障, fault, 異常, exception, 失敗, failure, 不能用, broken, 壞掉. |
結構化的 Bug 修復流程,包含根因分析和回歸測試。
┌─────────────────────────────────────────────────────────────┐
│ Bug Fix Workflow │
├─────────────────────────────────────────────────────────────┤
│ Step 1: 🔍 重現 (Reproduce) │
│ ├─ 確認重現步驟 │
│ ├─ 收集錯誤訊息/日誌 │
│ └─ 建立最小重現案例 │
├─────────────────────────────────────────────────────────────┤
│ Step 2: 🎯 定位 (Locate) │
│ ├─ 分析錯誤堆疊 │
│ ├─ 追蹤程式碼路徑 │
│ └─ 識別問題根因 │
├─────────────────────────────────────────────────────────────┤
│ Step 3: 🧪 測試先行 (Test First) │
│ ├─ 撰寫失敗的測試案例 │
│ ├─ 確認測試能重現問題 │
│ └─ 這將成為回歸測試 │
├─────────────────────────────────────────────────────────────┤
│ Step 4: 🔧 修復 (Fix) │
│ ├─ 實施修復 │
│ ├─ 最小化變更範圍 │
│ └─ 確認測試通過 │
├─────────────────────────────────────────────────────────────┤
│ Step 5: ✅ 驗證 (Verify) │
│ ├─ 執行完整測試套件 │
│ ├─ 檢查是否引入新問題 │
│ └─ [code-reviewer] 審查修復 │
├─────────────────────────────────────────────────────────────┤
│ Step 6: 📝 記錄 (Document) │
│ ├─ 更新 Memory Bank │
│ ├─ 記錄根因分析 │
│ └─ 更新相關文檔 │
└─────────────────────────────────────────────────────────────┘
「修 bug:用戶登入時出現 500 錯誤」
AI 執行:
1. 🔍 要求提供錯誤日誌和重現步驟
2. 🎯 分析堆疊追蹤,定位問題
3. 🧪 建立失敗測試案例
4. 🔧 實施修復
5. ✅ 驗證修復
6. 📝 記錄修復過程
「BF: TypeError: 'NoneType' object is not subscriptable at line 45」
AI 執行:
1. 讀取相關檔案的第 45 行
2. 分析為什麼變數是 None
3. 建立邊界條件測試
4. 加入 None 檢查或修正邏輯
## 🐛 Bug 修復報告
### 問題描述
用戶登入時出現 500 Internal Server Error
### 根因分析
- **位置**: `src/application/services/auth_service.py:45`
- **原因**: 當 user 不存在時,直接存取 `user.password_hash` 導致 NoneType 錯誤
- **類型**: 邊界條件未處理
### 修復方案
#### 回歸測試(先撰寫)
```python
def test_login_with_nonexistent_user():
"""登入不存在的用戶應返回 401"""
result = auth_service.login("nonexistent@test.com", "password")
assert result.is_error
assert result.error_code == "USER_NOT_FOUND"
# Before
def login(self, email: str, password: str):
user = self.user_repo.find_by_email(email)
if not bcrypt.verify(password, user.password_hash): # 💥 NoneType!
...
# After
def login(self, email: str, password: str):
user = self.user_repo.find_by_email(email)
if user is None:
return Result.failure("USER_NOT_FOUND")
if not bcrypt.verify(password, user.password_hash):
...
---
## 🎯 根因分類
| 類型 | 描述 | 預防 |
|------|------|------|
| **邊界條件** | 未處理 null/empty/邊界值 | 加強邊界測試 |
| **競爭條件** | 並發存取導致 | 加入鎖定機制 |
| **類型錯誤** | 類型不匹配 | 啟用 strict typing |
| **邏輯錯誤** | 業務邏輯不正確 | 加強 domain 測試 |
| **整合問題** | 外部服務互動 | 加強整合測試 |