mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-11 02:33:51 +08:00
refactor: Streamline intelligent tools strategy with structured prompt templates
- Reorganize content into logical sections: Core Framework, Tool Specifications, Decision Matrix, Workflow Integration, Usage Patterns - Add structured prompt templates with PURPOSE|TASK|EXPECTED format for both Gemini and Codex - Consolidate redundant sections while preserving all unique content - Reduce file size by 13% (221→193 lines) through better organization - Enhance workflow integration rules with mandatory planning process - Improve decision matrix with task categorization and frequency guidelines 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -6,83 +6,188 @@ type: strategic-guideline
|
||||
|
||||
# Intelligent Tools Selection Strategy
|
||||
|
||||
## ⚡ Core Decision Framework
|
||||
## ⚡ Core Framework
|
||||
|
||||
**Gemini**: Analysis & understanding large codebases
|
||||
**Codex**: Development & autonomous implementation
|
||||
**Gemini**: Analysis, understanding, exploration & documentation
|
||||
**Codex**: Development, implementation & automation
|
||||
|
||||
> **Implementation Details**: See @~/.claude/workflows/tools-implementation-guide.md
|
||||
### Decision Principles
|
||||
- **Use tools early and often** - Tools are faster, more thorough, and reliable than manual approaches
|
||||
- **When in doubt, use both** - Parallel usage provides comprehensive coverage
|
||||
- **Default to tools** - Use specialized tools for most coding tasks, no matter how small
|
||||
- **Lower barriers** - Engage tools immediately when encountering any complexity
|
||||
|
||||
## 🎯 Tool Selection Matrix
|
||||
### Quick Decision Rules
|
||||
1. **Exploring/Understanding?** → Start with Gemini
|
||||
2. **Building/Fixing?** → Start with Codex
|
||||
3. **Not sure?** → Use both in parallel
|
||||
4. **Small task?** → Still use tools - they're faster than manual work
|
||||
|
||||
### When to Use Gemini
|
||||
- **Command**: `~/.claude/scripts/gemini-wrapper -p "prompt"`
|
||||
- **Strengths**: Large context window, pattern recognition across modules
|
||||
- **Best For**:
|
||||
- Project architecture analysis (>50 files)
|
||||
- Cross-module pattern detection
|
||||
- Coding convention analysis
|
||||
- Refactoring with broad dependencies
|
||||
- Large codebase understanding
|
||||
## 🎯 Tool Specifications
|
||||
|
||||
### When to Use Codex
|
||||
- **Command**: `codex --full-auto exec "prompt" -s danger-full-access`
|
||||
- **Strengths**: Mathematical reasoning, autonomous development
|
||||
- **Best For**:
|
||||
- Complex algorithm analysis
|
||||
- Security vulnerability assessment
|
||||
- Performance optimization
|
||||
- Database schema design
|
||||
- API protocol specifications
|
||||
- Autonomous feature development
|
||||
### Gemini (Analysis & Understanding)
|
||||
**Command**: `~/.claude/scripts/gemini-wrapper -p "PURPOSE: [analysis goal] | TASK: [what to do] | EXPECTED: [expected results]"`
|
||||
|
||||
## 📊 Decision Framework
|
||||
**Strengths**: Large context window, pattern recognition across modules
|
||||
|
||||
| Analysis Need | Recommended Tool | Rationale |
|
||||
|--------------|------------------|-----------|
|
||||
| Project Architecture | Gemini | Needs broad context across many files |
|
||||
| Algorithm Optimization | Codex | Requires deep mathematical reasoning |
|
||||
| Security Analysis | Codex | Leverages deeper security knowledge |
|
||||
| Code Patterns | Gemini | Pattern recognition across modules |
|
||||
| Refactoring | Gemini | Needs understanding of all dependencies |
|
||||
| API Design | Codex | Technical specification expertise |
|
||||
| Test Coverage | Gemini | Cross-module test understanding |
|
||||
| Performance Tuning | Codex | Mathematical optimization capabilities |
|
||||
| Feature Implementation | Codex | Autonomous development capabilities |
|
||||
| Architectural Review | Gemini | Large context analysis |
|
||||
**Use Cases**:
|
||||
- Any project analysis (≥5 files)
|
||||
- Quick code exploration and familiarization
|
||||
- Cross-module pattern detection and consistency checks
|
||||
- Coding convention analysis and standardization
|
||||
- Refactoring planning with dependency mapping
|
||||
- Legacy code understanding and modernization paths
|
||||
- API surface analysis and integration points
|
||||
- Test coverage gaps and quality assessment
|
||||
- Configuration file analysis and optimization
|
||||
- Dependency audit and relationship mapping
|
||||
- Code review preparation and checklist generation
|
||||
- Documentation generation from existing code
|
||||
|
||||
## 🔄 Parallel Analysis Strategy
|
||||
### Codex (Development & Implementation)
|
||||
**Command**: `codex --full-auto exec "PURPOSE: [development goal] | TASK: [what to implement] | EXPECTED: [expected code/features]" -s danger-full-access`
|
||||
|
||||
**Strengths**: Mathematical reasoning, autonomous development
|
||||
|
||||
**Use Cases**:
|
||||
- Any feature development (simple to complex)
|
||||
- Quick prototyping and proof-of-concepts
|
||||
- Bug fixes and issue resolution
|
||||
- Test generation and validation
|
||||
- Code scaffolding and boilerplate creation
|
||||
- Configuration setup and environment preparation
|
||||
- Algorithm implementation and optimization
|
||||
- Security vulnerability assessment and fixes
|
||||
- Performance optimization and profiling
|
||||
- Database schema design and migration
|
||||
- API development and integration
|
||||
- DevOps automation and deployment scripts
|
||||
- Documentation automation and generation
|
||||
- Code modernization and refactoring execution
|
||||
- Dependency management and updates
|
||||
- Build system optimization and tooling
|
||||
|
||||
### Structured Prompt Templates
|
||||
```bash
|
||||
# Gemini Analysis
|
||||
~/.claude/scripts/gemini-wrapper -p "
|
||||
PURPOSE: [clear analysis goal]
|
||||
TASK: [specific analysis task]
|
||||
EXPECTED: [expected output]
|
||||
"
|
||||
|
||||
# Codex Development
|
||||
codex --full-auto exec "
|
||||
PURPOSE: [clear development goal]
|
||||
TASK: [specific development task]
|
||||
EXPECTED: [expected deliverables]
|
||||
" -s danger-full-access
|
||||
```
|
||||
|
||||
**Prompt Checklist**:
|
||||
- [ ] **PURPOSE** - Clear goal and intent
|
||||
- [ ] **TASK** - Specific execution task
|
||||
- [ ] **EXPECTED** - Clear expected results
|
||||
|
||||
## 📊 Decision Matrix
|
||||
|
||||
| Task Category | Tool | Rationale | Frequency |
|
||||
|--------------|------|-----------|-----------|
|
||||
| **Understanding & Analysis** |
|
||||
| Project Architecture | Gemini | Broad context across files | Weekly/Monthly |
|
||||
| Code Exploration | Gemini | Quick module familiarization | Daily |
|
||||
| Legacy Code Analysis | Gemini | Pattern recognition across systems | As needed |
|
||||
| Dependency Mapping | Gemini | Cross-module relationship analysis | Sprint planning |
|
||||
| Code Review Prep | Gemini | Comprehensive context understanding | Before reviews |
|
||||
| **Development & Implementation** |
|
||||
| Feature Development | Codex | Autonomous implementation capabilities | Daily |
|
||||
| Bug Fixes | Codex | Targeted problem resolution | As issues arise |
|
||||
| Prototyping | Codex | Rapid development and iteration | Weekly |
|
||||
| Test Generation | Codex | Automated test creation | After feature work |
|
||||
| Configuration Setup | Codex | Environment and tooling setup | Project setup |
|
||||
| **Optimization & Maintenance** |
|
||||
| Algorithm Optimization | Codex | Mathematical reasoning capabilities | Performance sprints |
|
||||
| Security Analysis | Codex | Security knowledge and fixes | Security reviews |
|
||||
| Performance Tuning | Codex | Mathematical optimization | Performance reviews |
|
||||
| Code Modernization | Both | Gemini for planning, Codex for execution | Quarterly |
|
||||
| **Documentation & Quality** |
|
||||
| Documentation Generation | Both | Gemini for analysis, Codex for automation | Continuous |
|
||||
| Coding Standards | Gemini | Pattern recognition and consistency | Code reviews |
|
||||
| Test Coverage Analysis | Gemini | Cross-module test understanding | Sprint retrospectives |
|
||||
|
||||
## 📋 Workflow Integration
|
||||
|
||||
### Mandatory Planning Process
|
||||
When planning any coding task, **ALWAYS** integrate CLI tools:
|
||||
|
||||
#### 1. Understanding Phase (Required)
|
||||
- **Gemini Analysis**: Understand existing patterns, architecture, dependencies
|
||||
- **Context Discovery**: Map related modules and integration points
|
||||
- **Pattern Recognition**: Identify existing conventions and standards
|
||||
|
||||
#### 2. Development Strategy
|
||||
- **Understanding/Analysis**: Gemini (primary), Codex (occasional)
|
||||
- **Implementation**: Codex (occasional), manual development (primary)
|
||||
- **Complex Tasks**: Both tools in sequence
|
||||
|
||||
#### 3. Workflow Pattern
|
||||
```
|
||||
Planning → Gemini Analysis → Manual Development → Codex Assistance (as needed)
|
||||
```
|
||||
|
||||
### Tool Usage Guidelines
|
||||
|
||||
#### Gemini (Primary for Understanding)
|
||||
- Always use for initial codebase analysis
|
||||
- Pattern discovery and convention mapping
|
||||
- Architecture understanding before implementation
|
||||
- Dependency analysis and impact assessment
|
||||
- Code review preparation
|
||||
|
||||
#### Codex (Occasional for Development)
|
||||
- Selective use for complex algorithms
|
||||
- Prototype generation for proof-of-concepts
|
||||
- Boilerplate creation when patterns are clear
|
||||
- Test generation and validation
|
||||
- Performance optimization tasks
|
||||
|
||||
### Planning Checklist
|
||||
For every development task:
|
||||
- [ ] **Gemini analysis** completed for understanding
|
||||
- [ ] **Existing patterns** identified and documented
|
||||
- [ ] **Dependencies mapped** and integration points clear
|
||||
- [ ] **CLI tool usage points** identified in workflow
|
||||
- [ ] **Manual development approach** defined
|
||||
- [ ] **Codex assistance triggers** identified (if applicable)
|
||||
|
||||
## 🚀 Usage Patterns
|
||||
|
||||
### Immediate Engagement Triggers
|
||||
- **New codebase**: Use Gemini to understand structure before changes
|
||||
- **Bug reports**: Use Codex to investigate and propose fixes
|
||||
- **Feature requests**: Use Codex for rapid prototyping and implementation
|
||||
- **Code reviews**: Use Gemini to prepare comprehensive analysis
|
||||
- **Refactoring needs**: Use Gemini for impact analysis, Codex for execution
|
||||
|
||||
### Daily Integration Points
|
||||
- **Morning standup prep**: Gemini for codebase overview
|
||||
- **Sprint planning**: Both tools for effort estimation
|
||||
- **Development tasks**: Codex for implementation
|
||||
- **Testing**: Codex for test generation and coverage
|
||||
- **Documentation**: Both tools for comprehensive docs
|
||||
|
||||
### Parallel Strategy
|
||||
For complex projects requiring both broad context and deep analysis:
|
||||
- **Gemini** for architectural understanding
|
||||
- **Codex** for focused development tasks
|
||||
- Run both via Task agents when comprehensive coverage needed
|
||||
|
||||
## 📈 Complexity-Based Selection
|
||||
### Frequency Guidelines
|
||||
- **Daily**: Use tools for routine development tasks
|
||||
- **Immediate**: Engage tools at first sign of complexity
|
||||
- **Continuous**: Integrate tools into regular workflow
|
||||
- **Proactive**: Don't wait for problems - use tools preventively
|
||||
|
||||
### Simple Projects (≤50 files)
|
||||
- **Content-driven choice**: Mathematical → Codex, Structural → Gemini
|
||||
## 🔗 Reference
|
||||
|
||||
### Medium Projects (50-200 files)
|
||||
- **Gemini first** for overview and patterns
|
||||
- **Codex second** for specific implementations
|
||||
|
||||
### Large Projects (>200 files)
|
||||
- **Parallel analysis** with both tools
|
||||
- **Gemini** for architectural understanding
|
||||
- **Codex** for focused development tasks
|
||||
|
||||
## 🎯 Strategic Guidelines
|
||||
|
||||
1. **Task-driven selection**: Let project characteristics drive tool choice
|
||||
2. **Start simple**: Begin with single tool, escalate to parallel if needed
|
||||
3. **Context first**: Understand scope before selecting approach
|
||||
4. **Trust autonomous capabilities**: Let tools handle their specialized domains
|
||||
|
||||
## 🔗 Implementation Details
|
||||
|
||||
**Complete syntax and usage patterns**: @~/.claude/workflows/tools-implementation-guide.md
|
||||
|
||||
---
|
||||
|
||||
**Decision Principle**: Choose based on task nature - Gemini excels at understanding, Codex excels at building.
|
||||
**Complete syntax and usage patterns**: @~/.claude/workflows/tools-implementation-guide.md
|
||||
@@ -126,19 +126,31 @@ All task files use this unified 5-field schema:
|
||||
{
|
||||
"step": "check_patterns",
|
||||
"action": "Analyze existing patterns",
|
||||
"command": "bash(rg 'auth' src/ | head -10)",
|
||||
"output_to": "auth_patterns"
|
||||
"command": "bash(rg 'auth' [focus_paths] | head -10)",
|
||||
"output_to": "patterns"
|
||||
},
|
||||
{
|
||||
"step": "analyze_architecture",
|
||||
"action": "Review system architecture",
|
||||
"command": "~/.claude/scripts/gemini-wrapper -p \"analyze patterns: [patterns]\"",
|
||||
"output_to": "design"
|
||||
},
|
||||
{
|
||||
"step": "check_deps",
|
||||
"action": "Check dependencies",
|
||||
"command": "bash(echo [depends_on] | xargs cat)",
|
||||
"output_to": "context"
|
||||
}
|
||||
],
|
||||
"implementation_approach": {
|
||||
"task_description": "Implement JWT authentication following existing patterns",
|
||||
"task_description": "Implement JWT authentication following [design]",
|
||||
"modification_points": [
|
||||
"Add JWT generation in login handler",
|
||||
"Implement token validation middleware"
|
||||
"Add JWT generation using [parent] patterns",
|
||||
"Implement validation middleware from [context]"
|
||||
],
|
||||
"logic_flow": [
|
||||
"User login → validate → generate JWT → return token",
|
||||
"Protected route → extract JWT → validate → allow/deny"
|
||||
"User login → validate with [inherited] → generate JWT",
|
||||
"Protected route → extract JWT → validate using [shared] rules"
|
||||
]
|
||||
},
|
||||
"target_files": [
|
||||
@@ -162,7 +174,7 @@ The **focus_paths** field specifies concrete project paths for task implementati
|
||||
The **flow_control** field manages task execution with two main components:
|
||||
|
||||
**pre_analysis** - Context gathering phase:
|
||||
- **Flexible commands**: Supports bash pipelines, CLI tools, and agent calls
|
||||
- **Flexible commands**: Supports multiple tool types (see Tool Reference below)
|
||||
- **Step structure**: Each step has `step`, `action`, `command` fields
|
||||
- **Variable accumulation**: Steps can reference previous outputs via `[variable_name]`
|
||||
- **Error handling**: `skip_optional`, `fail`, `retry_once`, `manual_intervention`
|
||||
@@ -173,13 +185,39 @@ The **flow_control** field manages task execution with two main components:
|
||||
- **logic_flow**: Business logic execution sequence
|
||||
- **target_files**: Target file list in `file:function:lines` format
|
||||
|
||||
#### Tool Reference
|
||||
**Command Types Available**:
|
||||
- **Gemini CLI**: `~/.claude/scripts/gemini-wrapper -p "prompt"`
|
||||
- **Codex CLI**: `codex --full-auto exec "task" -s danger-full-access`
|
||||
- **Built-in Tools**: `grep(pattern)`, `glob(pattern)`, `search(query)`
|
||||
- **Bash Commands**: `bash(rg 'pattern' src/)`, `bash(find . -name "*.ts")`
|
||||
|
||||
#### Variable System & Context Flow
|
||||
**Flow Control Variables**: Use `[variable_name]` format for dynamic content:
|
||||
- **Step outputs**: `[step_output_name]` - Reference any pre_analysis step output
|
||||
- **Task properties**: `[task_property]` - Reference any task context field
|
||||
- **Previous results**: `[analysis_result]` - Reference accumulated context
|
||||
- **Commands**: All commands wrapped with appropriate error handling
|
||||
|
||||
**Context Accumulation Process**:
|
||||
1. **Structure Analysis**: `get_modules_by_depth.sh` → project hierarchy
|
||||
2. **Pattern Analysis**: Tool-specific commands → existing patterns
|
||||
3. **Dependency Mapping**: Previous task summaries → inheritance context
|
||||
4. **Task Context Generation**: Combined analysis → task.context fields
|
||||
|
||||
**Context Inheritance Rules**:
|
||||
- **Parent → Child**: Container tasks pass context via `context.inherited`
|
||||
- **Dependency → Dependent**: Previous task summaries via `context.depends_on`
|
||||
- **Session → Task**: Global session context included in all tasks
|
||||
- **Module → Feature**: Module patterns inform feature implementation
|
||||
|
||||
### Task Validation Rules
|
||||
1. **ID Uniqueness**: All task IDs must be unique
|
||||
2. **Hierarchical Format**: Must follow IMPL-N[.M] pattern (maximum 2 levels)
|
||||
3. **Parent References**: All parent IDs must exist as JSON files
|
||||
4. **Status Consistency**: Status values from defined enumeration
|
||||
5. **Required Fields**: All 5 core fields must be present
|
||||
6. **Focus Paths Structure**: context.focus_paths must contain valid project paths
|
||||
6. **Focus Paths Structure**: context.focus_paths must contain concrete paths (no wildcards)
|
||||
7. **Flow Control Format**: pre_analysis must be array with required fields
|
||||
8. **Dependency Integrity**: All depends_on task IDs must exist as JSON files
|
||||
|
||||
@@ -199,8 +237,8 @@ All workflows use the same file structure definition regardless of complexity. *
|
||||
├── IMPL_PLAN.md # Planning document (REQUIRED)
|
||||
├── TODO_LIST.md # Progress tracking (REQUIRED)
|
||||
├── [.summaries/] # Task completion summaries (created when tasks complete)
|
||||
│ ├── IMPL-*.md # Main task summaries
|
||||
│ └── IMPL-*.*.md # Subtask summaries
|
||||
│ ├── IMPL-*-summary.md # Main task summaries
|
||||
│ └── IMPL-*.*-summary.md # Subtask summaries
|
||||
└── .task/ # Task definitions (REQUIRED)
|
||||
├── IMPL-*.json # Main task definitions
|
||||
└── IMPL-*.*.json # Subtask definitions (created dynamically)
|
||||
@@ -242,9 +280,9 @@ All workflows use the same file structure definition regardless of complexity. *
|
||||
## Task Progress
|
||||
▸ **IMPL-001**: [Main Task Group] → [📋](./.task/IMPL-001.json)
|
||||
- [ ] **IMPL-001.1**: [Subtask] → [📋](./.task/IMPL-001.1.json)
|
||||
- [x] **IMPL-001.2**: [Subtask] → [📋](./.task/IMPL-001.2.json) | [✅](./.summaries/IMPL-001.2.md)
|
||||
- [x] **IMPL-001.2**: [Subtask] → [📋](./.task/IMPL-001.2.json) | [✅](./.summaries/IMPL-001.2-summary.md)
|
||||
|
||||
- [x] **IMPL-002**: [Simple Task] → [📋](./.task/IMPL-002.json) | [✅](./.summaries/IMPL-002.md)
|
||||
- [x] **IMPL-002**: [Simple Task] → [📋](./.task/IMPL-002.json) | [✅](./.summaries/IMPL-002-summary.md)
|
||||
|
||||
## Status Legend
|
||||
- `▸` = Container task (has subtasks)
|
||||
@@ -314,22 +352,25 @@ fi
|
||||
| **Medium** | 5-15 tasks | 2 levels (IMPL-N.M) | Moderate decomposition, context coordination |
|
||||
| **Complex** | >15 tasks | 2 levels (IMPL-N.M) | Frequent decomposition, multi-agent orchestration |
|
||||
|
||||
### Workflow Characteristics
|
||||
### Workflow Characteristics & Tool Guidance
|
||||
|
||||
#### Simple Workflows
|
||||
- **Examples**: Bug fixes, small feature additions, configuration changes
|
||||
- **Task Decomposition**: Usually single-level tasks, minimal breakdown needed
|
||||
- **Agent Coordination**: Direct execution without complex orchestration
|
||||
- **Tool Strategy**: `bash()` commands, `grep()` for pattern matching
|
||||
|
||||
#### Medium Workflows
|
||||
- **Examples**: New features, API endpoints with integration, database schema changes
|
||||
- **Task Decomposition**: Two-level hierarchy when decomposition is needed
|
||||
- **Agent Coordination**: Context coordination between related tasks
|
||||
- **Tool Strategy**: `gemini-wrapper` for pattern analysis, `codex --full-auto` for implementation
|
||||
|
||||
#### Complex Workflows
|
||||
- **Examples**: Major features, architecture refactoring, security implementations, multi-service deployments
|
||||
- **Task Decomposition**: Frequent use of two-level hierarchy with dynamic subtask creation
|
||||
- **Agent Coordination**: Multi-agent orchestration with deep context analysis
|
||||
- **Tool Strategy**: `gemini-wrapper` for architecture analysis, `codex --full-auto` for complex problem solving, `bash()` commands for flexible analysis
|
||||
|
||||
### Assessment & Upgrades
|
||||
- **During Creation**: System evaluates requirements and assigns complexity
|
||||
|
||||
Reference in New Issue
Block a user