Skip to content

Commit 3670400

Browse files
catlog22claude
andcommitted
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>
1 parent 5249bd6 commit 3670400

File tree

11 files changed

+660
-1040
lines changed

11 files changed

+660
-1040
lines changed

.claude/agents/cli-execution-agent.md

Lines changed: 130 additions & 371 deletions
Large diffs are not rendered by default.

.claude/commands/cli/analyze.md

Lines changed: 80 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -9,142 +9,128 @@ allowed-tools: SlashCommand(*), Bash(*), TodoWrite(*), Read(*), Glob(*), Task(*)
99

1010
## Purpose
1111

12-
Quick codebase analysis using CLI tools. **Analysis only - does NOT modify code**.
12+
Quick codebase analysis using CLI tools. **Read-only - does NOT modify code**.
1313

14-
**Intent**: Understand code patterns, architecture, and provide insights/recommendations
15-
**Supported Tools**: codex, gemini (default), qwen
16-
17-
## Core Behavior
18-
19-
1. **Read-Only Analysis**: This command ONLY analyzes code and provides insights
20-
2. **No Code Modification**: Results are recommendations and analysis reports
21-
3. **Template-Based**: Automatically selects appropriate analysis template
22-
4. **Smart Pattern Detection**: Infers relevant files based on analysis target
14+
**Tool Selection**:
15+
- **gemini** (default) - Best for code analysis
16+
- **qwen** - Fallback when Gemini unavailable
17+
- **codex** - Alternative for deep analysis
2318

2419
## Parameters
2520

26-
- `--agent` - Use cli-execution-agent for automated context discovery (5-phase intelligent mode)
27-
- `--tool <codex|gemini|qwen>` - Tool selection (default: gemini, ignored in agent mode)
21+
- `--tool <gemini|qwen|codex>` - Tool selection (default: gemini)
22+
- `--agent` - Use cli-execution-agent for automated context discovery
2823
- `--enhance` - Use `/enhance-prompt` for context-aware enhancement
2924
- `<analysis-target>` - Description of what to analyze
3025

31-
## Execution Flow
26+
## Tool Usage
27+
28+
**Gemini** (Primary):
29+
```bash
30+
--tool gemini # or omit (default)
31+
```
3232

33-
### Standard Mode (Default)
33+
**Qwen** (Fallback):
34+
```bash
35+
--tool qwen
36+
```
3437

38+
**Codex** (Alternative):
39+
```bash
40+
--tool codex
41+
```
42+
43+
## Execution Flow
44+
45+
### Standard Mode
3546
1. Parse tool selection (default: gemini)
36-
2. If `--enhance`: Execute `/enhance-prompt` first to expand user intent
37-
3. Auto-detect analysis type from keywords → select template
38-
4. Build command with auto-detected file patterns and `MODE: analysis`
39-
5. Execute analysis (read-only, no code changes)
40-
6. Return analysis report with insights and recommendations
47+
2. Optional: enhance with `/enhance-prompt`
48+
3. Auto-detect file patterns from keywords
49+
4. Build command with analysis template
50+
5. Execute analysis (read-only)
51+
6. Save results
4152

42-
### Agent Mode (`--agent` flag)
53+
### Agent Mode (`--agent`)
4354

44-
Delegate task to `cli-execution-agent` for intelligent execution with automated context discovery.
55+
Delegates to agent for intelligent analysis:
4556

46-
**Agent invocation**:
4757
```javascript
4858
Task(
4959
subagent_type="cli-execution-agent",
50-
description="Analyze codebase with automated context discovery",
60+
description="Codebase analysis",
5161
prompt=`
5262
Task: ${analysis_target}
5363
Mode: analyze
54-
Tool Preference: ${tool_flag || 'auto-select'}
55-
${enhance_flag ? 'Enhance: true' : ''}
56-
57-
Agent will autonomously:
58-
- Discover relevant files and patterns
59-
- Build enhanced analysis prompt
60-
- Select optimal tool and execute
61-
- Route output to session/scratchpad
64+
Tool: ${tool_flag || 'auto-select'} // gemini|qwen|codex
65+
Enhance: ${enhance_flag || false}
66+
67+
Agent responsibilities:
68+
1. Context Discovery:
69+
- Discover relevant files/patterns
70+
- Identify analysis scope
71+
- Build file context
72+
73+
2. CLI Command Generation:
74+
- Build Gemini/Qwen/Codex command
75+
- Apply analysis template
76+
- Include discovered files
77+
78+
3. Execution & Output:
79+
- Execute analysis
80+
- Generate insights report
81+
- Save to .workflow/.chat/ or .scratchpad/
6282
`
6383
)
6484
```
6585

66-
The agent handles all phases internally (understanding, discovery, enhancement, execution, routing).
86+
## Core Rules
87+
88+
- **Read-only**: Analyzes code, does NOT modify files
89+
- **Auto-pattern**: Detects file patterns from keywords
90+
- **Template-based**: Auto-selects analysis template
91+
- **Output**: Saves to `.workflow/WFS-[id]/.chat/` or `.scratchpad/`
6792

