AgentSkillsCN

fix-bug

系统性地调查并修复Bug。专注于根源分析与回归预防。

SKILL.md
--- frontmatter
name: fix-bug
description: Systematically investigate and fix bugs. Focuses on root cause analysis and regression prevention.
argument-hint: "<bug-description>"
allowed-tools:
  - Read
  - Write
  - Edit
  - Glob
  - Grep
  - Bash
  - Task

Fix Bug (Systematic Bug Fixing)

Systematically investigate the reported bug, identify the root cause, and fix it.

Step 1: Understand the Bug

  • Organize the bug report
  • Identify reproduction conditions
  • Clarify expected vs actual behavior

Step 2: Root Cause Investigation

Investigate from the following perspectives:

Architecture-Related

  • Is the UDF flow broken (trace the state update path)?
  • Is the ViewModel state updated correctly?
  • Are there issues in the Repository → DataSource data flow?
  • Is the DI scope correct (unexpected instance sharing)?

Lifecycle-Related

  • Inconsistencies during Activity/Fragment state transitions
  • State loss on configuration change (rotation)
  • Resource release leaks (Camera, Listener, Receiver, etc.)
  • Issues with LifecycleOwner scope

Compose-Related

  • State not updating correctly (mutableStateOf vs MutableStateFlow)
  • Recomposition timing issues
  • remember key is incorrect, referencing stale values
  • Side effect execution order
  • LaunchedEffect not re-executing because key doesn't change

Async/Concurrency-Related

  • UI updates from non-main thread
  • Coroutine cancellation handling
  • Race conditions
  • Coroutine launched outside viewModelScope

Data-Related

  • Null pointer (bypassing Kotlin null safety)
  • Type mismatch, invalid casting
  • Missing handling for empty collections

Step 3: Fix

  • Apply the minimum change needed to fix the issue
  • Follow existing architecture patterns
  • Add comments explaining the fix rationale (only for complex fixes)

Step 4: Verification

bash
./gradlew assembleDebug   # Build check
./gradlew test            # Regression check
  • Add regression tests if needed

Step 5: Fix Report

code
## Bug Fix Report
- **Root Cause**: Root cause description
- **Fix**: What was changed
- **Impact**: Impact on other features
- **Tests**: Tests added/verified
- **Prevention**: Suggestions to prevent recurrence (if any)

Target Bug

$ARGUMENTS