Files
Claude-Code-Workflow/.claude/commands/cli/mode/code-analysis.md
catlog22 920b179440 docs: 更新所有命令描述并重新生成索引文件
- 更新所有69个命令文件的description字段,基于实际功能重新生成详细描述
- 重新生成5个索引文件(all-commands, by-category, by-use-case, essential-commands, command-relationships)
- 移动analyze_commands.py到scripts/目录并完善功能
- 移除临时备份文件

命令描述改进示例:
- workflow:plan: 增加了工具和代理的详细说明(Gemini, action-planning-agent)
- cli:execute: 说明了YOLO权限和多种执行模式
- memory:update-related: 详细说明了批处理策略和工具回退链

索引文件改进:
- usage_scenario从2种扩展到10种(更精细分类)
- command-relationships覆盖所有69个命令
- 区分built-in(内置调用)和sequential(用户顺序执行)关系

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-06 15:11:31 +08:00

4.0 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 [--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/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)
  • --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 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 ~/.claude/workflows/cli-templates/prompts/analysis/01-trace-code-execution.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/01-trace-code-execution.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/01-trace-code-execution.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: ~/.claude/workflows/cli-templates/prompts/analysis/01-trace-code-execution.txt

    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 ~/.claude/workflows/cli-templates/prompts/analysis/01-trace-code-execution.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/01-trace-code-execution.txt
  • See intelligent-tools-strategy.md for detailed tool usage