Skip to content
Development
Command

/bug-fix

Systematic bug investigation and fix workflow with GitHub integration

From plugin
claude-cmd
313180 skills180 commands

How it fires

How this command gets triggered: by you, by Claude, or both.

  • Fires itselfClaude auto-loads it when your prompt matches the work.
  • You can call itInvoke it directly when you want it.
  • Slash command/bug-fix

Context preview

What this command does when you run it.

Systematic bug investigation and fix workflow with GitHub integration

Command definition

bug-fix.md
allowed-tools: Bash(git:*), Bash(gh:*), Read, Write, Edit, MultiEdit, Task, Bash(gdate:*)
name: "Bug Fix"
description: "Systematic bug investigation and fix workflow with GitHub integration"
author: "wcygan"
tags: ["code","fix"]
version: "1.0.0"
created_at: "2025-07-14T00:00:00Z"
updated_at: "2025-07-14T00:00:00Z"

Context

  • Session ID: !`gdate +%s%N`
  • Current directory: !`pwd`
  • Git status: !`git status --porcelain || echo "Not a git repository"`
  • Current branch: !`git branch --show-current 2>/dev/null || echo "No git repository"`
  • Recent commits: !`git log --oneline -5 2>/dev/null || echo "No git history"`
  • Working directory status: !`git diff --name-only 2>/dev/null | wc -l | tr -d ' ' || echo "0"` modified files
  • Open issues: !`gh issue list --state open --json number,title --limit 5 2>/dev/null || echo "[]"`
  • Repository info: !`git remote get-url origin 2>/dev/null || echo "No remote origin"`

Your Task

Fix the bug described in: **$ARGUMENTS**

STEP 1: Bug Analysis and State Initialization

  • Initialize session state file: /tmp/bug-fix-state-$SESSION_ID.json
  • Parse bug description and extract key details
  • Think deeply about potential root causes and affected systems
  • FOR complex bugs: Use extended thinking to analyze the problem systematically
// /tmp/bug-fix-state-$SESSION_ID.json
{
  "sessionId": "$SESSION_ID",
  "timestamp": "ISO_8601_TIMESTAMP",
  "bug": "$ARGUMENTS",
  "phase": "analysis",
  "analysis": {
    "rootCause": null,
    "affectedFiles": [],
    "reproductionSteps": [],
    "priority": "normal"
  },
  "workflow": {
    "issueNumber": null,
    "branchName": null,
    "prNumber": null,
    "fixApplied": false
  },
  "checkpoints": {
    "analysis_complete": false,
    "issue_created": false,
    "branch_created": false,
    "fix_implemented": false,
    "tests_verified": false,
    "pr_created": false
  }
}

STEP 2: Repository Validation and Preparation

TRY:

  • Verify we're in a git repository
  • Check for clean working directory OR warn about uncommitted changes
  • Ensure gh CLI is authenticated: gh auth status

CATCH (git not available):

  • Exit with error: "This command requires a git repository"

CATCH (gh not authenticated):

  • Provide authentication instructions: gh auth login

STEP 3: GitHub Issue Creation

IF issue doesn't already exist:

  • Create descriptive GitHub issue with bug details
  • Use template format:
  ## Bug Description
  [Bug description from $ARGUMENTS]

  ## Expected Behavior
  [What should happen]

  ## Actual Behavior  
  [What currently happens]

  ## Steps to Reproduce
  1. [Step 1]
  2. [Step 2]

  ## Environment
  - Branch: [current branch]
  - Last commit: [latest commit hash]
  • Update state with issue number
  • Mark checkpoint: issue_created = true

STEP 4: Feature Branch Creation

  • Generate branch name: bugfix/[sanitized-bug-description]
  • Create and checkout branch: git checkout -b [branch-name]
  • Update state with branch name
  • Mark checkpoint: branch_created = true

STEP 5: Bug Investigation and Root Cause Analysis

Think deeply about the optimal debugging approach for this specific bug type and system complexity.

FOR complex bugs requiring comprehensive investigation:

**CRITICAL: Deploy parallel sub-agents for maximum performance (8-10x faster bug investigation)**

IMMEDIATELY launch 8 specialized bug investigation agents:

  • **Agent 1: Code Pattern Analysis**: Examine code patterns, recent changes, and potential regression sources
  • Focus: Function implementations, class hierarchies, recent commits, code quality patterns
  • Tools: Git blame, code pattern analysis, complexity metrics, refactoring impact assessment
  • Output: Code-level root cause analysis with change timeline and impact assessment
  • **Agent 2: Environment & Configuration Analysis**: Analyze configuration, dependencies, and deployment differences
  • Focus: Environment variables, configuration files, dependency versions, deployment settings
  • Tools: Configuration validation, dependency analysis, environment comparison, deployment history
  • Output: Environment-related causes with configuration drift analysis and dependency conflicts
  • **Agent 3: Data Flow & State Analysis**: Trace data flow and identify transformation issues
  • Focus: Data transformations, state mutations, database interactions, API data contracts
  • Tools: Data flow tracing, state analysis, database query analysis, API contract validation
  • Output: Data-related issues with flow diagrams and state corruption analysis
  • **Agent 4: Integration & Service Analysis**: Check API contracts, service interactions, and third-party integrations
  • Focus: Service boundaries, API calls, message queues, external service dependencies
  • Tools: API testing, service mesh analysis, integration testing, dependency mapping
  • Output: Integration issues with service interaction analysis and external dependency validation
  • **Agent 5: Security & Authentication Analysis**: Assess security implications and vulnerability patterns
  • Focus: Authentication flows, authorization checks, input validation, security policies
  • Tools: Security scanning, vulnerability analysis, authentication testing, policy validation
  • Output: Security-related causes with vulnerability assessment and authentication flow analysis
  • **Agent 6: Performance & Resource Analysis**: Identify performance bottlenecks and resource constraints
  • Focus: CPU usage, memory consumption, database performance, network latency
  • Tools: Performance profiling, resource monitoring, database query analysis, latency measurement
  • Output: Performance issues with bottleneck identification and resource utilization patterns
  • **Agent 7: Testing & Validation Analysis**: Examine test coverage, test failures, and validation gaps
  • Focus: Test suite analysis, coverage gaps, failing tests, validation logic
  • Tools: Test coverage analysis, test failure investigation, validation testing, quality m
Read more
Ships withclaude-cmd

A lightweight (~46kB) and comprehensive CLI tool for managing Claude commands, configurations, and workflows.

Get the whole plugin