mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-09 02:24:11 +08:00
feat: Update workflow architecture documentation and clean up scripts
- Update agent definitions with enhanced context and flow control - Standardize command templates for consistent CLI tool integration - Improve gemini-wrapper with better token management and path handling - Simplify qwen-wrapper for streamlined execution - Enhance intelligent-tools-strategy with directory navigation patterns - Add proper quoting for Windows path compatibility in all commands - Update workflow planning documentation with current architectural insights These changes align the command system with the four-layer architecture analysis and improve cross-platform compatibility. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -35,21 +35,50 @@ You are a code execution specialist focused on implementing high-quality, produc
|
|||||||
- Existing documentation and code examples
|
- Existing documentation and code examples
|
||||||
- Project CLAUDE.md standards
|
- Project CLAUDE.md standards
|
||||||
|
|
||||||
|
**Pre-Analysis: Tech Stack Detection and Loading**:
|
||||||
|
```bash
|
||||||
|
# Step 1: Detect project tech stack
|
||||||
|
TECH_STACK="default"
|
||||||
|
if find . -name "tsconfig.json" -o -name "*.ts" -o -name "*.tsx" 2>/dev/null | head -1; then
|
||||||
|
TECH_STACK="typescript-dev"
|
||||||
|
elif find . -name "package.json" 2>/dev/null | xargs grep -l "react" 2>/dev/null; then
|
||||||
|
TECH_STACK="react-dev"
|
||||||
|
elif find . -name "*.py" -o -name "requirements.txt" -o -name "pyproject.toml" 2>/dev/null | head -1; then
|
||||||
|
TECH_STACK="python-dev"
|
||||||
|
elif find . -name "*.java" -o -name "pom.xml" -o -name "build.gradle" 2>/dev/null | head -1; then
|
||||||
|
TECH_STACK="java-dev"
|
||||||
|
elif find . -name "*.go" -o -name "go.mod" 2>/dev/null | head -1; then
|
||||||
|
TECH_STACK="go-dev"
|
||||||
|
elif find . -name "*.js" -o -name "package.json" 2>/dev/null | head -1; then
|
||||||
|
TECH_STACK="javascript-dev"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Step 2: Load tech stack guidelines
|
||||||
|
TECH_GUIDELINES=$(cat ~/.claude/workflows/cli-templates/tech-stacks/${TECH_STACK}.md 2>/dev/null || echo "# Default Development Guidelines\nFollow general best practices.")
|
||||||
|
```
|
||||||
|
|
||||||
**Context Evaluation**:
|
**Context Evaluation**:
|
||||||
```
|
```
|
||||||
|
MANDATORY FIRST STEP:
|
||||||
|
→ Execute tech stack detection and load guidelines into [tech_guidelines] variable
|
||||||
|
→ All subsequent development must follow loaded tech stack principles
|
||||||
|
|
||||||
IF context sufficient for implementation:
|
IF context sufficient for implementation:
|
||||||
→ Proceed with execution
|
→ Apply [tech_guidelines] to execution
|
||||||
|
→ Proceed with tech-stack-compliant implementation
|
||||||
ELIF context insufficient OR task has flow control marker:
|
ELIF context insufficient OR task has flow control marker:
|
||||||
→ Check for [FLOW_CONTROL] marker:
|
→ Check for [FLOW_CONTROL] marker:
|
||||||
- Execute flow_control.pre_analysis steps sequentially for context gathering
|
- Execute flow_control.pre_analysis steps sequentially for context gathering
|
||||||
- Use four flexible context acquisition methods:
|
- Use four flexible context acquisition methods:
|
||||||
* Document references (cat commands)
|
* Document references (cat commands with tech stack context)
|
||||||
* Search commands (grep/rg/find)
|
* Search commands (grep/rg/find for tech-specific patterns)
|
||||||
* CLI analysis (gemini/codex)
|
* CLI analysis (gemini/codex with tech stack guidelines)
|
||||||
* Free exploration (Read/Grep/Search tools)
|
* Free exploration (Read/Grep/Search tools guided by tech principles)
|
||||||
- Pass context between steps via [variable_name] references
|
- Pass context between steps via [variable_name] references
|
||||||
|
- Ensure [tech_guidelines] is available to all steps
|
||||||
→ Extract patterns and conventions from accumulated context
|
→ Extract patterns and conventions from accumulated context
|
||||||
→ Proceed with execution
|
→ Apply tech stack principles to all implementation decisions
|
||||||
|
→ Proceed with tech-stack-compliant execution
|
||||||
```
|
```
|
||||||
### Module Verification Guidelines
|
### Module Verification Guidelines
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,29 @@ You will review code changes AND handle test implementation by understanding the
|
|||||||
|
|
||||||
## Analysis CLI Context Activation Rules
|
## Analysis CLI Context Activation Rules
|
||||||
|
|
||||||
|
**🎯 Pre-Analysis: Tech Stack Detection and Loading**
|
||||||
|
MANDATORY FIRST STEP for all reviews:
|
||||||
|
```bash
|
||||||
|
# Step 1: Detect project tech stack
|
||||||
|
TECH_STACK="default"
|
||||||
|
if find . -name "tsconfig.json" -o -name "*.ts" -o -name "*.tsx" 2>/dev/null | head -1; then
|
||||||
|
TECH_STACK="typescript-dev"
|
||||||
|
elif find . -name "package.json" 2>/dev/null | xargs grep -l "react" 2>/dev/null; then
|
||||||
|
TECH_STACK="react-dev"
|
||||||
|
elif find . -name "*.py" -o -name "requirements.txt" -o -name "pyproject.toml" 2>/dev/null | head -1; then
|
||||||
|
TECH_STACK="python-dev"
|
||||||
|
elif find . -name "*.java" -o -name "pom.xml" -o -name "build.gradle" 2>/dev/null | head -1; then
|
||||||
|
TECH_STACK="java-dev"
|
||||||
|
elif find . -name "*.go" -o -name "go.mod" 2>/dev/null | head -1; then
|
||||||
|
TECH_STACK="go-dev"
|
||||||
|
elif find . -name "*.js" -o -name "package.json" 2>/dev/null | head -1; then
|
||||||
|
TECH_STACK="javascript-dev"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Step 2: Load tech stack guidelines
|
||||||
|
TECH_GUIDELINES=$(cat ~/.claude/workflows/cli-templates/tech-stacks/${TECH_STACK}.md 2>/dev/null || echo "# Default Development Guidelines\nFollow general best practices.")
|
||||||
|
```
|
||||||
|
|
||||||
**🎯 Flow Control Detection**
|
**🎯 Flow Control Detection**
|
||||||
When task assignment includes flow control marker:
|
When task assignment includes flow control marker:
|
||||||
- **[FLOW_CONTROL]**: Execute sequential flow control steps with context accumulation and variable passing
|
- **[FLOW_CONTROL]**: Execute sequential flow control steps with context accumulation and variable passing
|
||||||
@@ -62,19 +85,24 @@ When task assignment includes flow control marker:
|
|||||||
|
|
||||||
**Context Gathering Decision Logic**:
|
**Context Gathering Decision Logic**:
|
||||||
```
|
```
|
||||||
|
MANDATORY FIRST STEP:
|
||||||
|
→ Execute tech stack detection and load guidelines into [tech_guidelines] variable
|
||||||
|
→ All subsequent review criteria must align with loaded tech stack principles
|
||||||
|
|
||||||
IF task contains [FLOW_CONTROL] flag:
|
IF task contains [FLOW_CONTROL] flag:
|
||||||
→ Execute each flow control step sequentially for context gathering
|
→ Execute each flow control step sequentially for context gathering
|
||||||
→ Use four flexible context acquisition methods:
|
→ Use four flexible context acquisition methods:
|
||||||
* Document references (cat commands)
|
* Document references (cat commands with tech stack context)
|
||||||
* Search commands (grep/rg/find)
|
* Search commands (grep/rg/find for tech-specific patterns)
|
||||||
* CLI analysis (gemini/codex)
|
* CLI analysis (gemini/codex with tech stack guidelines)
|
||||||
* Free exploration (Read/Grep/Search tools)
|
* Free exploration (Read/Grep/Search tools guided by tech principles)
|
||||||
→ Process [variable_name] references in commands
|
→ Process [variable_name] references in commands
|
||||||
→ Accumulate context through step outputs
|
→ Accumulate context through step outputs
|
||||||
|
→ Ensure [tech_guidelines] informs all analysis steps
|
||||||
ELIF reviewing >3 files OR security changes OR architecture modifications:
|
ELIF reviewing >3 files OR security changes OR architecture modifications:
|
||||||
→ Execute default flow control analysis (AUTO-TRIGGER)
|
→ Execute default flow control analysis (AUTO-TRIGGER) with tech stack guidelines
|
||||||
ELSE:
|
ELSE:
|
||||||
→ Proceed with review using standard quality checks
|
→ Proceed with tech-stack-informed review using standard quality checks
|
||||||
```
|
```
|
||||||
|
|
||||||
## Review Process (Mode-Adaptive)
|
## Review Process (Mode-Adaptive)
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ development_type: feature|component|refactor|debug|testing
|
|||||||
### Step 1: Template Discovery
|
### Step 1: Template Discovery
|
||||||
```bash
|
```bash
|
||||||
# Dynamically discover development templates
|
# Dynamically discover development templates
|
||||||
cd ~/.claude/workflows/cli-templates/prompts && echo "Discovering development templates..." && for dir in development automation analysis integration; do if [ -d "$dir" ]; then echo "=== $dir templates ==="; for template_file in "$dir"/*.txt; do if [ -f "$template_file" ]; then echo "Template: $(basename "$template_file")"; head -10 "$template_file" 2>/dev/null | grep -E "^(name|description|keywords):" || echo "No metadata"; echo; fi; done; fi; done
|
cd "~/.claude/workflows/cli-templates/prompts" && echo "Discovering development templates..." && for dir in development automation analysis integration; do if [ -d "$dir" ]; then echo "=== $dir templates ==="; for template_file in "$dir"/*.txt; do if [ -f "$template_file" ]; then echo "Template: $(basename "$template_file")"; head -10 "$template_file" 2>/dev/null | grep -E "^(name|description|keywords):" || echo "No metadata"; echo; fi; done; fi; done
|
||||||
```
|
```
|
||||||
|
|
||||||
### Step 2: Dynamic Template Analysis & Selection
|
### Step 2: Dynamic Template Analysis & Selection
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ model: sonnet
|
|||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
Comprehensive development planning and implementation strategy using expert planning templates with Codex CLI.
|
Comprehensive development planning and implementation strategy using expert planning templates with Codex CLI.
|
||||||
- **Directory Analysis Rule**: When user intends to analyze specific directory (cd XXX), use: `codex --cd XXX --full-auto exec "prompt" -s danger-full-access` or `cd XXX && codex --full-auto exec "@{**/*} prompt" -s danger-full-access`
|
- **Directory Analysis Rule**: When user intends to analyze specific directory (cd XXX), use: `codex --cd XXX --full-auto exec "prompt" -s danger-full-access` or `cd "XXX" && codex --full-auto exec "@{**/*} prompt" -s danger-full-access`
|
||||||
- **Default Mode**: `--full-auto exec` autonomous development mode (RECOMMENDED for all tasks).
|
- **Default Mode**: `--full-auto exec` autonomous development mode (RECOMMENDED for all tasks).
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ Automatically analyzes user input to select the most appropriate template and ex
|
|||||||
|
|
||||||
**Directory Analysis Rule**: Intelligent detection of directory context intent - automatically navigate to target directory when analysis scope is directory-specific.
|
**Directory Analysis Rule**: Intelligent detection of directory context intent - automatically navigate to target directory when analysis scope is directory-specific.
|
||||||
|
|
||||||
**--cd Parameter Rule**: When `--cd` parameter is provided, always execute `cd [path] && gemini --all-files -p "prompt"` to ensure analysis occurs in the specified directory context.
|
**--cd Parameter Rule**: When `--cd` parameter is provided, always execute `cd "[path]" && gemini --all-files -p "prompt"` to ensure analysis occurs in the specified directory context.
|
||||||
|
|
||||||
**Process**: List Templates → Analyze Input → Select Template → Execute with Context
|
**Process**: List Templates → Analyze Input → Select Template → Execute with Context
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ keywords: [keyword1, keyword2, keyword3]
|
|||||||
### Step 1: Template Discovery
|
### Step 1: Template Discovery
|
||||||
```bash
|
```bash
|
||||||
# Dynamically discover all templates and extract YAML frontmatter
|
# Dynamically discover all templates and extract YAML frontmatter
|
||||||
cd ~/.claude/prompt-templates && echo "Discovering templates..." && for template_file in *.md; do echo "=== $template_file ==="; head -6 "$template_file" 2>/dev/null || echo "Error reading $template_file"; echo; done
|
cd "~/.claude/prompt-templates" && echo "Discovering templates..." && for template_file in *.md; do echo "=== $template_file ==="; head -6 "$template_file" 2>/dev/null || echo "Error reading $template_file"; echo; done
|
||||||
```
|
```
|
||||||
|
|
||||||
### Step 2: Dynamic Template Analysis & Selection
|
### Step 2: Dynamic Template Analysis & Selection
|
||||||
@@ -131,7 +131,7 @@ gemini --all-files -p "$(cat ~/.claude/prompt-templates/[selected_template])
|
|||||||
User Input: [user_input]"
|
User Input: [user_input]"
|
||||||
|
|
||||||
# With --cd parameter
|
# With --cd parameter
|
||||||
cd [specified_directory] && gemini --all-files -p "$(cat ~/.claude/prompt-templates/[selected_template])
|
cd "[specified_directory]" && gemini --all-files -p "$(cat ~/.claude/prompt-templates/[selected_template])
|
||||||
|
|
||||||
User Input: [user_input]"
|
User Input: [user_input]"
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ Systematic bug analysis and fix suggestions using expert diagnostic template.
|
|||||||
|
|
||||||
**Directory Analysis Rule**: Intelligent detection of directory context intent - automatically navigate to target directory when analysis scope is directory-specific.
|
**Directory Analysis Rule**: Intelligent detection of directory context intent - automatically navigate to target directory when analysis scope is directory-specific.
|
||||||
|
|
||||||
**--cd Parameter Rule**: When `--cd` parameter is provided, always execute `cd [path] && gemini --all-files -p "prompt"` to ensure analysis occurs in the specified directory context.
|
**--cd Parameter Rule**: When `--cd` parameter is provided, always execute `cd "[path]" && gemini --all-files -p "prompt"` to ensure analysis occurs in the specified directory context.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@ gemini --all-files -p "$(cat ~/.claude/prompt-templates/bug-fix.md)
|
|||||||
Bug Description: [user_description]"
|
Bug Description: [user_description]"
|
||||||
|
|
||||||
# With --cd parameter
|
# With --cd parameter
|
||||||
cd [specified_directory] && gemini --all-files -p "$(cat ~/.claude/prompt-templates/bug-fix.md)
|
cd "[specified_directory]" && gemini --all-files -p "$(cat ~/.claude/prompt-templates/bug-fix.md)
|
||||||
|
|
||||||
Bug Description: [user_description]"
|
Bug Description: [user_description]"
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ model: sonnet
|
|||||||
### Key Features
|
### Key Features
|
||||||
- **Gemini CLI Integration**: Utilizes Gemini CLI's deep codebase analysis for informed planning decisions
|
- **Gemini CLI Integration**: Utilizes Gemini CLI's deep codebase analysis for informed planning decisions
|
||||||
|
|
||||||
**--cd Parameter Rule**: When `--cd` parameter is provided, always execute `cd [path] && gemini --all-files -p "prompt"` to ensure analysis occurs in the specified directory context.
|
**--cd Parameter Rule**: When `--cd` parameter is provided, always execute `cd "[path]" && gemini --all-files -p "prompt"` to ensure analysis occurs in the specified directory context.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ gemini --all-files -p "$(cat ~/.claude/prompt-templates/plan.md)
|
|||||||
Planning Topic: [user_description]"
|
Planning Topic: [user_description]"
|
||||||
|
|
||||||
# Directory-specific analysis
|
# Directory-specific analysis
|
||||||
cd [directory] && gemini --all-files -p "$(cat ~/.claude/prompt-templates/plan.md)
|
cd "[directory]" && gemini --all-files -p "$(cat ~/.claude/prompt-templates/plan.md)
|
||||||
Planning Topic: [user_description]"
|
Planning Topic: [user_description]"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ Automatically analyzes user input to select the most appropriate template and ex
|
|||||||
|
|
||||||
**Directory Analysis Rule**: Intelligent detection of directory context intent - automatically navigate to target directory when analysis scope is directory-specific.
|
**Directory Analysis Rule**: Intelligent detection of directory context intent - automatically navigate to target directory when analysis scope is directory-specific.
|
||||||
|
|
||||||
**--cd Parameter Rule**: When `--cd` parameter is provided, always execute `cd [path] && qwen --all-files -p "prompt"` to ensure analysis occurs in the specified directory context.
|
**--cd Parameter Rule**: When `--cd` parameter is provided, always execute `cd "[path]" && qwen --all-files -p "prompt"` to ensure analysis occurs in the specified directory context.
|
||||||
|
|
||||||
**Process**: List Templates → Analyze Input → Select Template → Execute with Context
|
**Process**: List Templates → Analyze Input → Select Template → Execute with Context
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ keywords: [keyword1, keyword2, keyword3]
|
|||||||
### Step 1: Template Discovery
|
### Step 1: Template Discovery
|
||||||
```bash
|
```bash
|
||||||
# Dynamically discover all templates and extract YAML frontmatter
|
# Dynamically discover all templates and extract YAML frontmatter
|
||||||
cd ~/.claude/prompt-templates && echo "Discovering templates..." && for template_file in *.md; do echo "=== $template_file ==="; head -6 "$template_file" 2>/dev/null || echo "Error reading $template_file"; echo; done
|
cd "~/.claude/prompt-templates" && echo "Discovering templates..." && for template_file in *.md; do echo "=== $template_file ==="; head -6 "$template_file" 2>/dev/null || echo "Error reading $template_file"; echo; done
|
||||||
```
|
```
|
||||||
|
|
||||||
### Step 2: Dynamic Template Analysis & Selection
|
### Step 2: Dynamic Template Analysis & Selection
|
||||||
@@ -131,7 +131,7 @@ qwen --all-files -p "$(cat ~/.claude/prompt-templates/[selected_template])
|
|||||||
User Input: [user_input]"
|
User Input: [user_input]"
|
||||||
|
|
||||||
# With --cd parameter
|
# With --cd parameter
|
||||||
cd [specified_directory] && qwen --all-files -p "$(cat ~/.claude/prompt-templates/[selected_template])
|
cd "[specified_directory]" && qwen --all-files -p "$(cat ~/.claude/prompt-templates/[selected_template])
|
||||||
|
|
||||||
User Input: [user_input]"
|
User Input: [user_input]"
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ Systematic bug analysis and fix suggestions using expert diagnostic template.
|
|||||||
|
|
||||||
**Directory Analysis Rule**: Intelligent detection of directory context intent - automatically navigate to target directory when analysis scope is directory-specific.
|
**Directory Analysis Rule**: Intelligent detection of directory context intent - automatically navigate to target directory when analysis scope is directory-specific.
|
||||||
|
|
||||||
**--cd Parameter Rule**: When `--cd` parameter is provided, always execute `cd [path] && qwen --all-files -p "prompt"` to ensure analysis occurs in the specified directory context.
|
**--cd Parameter Rule**: When `--cd` parameter is provided, always execute `cd "[path]" && qwen --all-files -p "prompt"` to ensure analysis occurs in the specified directory context.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@ qwen --all-files -p "$(cat ~/.claude/prompt-templates/bug-fix.md)
|
|||||||
Bug Description: [user_description]"
|
Bug Description: [user_description]"
|
||||||
|
|
||||||
# With --cd parameter
|
# With --cd parameter
|
||||||
cd [specified_directory] && qwen --all-files -p "$(cat ~/.claude/prompt-templates/bug-fix.md)
|
cd "[specified_directory]" && qwen --all-files -p "$(cat ~/.claude/prompt-templates/bug-fix.md)
|
||||||
|
|
||||||
Bug Description: [user_description]"
|
Bug Description: [user_description]"
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ model: sonnet
|
|||||||
### Key Features
|
### Key Features
|
||||||
- **qwen CLI Integration**: Utilizes qwen CLI's deep codebase analysis for informed planning decisions
|
- **qwen CLI Integration**: Utilizes qwen CLI's deep codebase analysis for informed planning decisions
|
||||||
|
|
||||||
**--cd Parameter Rule**: When `--cd` parameter is provided, always execute `cd [path] && qwen --all-files -p "prompt"` to ensure analysis occurs in the specified directory context.
|
**--cd Parameter Rule**: When `--cd` parameter is provided, always execute `cd "[path]" && qwen --all-files -p "prompt"` to ensure analysis occurs in the specified directory context.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ qwen --all-files -p "$(cat ~/.claude/prompt-templates/plan.md)
|
|||||||
Planning Topic: [user_description]"
|
Planning Topic: [user_description]"
|
||||||
|
|
||||||
# Directory-specific analysis
|
# Directory-specific analysis
|
||||||
cd [directory] && qwen --all-files -p "$(cat ~/.claude/prompt-templates/plan.md)
|
cd "[directory]" && qwen --all-files -p "$(cat ~/.claude/prompt-templates/plan.md)
|
||||||
Planning Topic: [user_description]"
|
Planning Topic: [user_description]"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ The command performs comprehensive analysis through:
|
|||||||
- **Simple tasks** (≤3 modules): Direct CLI tools with intelligent path navigation and multi-round analysis
|
- **Simple tasks** (≤3 modules): Direct CLI tools with intelligent path navigation and multi-round analysis
|
||||||
```bash
|
```bash
|
||||||
# Analyze specific directory
|
# Analyze specific directory
|
||||||
~/.claude/scripts/gemini-wrapper -C src/auth -p "
|
cd "src/auth" && ~/.claude/scripts/gemini-wrapper -p "
|
||||||
PURPOSE: Analyze authentication patterns
|
PURPOSE: Analyze authentication patterns
|
||||||
TASK: Review auth implementation for security patterns
|
TASK: Review auth implementation for security patterns
|
||||||
CONTEXT: Focus on JWT handling and user validation
|
CONTEXT: Focus on JWT handling and user validation
|
||||||
@@ -106,7 +106,7 @@ The following pre_analysis steps are generated for agent execution:
|
|||||||
{
|
{
|
||||||
"step": "analyze_patterns",
|
"step": "analyze_patterns",
|
||||||
"action": "Analyze codebase patterns and architecture using CLI tools with directory context",
|
"action": "Analyze codebase patterns and architecture using CLI tools with directory context",
|
||||||
"command": "bash(~/.claude/scripts/gemini-wrapper -C [target_directory] -p \"PURPOSE: Analyze existing patterns TASK: Identify implementation patterns for [task_type] CONTEXT: [planning_context] [dependency_context] EXPECTED: Pattern analysis and recommendations RULES: Focus on architectural consistency\")",
|
"command": "bash(cd \"[target_directory]\" && ~/.claude/scripts/gemini-wrapper -p \"PURPOSE: Analyze existing patterns TASK: Identify implementation patterns for [task_type] CONTEXT: [planning_context] [dependency_context] EXPECTED: Pattern analysis and recommendations RULES: Focus on architectural consistency\")",
|
||||||
"output_to": "pattern_analysis",
|
"output_to": "pattern_analysis",
|
||||||
"on_error": "skip_optional"
|
"on_error": "skip_optional"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
# Location: ~/.claude/scripts/gemini-wrapper
|
# Location: ~/.claude/scripts/gemini-wrapper
|
||||||
#
|
#
|
||||||
# This wrapper automatically manages --all-files flag based on project token count
|
# This wrapper automatically manages --all-files flag based on project token count
|
||||||
# Usage: gemini-wrapper [-C <directory>] [all gemini options]
|
# Usage: gemini-wrapper [all gemini options]
|
||||||
# -C <directory> Change to specified directory before analysis (relative or absolute path)
|
# Note: Executes in current working directory
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
@@ -18,20 +18,72 @@ GREEN='\033[0;32m'
|
|||||||
YELLOW='\033[1;33m'
|
YELLOW='\033[1;33m'
|
||||||
NC='\033[0m' # No Color
|
NC='\033[0m' # No Color
|
||||||
|
|
||||||
# Function to count tokens (approximate: chars/4)
|
# Function to count tokens (approximate: chars/4) - optimized version
|
||||||
count_tokens() {
|
count_tokens() {
|
||||||
local total_chars=0
|
local total_chars=0
|
||||||
local file_count=0
|
local file_count=0
|
||||||
|
|
||||||
# Count characters in common source files
|
# Use single find with bulk wc for better performance
|
||||||
while IFS= read -r -d '' file; do
|
# Common source file extensions
|
||||||
if [[ -f "$file" && -r "$file" ]]; then
|
local extensions="py js ts tsx jsx java cpp c h rs go md txt json yaml yml xml html css scss sass php rb sh bash"
|
||||||
local chars=$(wc -c < "$file" 2>/dev/null || echo 0)
|
|
||||||
total_chars=$((total_chars + chars))
|
# Build find command with extension patterns
|
||||||
file_count=$((file_count + 1))
|
local find_cmd="find . -type f \("
|
||||||
|
local first=true
|
||||||
|
for ext in $extensions; do
|
||||||
|
if [[ "$first" == true ]]; then
|
||||||
|
find_cmd+=" -name \"*.$ext\""
|
||||||
|
first=false
|
||||||
|
else
|
||||||
|
find_cmd+=" -o -name \"*.$ext\""
|
||||||
fi
|
fi
|
||||||
done < <(find . -type f \( -name "*.py" -o -name "*.js" -o -name "*.ts" -o -name "*.tsx" -o -name "*.jsx" -o -name "*.java" -o -name "*.cpp" -o -name "*.c" -o -name "*.h" -o -name "*.rs" -o -name "*.go" -o -name "*.md" -o -name "*.txt" -o -name "*.json" -o -name "*.yaml" -o -name "*.yml" -o -name "*.xml" -o -name "*.html" -o -name "*.css" -o -name "*.scss" -o -name "*.sass" -o -name "*.php" -o -name "*.rb" -o -name "*.sh" -o -name "*.bash" \) -not -path "*/node_modules/*" -not -path "*/.git/*" -not -path "*/dist/*" -not -path "*/build/*" -not -path "*/.next/*" -not -path "*/.nuxt/*" -not -path "*/target/*" -not -path "*/vendor/*" -print0 2>/dev/null)
|
done
|
||||||
|
find_cmd+=" \)"
|
||||||
|
|
||||||
|
# Exclude common build/cache directories
|
||||||
|
find_cmd+=" -not -path \"*/node_modules/*\""
|
||||||
|
find_cmd+=" -not -path \"*/.git/*\""
|
||||||
|
find_cmd+=" -not -path \"*/dist/*\""
|
||||||
|
find_cmd+=" -not -path \"*/build/*\""
|
||||||
|
find_cmd+=" -not -path \"*/.next/*\""
|
||||||
|
find_cmd+=" -not -path \"*/.nuxt/*\""
|
||||||
|
find_cmd+=" -not -path \"*/target/*\""
|
||||||
|
find_cmd+=" -not -path \"*/vendor/*\""
|
||||||
|
find_cmd+=" -not -path \"*/__pycache__/*\""
|
||||||
|
find_cmd+=" -not -path \"*/.cache/*\""
|
||||||
|
find_cmd+=" 2>/dev/null"
|
||||||
|
|
||||||
|
# Use efficient bulk processing with wc
|
||||||
|
if command -v wc >/dev/null 2>&1; then
|
||||||
|
# Try bulk wc first - much faster for many files
|
||||||
|
local wc_output
|
||||||
|
wc_output=$(eval "$find_cmd" | xargs wc -c 2>/dev/null | tail -n 1)
|
||||||
|
|
||||||
|
# Parse the total line (last line of wc output when processing multiple files)
|
||||||
|
if [[ -n "$wc_output" && "$wc_output" =~ ^[[:space:]]*([0-9]+)[[:space:]]+total[[:space:]]*$ ]]; then
|
||||||
|
total_chars="${BASH_REMATCH[1]}"
|
||||||
|
file_count=$(eval "$find_cmd" | wc -l 2>/dev/null || echo 0)
|
||||||
|
else
|
||||||
|
# Fallback: single file processing
|
||||||
|
while IFS= read -r file; do
|
||||||
|
if [[ -f "$file" && -r "$file" ]]; then
|
||||||
|
local chars=$(wc -c < "$file" 2>/dev/null || echo 0)
|
||||||
|
total_chars=$((total_chars + chars))
|
||||||
|
file_count=$((file_count + 1))
|
||||||
|
fi
|
||||||
|
done < <(eval "$find_cmd")
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# No wc available - fallback method
|
||||||
|
while IFS= read -r file; do
|
||||||
|
if [[ -f "$file" && -r "$file" ]]; then
|
||||||
|
local chars=$(stat -c%s "$file" 2>/dev/null || echo 0)
|
||||||
|
total_chars=$((total_chars + chars))
|
||||||
|
file_count=$((file_count + 1))
|
||||||
|
fi
|
||||||
|
done < <(eval "$find_cmd")
|
||||||
|
fi
|
||||||
|
|
||||||
local estimated_tokens=$((total_chars / 4))
|
local estimated_tokens=$((total_chars / 4))
|
||||||
echo "$estimated_tokens $file_count"
|
echo "$estimated_tokens $file_count"
|
||||||
}
|
}
|
||||||
@@ -39,13 +91,10 @@ count_tokens() {
|
|||||||
# Parse arguments to check for flags
|
# Parse arguments to check for flags
|
||||||
has_all_files=false
|
has_all_files=false
|
||||||
has_approval_mode=false
|
has_approval_mode=false
|
||||||
change_dir=""
|
|
||||||
args=()
|
args=()
|
||||||
|
|
||||||
# Check for existing flags and -c parameter
|
# Check for existing flags
|
||||||
i=0
|
for arg in "$@"; do
|
||||||
while [[ $i -lt $# ]]; do
|
|
||||||
arg="${!i}"
|
|
||||||
case "$arg" in
|
case "$arg" in
|
||||||
"--all-files")
|
"--all-files")
|
||||||
has_all_files=true
|
has_all_files=true
|
||||||
@@ -55,39 +104,14 @@ while [[ $i -lt $# ]]; do
|
|||||||
has_approval_mode=true
|
has_approval_mode=true
|
||||||
args+=("$arg")
|
args+=("$arg")
|
||||||
;;
|
;;
|
||||||
"-C")
|
|
||||||
# Next argument is the directory
|
|
||||||
i=$((i + 1))
|
|
||||||
if [[ $i -lt $# ]]; then
|
|
||||||
change_dir="${!i}"
|
|
||||||
echo -e "${YELLOW}📁 Directory change requested: $change_dir${NC}" >&2
|
|
||||||
else
|
|
||||||
echo -e "${RED}❌ Error: -C requires a directory path${NC}" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*)
|
*)
|
||||||
args+=("$arg")
|
args+=("$arg")
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
i=$((i + 1))
|
|
||||||
done
|
done
|
||||||
|
|
||||||
# Change directory if requested
|
# Analyze current working directory
|
||||||
original_dir=""
|
echo -e "${GREEN}📁 Analyzing current directory: $(pwd)${NC}" >&2
|
||||||
if [[ -n "$change_dir" ]]; then
|
|
||||||
original_dir=$(pwd)
|
|
||||||
if [[ -d "$change_dir" ]]; then
|
|
||||||
echo -e "${GREEN}📁 Changing to directory: $change_dir${NC}" >&2
|
|
||||||
cd "$change_dir" || {
|
|
||||||
echo -e "${RED}❌ Error: Cannot change to directory: $change_dir${NC}" >&2
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
else
|
|
||||||
echo -e "${RED}❌ Error: Directory does not exist: $change_dir${NC}" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Count tokens (in the target directory if -c was used)
|
# Count tokens (in the target directory if -c was used)
|
||||||
echo -e "${YELLOW}🔍 Analyzing project size...${NC}" >&2
|
echo -e "${YELLOW}🔍 Analyzing project size...${NC}" >&2
|
||||||
@@ -137,5 +161,5 @@ fi
|
|||||||
# Show final command (for transparency)
|
# Show final command (for transparency)
|
||||||
echo -e "${YELLOW}🚀 Executing: gemini ${args[*]}${NC}" >&2
|
echo -e "${YELLOW}🚀 Executing: gemini ${args[*]}${NC}" >&2
|
||||||
|
|
||||||
# Execute gemini with adjusted arguments
|
# Execute gemini with adjusted arguments (we're already in the right directory)
|
||||||
exec gemini "${args[@]}"
|
gemini "${args[@]}"
|
||||||
@@ -3,8 +3,8 @@
|
|||||||
# Location: ~/.claude/scripts/qwen-wrapper
|
# Location: ~/.claude/scripts/qwen-wrapper
|
||||||
#
|
#
|
||||||
# This wrapper automatically manages --all-files flag based on project token count
|
# This wrapper automatically manages --all-files flag based on project token count
|
||||||
# Usage: qwen-wrapper [-C <directory>] [all qwen options]
|
# Usage: qwen-wrapper [all qwen options]
|
||||||
# -C <directory> Change to specified directory before analysis (relative or absolute path)
|
# Note: Executes in current working directory
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
@@ -39,13 +39,10 @@ count_tokens() {
|
|||||||
# Parse arguments to check for flags
|
# Parse arguments to check for flags
|
||||||
has_all_files=false
|
has_all_files=false
|
||||||
has_approval_mode=false
|
has_approval_mode=false
|
||||||
change_dir=""
|
|
||||||
args=()
|
args=()
|
||||||
|
|
||||||
# Check for existing flags and -c parameter
|
# Check for existing flags
|
||||||
i=0
|
for arg in "$@"; do
|
||||||
while [[ $i -lt $# ]]; do
|
|
||||||
arg="${!i}"
|
|
||||||
case "$arg" in
|
case "$arg" in
|
||||||
"--all-files")
|
"--all-files")
|
||||||
has_all_files=true
|
has_all_files=true
|
||||||
@@ -55,39 +52,14 @@ while [[ $i -lt $# ]]; do
|
|||||||
has_approval_mode=true
|
has_approval_mode=true
|
||||||
args+=("$arg")
|
args+=("$arg")
|
||||||
;;
|
;;
|
||||||
"-C")
|
|
||||||
# Next argument is the directory
|
|
||||||
i=$((i + 1))
|
|
||||||
if [[ $i -lt $# ]]; then
|
|
||||||
change_dir="${!i}"
|
|
||||||
echo -e "${YELLOW}📁 Directory change requested: $change_dir${NC}" >&2
|
|
||||||
else
|
|
||||||
echo -e "${RED}❌ Error: -C requires a directory path${NC}" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*)
|
*)
|
||||||
args+=("$arg")
|
args+=("$arg")
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
i=$((i + 1))
|
|
||||||
done
|
done
|
||||||
|
|
||||||
# Change directory if requested
|
# Analyze current working directory
|
||||||
original_dir=""
|
echo -e "${GREEN}📁 Analyzing current directory: $(pwd)${NC}" >&2
|
||||||
if [[ -n "$change_dir" ]]; then
|
|
||||||
original_dir=$(pwd)
|
|
||||||
if [[ -d "$change_dir" ]]; then
|
|
||||||
echo -e "${GREEN}📁 Changing to directory: $change_dir${NC}" >&2
|
|
||||||
cd "$change_dir" || {
|
|
||||||
echo -e "${RED}❌ Error: Cannot change to directory: $change_dir${NC}" >&2
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
else
|
|
||||||
echo -e "${RED}❌ Error: Directory does not exist: $change_dir${NC}" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Count tokens (in the target directory if -c was used)
|
# Count tokens (in the target directory if -c was used)
|
||||||
echo -e "${YELLOW}🔍 Analyzing project size...${NC}" >&2
|
echo -e "${YELLOW}🔍 Analyzing project size...${NC}" >&2
|
||||||
@@ -137,5 +109,5 @@ fi
|
|||||||
# Show final command (for transparency)
|
# Show final command (for transparency)
|
||||||
echo -e "${YELLOW}🚀 Executing: qwen ${args[*]}${NC}" >&2
|
echo -e "${YELLOW}🚀 Executing: qwen ${args[*]}${NC}" >&2
|
||||||
|
|
||||||
# Execute qwen with adjusted arguments
|
# Execute qwen with adjusted arguments (we're already in the right directory)
|
||||||
exec qwen "${args[@]}"
|
qwen "${args[@]}"
|
||||||
@@ -29,7 +29,7 @@ type: strategic-guideline
|
|||||||
### Core Execution Rules
|
### Core Execution Rules
|
||||||
- **Default Timeout**: Bash commands default execution time = 20 minutes (1200000ms)
|
- **Default Timeout**: Bash commands default execution time = 20 minutes (1200000ms)
|
||||||
- **Apply to All Tools**: All bash() wrapped commands including Gemini, Qwen wrapper and Codex executions use this timeout
|
- **Apply to All Tools**: All bash() wrapped commands including Gemini, Qwen wrapper and Codex executions use this timeout
|
||||||
- **Command Examples**: `bash(~/.claude/scripts/gemini-wrapper -p "prompt")`, `bash(~/.claude/scripts/qwen-wrapper -p "prompt")`, `bash(codex --full-auto exec "task")`
|
- **Command Examples**: `bash(cd target/directory && ~/.claude/scripts/gemini-wrapper -p "prompt")`, `bash(cd target/directory && ~/.claude/scripts/qwen-wrapper -p "prompt")`, `bash(codex -C directory --full-auto exec "task")`
|
||||||
- **Override When Needed**: Specify custom timeout for longer operations
|
- **Override When Needed**: Specify custom timeout for longer operations
|
||||||
|
|
||||||
## 🎯 Universal Command Template
|
## 🎯 Universal Command Template
|
||||||
@@ -37,7 +37,7 @@ type: strategic-guideline
|
|||||||
### Standard Format (REQUIRED)
|
### Standard Format (REQUIRED)
|
||||||
```bash
|
```bash
|
||||||
# Gemini Analysis
|
# Gemini Analysis
|
||||||
~/.claude/scripts/gemini-wrapper -C [directory] -p "
|
cd [directory] && ~/.claude/scripts/gemini-wrapper -p "
|
||||||
PURPOSE: [clear analysis goal]
|
PURPOSE: [clear analysis goal]
|
||||||
TASK: [specific analysis task]
|
TASK: [specific analysis task]
|
||||||
CONTEXT: [file references and memory context]
|
CONTEXT: [file references and memory context]
|
||||||
@@ -46,7 +46,7 @@ RULES: [template reference and constraints]
|
|||||||
"
|
"
|
||||||
|
|
||||||
# Qwen Architecture & Code Generation
|
# Qwen Architecture & Code Generation
|
||||||
~/.claude/scripts/qwen-wrapper -C [directory] -p "
|
cd [directory] && ~/.claude/scripts/qwen-wrapper -p "
|
||||||
PURPOSE: [clear architecture/code goal]
|
PURPOSE: [clear architecture/code goal]
|
||||||
TASK: [specific architecture/code task]
|
TASK: [specific architecture/code task]
|
||||||
CONTEXT: [file references and memory context]
|
CONTEXT: [file references and memory context]
|
||||||
@@ -71,13 +71,13 @@ RULES: [template reference and constraints]
|
|||||||
- [ ] **EXPECTED** - Clear expected results
|
- [ ] **EXPECTED** - Clear expected results
|
||||||
- [ ] **RULES** - Template reference and constraints
|
- [ ] **RULES** - Template reference and constraints
|
||||||
|
|
||||||
### Directory Context (-C parameter)
|
### Directory Context
|
||||||
All tools support changing working directory before execution:
|
Tools execute in current working directory:
|
||||||
- **Gemini**: `~/.claude/scripts/gemini-wrapper -C path/to/project -p "prompt"`
|
- **Gemini**: `cd path/to/project && ~/.claude/scripts/gemini-wrapper -p "prompt"`
|
||||||
- **Qwen**: `~/.claude/scripts/qwen-wrapper -C path/to/project -p "prompt"`
|
- **Qwen**: `cd path/to/project && ~/.claude/scripts/qwen-wrapper -p "prompt"`
|
||||||
- **Codex**: `codex -C path/to/project --full-auto exec "task"`
|
- **Codex**: `codex -C path/to/project --full-auto exec "task"` (Codex still supports -C)
|
||||||
- **Path types**: Supports both relative (`../project`) and absolute (`/full/path`) paths
|
- **Path types**: Supports both relative (`../project`) and absolute (`/full/path`) paths
|
||||||
- **Token analysis**: For gemini-wrapper and qwen-wrapper, token counting happens in target directory
|
- **Token analysis**: For gemini-wrapper and qwen-wrapper, token counting happens in current directory
|
||||||
|
|
||||||
### Rules Field Format
|
### Rules Field Format
|
||||||
```bash
|
```bash
|
||||||
@@ -155,7 +155,7 @@ RULES: $(cat ~/.claude/workflows/cli-templates/prompts/analysis/architecture.txt
|
|||||||
"
|
"
|
||||||
|
|
||||||
# Project Analysis (in different directory)
|
# Project Analysis (in different directory)
|
||||||
~/.claude/scripts/gemini-wrapper -C ../other-project -p "
|
cd ../other-project && ~/.claude/scripts/gemini-wrapper -p "
|
||||||
PURPOSE: Compare authentication patterns
|
PURPOSE: Compare authentication patterns
|
||||||
TASK: Analyze auth implementation in related project
|
TASK: Analyze auth implementation in related project
|
||||||
CONTEXT: @{src/auth/**/*} Current project context from session memory
|
CONTEXT: @{src/auth/**/*} Current project context from session memory
|
||||||
@@ -164,7 +164,7 @@ RULES: $(cat ~/.claude/workflows/cli-templates/prompts/analysis/pattern.txt) | F
|
|||||||
"
|
"
|
||||||
|
|
||||||
# Architecture Design (with Qwen)
|
# Architecture Design (with Qwen)
|
||||||
~/.claude/scripts/qwen-wrapper -C src/auth -p "
|
cd src/auth && ~/.claude/scripts/qwen-wrapper -p "
|
||||||
PURPOSE: Design authentication system architecture
|
PURPOSE: Design authentication system architecture
|
||||||
TASK: Create modular JWT-based auth system design
|
TASK: Create modular JWT-based auth system design
|
||||||
CONTEXT: @{src/auth/**/*} Existing patterns and requirements
|
CONTEXT: @{src/auth/**/*} Existing patterns and requirements
|
||||||
@@ -236,20 +236,20 @@ For every development task:
|
|||||||
- **Document context** - Always reference CLAUDE.md for context
|
- **Document context** - Always reference CLAUDE.md for context
|
||||||
|
|
||||||
### Context Optimization Strategy
|
### Context Optimization Strategy
|
||||||
**Directory Navigation**: Use `-C [directory]` parameter when analyzing specific areas to reduce irrelevant context
|
**Directory Navigation**: Use `cd [directory] &&` pattern when analyzing specific areas to reduce irrelevant context
|
||||||
|
|
||||||
**When to use `-C`**:
|
**When to change directory**:
|
||||||
- Specific directory mentioned → Use `-C directory` parameter
|
- Specific directory mentioned → Use `cd directory &&` pattern
|
||||||
- Focused analysis needed → Target specific directory with `-C`
|
- Focused analysis needed → Target specific directory with cd
|
||||||
- Multi-directory scope → Stay in root, use explicit paths or multiple commands
|
- Multi-directory scope → Stay in root, use explicit paths or multiple commands
|
||||||
|
|
||||||
**Example**:
|
**Example**:
|
||||||
```bash
|
```bash
|
||||||
# Focused analysis (preferred)
|
# Focused analysis (preferred)
|
||||||
~/.claude/scripts/gemini-wrapper -C src/auth -p "analyze auth patterns"
|
cd src/auth && ~/.claude/scripts/gemini-wrapper -p "analyze auth patterns"
|
||||||
|
|
||||||
# Focused architecture (Qwen)
|
# Focused architecture (Qwen)
|
||||||
~/.claude/scripts/qwen-wrapper -C src/auth -p "design auth architecture"
|
cd src/auth && ~/.claude/scripts/qwen-wrapper -p "design auth architecture"
|
||||||
|
|
||||||
# Focused implementation (Codex)
|
# Focused implementation (Codex)
|
||||||
codex -C src/auth --full-auto exec "analyze auth implementation"
|
codex -C src/auth --full-auto exec "analyze auth implementation"
|
||||||
|
|||||||
Reference in New Issue
Block a user