Files
Claude-Code-Workflow/.claude/commands/cli/mode/code-analysis.md
catlog22 367040037a refactor: migrate prompt templates to standardized structure and enhance CLI command documentation
Template Migration:
- Move templates from .claude/prompt-templates/ to .claude/workflows/cli-templates/prompts/
- Rename and reorganize: bug-fix.md → development/bug-diagnosis.txt
- Rename and reorganize: code-analysis.md → analysis/code-execution-tracing.txt
- Rename and reorganize: plan.md → planning/architecture-planning.txt

CLI Command Enhancements:
- Add clear tool selection hierarchy (gemini primary, qwen fallback, codex alternative)
- Enhance analyze.md, chat.md with tool descriptions and agent context
- Enhance mode/code-analysis.md, mode/bug-diagnosis.md, mode/plan.md with Task() wrapper
- Add all necessary codex parameters (--skip-git-repo-check -s danger-full-access)
- Simplify descriptions while preserving core functionality

Agent Updates:
- Streamline cli-execution-agent.md (600→250 lines, -60%)
- Add complete templates reference for standalone usage
- Remove dependency on intelligent-tools-strategy.md

Reference Updates:
- Update test-task-generate.md template path references
- Delete duplicate bug-index.md
- All template paths now use ~/.claude/workflows/cli-templates/prompts/ format

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-27 10:26:35 +08:00

3.8 KiB

name, description, argument-hint, allowed-tools
name description argument-hint allowed-tools
code-analysis Deep code analysis and debugging using CLI tools with specialized template [--agent] [--tool codex|gemini|qwen] [--enhance] [--cd path] analysis target SlashCommand(*), Bash(*), Task(*)

CLI Mode: Code Analysis (/cli:mode:code-analysis)

Purpose

Systematic code analysis with execution path tracing template (~/.claude/workflows/cli-templates/prompts/analysis/code-execution-tracing.txt).

Tool Selection:

  • gemini (default) - Best for code analysis and tracing
  • qwen - Fallback when Gemini unavailable
  • codex - Alternative for complex analysis tasks

Key Feature: --cd flag for directory-scoped analysis

Parameters

  • --tool <gemini|qwen|codex> - Tool selection (default: gemini)
  • --agent - Use cli-execution-agent for automated context discovery
  • --enhance - Enhance analysis target with /enhance-prompt first
  • --cd "path" - Target directory for focused analysis
  • <analysis-target> (Required) - Code analysis target or question

Tool Usage

Gemini (Primary):

/cli:mode:code-analysis --tool gemini "trace auth flow"
# OR (default)
/cli:mode:code-analysis "trace auth flow"

Qwen (Fallback):

/cli:mode:code-analysis --tool qwen "trace auth flow"

Codex (Alternative):

/cli:mode:code-analysis --tool codex "trace auth flow"

Execution Flow

Standard Mode (Default)

  1. Parse tool selection (default: gemini)
  2. Optional: enhance analysis target with /enhance-prompt
  3. Detect target directory from --cd or auto-infer
  4. Build command with execution-tracing template
  5. Execute analysis (read-only)
  6. Save to .workflow/WFS-[id]/.chat/code-analysis-[timestamp].md

Agent Mode (--agent flag)

Delegates to cli-execution-agent for intelligent context discovery and analysis.

Core Rules

  • Read-only: Analyzes code, does NOT modify files
  • Template: Uses code-execution-tracing.txt for systematic analysis
  • Output: Saves to .workflow/WFS-[id]/.chat/

CLI Command Templates

Gemini/Qwen (default, read-only analysis):

cd [dir] && gemini -p "
PURPOSE: [goal]
TASK: Execution path tracing
MODE: analysis
CONTEXT: @**/*
EXPECTED: Trace, call diagram
RULES: $(cat ~/.claude/workflows/cli-templates/prompts/analysis/code-execution-tracing.txt)
"
# Qwen: Replace 'gemini' with 'qwen'

Codex (analysis + optimization suggestions):

codex -C [dir] --full-auto exec "
PURPOSE: [goal]
TASK: Path analysis
MODE: analysis
CONTEXT: @**/*
EXPECTED: Trace, optimization
RULES: $(cat ~/.claude/workflows/cli-templates/prompts/analysis/code-execution-tracing.txt)
" -m gpt-5 --skip-git-repo-check -s danger-full-access

Agent Execution Context

When --agent flag is used, delegate to agent:

Task(
  subagent_type="cli-execution-agent",
  description="Code execution path analysis",
  prompt=`
    Task: ${analysis_target}
    Mode: code-analysis
    Tool: ${tool_flag || 'auto-select'}  // gemini|qwen|codex
    Directory: ${cd_path || 'auto-detect'}
    Template: code-execution-tracing

    Agent responsibilities:
    1. Context Discovery:
       - Identify entry points and call chains
       - Discover related files (MCP/ripgrep)
       - Map execution flow paths

    2. CLI Command Generation:
       - Build Gemini/Qwen/Codex command
       - Include discovered context
       - Apply code-execution-tracing.txt template

    3. Execution & Output:
       - Execute analysis with selected tool
       - Save to .workflow/WFS-[id]/.chat/
  `
)

Output

  • With session: .workflow/WFS-[id]/.chat/code-analysis-[timestamp].md
  • No session: .workflow/.scratchpad/code-analysis-[desc]-[timestamp].md

Notes

  • Template: ~/.claude/workflows/cli-templates/prompts/analysis/code-execution-tracing.txt
  • See intelligent-tools-strategy.md for detailed tool usage