mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-10 02:24:35 +08:00
主要变更: - 模板重命名:采用优先级前缀(01-通用, 02-专用, 03-领域特定) - 目录调整:bug-diagnosis从development移至analysis - 引用更新:5个命令文件中21处模板引用更新为新路径 - 路径统一:所有引用统一使用完整路径格式 模板变更详情: - analysis/:8个模板(01-trace-code-execution, 01-diagnose-bug-root-cause等) - development/:5个模板(02-implement-feature, 02-refactor-codebase等) - planning/:5个模板(01-plan-architecture-design, 02-breakdown-task-steps等) - memory/:1个模板(02-document-module-structure) 命令文件更新: - cli/mode/bug-diagnosis.md(6处引用) - cli/mode/code-analysis.md(6处引用) - cli/mode/plan.md(6处引用) - task/execute.md(1处引用) - workflow/tools/test-task-generate.md(2处引用) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
138 lines
4.0 KiB
Markdown
138 lines
4.0 KiB
Markdown
---
|
|
name: code-analysis
|
|
description: Deep code analysis and debugging using CLI tools with specialized template
|
|
argument-hint: "[--agent] [--tool codex|gemini|qwen] [--enhance] [--cd path] analysis target"
|
|
allowed-tools: 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):
|
|
```bash
|
|
/cli:mode:code-analysis --tool gemini "trace auth flow"
|
|
# OR (default)
|
|
/cli:mode:code-analysis "trace auth flow"
|
|
```
|
|
|
|
**Qwen** (Fallback):
|
|
```bash
|
|
/cli:mode:code-analysis --tool qwen "trace auth flow"
|
|
```
|
|
|
|
**Codex** (Alternative):
|
|
```bash
|
|
/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):
|
|
```bash
|
|
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):
|
|
```bash
|
|
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:
|
|
|
|
```javascript
|
|
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
|