6893
## File Pattern Auto-Detection
6994

70-
Keywords trigger specific file patterns (each @ references one pattern):
95+
Keywords file patterns:
7196
- "auth" → `@**/*auth* @**/*user*`
72-
- "component" → `@src/components/**/* @**/*.component.*`
97+
- "component" → `@src/components/**/*`
7398
- "API" → `@**/api/**/* @**/routes/**/*`
7499
- "test" → `@**/*.test.* @**/*.spec.*`
75-
- "config" → `@*.config.* @**/config/**/*`
76100
- Generic → `@src/**/*`
77101

78-
For complex patterns, use `rg` or MCP tools to discover files first, then execute CLI with precise file references.
79-
80-
## Command Template
102+
## CLI Command Templates
81103

104+
**Gemini/Qwen**:
82105
```bash
83106
cd . && gemini -p "
84-
PURPOSE: [analysis goal from target]
85-
TASK: [auto-detected analysis type]
107+
PURPOSE: [goal]
108+
TASK: [analysis type]
86109
MODE: analysis
87-
CONTEXT: @CLAUDE.md [auto-detected file patterns]
88-
EXPECTED: Insights, patterns, recommendations (NO code modification)
89-
RULES: [auto-selected template] | Focus on [analysis aspect]
110+
CONTEXT: @CLAUDE.md [auto-detected patterns]
111+
EXPECTED: Insights, recommendations
112+
RULES: [auto-selected template]
90113
"
114+
# Qwen: Replace 'gemini' with 'qwen'
91115
```
92116

93-
## Examples
94-
95-
**Basic Analysis (Standard Mode)**:
96-
```bash
97-
/cli:analyze "authentication patterns"
98-
# Executes: Gemini analysis with auth file patterns
99-
# Returns: Pattern analysis, architecture insights, recommendations
100-
```
101-
102-
**Intelligent Analysis (Agent Mode)**:
117+
**Codex**:
103118
```bash
104-
/cli:analyze --agent "authentication patterns"
105-
# Phase 1: Classifies intent=analyze, complexity=simple, keywords=['auth', 'patterns']
106-
# Phase 2: MCP discovers 12 auth files, identifies patterns
107-
# Phase 3: Builds enhanced prompt with discovered context
108-
# Phase 4: Executes Gemini with comprehensive file references
109-
# Phase 5: Saves execution log with all 5 phases documented
110-
# Returns: Comprehensive analysis + detailed execution log
111-
```
112-
113-
**Architecture Analysis**:
114-
```bash
115-
/cli:analyze --tool qwen -p "component architecture"
116-
# Executes: Qwen with component file patterns
117-
# Returns: Architecture review, design patterns, improvement suggestions
118-
```
119-
120-
**Performance Analysis**:
121-
```bash
122-
/cli:analyze --tool codex "performance bottlenecks"
123-
# Executes: Codex deep analysis with performance focus
124-
# Returns: Bottleneck identification, optimization recommendations
125-
```
126-
127-
**Enhanced Analysis**:
128-
```bash
129-
/cli:analyze --enhance "fix auth issues"
130-
# Step 1: Enhance prompt to expand context
131-
# Step 2: Analysis with expanded context
132-
# Returns: Root cause analysis, fix recommendations (NO automatic fixes)
119+
codex -C . --full-auto exec "
120+
PURPOSE: [goal]
121+
TASK: [analysis type]
122+
MODE: analysis
123+
CONTEXT: @CLAUDE.md [patterns]
124+
EXPECTED: Deep insights
125+
RULES: [template]
126+
" -m gpt-5 --skip-git-repo-check -s danger-full-access
133127
```
134128

135-
## Output Routing
136-
137-
**Output Destination Logic**:
138-
- **Active session exists AND analysis is session-relevant**:
139-
- Save to `.workflow/WFS-[id]/.chat/analyze-[timestamp].md`
140-
- **No active session OR one-off analysis**:
141-
- Save to `.workflow/.scratchpad/analyze-[description]-[timestamp].md`
129+
## Output
142130

143-
**Examples**:
144-
- During active session `WFS-auth-system`, analyzing auth patterns → `.chat/analyze-20250105-143022.md`
145-
- No session, quick security check → `.scratchpad/analyze-security-20250105-143045.md`
131+
- **With session**: `.workflow/WFS-[id]/.chat/analyze-[timestamp].md`
132+
- **No session**: `.workflow/.scratchpad/analyze-[desc]-[timestamp].md`
146133

147134
## Notes
148135

149-
- Command templates, file patterns, and best practices: see intelligent-tools-strategy.md (loaded in memory)
150-
- Scratchpad files can be promoted to workflow sessions if analysis proves valuable
136+
- See `intelligent-tools-strategy.md` for detailed tool usage and templates

0 commit comments

Comments
 (0)