diff --git a/.claude/scripts/gemini-wrapper b/.claude/scripts/gemini-wrapper index b9ccde99..fa69f4b4 100644 --- a/.claude/scripts/gemini-wrapper +++ b/.claude/scripts/gemini-wrapper @@ -1,9 +1,10 @@ #!/bin/bash # gemini-wrapper - Token-aware wrapper for gemini command # Location: ~/.claude/scripts/gemini-wrapper -# +# # This wrapper automatically manages --all-files flag based on project token count -# Usage: gemini-wrapper [all gemini options] +# Usage: gemini-wrapper [-C ] [all gemini options] +# -C Change to specified directory before analysis (relative or absolute path) set -e @@ -38,19 +39,57 @@ count_tokens() { # Parse arguments to check for flags has_all_files=false has_approval_mode=false +change_dir="" args=() -# Check for existing flags -for arg in "$@"; do - if [[ "$arg" == "--all-files" ]]; then - has_all_files=true - elif [[ "$arg" == --approval-mode* ]]; then - has_approval_mode=true - fi - args+=("$arg") +# Check for existing flags and -c parameter +i=0 +while [[ $i -lt $# ]]; do + arg="${!i}" + case "$arg" in + "--all-files") + has_all_files=true + args+=("$arg") + ;; + --approval-mode*) + has_approval_mode=true + 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") + ;; + esac + i=$((i + 1)) done -# Count tokens +# Change directory if requested +original_dir="" +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) echo -e "${YELLOW}🔍 Analyzing project size...${NC}" >&2 read -r token_count file_count <<< "$(count_tokens)" diff --git a/.claude/workflows/intelligent-tools-strategy.md b/.claude/workflows/intelligent-tools-strategy.md index d8303500..186c6e62 100644 --- a/.claude/workflows/intelligent-tools-strategy.md +++ b/.claude/workflows/intelligent-tools-strategy.md @@ -16,7 +16,7 @@ type: strategic-guideline - **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 -- **Context optimization** - Based on user intent, determine whether to use `cd [directory]` for focused analysis to reduce irrelevant context import +- **Context optimization** - Based on user intent, determine whether to use `-C [directory]` parameter for focused analysis to reduce irrelevant context import ### Quick Decision Rules 1. **Exploring/Understanding?** → Start with Gemini @@ -35,7 +35,7 @@ type: strategic-guideline ### Standard Format (REQUIRED) ```bash # Gemini Analysis -~/.claude/scripts/gemini-wrapper -p " +~/.claude/scripts/gemini-wrapper [-C directory] -p " PURPOSE: [clear analysis goal] TASK: [specific analysis task] CONTEXT: [file references and memory context] @@ -44,7 +44,7 @@ RULES: [template reference and constraints] " # Codex Development -codex --full-auto exec " +codex [-C directory] --full-auto exec " PURPOSE: [clear development goal] TASK: [specific development task] CONTEXT: [file references and memory context] @@ -60,6 +60,13 @@ RULES: [template reference and constraints] - [ ] **EXPECTED** - Clear expected results - [ ] **RULES** - Template reference and constraints +### Directory Context (-C parameter) +Both tools support changing working directory before execution: +- **Gemini**: `~/.claude/scripts/gemini-wrapper -C path/to/project -p "prompt"` +- **Codex**: `codex -C path/to/project --full-auto exec "task"` +- **Path types**: Supports both relative (`../project`) and absolute (`/full/path`) paths +- **Token analysis**: For gemini-wrapper, token counting happens in target directory + ### Rules Field Format ```bash RULES: $(cat ~/.claude/workflows/cli-templates/prompts/[category]/[template].txt) | [constraints] @@ -123,7 +130,7 @@ When planning any coding task, **ALWAYS** integrate CLI tools: ### Common Scenarios ```bash -# Project Analysis +# Project Analysis (in current directory) ~/.claude/scripts/gemini-wrapper -p " PURPOSE: Understand codebase architecture TASK: Analyze project structure and identify patterns @@ -132,8 +139,17 @@ EXPECTED: Architecture overview and integration points RULES: $(cat ~/.claude/workflows/cli-templates/prompts/analysis/architecture.txt) | Focus on integration points " -# Feature Development -codex --full-auto exec " +# Project Analysis (in different directory) +~/.claude/scripts/gemini-wrapper -C ../other-project -p " +PURPOSE: Compare authentication patterns +TASK: Analyze auth implementation in related project +CONTEXT: @{src/auth/**/*} Current project context from session memory +EXPECTED: Pattern comparison and recommendations +RULES: $(cat ~/.claude/workflows/cli-templates/prompts/analysis/pattern.txt) | Focus on architectural differences +" + +# Feature Development (in target directory) +codex -C path/to/project --full-auto exec " PURPOSE: Implement user authentication TASK: Create JWT-based authentication system CONTEXT: @{src/auth/**/*} Database schema from session memory @@ -191,18 +207,21 @@ For every development task: - **Document context** - Always reference CLAUDE.md for context ### Context Optimization Strategy -**Directory Navigation**: Use `cd [directory]` when analyzing specific areas to reduce irrelevant context +**Directory Navigation**: Use `-C [directory]` parameter when analyzing specific areas to reduce irrelevant context -**When to use `cd`**: -- Specific directory mentioned → Navigate first -- Focused analysis needed → Change to target directory -- Multi-directory scope → Stay in root, use explicit paths +**When to use `-C`**: +- Specific directory mentioned → Use `-C directory` parameter +- Focused analysis needed → Target specific directory with `-C` +- Multi-directory scope → Stay in root, use explicit paths or multiple commands **Example**: ```bash # Focused (preferred) -cd src/auth && ~/.claude/scripts/gemini-wrapper -p "analyze auth patterns" +~/.claude/scripts/gemini-wrapper -C src/auth -p "analyze auth patterns" -# Multi-scope +# Alternative for codex +codex -C src/auth --full-auto exec "analyze auth implementation" + +# Multi-scope (stay in root) ~/.claude/scripts/gemini-wrapper -p "CONTEXT: @{src/auth/**/*,src/api/**/*}" ``` \ No newline at end of file diff --git a/.claude/workflows/workflow-architecture.md b/.claude/workflows/workflow-architecture.md index ad417457..5d29171c 100644 --- a/.claude/workflows/workflow-architecture.md +++ b/.claude/workflows/workflow-architecture.md @@ -114,7 +114,7 @@ All task files use this unified 5-field schema: "meta": { "type": "feature|bugfix|refactor|test|docs", - "agent": "@code-developer|@planning-agent|@code-review-test-agent" + "agent": "code-developer|planning-agent|code-review-test-agent" }, "context": {