Files
Claude-Code-Workflow/.claude/commands/cli/mode/bug-diagnosis.md
catlog22 bc959b1a0f refactor(cli): remove --agent flag and enhance agent execution context
- Remove --agent parameter from all CLI commands (now default behavior)
- Restore and enhance Task() invocation context for cli-execution-agent
- Add detailed execution phases and context discovery strategies
- Simplify documentation by removing redundant CLI command templates
- Consolidate output documentation to unified format

Modified commands:
- /cli:analyze, /cli:chat, /cli:execute
- /cli:mode:plan, /cli:mode:code-analysis, /cli:mode:bug-diagnosis

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-10 16:12:04 +08:00

3.0 KiB

name, description, argument-hint, allowed-tools
name description argument-hint allowed-tools
bug-diagnosis Read-only bug root cause analysis using Gemini/Qwen/Codex with systematic diagnosis template for fix suggestions [--tool codex|gemini|qwen] [--enhance] [--cd path] bug description SlashCommand(*), Bash(*), Task(*)

CLI Mode: Bug Diagnosis (/cli:mode:bug-diagnosis)

Purpose

Systematic bug diagnosis with root cause analysis template (~/.claude/workflows/cli-templates/prompts/analysis/01-diagnose-bug-root-cause.txt).

Tool Selection:

  • gemini (default) - Best for bug diagnosis
  • qwen - Fallback when Gemini unavailable
  • codex - Alternative for complex bug analysis

Parameters

  • --tool <gemini|qwen|codex> - Tool selection (default: gemini)
  • --enhance - Enhance bug description with /enhance-prompt
  • --cd "path" - Target directory for focused diagnosis
  • <bug-description> (Required) - Bug description or error details

Tool Usage

Gemini (Primary):

# Uses gemini by default, or specify explicitly
--tool gemini

Qwen (Fallback):

--tool qwen

Codex (Alternative):

--tool codex

Execution Flow

Uses cli-execution-agent (default) for automated bug diagnosis:

Task(
  subagent_type="cli-execution-agent",
  description="Bug root cause diagnosis with fix suggestions",
  prompt=`
    Task: ${bug_description}
    Mode: bug-diagnosis
    Tool: ${tool_flag || 'gemini'}
    Directory: ${cd_path || '.'}
    Enhance: ${enhance_flag}
    Template: ~/.claude/workflows/cli-templates/prompts/analysis/01-diagnose-bug-root-cause.txt

    Execute systematic bug diagnosis and root cause analysis:

    1. Context Discovery:
       - Locate error traces, stack traces, and log messages
       - Find related code sections and affected modules
       - Identify data flow paths leading to the bug
       - Discover test cases related to bug area
       - Use MCP/ripgrep for comprehensive context gathering

    2. Root Cause Analysis:
       - Apply diagnostic template methodology
       - Trace execution to identify failure point
       - Analyze state, data, and logic causing issue
       - Document potential root causes with evidence
       - Assess bug severity and impact scope

    3. CLI Command Construction:
       - Tool: ${tool_flag || 'gemini'} (qwen fallback, codex for complex bugs)
       - Directory: cd ${cd_path || '.'} &&
       - Context: @**/* + error traces + affected code
       - Mode: analysis (read-only)
       - Template: analysis/01-diagnose-bug-root-cause.txt

    4. Output Generation:
       - Root cause diagnosis with evidence
       - Fix suggestions and recommendations
       - Prevention strategies
       - Save to .workflow/WFS-[id]/.chat/bug-diagnosis-[timestamp].md (or .scratchpad/)
  `
)

Core Rules

  • Read-only: Diagnoses bugs, does NOT modify code
  • Template: ~/.claude/workflows/cli-templates/prompts/analysis/01-diagnose-bug-root-cause.txt
  • Output: .workflow/WFS-[id]/.chat/bug-diagnosis-[timestamp].md (or .scratchpad/ if no session)