Files
Claude-Code-Workflow/.claude/commands/cli/mode/code-analysis.md
catlog22 292dc113e3 refactor(workflow): complete migration from .workflow/sessions/ to .workflow/active/ directory structure
Update all command files to use the new standardized directory structure:
- Active sessions: .workflow/active/WFS-{session}/
- Archived sessions: .workflow/archives/WFS-{session}/

Changes:
- Updated workflow-architecture.md with new directory structure (active/ not sessions/)
- Fixed 31 path references across 12 command files
- Verified compliance across all 73 command files using parallel agent checks
- Confirmed directory naming: active/ (adjective, no plural) + archives/ (noun plural)

Files modified:
- .claude/workflows/workflow-architecture.md (directory structure definition)
- .claude/commands/cli/*.md (8 files: analyze, chat, codex-execute, discuss-plan, execute, mode/*)
- .claude/commands/memory/docs.md (4 path fixes)
- .claude/commands/task/*.md (execute, replan)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 10:25:28 +08:00

3.2 KiB

name, description, argument-hint, allowed-tools
name description argument-hint allowed-tools
code-analysis Read-only execution path tracing using Gemini/Qwen/Codex with specialized analysis template for call flow and optimization [--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/01-trace-code-execution.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)
  • --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

Uses cli-execution-agent (default) for automated code analysis:

Task(
  subagent_type="cli-execution-agent",
  description="Execution path tracing and call flow analysis",
  prompt=`
    Task: ${analysis_target}
    Mode: code-analysis
    Tool: ${tool_flag || 'gemini'}
    Directory: ${cd_path || '.'}
    Enhance: ${enhance_flag}
    Template: ~/.claude/workflows/cli-templates/prompts/analysis/01-trace-code-execution.txt

    Execute systematic code analysis with execution path tracing:

    1. Context Discovery:
       - Identify entry points and function signatures
       - Trace call chains and execution flows
       - Discover related files (implementations, dependencies, tests)
       - Map data flow and state transformations
       - Use MCP/ripgrep for comprehensive file discovery

    2. Analysis Execution:
       - Apply execution tracing template
       - Generate call flow diagrams (textual)
       - Document execution paths and branching logic
       - Identify optimization opportunities

    3. CLI Command Construction:
       - Tool: ${tool_flag || 'gemini'} (qwen fallback, codex for complex analysis)
       - Directory: cd ${cd_path || '.'} &&
       - Context: @**/* + discovered execution context
       - Mode: analysis (read-only)
       - Template: analysis/01-trace-code-execution.txt

    4. Output Generation:
       - Execution trace documentation
       - Call flow analysis with diagrams
       - Performance and optimization insights
       - Save to .workflow/active/WFS-[id]/.chat/code-analysis-[timestamp].md (or .scratchpad/)
  `
)

Core Rules

  • Read-only: Analyzes code, does NOT modify files
  • Template: ~/.claude/workflows/cli-templates/prompts/analysis/01-trace-code-execution.txt
  • Output: .workflow/active/WFS-[id]/.chat/code-analysis-[timestamp].md (or .scratchpad/ if no session)