From 83664cb777237cbee43ef311f075b6786f1b50c1 Mon Sep 17 00:00:00 2001 From: catlog22 Date: Tue, 21 Oct 2025 14:46:16 +0800 Subject: [PATCH 1/3] feat: migrate to Gemini CLI v0.11.0-nightly with native prompt support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Major Changes ### Gemini CLI Integration (google-gemini/gemini-cli#11228) - Migrate from wrapper scripts to native Gemini CLI v0.11.0-nightly - Remove `-p` flag requirement for prompt strings - Deprecate `gemini-wrapper` and `qwen-wrapper` scripts - Update all commands and workflows to use direct CLI syntax ### Command Syntax Updates - **Before**: `gemini -p "CONTEXT: @**/* prompt"` - **After**: `gemini "CONTEXT: @**/* prompt"` - Apply to all 70+ command files and workflow templates - Maintain backward compatibility for Qwen fallback ### File Pattern Migration - Replace `@{CLAUDE.md}` with `@CLAUDE.md` - Replace `@{**/*}` with `@**/*` - Update all file references to use direct @ notation - Remove legacy brace syntax across all documentation ### Documentation Improvements - Reorganize `intelligent-tools-strategy.md` structure - Add Quick Start section with decision matrix - Enhance `--include-directories` best practices - Add comprehensive command templates and examples - Improve navigation with clearer section hierarchy ### Files Modified (75+ files) - Commands: All CLI commands updated (cli/, workflow/, task/, memory/) - Workflows: Core strategy files and templates - Agents: CLI execution agent and doc generator - Templates: Planning roles and tech stack guides ## Breaking Changes - Gemini CLI v0.11.0-nightly or later required - Old wrapper scripts no longer supported - Legacy `@{pattern}` syntax deprecated ## Migration Guide Users should: 1. Update Gemini CLI to v0.11.0-nightly or later 2. Remove `-p` flag from existing commands 3. Update file patterns from `@{pattern}` to `@pattern` ๐Ÿค– Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .claude/agents/cli-execution-agent.md | 2 +- .claude/agents/doc-generator.md | 3 +- .claude/commands/cli/analyze.md | 20 +- .claude/commands/cli/chat.md | 21 +- .claude/commands/cli/codex-execute.md | 4 +- .claude/commands/cli/discuss-plan.md | 6 +- .claude/commands/cli/execute.md | 14 +- .claude/commands/cli/mode/bug-index.md | 14 +- .claude/commands/cli/mode/code-analysis.md | 14 +- .claude/commands/cli/mode/plan.md | 14 +- .claude/commands/memory/docs.md | 10 +- .claude/commands/memory/load.md | 6 +- .claude/commands/workflow/review.md | 16 +- .claude/commands/workflow/tdd-verify.md | 4 +- .../commands/workflow/test-cycle-execute.md | 4 +- .../workflow/tools/task-generate-tdd.md | 2 +- .../commands/workflow/tools/task-generate.md | 2 +- .../workflow/tools/test-concept-enhanced.md | 2 +- .../workflow/tools/test-task-generate.md | 8 +- .claude/scripts/update_module_claude.sh | 16 +- .claude/skills/prompt-enhancer/SKILL.md | 124 ---- .../prompts/workflow/task-json-cli-mode.txt | 6 +- .claude/workflows/context-search-strategy.md | 6 +- .../workflows/intelligent-tools-strategy.md | 563 +++++++++--------- .claude/workflows/mcp-tool-strategy.md | 8 +- .claude/workflows/workflow-architecture.md | 20 +- 26 files changed, 375 insertions(+), 534 deletions(-) delete mode 100644 .claude/skills/prompt-enhancer/SKILL.md diff --git a/.claude/agents/cli-execution-agent.md b/.claude/agents/cli-execution-agent.md index cf24c278..c4de2dd2 100644 --- a/.claude/agents/cli-execution-agent.md +++ b/.claude/agents/cli-execution-agent.md @@ -174,7 +174,7 @@ score = 0 **2. Context Assembly**: ```bash -CONTEXT: @{CLAUDE.md} @{discovered_file1} @{discovered_file2} ... +CONTEXT: @CLAUDE.md @{discovered_file1} @{discovered_file2} ... ## Discovered Context - **Project Structure**: {module_summary} diff --git a/.claude/agents/doc-generator.md b/.claude/agents/doc-generator.md index 6a30ea13..b1c3f44d 100644 --- a/.claude/agents/doc-generator.md +++ b/.claude/agents/doc-generator.md @@ -53,8 +53,7 @@ You are an expert technical documentation specialist. Your responsibility is to { "step": "analyze_module_structure", "action": "Deep analysis of module structure and API", - "command": "bash(cd src/auth && ~/.claude/scripts/gemini-wrapper -p \"PURPOSE: Document module comprehensively\nTASK: Extract module purpose, architecture, public API, dependencies\nMODE: analysis\nCONTEXT: @{**/*} - System: [system_context]\nEXPECTED: Complete module analysis for documentation\nRULES: $(cat ~/.claude/workflows/cli-templates/prompts/documentation/module-documentation.txt)\")", + "command": "bash(cd src/auth && gemini \"PURPOSE: Document module comprehensively\nTASK: Extract module purpose, architecture, public API, dependencies\nMODE: analysis\nCONTEXT: @**/* System: [system_context]\nEXPECTED: Complete module analysis for documentation\nRULES: $(cat ~/.claude/workflows/cli-templates/prompts/documentation/module-documentation.txt)\")", "output_to": "module_analysis", "on_error": "fail" } diff --git a/.claude/commands/cli/analyze.md b/.claude/commands/cli/analyze.md index 6d28bd2c..4b5d0f6e 100644 --- a/.claude/commands/cli/analyze.md +++ b/.claude/commands/cli/analyze.md @@ -67,24 +67,24 @@ The agent handles all phases internally (understanding, discovery, enhancement, ## File Pattern Auto-Detection -Keywords trigger specific file patterns: -- "auth" โ†’ `@{**/*auth*,**/*user*}` -- "component" โ†’ `@{src/components/**/*,**/*.component.*}` -- "API" โ†’ `@{**/api/**/*,**/routes/**/*}` -- "test" โ†’ `@{**/*.test.*,**/*.spec.*}` -- "config" โ†’ `@{*.config.*,**/config/**/*}` -- Generic โ†’ `@{src/**/*}` +Keywords trigger specific file patterns (each @ references one pattern): +- "auth" โ†’ `@**/*auth* @**/*user*` +- "component" โ†’ `@src/components/**/* @**/*.component.*` +- "API" โ†’ `@**/api/**/* @**/routes/**/*` +- "test" โ†’ `@**/*.test.* @**/*.spec.*` +- "config" โ†’ `@*.config.* @**/config/**/*` +- Generic โ†’ `@src/**/*` For complex patterns, use `rg` or MCP tools to discover files first, then execute CLI with precise file references. ## Command Template ```bash -cd . && ~/.claude/scripts/gemini-wrapper -p " +cd . && gemini -p " PURPOSE: [analysis goal from target] TASK: [auto-detected analysis type] MODE: analysis -CONTEXT: @{CLAUDE.md} [auto-detected file patterns] +CONTEXT: @CLAUDE.md [auto-detected file patterns] EXPECTED: Insights, patterns, recommendations (NO code modification) RULES: [auto-selected template] | Focus on [analysis aspect] " @@ -112,7 +112,7 @@ RULES: [auto-selected template] | Focus on [analysis aspect] **Architecture Analysis**: ```bash -/cli:analyze --tool qwen "component architecture" +/cli:analyze --tool qwen -p "component architecture" # Executes: Qwen with component file patterns # Returns: Architecture review, design patterns, improvement suggestions ``` diff --git a/.claude/commands/cli/chat.md b/.claude/commands/cli/chat.md index 3ea5880d..7328c98d 100644 --- a/.claude/commands/cli/chat.md +++ b/.claude/commands/cli/chat.md @@ -27,7 +27,6 @@ Direct Q&A interaction with CLI tools for codebase analysis. **Analysis only - d - `--agent` - Use cli-execution-agent for automated context discovery (5-phase intelligent mode) - `--tool ` - Select CLI tool (default: gemini, ignored in agent mode) - `--enhance` - Enhance inquiry with `/enhance-prompt` first -- `--all-files` - Include entire codebase in context - `--save-session` - Save interaction to workflow session ## Execution Flow @@ -36,7 +35,7 @@ Direct Q&A interaction with CLI tools for codebase analysis. **Analysis only - d 1. Parse tool selection (default: gemini) 2. If `--enhance`: Execute `/enhance-prompt` to expand user intent -3. Assemble context: `@{CLAUDE.md}` + user-specified files or `--all-files` +3. Assemble context: `@CLAUDE.md` + user-specified files or `@**/*` for entire codebase 4. Execute CLI tool with assembled context (read-only, analysis mode) 5. Return explanations and insights (NO code changes) 6. Optionally save to workflow session @@ -54,7 +53,6 @@ Task( Task: ${inquiry} Mode: analyze (Q&A) Tool Preference: ${tool_flag || 'auto-select'} - ${all_files_flag ? 'Scope: all-files' : ''} Agent will autonomously: - Discover files relevant to the question @@ -69,20 +67,20 @@ The agent handles all phases internally. ## Context Assembly -**Always included**: `@{CLAUDE.md,**/*CLAUDE.md}` (project guidelines) +**Always included**: `@CLAUDE.md @**/*CLAUDE.md` (project guidelines) **Optional**: - User-explicit files from inquiry keywords -- `--all-files` flag includes entire codebase (`--all-files` wrapper parameter) +- Use `@**/*` in CONTEXT for entire codebase For targeted analysis, use `rg` or MCP tools to discover relevant files first, then build precise CONTEXT field. ## Command Template ```bash -cd . && ~/.claude/scripts/gemini-wrapper -p " +cd . && gemini -p " INQUIRY: [user question] -CONTEXT: @{CLAUDE.md,**/*CLAUDE.md} [inferred or --all-files] +CONTEXT: @CLAUDE.md,**/*CLAUDE.md [inferred files or @**/* for all files] MODE: analysis RESPONSE: Direct answer, explanation, insights (NO code modification) " @@ -110,7 +108,7 @@ RESPONSE: Direct answer, explanation, insights (NO code modification) **Architecture Question**: ```bash -/cli:chat --tool qwen "how does React component optimization work here" +/cli:chat --tool qwen -p "how does React component optimization work here" # Executes: Qwen architecture analysis # Returns: Component structure explanation, optimization patterns used ``` @@ -130,13 +128,6 @@ RESPONSE: Direct answer, explanation, insights (NO code modification) # Returns: Detailed explanation of login flow and potential issues ``` -**Broad Context**: -```bash -/cli:chat --all-files "find all API endpoints" -# Executes: Analysis across entire codebase -# Returns: List and explanation of API endpoints (NO code generation) -``` - ## Output Routing **Output Destination Logic**: diff --git a/.claude/commands/cli/codex-execute.md b/.claude/commands/cli/codex-execute.md index 4528064f..75f9f307 100644 --- a/.claude/commands/cli/codex-execute.md +++ b/.claude/commands/cli/codex-execute.md @@ -130,7 +130,7 @@ git status --short codex -C [dir] --full-auto exec " PURPOSE: [group goal] TASK: [subtask description - first in group] -CONTEXT: @{relevant_files} @{CLAUDE.md} +CONTEXT: @{relevant_files} @CLAUDE.md EXPECTED: [specific deliverables] RULES: [constraints] Group [X]: [group name] - Subtask 1 of N in this group @@ -164,7 +164,7 @@ git add -A codex -C [dir] --full-auto exec " PURPOSE: [new group goal] TASK: [subtask description - first in new group] -CONTEXT: @{different_files} @{CLAUDE.md} +CONTEXT: @{different_files} @CLAUDE.md EXPECTED: [specific deliverables] RULES: [constraints] Group [Y]: [new group name] - Subtask 1 of N in this group diff --git a/.claude/commands/cli/discuss-plan.md b/.claude/commands/cli/discuss-plan.md index f9bd23ac..a23a8729 100644 --- a/.claude/commands/cli/discuss-plan.md +++ b/.claude/commands/cli/discuss-plan.md @@ -69,11 +69,11 @@ Gemini analyzes the topic and proposes preliminary plan. ```bash # Round 1: CONTEXT_INPUT is the initial topic # Subsequent rounds: CONTEXT_INPUT is the synthesis from previous round -~/.claude/scripts/gemini-wrapper -p " +gemini -p " PURPOSE: Analyze and propose a plan for '[topic]' TASK: Provide initial analysis, identify key modules, and draft implementation plan MODE: analysis -CONTEXT: @{CLAUDE.md} [auto-detected files] +CONTEXT: @CLAUDE.md [auto-detected files] INPUT: [CONTEXT_INPUT] EXPECTED: Structured analysis and draft plan for discussion RULES: Focus on technical depth and practical considerations @@ -90,7 +90,7 @@ codex --full-auto exec " PURPOSE: Critically review technical plan TASK: Review the provided plan, identify weaknesses, suggest alternatives, reason about trade-offs MODE: analysis -CONTEXT: @{CLAUDE.md} [relevant files] +CONTEXT: @CLAUDE.md [relevant files] INPUT_PLAN: [Output from Gemini's analysis] EXPECTED: Critical review with alternative ideas and risk analysis RULES: Focus on architectural soundness and implementation feasibility diff --git a/.claude/commands/cli/execute.md b/.claude/commands/cli/execute.md index b14e695b..124bae73 100644 --- a/.claude/commands/cli/execute.md +++ b/.claude/commands/cli/execute.md @@ -45,11 +45,11 @@ Auto-approves: file pattern inference, execution, **file modifications**, summar ### Context Inference -Auto-selects files based on keywords and technology: -- "auth" โ†’ `@{**/*auth*,**/*user*}` -- "React" โ†’ `@{src/**/*.{jsx,tsx}}` -- "api" โ†’ `@{**/api/**/*,**/routes/**/*}` -- Always includes: `@{CLAUDE.md,**/*CLAUDE.md}` +Auto-selects files based on keywords and technology (each @ references one pattern): +- "auth" โ†’ `@**/*auth* @**/*user*` +- "React" โ†’ `@src/**/*.jsx @src/**/*.tsx` +- "api" โ†’ `@**/api/**/* @**/routes/**/*` +- Always includes: `@CLAUDE.md @**/*CLAUDE.md` For precise file targeting, use `rg` or MCP tools to discover files first. @@ -111,11 +111,11 @@ Use `resume --last` when current task extends/relates to previous execution. See ### Standard Mode (Default) ```bash # Gemini/Qwen: MODE=write with --approval-mode yolo -cd . && ~/.claude/scripts/gemini-wrapper --approval-mode yolo -p " +cd . && gemini --approval-mode yolo " PURPOSE: [implementation goal] TASK: [specific implementation] MODE: write -CONTEXT: @{CLAUDE.md} [auto-detected files] +CONTEXT: @CLAUDE.md [auto-detected files] EXPECTED: Working implementation with code changes RULES: [constraints] | Auto-approve all changes " diff --git a/.claude/commands/cli/mode/bug-index.md b/.claude/commands/cli/mode/bug-index.md index ecc74be2..91524c95 100644 --- a/.claude/commands/cli/mode/bug-index.md +++ b/.claude/commands/cli/mode/bug-index.md @@ -79,11 +79,11 @@ The agent handles all phases internally. ## Command Template ```bash -cd [directory] && ~/.claude/scripts/gemini-wrapper --all-files -p " +cd [directory] && gemini -p " PURPOSE: [bug analysis goal] TASK: Systematic bug analysis and fix recommendations MODE: analysis -CONTEXT: @{CLAUDE.md,**/*CLAUDE.md} [entire codebase in directory] +CONTEXT: @CLAUDE.md @**/*CLAUDE.md [entire codebase in directory] EXPECTED: Root cause analysis, code path tracing, targeted fix suggestions RULES: $(cat ~/.claude/prompt-templates/bug-fix.md) | Bug: [description] " @@ -111,11 +111,11 @@ RULES: $(cat ~/.claude/prompt-templates/bug-fix.md) | Bug: [description] **Standard Template Example**: ```bash -cd . && ~/.claude/scripts/gemini-wrapper --all-files -p " +cd . && gemini -p " PURPOSE: Debug authentication null pointer error TASK: Identify root cause and provide fix recommendations MODE: analysis -CONTEXT: @{CLAUDE.md,**/*CLAUDE.md} +CONTEXT: @CLAUDE.md @**/*CLAUDE.md EXPECTED: Root cause, code path, minimal fix suggestion, impact assessment RULES: $(cat ~/.claude/prompt-templates/bug-fix.md) | Bug: null pointer in login flow " @@ -123,11 +123,11 @@ RULES: $(cat ~/.claude/prompt-templates/bug-fix.md) | Bug: null pointer in login **Directory-Specific**: ```bash -cd src/auth && ~/.claude/scripts/gemini-wrapper --all-files -p " +cd src/auth && gemini -p " PURPOSE: Fix token validation failure TASK: Analyze token validation bug in auth module MODE: analysis -CONTEXT: @{CLAUDE.md,**/*CLAUDE.md} +CONTEXT: @CLAUDE.md @**/*CLAUDE.md EXPECTED: Validation logic analysis, fix recommendation with minimal changes RULES: $(cat ~/.claude/prompt-templates/bug-fix.md) | Bug: token validation fails intermittently " @@ -161,4 +161,4 @@ mcp__code-index__search_code_advanced(pattern="error|exception", file_pattern="* - Command templates and file patterns: see intelligent-tools-strategy.md (loaded in memory) - Scratchpad directory details: see workflow-architecture.md - Template path: `~/.claude/prompt-templates/bug-fix.md` -- Always uses `--all-files` for comprehensive codebase context +- Uses `@**/*` for in CONTEXT field for comprehensive codebase context diff --git a/.claude/commands/cli/mode/code-analysis.md b/.claude/commands/cli/mode/code-analysis.md index 86c4d088..7c8cac5a 100644 --- a/.claude/commands/cli/mode/code-analysis.md +++ b/.claude/commands/cli/mode/code-analysis.md @@ -82,11 +82,11 @@ The agent handles all phases internally. ## Command Template ```bash -cd [directory] && ~/.claude/scripts/gemini-wrapper --all-files -p " +cd [directory] && gemini -p " PURPOSE: [analysis goal] TASK: Systematic code analysis and execution path tracing MODE: analysis -CONTEXT: @{CLAUDE.md,**/*CLAUDE.md} [entire codebase in directory] +CONTEXT: @CLAUDE.md @**/*CLAUDE.md [entire codebase in directory] EXPECTED: Execution trace, call flow diagram, debugging insights RULES: $(cat ~/.claude/prompt-templates/code-analysis.md) | Focus on [aspect] " @@ -114,11 +114,11 @@ RULES: $(cat ~/.claude/prompt-templates/code-analysis.md) | Focus on [aspect] **Standard Template Example**: ```bash -cd . && ~/.claude/scripts/gemini-wrapper --all-files -p " +cd . && gemini -p " PURPOSE: Trace authentication execution flow TASK: Analyze complete auth flow from request to response MODE: analysis -CONTEXT: @{CLAUDE.md,**/*CLAUDE.md} +CONTEXT: @CLAUDE.md @**/*CLAUDE.md EXPECTED: Step-by-step execution trace with call diagram, variable states RULES: $(cat ~/.claude/prompt-templates/code-analysis.md) | Focus on control flow " @@ -126,11 +126,11 @@ RULES: $(cat ~/.claude/prompt-templates/code-analysis.md) | Focus on control flo **Directory-Specific Analysis**: ```bash -cd src/auth && ~/.claude/scripts/gemini-wrapper --all-files -p " +cd src/auth && gemini -p " PURPOSE: Understand JWT token validation logic TASK: Trace JWT validation from middleware to service layer MODE: analysis -CONTEXT: @{CLAUDE.md,**/*CLAUDE.md} +CONTEXT: @CLAUDE.md @**/*CLAUDE.md EXPECTED: Validation flow diagram, token lifecycle analysis RULES: $(cat ~/.claude/prompt-templates/code-analysis.md) | Focus on security " @@ -167,4 +167,4 @@ mcp__code-index__search_code_advanced(pattern="authenticate|login", file_pattern - Command templates and file patterns: see intelligent-tools-strategy.md (loaded in memory) - Scratchpad directory details: see workflow-architecture.md - Template path: `~/.claude/prompt-templates/code-analysis.md` -- Always uses `--all-files` for comprehensive code context +- Uses `@**/*` for in CONTEXT field for comprehensive code context diff --git a/.claude/commands/cli/mode/plan.md b/.claude/commands/cli/mode/plan.md index 58b4ba0d..9696a8dc 100644 --- a/.claude/commands/cli/mode/plan.md +++ b/.claude/commands/cli/mode/plan.md @@ -80,11 +80,11 @@ The agent handles all phases internally. ## Command Template ```bash -cd [directory] && ~/.claude/scripts/gemini-wrapper --all-files -p " +cd [directory] && gemini -p " PURPOSE: [planning goal from topic] TASK: Comprehensive planning and architecture analysis MODE: analysis -CONTEXT: @{CLAUDE.md,**/*CLAUDE.md} [entire codebase in directory] +CONTEXT: @CLAUDE.md @**/*CLAUDE.md [entire codebase in directory] EXPECTED: Strategic insights, implementation recommendations, key decisions RULES: $(cat ~/.claude/prompt-templates/plan.md) | Focus on [topic area] " @@ -112,11 +112,11 @@ RULES: $(cat ~/.claude/prompt-templates/plan.md) | Focus on [topic area] **Standard Template Example**: ```bash -cd . && ~/.claude/scripts/gemini-wrapper --all-files -p " +cd . && gemini -p " PURPOSE: Design user dashboard architecture TASK: Plan dashboard component structure and data flow MODE: analysis -CONTEXT: @{CLAUDE.md,**/*CLAUDE.md} +CONTEXT: @CLAUDE.md @**/*CLAUDE.md EXPECTED: Architecture recommendations, component design, data flow diagram RULES: $(cat ~/.claude/prompt-templates/plan.md) | Focus on scalability " @@ -124,11 +124,11 @@ RULES: $(cat ~/.claude/prompt-templates/plan.md) | Focus on scalability **Directory-Specific Planning**: ```bash -cd src/api && ~/.claude/scripts/gemini-wrapper --all-files -p " +cd src/api && gemini -p " PURPOSE: Plan API refactoring strategy TASK: Analyze current API structure and recommend improvements MODE: analysis -CONTEXT: @{CLAUDE.md,**/*CLAUDE.md} +CONTEXT: @CLAUDE.md @**/*CLAUDE.md EXPECTED: Refactoring roadmap, breaking change analysis, migration plan RULES: $(cat ~/.claude/prompt-templates/plan.md) | Maintain backward compatibility " @@ -165,4 +165,4 @@ rg "architecture|design" --files-with-matches - Command templates and file patterns: see intelligent-tools-strategy.md (loaded in memory) - Scratchpad directory details: see workflow-architecture.md - Template path: `~/.claude/prompt-templates/plan.md` -- Always uses `--all-files` for comprehensive project context +- Uses `@**/*` for in CONTEXT field for comprehensive project context diff --git a/.claude/commands/memory/docs.md b/.claude/commands/memory/docs.md index 43a5adbe..c8875ec2 100644 --- a/.claude/commands/memory/docs.md +++ b/.claude/commands/memory/docs.md @@ -394,7 +394,7 @@ bash( }, { "step": "analyze_module_tree", - "command": "bash(cd src/modules && ~/.claude/scripts/gemini-wrapper -p \"PURPOSE: Analyze module structure\\nTASK: Generate documentation outline\\nMODE: analysis\\nCONTEXT: @{**/*} [target_folders]\\nEXPECTED: Structure outline\\nRULES: Analyze only\")", + "command": "bash(cd src/modules && gemini \"PURPOSE: Analyze module structure\\nTASK: Generate documentation outline\\nMODE: analysis\\nCONTEXT: @**/* [target_folders]\\nEXPECTED: Structure outline\\nRULES: Analyze only\")", "output_to": "tree_outline", "note": "CLI for analysis only" } @@ -490,7 +490,7 @@ bash( "CLI writes documentation to .workflow/docs/src/modules/", "Maintains directory structure mirroring" ], - "command": "bash(cd src/modules && ~/.claude/scripts/gemini-wrapper --approval-mode yolo -p \"PURPOSE: Generate module docs\\nTASK: Create documentation files in .workflow/docs/src/modules/\\nMODE: write\\nCONTEXT: @{**/*} [target_folders] [existing_module_docs]\\nEXPECTED: API.md and README.md in .workflow/docs/src/modules/\\nRULES: Mirror source structure, generate complete docs\")", + "command": "bash(cd src/modules && gemini --approval-mode yolo \"PURPOSE: Generate module docs\\nTASK: Create documentation files in .workflow/docs/src/modules/\\nMODE: write\\nCONTEXT: @**/* [target_folders] [existing_module_docs]\\nEXPECTED: API.md and README.md in .workflow/docs/src/modules/\\nRULES: Mirror source structure, generate complete docs\")", "depends_on": [1], "output": "generated_docs" } @@ -533,7 +533,7 @@ bash( }, { "step": "analyze_project", - "command": "bash(~/.claude/scripts/gemini-wrapper -p \"PURPOSE: Analyze project structure\\nTASK: Extract overview from modules\\nMODE: analysis\\nCONTEXT: [all_module_docs]\\nEXPECTED: Project outline\")", + "command": "bash(gemini \"PURPOSE: Analyze project structure\\nTASK: Extract overview from modules\\nMODE: analysis\\nCONTEXT: [all_module_docs]\\nEXPECTED: Project outline\")", "output_to": "project_outline" } ], @@ -583,7 +583,7 @@ bash( }, { "step": "analyze_architecture_and_examples", - "command": "bash(~/.claude/scripts/gemini-wrapper -p \"PURPOSE: Analyze system architecture and generate examples\\nTASK: Synthesize architectural overview and usage patterns\\nMODE: analysis\\nCONTEXT: [all_docs]\\nEXPECTED: Architecture outline + Examples outline\")", + "command": "bash(gemini \"PURPOSE: Analyze system architecture and generate examples\\nTASK: Synthesize architectural overview and usage patterns\\nMODE: analysis\\nCONTEXT: [all_docs]\\nEXPECTED: Architecture outline + Examples outline\")", "output_to": "arch_examples_outline" } ], @@ -645,7 +645,7 @@ bash( }, { "step": "analyze_api", - "command": "bash(~/.claude/scripts/gemini-wrapper -p \"PURPOSE: Document HTTP API\\nTASK: Analyze API endpoints\\nMODE: analysis\\nCONTEXT: @{src/api/**/*} [endpoint_discovery]\\nEXPECTED: API outline\")", + "command": "bash(gemini \"PURPOSE: Document HTTP API\\nTASK: Analyze API endpoints\\nMODE: analysis\\nCONTEXT: @src/api/**/* [endpoint_discovery]\\nEXPECTED: API outline\")", "output_to": "api_outline" } ], diff --git a/.claude/commands/memory/load.md b/.claude/commands/memory/load.md index 32eca9b2..5fd44eaa 100644 --- a/.claude/commands/memory/load.md +++ b/.claude/commands/memory/load.md @@ -5,7 +5,7 @@ argument-hint: "[--tool gemini|qwen] \"task context description\"" allowed-tools: Task(*), Bash(*) examples: - /memory:load "ๅœจๅฝ“ๅ‰ๅ‰็ซฏๅŸบ็ก€ไธŠๅผ€ๅ‘็”จๆˆท่ฎค่ฏๅŠŸ่ƒฝ" - - /memory:load --tool qwen "้‡ๆž„ๆ”ฏไป˜ๆจกๅ—API" + - /memory:load --tool qwen -p "้‡ๆž„ๆ”ฏไป˜ๆจกๅ—API" --- # Memory Load Command (/memory:load) @@ -140,7 +140,7 @@ cd . && ~/.claude/scripts/${tool}-wrapper -p " PURPOSE: Extract project core context for task: ${task_description} TASK: Analyze project architecture, tech stack, key patterns, relevant files MODE: analysis -CONTEXT: @{CLAUDE.md,README.md,${discovered_files}} +CONTEXT: @CLAUDE.md,README.md @${discovered_files} EXPECTED: Structured project summary and integration point analysis RULES: - Focus on task-relevant core information @@ -212,7 +212,7 @@ Before returning: ### Example 2: Using Qwen Tool ```bash -/memory:load --tool qwen "้‡ๆž„ๆ”ฏไป˜ๆจกๅ—API" +/memory:load --tool qwen -p "้‡ๆž„ๆ”ฏไป˜ๆจกๅ—API" ``` Agent uses Qwen CLI for analysis, returns same structured package. diff --git a/.claude/commands/workflow/review.md b/.claude/commands/workflow/review.md index d4d1dc0e..ac4ac405 100644 --- a/.claude/commands/workflow/review.md +++ b/.claude/commands/workflow/review.md @@ -99,10 +99,10 @@ After bash validation, the model takes control to: ``` - Use Gemini for security analysis: ```bash - cd .workflow/${sessionId} && ~/.claude/scripts/gemini-wrapper -p " + cd .workflow/${sessionId} && gemini -p " PURPOSE: Security audit of completed implementation TASK: Review code for security vulnerabilities, insecure patterns, auth/authz issues - CONTEXT: @{.summaries/IMPL-*.md,../..,../../CLAUDE.md} + CONTEXT: @.summaries/IMPL-*.md,../.. @../../CLAUDE.md EXPECTED: Security findings report with severity levels RULES: Focus on OWASP Top 10, authentication, authorization, data validation, injection risks " --approval-mode yolo @@ -111,10 +111,10 @@ After bash validation, the model takes control to: **Architecture Review** (`--type=architecture`): - Use Qwen for architecture analysis: ```bash - cd .workflow/${sessionId} && ~/.claude/scripts/qwen-wrapper -p " + cd .workflow/${sessionId} && qwen -p " PURPOSE: Architecture compliance review TASK: Evaluate adherence to architectural patterns, identify technical debt, review design decisions - CONTEXT: @{.summaries/IMPL-*.md,../..,../../CLAUDE.md} + CONTEXT: @.summaries/IMPL-*.md,../.. @../../CLAUDE.md EXPECTED: Architecture assessment with recommendations RULES: Check for patterns, separation of concerns, modularity, scalability " --approval-mode yolo @@ -123,10 +123,10 @@ After bash validation, the model takes control to: **Quality Review** (`--type=quality`): - Use Gemini for code quality: ```bash - cd .workflow/${sessionId} && ~/.claude/scripts/gemini-wrapper -p " + cd .workflow/${sessionId} && gemini -p " PURPOSE: Code quality and best practices review TASK: Assess code readability, maintainability, adherence to best practices - CONTEXT: @{.summaries/IMPL-*.md,../..,../../CLAUDE.md} + CONTEXT: @.summaries/IMPL-*.md,../.. @../../CLAUDE.md EXPECTED: Quality assessment with improvement suggestions RULES: Check for code smells, duplication, complexity, naming conventions " --approval-mode yolo @@ -143,10 +143,10 @@ After bash validation, the model takes control to: ' {} \; # Check implementation summaries against requirements - cd .workflow/${sessionId} && ~/.claude/scripts/gemini-wrapper -p " + cd .workflow/${sessionId} && gemini -p " PURPOSE: Verify all requirements and acceptance criteria are met TASK: Cross-check implementation summaries against original requirements - CONTEXT: @{.task/IMPL-*.json,.summaries/IMPL-*.md,../..,../../CLAUDE.md} + CONTEXT: @.task/IMPL-*.json,.summaries/IMPL-*.md,../.. @../../CLAUDE.md EXPECTED: - Requirements coverage matrix - Acceptance criteria verification diff --git a/.claude/commands/workflow/tdd-verify.md b/.claude/commands/workflow/tdd-verify.md index f1194147..017feafe 100644 --- a/.claude/commands/workflow/tdd-verify.md +++ b/.claude/commands/workflow/tdd-verify.md @@ -3,7 +3,7 @@ name: tdd-verify description: Verify TDD workflow compliance and generate quality report argument-hint: "[optional: WFS-session-id]" -allowed-tools: SlashCommand(*), TodoWrite(*), Read(*), Bash(gemini-wrapper:*) +allowed-tools: SlashCommand(*), TodoWrite(*), Read(*), Bash(gemini:*) --- # TDD Verification Command (/workflow:tdd-verify) @@ -94,7 +94,7 @@ find .workflow/{sessionId}/.task/ -name '*.json' -exec jq -r '.meta.agent' {} \; **Gemini analysis for comprehensive TDD compliance report** ```bash -cd project-root && ~/.claude/scripts/gemini-wrapper -p " +cd project-root && gemini -p " PURPOSE: Generate TDD compliance report TASK: Analyze TDD workflow execution and generate quality report CONTEXT: @{.workflow/{sessionId}/.task/*.json,.workflow/{sessionId}/.summaries/*,.workflow/{sessionId}/.process/tdd-cycle-report.md} diff --git a/.claude/commands/workflow/test-cycle-execute.md b/.claude/commands/workflow/test-cycle-execute.md index a1a68a2b..eaf1d702 100644 --- a/.claude/commands/workflow/test-cycle-execute.md +++ b/.claude/commands/workflow/test-cycle-execute.md @@ -226,11 +226,11 @@ Iteration N (managed by test-cycle-execute orchestrator): #### CLI Analysis Command (executed by orchestrator) ```bash -cd {project_root} && ~/.claude/scripts/gemini-wrapper -p " +cd {project_root} && gemini -p " PURPOSE: Analyze test failures and generate fix strategy TASK: Review test failures and identify root causes MODE: analysis -CONTEXT: @{test files, implementation files} +CONTEXT: @test files @ implementation files [Test failure context and requirements...] diff --git a/.claude/commands/workflow/tools/task-generate-tdd.md b/.claude/commands/workflow/tools/task-generate-tdd.md index 196189bc..812d1227 100644 --- a/.claude/commands/workflow/tools/task-generate-tdd.md +++ b/.claude/commands/workflow/tools/task-generate-tdd.md @@ -2,7 +2,7 @@ name: task-generate-tdd description: Generate TDD task chains with Red-Green-Refactor dependencies argument-hint: "--session WFS-session-id [--agent]" -allowed-tools: Read(*), Write(*), Bash(gemini-wrapper:*), TodoWrite(*) +allowed-tools: Read(*), Write(*), Bash(gemini:*), TodoWrite(*) --- # TDD Task Generation Command diff --git a/.claude/commands/workflow/tools/task-generate.md b/.claude/commands/workflow/tools/task-generate.md index 9b5e842e..e21a257e 100644 --- a/.claude/commands/workflow/tools/task-generate.md +++ b/.claude/commands/workflow/tools/task-generate.md @@ -256,7 +256,7 @@ This enhanced 5-field schema embeds all necessary context, artifacts, and execut "action": "Analyze existing code patterns and identify modification targets", "commands": [ "bash(cd \"[focus_paths]\")", - "bash(~/.claude/scripts/gemini-wrapper -p \"PURPOSE: Identify modification targets TASK: Analyze '[title]' and locate specific files/functions/lines to modify CONTEXT: [synthesis_specification] [individual_artifacts] EXPECTED: Code locations in format 'file:function:lines' RULES: Prioritize synthesis-specification.md, identify exact modification points\")" + "bash(gemini \"PURPOSE: Identify modification targets TASK: Analyze '[title]' and locate specific files/functions/lines to modify CONTEXT: [synthesis_specification] [individual_artifacts] EXPECTED: Code locations in format 'file:function:lines' RULES: Prioritize synthesis-specification.md, identify exact modification points\")" ], "output_to": "task_context_with_targets", "on_error": "fail" diff --git a/.claude/commands/workflow/tools/test-concept-enhanced.md b/.claude/commands/workflow/tools/test-concept-enhanced.md index ef524b26..91000364 100644 --- a/.claude/commands/workflow/tools/test-concept-enhanced.md +++ b/.claude/commands/workflow/tools/test-concept-enhanced.md @@ -48,7 +48,7 @@ Specialized analysis tool for test generation workflows that uses Gemini to anal **Tool Configuration**: ```bash -cd .workflow/{test_session_id}/.process && ~/.claude/scripts/gemini-wrapper -p " +cd .workflow/{test_session_id}/.process && gemini -p " PURPOSE: Analyze test coverage gaps and design comprehensive test generation strategy TASK: Study implementation context, existing tests, and generate test requirements for missing coverage MODE: analysis diff --git a/.claude/commands/workflow/tools/test-task-generate.md b/.claude/commands/workflow/tools/test-task-generate.md index ec9bd956..e244244f 100644 --- a/.claude/commands/workflow/tools/test-task-generate.md +++ b/.claude/commands/workflow/tools/test-task-generate.md @@ -198,7 +198,7 @@ Generate **TWO task JSON files**: "Codex generates comprehensive test suite", "Codex validates test syntax and executability" ], - "command": "bash(codex -C [focus_paths] --full-auto exec \"PURPOSE: Generate comprehensive test suite TASK: Create test files based on TEST_ANALYSIS_RESULTS.md section 5 MODE: write CONTEXT: @{.workflow/WFS-test-[session]/.process/TEST_ANALYSIS_RESULTS.md,.workflow/WFS-test-[session]/.process/test-context-package.json} EXPECTED: All test files with happy path, error handling, edge cases, integration tests RULES: Follow test framework conventions, ensure tests are executable\" --skip-git-repo-check -s danger-full-access)", + "command": "bash(codex -C [focus_paths] --full-auto exec \"PURPOSE: Generate comprehensive test suite TASK: Create test files based on TEST_ANALYSIS_RESULTS.md section 5 MODE: write CONTEXT: @.workflow/WFS-test-[session]/.process/TEST_ANALYSIS_RESULTS.md @.workflow/WFS-test-[session]/.process/test-context-package.json EXPECTED: All test files with happy path, error handling, edge cases, integration tests RULES: Follow test framework conventions, ensure tests are executable\" --skip-git-repo-check -s danger-full-access)", "depends_on": [], "output": "test_generation" }], @@ -323,7 +323,7 @@ Generate **TWO task JSON files**: "cycle_pattern": "test โ†’ gemini_diagnose โ†’ manual_fix (or codex if needed) โ†’ retest", "tools": { "test_execution": "bash(test_command)", - "diagnosis": "gemini-wrapper (MODE: analysis, uses bug-fix template)", + "diagnosis": "gemini (MODE: analysis, uses bug-fix template)", "fix_application": "manual (default) or codex exec resume --last (if explicitly needed)", "verification": "bash(test_command) + regression_check" }, @@ -354,11 +354,11 @@ Generate **TWO task JSON files**: " * Source files from focus_paths", " * Implementation summaries from source session", " - Execute Gemini analysis with bug-fix template:", - " bash(cd .workflow/WFS-test-[session]/.process && ~/.claude/scripts/gemini-wrapper --all-files -p \"", + " bash(cd .workflow/WFS-test-[session]/.process && gemini \"", " PURPOSE: Diagnose test failure iteration [N] and propose minimal fix", " TASK: Systematic bug analysis and fix recommendations for test failure", " MODE: analysis", - " CONTEXT: @{CLAUDE.md,**/*CLAUDE.md}", + " CONTEXT: @CLAUDE.md,**/*CLAUDE.md", " Test output: [test_failures]", " Source files: [focus_paths]", " Implementation: [implementation_context]", diff --git a/.claude/scripts/update_module_claude.sh b/.claude/scripts/update_module_claude.sh index 539b5632..e0a26ae0 100644 --- a/.claude/scripts/update_module_claude.sh +++ b/.claude/scripts/update_module_claude.sh @@ -88,8 +88,7 @@ update_module_claude() { # Use unified template for all modules local template_path="$HOME/.claude/workflows/cli-templates/prompts/memory/claude-module-unified.txt" - local analysis_strategy="--all-files" - + # Prepare logging info local module_name=$(basename "$module_path") @@ -131,8 +130,10 @@ update_module_claude() { $template_content - $update_context" - + $update_context + + CONTEXT: @**/*" + # Execute update local start_time=$(date +%s) echo " ๐Ÿ”„ Starting update..." @@ -146,10 +147,11 @@ update_module_claude() { - Path: $module_path - Tool: $tool" - # Execute with selected tool (always use --all-files) + # Execute with selected tool + # NOTE: Prompt is passed via -p flag for gemini/qwen, first parameter for codex case "$tool" in qwen) - qwen --all-files --yolo -p "$final_prompt" 2>&1 + qwen -p "$final_prompt" --yolo 2>&1 tool_result=$? ;; codex) @@ -157,7 +159,7 @@ update_module_claude() { tool_result=$? ;; gemini|*) - gemini --all-files --yolo -p "$final_prompt" 2>&1 + gemini -p "$final_prompt" --yolo 2>&1 tool_result=$? ;; esac diff --git a/.claude/skills/prompt-enhancer/SKILL.md b/.claude/skills/prompt-enhancer/SKILL.md deleted file mode 100644 index 348515ce..00000000 --- a/.claude/skills/prompt-enhancer/SKILL.md +++ /dev/null @@ -1,124 +0,0 @@ ---- -name: Prompt Enhancer -description: Transform vague prompts into actionable specs using intelligent analysis and session memory. Use when user input contains -e or --enhance flag. -allowed-tools: (none) ---- - -# Prompt Enhancer - -**Transform**: Vague intent โ†’ Structured specification (Memory-based, Direct Output) - -**Languages**: English + Chinese (ไธญ่‹ฑๆ–‡่ฏญไน‰่ฏ†ๅˆซ) - -## Process (Internal โ†’ Direct Output) - -**Internal Analysis**: Intelligently extract session context, identify tech stack, and structure into actionable format. - -**Output**: Direct structured prompt (no intermediate steps shown) - -## Output Format - -**Dynamic Structure**: Adapt fields based on task type and context needs. Not all fields are required. - -**Core Fields** (always present): -- **INTENT**: One-sentence technical goal -- **ACTION**: Concrete steps with technical details - -**Optional Fields** (include when relevant): -- **TECH STACK**: Relevant technologies (when tech-specific) -- **CONTEXT**: Session memory findings (when context matters) -- **ATTENTION**: Critical constraints (when risks/requirements exist) -- **SCOPE**: Affected modules/files (for multi-module tasks) -- **METRICS**: Success criteria (for optimization/performance tasks) -- **DEPENDENCIES**: Related components (for integration tasks) - -**Example (Simple Task)**: -``` -๐Ÿ“‹ ENHANCED PROMPT - -INTENT: Fix authentication token validation in JWT middleware - -ACTION: -1. Review token expiration logic in auth middleware -2. Add proper error handling for expired tokens -3. Test with valid/expired/malformed tokens -``` - -**Example (Complex Task)**: -``` -๐Ÿ“‹ ENHANCED PROMPT - -INTENT: Optimize API performance with caching and database indexing - -TECH STACK: -- Redis: Response caching -- PostgreSQL: Query optimization - -CONTEXT: -- API response times >2s mentioned in previous conversation -- PostgreSQL slow query logs show N+1 problems - -ACTION: -1. Profile endpoints to identify slow queries -2. Add PostgreSQL indexes on frequently queried columns -3. Implement Redis caching for read-heavy endpoints -4. Add cache invalidation on data updates - -METRICS: -- Target: <500ms API response time -- Cache hit ratio: >80% - -ATTENTION: -- Maintain backward compatibility with existing API contracts -- Handle cache invalidation correctly to avoid stale data -``` -## Workflow - -``` -Trigger (-e/--enhance) โ†’ Internal Analysis โ†’ Dynamic Output - โ†“ โ†“ โ†“ - User Input Assess Task Type Select Fields - Extract Memory Context Structure Prompt -``` - -1. **Detect**: User input contains `-e` or `--enhance` -2. **Analyze**: - - Determine task type (fix/optimize/implement/refactor) - - Extract relevant session context - - Identify tech stack and constraints -3. **Structure**: - - Always include: INTENT + ACTION - - Conditionally add: TECH STACK, CONTEXT, ATTENTION, METRICS, etc. -4. **Output**: Present dynamically structured prompt - -## Enhancement Guidelines (Internal) - -**Always Include**: -- Clear, actionable INTENT -- Concrete ACTION steps with technical details - -**Add When Relevant**: -- TECH STACK: Task involves specific technologies -- CONTEXT: Session memory provides useful background -- ATTENTION: Security/compatibility/performance concerns exist -- SCOPE: Multi-module or cross-component changes -- METRICS: Performance/optimization goals need measurement -- DEPENDENCIES: Integration points matter - -**Quality Checks**: -- Make vague intent explicit -- Resolve ambiguous references -- Add testing/validation steps -- Include constraints from memory - -## Best Practices - -- โœ… Trigger only on `-e`/`--enhance` flags -- โœ… Use **dynamic field selection** based on task type -- โœ… Extract **memory context ONLY** (no file reading) -- โœ… Always include INTENT + ACTION as core fields -- โœ… Add optional fields only when relevant to task -- โœ… Direct output (no intermediate steps shown) -- โŒ NO tool calls -- โŒ NO file operations (Bash, Read, Glob, Grep) -- โŒ NO fixed template - adapt to task needs diff --git a/.claude/workflows/cli-templates/prompts/workflow/task-json-cli-mode.txt b/.claude/workflows/cli-templates/prompts/workflow/task-json-cli-mode.txt index 34859980..baa42c5c 100644 --- a/.claude/workflows/cli-templates/prompts/workflow/task-json-cli-mode.txt +++ b/.claude/workflows/cli-templates/prompts/workflow/task-json-cli-mode.txt @@ -148,10 +148,10 @@ bash(codex --full-auto exec "..." resume --last --skip-git-repo-check -s danger- ### Gemini/Qwen Commands (Analysis/Documentation) ```bash -bash(~/.claude/scripts/gemini-wrapper -p "PURPOSE: {purpose} TASK: {task} MODE: analysis CONTEXT: @{{synthesis_spec_path}} EXPECTED: {expected} RULES: {rules}") +bash(gemini "PURPOSE: {purpose} TASK: {task} MODE: analysis CONTEXT: @{synthesis_spec_path} EXPECTED: {expected} RULES: {rules}") # With write permission -bash(~/.claude/scripts/gemini-wrapper --approval-mode yolo -p "PURPOSE: {purpose} TASK: {task} MODE: write CONTEXT: @{{context}} EXPECTED: {expected} RULES: {rules}") +bash(gemini --approval-mode yolo "PURPOSE: {purpose} TASK: {task} MODE: write CONTEXT: @{context} EXPECTED: {expected} RULES: {rules}") ``` ## Field Descriptions @@ -175,4 +175,4 @@ bash(~/.claude/scripts/gemini-wrapper --approval-mode yolo -p "PURPOSE: {purpose 5. **Step Dependencies**: Use `depends_on: [1, 2]` to specify execution order 6. **Parameter Position**: - Codex: `--skip-git-repo-check -s danger-full-access` at END - - Gemini/Qwen: `--approval-mode yolo` AFTER wrapper command, BEFORE -p + - Gemini/Qwen: `--approval-mode yolo` BEFORE the prompt diff --git a/.claude/workflows/context-search-strategy.md b/.claude/workflows/context-search-strategy.md index fe193a6a..4c0eb68e 100644 --- a/.claude/workflows/context-search-strategy.md +++ b/.claude/workflows/context-search-strategy.md @@ -40,8 +40,8 @@ type: search-guideline ### Quick Command Reference ```bash # Semantic File Discovery (codebase-retrieval) -~/.claude/scripts/gemini-wrapper --all-files -p "List all files relevant to: [task/feature description]" -bash(~/.claude/scripts/gemini-wrapper --all-files -p "List all files relevant to: [task/feature description]") +gemini "CONTEXT: @**/* List all files relevant to: [task/feature description]" +bash(gemini "CONTEXT: @**/* List all files relevant to: [task/feature description]") # Program Architecture Analysis (MANDATORY FIRST) ~/.claude/scripts/get_modules_by_depth.sh # Discover program architecture @@ -65,7 +65,7 @@ grep -n -i "pattern" file.txt # Line numbers, case-insensitive ### Workflow Integration Examples ```bash # Semantic Discovery โ†’ Content Search โ†’ Analysis (Recommended Pattern) -~/.claude/scripts/gemini-wrapper --all-files -p "List all files relevant to: [task/feature]" # Get relevant files +gemini "CONTEXT: @**/* List all files relevant to: [task/feature]" # Get relevant files rg "[pattern]" --type [filetype] # Then search within discovered files # Program Architecture Analysis (MANDATORY BEFORE PLANNING) diff --git a/.claude/workflows/intelligent-tools-strategy.md b/.claude/workflows/intelligent-tools-strategy.md index feaeb0c2..b9578ab7 100644 --- a/.claude/workflows/intelligent-tools-strategy.md +++ b/.claude/workflows/intelligent-tools-strategy.md @@ -7,67 +7,77 @@ type: strategic-guideline # Intelligent Tools Selection Strategy ## ๐Ÿ“‹ Table of Contents -1. [Core Framework](#-core-framework) +1. [Quick Start](#-quick-start) 2. [Tool Specifications](#-tool-specifications) 3. [Command Templates](#-command-templates) -4. [Tool Selection Guide](#-tool-selection-guide) -5. [Usage Patterns](#-usage-patterns) -6. [Best Practices](#-best-practices) +4. [Execution Configuration](#-execution-configuration) +5. [Best Practices](#-best-practices) --- -## โšก Core Framework +## โšก Quick Start ### Tool Overview - **Gemini**: Analysis, understanding, exploration & documentation (primary) - **Qwen**: Analysis, understanding, exploration & documentation (fallback, same capabilities as Gemini) - **Codex**: Development, implementation & automation -### Decision Principles +### Quick Decision Matrix + +| Scenario | Tool | Command Pattern | +|----------|------|-----------------| +| **Exploring/Understanding** | Gemini โ†’ Qwen | `cd [dir] && gemini "PURPOSE:... CONTEXT: @**/*"` | +| **Architecture/Analysis** | Gemini โ†’ Qwen | `cd [dir] && gemini "PURPOSE:... CONTEXT: @**/*"` | +| **Building/Fixing** | Codex | `codex -C [dir] --full-auto exec "PURPOSE:... MODE: auto"` | +| **Not sure?** | Multiple | Use tools in parallel | +| **Small task?** | Still use tools | Tools are faster than manual work | + +### Core 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 -- **Context optimization** - Based on user intent, determine whether to use `-C [directory]` parameter for focused analysis to reduce irrelevant context import - **โš ๏ธ Write operation protection** - For local codebase write/modify operations, require EXPLICIT user confirmation unless user provides clear instructions containing MODE=write or MODE=auto -### Quick Decision Rules -1. **Exploring/Understanding?** โ†’ Start with Gemini (fallback to Qwen if needed) -2. **Architecture/Analysis?** โ†’ Start with Gemini (fallback to Qwen if needed) -3. **Building/Fixing?** โ†’ Start with Codex -4. **Not sure?** โ†’ Use multiple tools in parallel -5. **Small task?** โ†’ Still use tools - they're faster than manual work - --- ## ๐ŸŽฏ Tool Specifications -### Gemini -- **Command**: `~/.claude/scripts/gemini-wrapper` +### Gemini & Qwen + +#### Overview +- **Commands**: `gemini` (primary) | `qwen` (fallback) - **Strengths**: Large context window, pattern recognition -- **Best For**: Analysis, documentation generation, code exploration -- **Permissions**: Default read-only analysis, MODE=write requires explicit specification (auto-enables --approval-mode yolo) +- **Best For**: Analysis, documentation generation, code exploration, architecture review +- **Permissions**: Default read-only analysis, MODE=write requires explicit specification - **Default MODE**: `analysis` (read-only) - **โš ๏ธ Write Trigger**: Only when user explicitly requests "generate documentation", "modify code", or specifies MODE=write +- **Priority**: Prefer Gemini; use Qwen as fallback when Gemini unavailable #### MODE Options -- `analysis` (default) - Read-only analysis and documentation generation -- `write` - โš ๏ธ Create/modify codebase files (requires explicit specification, auto-enables --approval-mode yolo) -### Qwen -- **Command**: `~/.claude/scripts/qwen-wrapper` -- **Strengths**: Large context window, pattern recognition (same as Gemini) -- **Best For**: Analysis, documentation generation, code exploration (fallback option when Gemini unavailable) -- **Permissions**: Default read-only analysis, MODE=write requires explicit specification (auto-enables --approval-mode yolo) -- **Default MODE**: `analysis` (read-only) -- **โš ๏ธ Write Trigger**: Only when user explicitly requests "generate documentation", "modify code", or specifies MODE=write -- **Priority**: Secondary to Gemini - use as fallback for same tasks +**analysis** (default) - Read-only analysis and documentation generation +- **โš ๏ธ CRITICAL CONSTRAINT**: Absolutely NO file creation, modification, or deletion operations +- Analysis output should be returned as text response only +- Use for: code review, architecture analysis, pattern discovery, documentation reading -#### MODE Options -- `analysis` (default) - Read-only analysis and documentation generation (same as Gemini) -- `write` - โš ๏ธ Create/modify codebase files (requires explicit specification, auto-enables --approval-mode yolo) +**write** - โš ๏ธ Create/modify codebase files (requires explicit specification, auto-enables --approval-mode yolo) +- Use for: generating documentation files, creating code files, modifying existing files + +#### Tool Selection +```bash +# Default: Use Gemini +gemini "analysis prompt" + +# Fallback: Use Qwen if Gemini unavailable +qwen "analysis prompt" +``` + +--- ### Codex + +#### Overview - **Command**: `codex --full-auto exec` - **Strengths**: Autonomous development, mathematical reasoning - **Best For**: Implementation, testing, automation @@ -76,27 +86,39 @@ type: strategic-guideline - **โš ๏ธ Write Trigger**: Only when user explicitly requests "implement", "modify", "generate code" AND specifies MODE #### MODE Options -- `auto` - โš ๏ธ Autonomous development with full file operations (requires explicit specification, enables -s danger-full-access) -- `write` - โš ๏ธ Test generation and file modification (requires explicit specification) -- **Default**: No default mode, MODE must be explicitly specified + +**auto** - โš ๏ธ Autonomous development with full file operations +- Requires explicit specification +- Enables `-s danger-full-access` +- Use for: feature implementation, bug fixes, autonomous development + +**write** - โš ๏ธ Test generation and file modification +- Requires explicit specification +- Use for: test generation, focused file modifications #### Session Management -- `codex resume` - Resume previous interactive session (picker by default) -- `codex exec "task" resume --last` - Continue most recent session with new task (maintains context) -- `codex -i ` - Attach image(s) to initial prompt (useful for UI/design references) -- **Multi-task Pattern**: First task uses `exec`, subsequent tasks use `exec "..." resume --last` for context continuity - - **Parameter Position**: `resume --last` must be placed AFTER the prompt string at command END - - **Example**: - ```bash - # First task - establish session - codex -C project --full-auto exec "Implement auth module" --skip-git-repo-check -s danger-full-access - # Subsequent tasks - continue same session - codex --full-auto exec "Add JWT validation" resume --last --skip-git-repo-check -s danger-full-access - codex --full-auto exec "Write auth tests" resume --last --skip-git-repo-check -s danger-full-access - ``` +**Basic Commands**: +- `codex resume` - Resume previous interactive session (picker by default) +- `codex resume --last` - Resume most recent session directly +- `codex -i ` - Attach image(s) to initial prompt (useful for UI/design references) + +**Multi-task Pattern**: First task uses `exec`, subsequent tasks use `exec "..." resume --last` for context continuity + +**Parameter Position**: `resume --last` must be placed AFTER the prompt string at command END + +**Example**: +```bash +# First task - establish session +codex -C project --full-auto exec "Implement auth module" --skip-git-repo-check -s danger-full-access + +# Subsequent tasks - continue same session +codex --full-auto exec "Add JWT validation" resume --last --skip-git-repo-check -s danger-full-access +codex --full-auto exec "Write auth tests" resume --last --skip-git-repo-check -s danger-full-access +``` #### Auto-Resume Decision Rules + **When to use `resume --last`**: - Current task is related to/extends previous Codex task in conversation memory - Current task requires context from previous implementation @@ -114,6 +136,7 @@ type: strategic-guideline ## ๐ŸŽฏ Command Templates ### Universal Template Structure + Every command MUST follow this structure: - [ ] **PURPOSE** - Clear goal and intent - [ ] **TASK** - Specific execution task @@ -122,57 +145,41 @@ Every command MUST follow this structure: - [ ] **EXPECTED** - Clear expected results - [ ] **RULES** - Template reference and constraints +--- + ### Standard Command Formats -#### Gemini Commands +#### Gemini & Qwen Commands + ```bash -# Gemini Analysis (read-only, default) -cd [directory] && ~/.claude/scripts/gemini-wrapper -p " +# Analysis Mode (read-only, default) +# Use 'gemini' (primary) or 'qwen' (fallback) +cd [directory] && gemini " PURPOSE: [clear analysis goal] TASK: [specific analysis task] MODE: analysis -CONTEXT: [file references and memory context] +CONTEXT: @**/* [default: all files, or specify file patterns] EXPECTED: [expected output] RULES: [template reference and constraints] " -# Gemini Write Mode (requires explicit MODE=write) -# NOTE: --approval-mode yolo must be placed AFTER wrapper command, BEFORE -p -cd [directory] && ~/.claude/scripts/gemini-wrapper --approval-mode yolo -p " +# Write Mode (requires explicit MODE=write) +# NOTE: --approval-mode yolo must be placed AFTER the prompt +cd [directory] && gemini " PURPOSE: [clear goal] TASK: [specific task] MODE: write -CONTEXT: [file references and memory context] +CONTEXT: @**/* [default: all files, or specify file patterns] EXPECTED: [expected output] RULES: [template reference and constraints] -" -``` +" --approval-mode yolo -#### Qwen Commands -```bash -# Qwen Analysis (read-only, default) - Same as Gemini, use as fallback -cd [directory] && ~/.claude/scripts/qwen-wrapper -p " -PURPOSE: [clear analysis goal] -TASK: [specific analysis task] -MODE: analysis -CONTEXT: [file references and memory context] -EXPECTED: [expected output] -RULES: [template reference and constraints] -" - -# Qwen Write Mode (requires explicit MODE=write) -# NOTE: --approval-mode yolo must be placed AFTER wrapper command, BEFORE -p -cd [directory] && ~/.claude/scripts/qwen-wrapper --approval-mode yolo -p " -PURPOSE: [clear goal] -TASK: [specific task] -MODE: write -CONTEXT: [file references and memory context] -EXPECTED: [expected output] -RULES: [template reference and constraints] -" +# Fallback: Replace 'gemini' with 'qwen' if Gemini unavailable +cd [directory] && qwen "..." # Same syntax as gemini ``` #### Codex Commands + ```bash # Codex Development (requires explicit MODE=auto) # NOTE: --skip-git-repo-check and -s danger-full-access must be placed at command END @@ -180,7 +187,7 @@ codex -C [directory] --full-auto exec " PURPOSE: [clear development goal] TASK: [specific development task] MODE: auto -CONTEXT: [file references and memory context] +CONTEXT: @**/* [default: all files, or specify file patterns and memory context] EXPECTED: [expected deliverables] RULES: [template reference and constraints] " --skip-git-repo-check -s danger-full-access @@ -191,48 +198,79 @@ codex -C [directory] --full-auto exec " PURPOSE: [clear goal] TASK: [specific task] MODE: write -CONTEXT: [file references and memory context] +CONTEXT: @**/* [default: all files, or specify file patterns and memory context] EXPECTED: [expected deliverables] RULES: [template reference and constraints] " --skip-git-repo-check -s danger-full-access ``` +--- + ### Directory Context Configuration -Tools execute in current working directory: -- **Gemini**: `cd path/to/project && ~/.claude/scripts/gemini-wrapper -p "prompt"` -- **Qwen**: `cd path/to/project && ~/.claude/scripts/qwen-wrapper -p "prompt"` + +**Tool Directory Navigation**: +- **Gemini & Qwen**: `cd path/to/project && gemini "prompt"` (or `qwen`) - **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 -- **Token analysis**: For gemini-wrapper and qwen-wrapper, token counting happens in current directory +- **Token analysis**: For Gemini/Qwen, token counting happens in current directory -### RULES Field Format +#### Multi-Directory Support (Gemini & Qwen) + +**Purpose**: For large projects requiring fine-grained access across multiple directories + +**Use Case**: When `cd` limits global visibility but you need to reference files from other folders + +**Parameter**: `--include-directories ` +- Includes additional directories in the workspace +- Can be specified multiple times or as comma-separated values +- Maximum 5 directories can be added +- Particularly useful when working in a subdirectory but needing context from parent or sibling directories + +**Syntax Options**: ```bash -RULES: $(cat "~/.claude/workflows/cli-templates/prompts/[category]/[template].txt") | [constraints] +# Comma-separated format +gemini "prompt" --include-directories /path/to/project1,/path/to/project2 + +# Multiple flags format +gemini "prompt" --include-directories /path/to/project1 --include-directories /path/to/project2 + +# Combined with cd for focused analysis with extended context (RECOMMENDED) +cd src/auth && gemini " +PURPOSE: Analyze authentication with shared utilities context +TASK: Review auth implementation and its dependencies +MODE: analysis +CONTEXT: @**/* (includes current dir + shared + types directories) +EXPECTED: Complete analysis with cross-directory dependencies +RULES: Focus on integration patterns +" --include-directories ../shared,../types ``` -**โš ๏ธ CRITICAL: Command Substitution Rules** -When using `$(cat ...)` for template loading in actual CLI commands: -- **Template reference only, never read**: When user specifies template name, use `$(cat ...)` directly in RULES field, do NOT read template content first -- **NEVER use escape characters**: `\$`, `\"`, `\'` will break command substitution -- **In -p "..." context**: Path in `$(cat ...)` needs NO quotes (tilde expands correctly) -- **Correct**: `RULES: $(cat ~/.claude/workflows/cli-templates/prompts/analysis/pattern.txt)` -- **WRONG**: `RULES: \$(cat ...)` or `RULES: $(cat \"...\")` or `RULES: $(cat '...')` -- **Why**: Shell executes `$(...)` in subshell where path is safe without quotes +**Best Practices**: +- **Recommended Pattern**: Use `cd` to navigate to primary focus directory, then use `--include-directories` for additional context + - Example: `cd src/auth && gemini "..." --include-directories ../shared,../types` + - Benefits: More precise file references (relative to current directory), clearer intent, better context control +- Use when `cd` alone limits necessary context visibility +- Keep directory count โ‰ค 5 for optimal performance +- Combine with specific file patterns in CONTEXT for precision +- Prefer `cd + --include-directories` over multiple `cd` commands for cross-directory analysis -**Examples**: -- Single template: `$(cat "~/.claude/workflows/cli-templates/prompts/analysis/pattern.txt") | Focus on security` -- Multiple templates: `$(cat "template1.txt") $(cat "template2.txt") | Enterprise standards` -- No template: `Focus on security patterns, include dependency analysis` -- File patterns: `@{src/**/*.ts,CLAUDE.md} - Stay within scope` +--- -### File Pattern Reference -- All files: `@{**/*}` -- Source files: `@{src/**/*}` -- TypeScript: `@{*.ts,*.tsx}` -- With docs: `@{CLAUDE.md,**/*CLAUDE.md}` -- Tests: `@{src/**/*.test.*}` +### CONTEXT Field Configuration + +#### File Pattern Reference + +**Default Pattern**: +- **All files (default)**: `@**/*` - Use this as default for comprehensive context + +**Common Patterns**: +- Source files: `@src/**/*` +- TypeScript: `@*.ts @*.tsx` (multiple @ for multiple patterns) +- With docs: `@CLAUDE.md @**/*CLAUDE.md` (multiple @ for multiple patterns) +- Tests: `@src/**/*.test.*` + +#### Complex Pattern Discovery -**Complex Pattern Discovery**: For complex file pattern requirements, use semantic discovery tools BEFORE CLI execution: - **rg (ripgrep)**: Content-based file discovery with regex patterns - **Code Index MCP**: Semantic file search based on task requirements @@ -245,14 +283,14 @@ rg "export.*Component" --files-with-matches --type ts # Find component files mcp__code-index__search_code_advanced(pattern="interface.*Props", file_pattern="*.tsx") # Find interface files # Step 2: Build precise CONTEXT from discovery results -CONTEXT: @{src/components/Auth.tsx,src/types/auth.d.ts,src/hooks/useAuth.ts} +CONTEXT: @src/components/Auth.tsx @src/types/auth.d.ts @src/hooks/useAuth.ts # Step 3: Execute CLI with precise file references -cd src && ~/.claude/scripts/gemini-wrapper -p " +cd src && gemini " PURPOSE: Analyze authentication components TASK: Review auth component patterns and props interfaces MODE: analysis -CONTEXT: @{components/Auth.tsx,types/auth.d.ts,hooks/useAuth.ts} +CONTEXT: @components/Auth.tsx @types/auth.d.ts @hooks/useAuth.ts EXPECTED: Pattern analysis and improvement suggestions RULES: Focus on type safety and component composition " @@ -260,26 +298,38 @@ RULES: Focus on type safety and component composition --- -## ๐Ÿ“Š Tool Selection Guide +### RULES Field Configuration -### Selection Matrix +#### Basic Format +```bash +RULES: $(cat ~/.claude/workflows/cli-templates/prompts/[category]/[template].txt) | [constraints] +``` -| Task Type | Tool | Use Case | Template | -|-----------|------|----------|-----------| -| **Analysis** | Gemini (Qwen fallback) | Code exploration, architecture review, patterns | `analysis/pattern.txt` | -| **Architecture** | Gemini (Qwen fallback) | System design, architectural analysis | `analysis/architecture.txt` | -| **Documentation** | Gemini (Qwen fallback) | Code docs, API specs, guides | `analysis/quality.txt` | -| **Development** | Codex | Feature implementation, bug fixes, testing | `development/feature.txt` | -| **Planning** | Gemini/Qwen | Task breakdown, migration planning | `planning/task-breakdown.txt` | -| **Security** | Codex | Vulnerability assessment, fixes | `analysis/security.txt` | -| **Refactoring** | Multiple | Gemini/Qwen for analysis, Codex for execution | `development/refactor.txt` | -| **Module Documentation** | Gemini (Qwen fallback) | Universal module/file documentation for all levels | `memory/claude-module-unified.txt` | +#### โš ๏ธ CRITICAL: Command Substitution Rules + +When using `$(cat ...)` for template loading in actual CLI commands: +- **Template reference only, never read**: When user specifies template name, use `$(cat ...)` directly in RULES field, do NOT read template content first +- **NEVER use escape characters**: `\$`, `\"`, `\'` will break command substitution +- **In prompt context**: Path in `$(cat ...)` needs NO quotes (tilde expands correctly) +- **Correct**: `RULES: $(cat ~/.claude/workflows/cli-templates/prompts/analysis/pattern.txt)` +- **WRONG**: `RULES: \$(cat ...)` or `RULES: $(cat \"...\")` or `RULES: $(cat '...')` +- **Why**: Shell executes `$(...)` in subshell where path is safe without quotes + +#### Examples +- Single template: `$(cat ~/.claude/workflows/cli-templates/prompts/analysis/pattern.txt) | Focus on security` +- Multiple templates: `$(cat template1.txt) $(cat template2.txt) | Enterprise standards` +- No template: `Focus on security patterns, include dependency analysis` +- File patterns: `@src/**/*.ts @CLAUDE.md - Stay within scope` + +--- ### Template System -**Base Structure**: `~/.claude/workflows/cli-templates/` +#### Base Structure +`~/.claude/workflows/cli-templates/` #### Available Templates + ``` prompts/ โ”œโ”€โ”€ analysis/ @@ -307,11 +357,103 @@ tech-stacks/ โ””โ”€โ”€ react-dev.md - React architecture ``` +#### Task-Template Selection Matrix + +| Task Type | Tool | Use Case | Template | +|-----------|------|----------|-----------| +| **Analysis** | Gemini (Qwen fallback) | Code exploration, architecture review, patterns | `analysis/pattern.txt` | +| **Architecture** | Gemini (Qwen fallback) | System design, architectural analysis | `analysis/architecture.txt` | +| **Documentation** | Gemini (Qwen fallback) | Code docs, API specs, guides | `analysis/quality.txt` | +| **Development** | Codex | Feature implementation, bug fixes, testing | `development/feature.txt` | +| **Planning** | Gemini/Qwen | Task breakdown, migration planning | `planning/task-breakdown.txt` | +| **Security** | Codex | Vulnerability assessment, fixes | `analysis/security.txt` | +| **Refactoring** | Multiple | Gemini/Qwen for analysis, Codex for execution | `development/refactor.txt` | +| **Module Documentation** | Gemini (Qwen fallback) | Universal module/file documentation for all levels | `memory/claude-module-unified.txt` | + --- -## ๐Ÿš€ Usage Patterns +## โš™๏ธ Execution Configuration + +### Dynamic Timeout Allocation + +**Timeout Ranges**: +- **Simple tasks** (analysis, search): 20-40min (1200000-2400000ms) +- **Medium tasks** (refactoring, documentation): 40-60min (2400000-3600000ms) +- **Complex tasks** (implementation, migration): 60-120min (3600000-7200000ms) + +**Codex Multiplier**: Codex commands use 1.5x of allocated time + +**Application**: All bash() wrapped commands including Gemini, Qwen and Codex executions + +**Auto-detection**: Analyze PURPOSE and TASK fields to determine appropriate timeout + +**Command Examples**: +```bash +bash(gemini "prompt") # Simple analysis: 20-40min +bash(codex -C directory --full-auto exec "task") # Complex implementation: 90-180min +``` + +--- + +### Permission Framework + +#### Write Operation Protection + +**โš ๏ธ WRITE PROTECTION**: Local codebase write/modify requires EXPLICIT user confirmation + +**Mode Hierarchy**: +- **Analysis Mode (default)**: Read-only, safe for auto-execution +- **Write Mode**: Requires user explicitly states MODE=write or MODE=auto in prompt +- **Exception**: User provides clear instructions like "modify", "create", "implement" + +#### Tool-Specific Permissions + +**Gemini/Qwen Write Access**: +- Use `--approval-mode yolo` ONLY when MODE=write explicitly specified +- **Parameter Position**: Place AFTER the prompt: `gemini "..." --approval-mode yolo` + +**Codex Write Access**: +- Use `-s danger-full-access` and `--skip-git-repo-check` ONLY when MODE=auto explicitly specified +- **Parameter Position**: Place AFTER the prompt string at command END: `codex ... exec "..." --skip-git-repo-check -s danger-full-access` + +**Default Behavior**: All tools default to analysis/read-only mode without explicit write permission + +--- + +## ๐Ÿ”ง Best Practices + +### General Guidelines + +**Workflow Principles**: +- **Start with templates** - Use predefined templates for consistency +- **Be specific** - Clear PURPOSE, TASK, and EXPECTED fields +- **Include constraints** - File patterns, scope, requirements in RULES +- **Discover patterns first** - Use rg/MCP for complex file discovery before CLI execution +- **Build precise CONTEXT** - Convert discovery results to explicit file references +- **Document context** - Always reference CLAUDE.md for context +- **Default to full context** - Use `@**/*` in CONTEXT for comprehensive analysis unless specific files needed +- **โš ๏ธ No escape characters in CLI commands** - NEVER use `\$`, `\"`, `\'` in actual CLI execution (breaks command substitution and path expansion) + +--- + +### Context Optimization Strategy + +**Directory Navigation**: Use `cd [directory] &&` pattern when analyzing specific areas to reduce irrelevant context + +**When to change directory**: +- Specific directory mentioned โ†’ Use `cd directory &&` pattern +- Focused analysis needed โ†’ Target specific directory with cd +- Multi-directory scope โ†’ Use `cd` + `--include-directories` for precise control + +**When to use `--include-directories`**: +- Working in subdirectory but need parent/sibling context +- Cross-directory dependency analysis required +- Multiple related modules need simultaneous access + +--- ### Workflow Integration (REQUIRED) + When planning any coding task, **ALWAYS** integrate CLI tools: 1. **Understanding Phase**: Use Gemini for analysis (Qwen as fallback) @@ -319,185 +461,16 @@ When planning any coding task, **ALWAYS** integrate CLI tools: 3. **Implementation Phase**: Use Codex for development 4. **Quality Phase**: Use Codex for testing and validation -### Common Scenarios - -#### Code Analysis -```bash -~/.claude/scripts/gemini-wrapper -p " -PURPOSE: Understand codebase architecture -TASK: Analyze project structure and identify patterns -MODE: analysis -CONTEXT: @{src/**/*.ts,CLAUDE.md} Previous analysis of auth system -EXPECTED: Architecture overview and integration points -RULES: $(cat ~/.claude/workflows/cli-templates/prompts/analysis/architecture.txt) | Focus on integration points -" -``` - -#### Documentation Generation -```bash -~/.claude/scripts/gemini-wrapper -p " -PURPOSE: Generate API documentation -TASK: Create comprehensive API reference from code -MODE: write -CONTEXT: @{src/api/**/*} -EXPECTED: API.md with all endpoints documented -RULES: Follow project documentation standards -" -``` - -#### Architecture Analysis (Qwen as Gemini fallback) -```bash -# Prefer Gemini for architecture analysis -cd src/auth && ~/.claude/scripts/gemini-wrapper -p " -PURPOSE: Analyze authentication system architecture -TASK: Review JWT-based auth system design -MODE: analysis -CONTEXT: @{src/auth/**/*} Existing patterns and requirements -EXPECTED: Architecture analysis report with recommendations -RULES: $(cat ~/.claude/workflows/cli-templates/prompts/analysis/architecture.txt) | Focus on security -" - -# Use Qwen only if Gemini unavailable -cd src/auth && ~/.claude/scripts/qwen-wrapper -p " -PURPOSE: Analyze authentication system architecture -TASK: Review JWT-based auth system design -MODE: analysis -CONTEXT: @{src/auth/**/*} Existing patterns and requirements -EXPECTED: Architecture analysis report with recommendations -RULES: $(cat ~/.claude/workflows/cli-templates/prompts/analysis/architecture.txt) | Focus on security -" -``` - -#### Feature Development (Multi-task with Resume) -```bash -# First task - establish session -codex -C path/to/project --full-auto exec " -PURPOSE: Implement user authentication -TASK: Create JWT-based authentication system -MODE: auto -CONTEXT: @{src/auth/**/*} Database schema from session memory -EXPECTED: Complete auth module with tests -RULES: $(cat ~/.claude/workflows/cli-templates/prompts/development/feature.txt) | Follow security best practices -" --skip-git-repo-check -s danger-full-access - -# Continue in same session - Add JWT validation -codex --full-auto exec " -PURPOSE: Enhance authentication security -TASK: Add JWT token validation and refresh logic -MODE: auto -CONTEXT: Previous auth implementation from current session -EXPECTED: JWT validation middleware and token refresh endpoints -RULES: Follow JWT best practices, maintain session context -" resume --last --skip-git-repo-check -s danger-full-access - -# Continue in same session - Add tests -codex --full-auto exec " -PURPOSE: Increase test coverage -TASK: Generate comprehensive tests for auth module -MODE: write -CONTEXT: Auth implementation from current session -EXPECTED: Complete test suite with 80%+ coverage -RULES: Use Jest, follow existing patterns -" resume --last --skip-git-repo-check -s danger-full-access -``` - -#### Interactive Session Resume -```bash -# Resume previous session with picker -codex resume - -# Or resume most recent session directly -codex resume --last -``` - --- -## ๐Ÿ”ง Best Practices - -### General Guidelines -- **Start with templates** - Use predefined templates for consistency -- **Be specific** - Clear PURPOSE, TASK, and EXPECTED fields -- **Include constraints** - File patterns, scope, requirements in RULES -- **Discover patterns first** - Use rg/MCP for complex file discovery before CLI execution -- **Build precise CONTEXT** - Convert discovery results to explicit file references -- **Document context** - Always reference CLAUDE.md for context -- **โš ๏ธ No escape characters in CLI commands** - NEVER use `\$`, `\"`, `\'` in actual CLI execution (breaks command substitution and path expansion) - -### Context Optimization Strategy -**Directory Navigation**: Use `cd [directory] &&` pattern when analyzing specific areas to reduce irrelevant context - -**When to change directory**: -- Specific directory mentioned โ†’ Use `cd directory &&` pattern -- Focused analysis needed โ†’ Target specific directory with cd -- Multi-directory scope โ†’ Stay in root, use explicit paths or multiple commands - -**Example**: -```bash -# Gemini - Focused analysis -cd src/auth && ~/.claude/scripts/gemini-wrapper -p " -PURPOSE: Understand authentication patterns -TASK: Analyze auth implementation -MODE: analysis -CONTEXT: @{**/*.ts} -EXPECTED: Pattern documentation -RULES: Focus on security best practices -" - -# Qwen - Analysis (fallback option, same as Gemini) -cd src/auth && ~/.claude/scripts/qwen-wrapper -p " -PURPOSE: Analyze auth architecture -TASK: Review auth system design and patterns -MODE: analysis -CONTEXT: @{**/*} -EXPECTED: Architecture analysis report -RULES: Focus on modularity and security -" - -# Codex - Implementation -codex -C src/auth --full-auto exec " -PURPOSE: Improve auth implementation -TASK: Review and enhance auth code -MODE: auto -CONTEXT: @{**/*.ts} -EXPECTED: Code improvements and fixes -RULES: Maintain backward compatibility -" --skip-git-repo-check -s danger-full-access -``` - ### Planning Checklist For every development task: - [ ] **Purpose defined** - Clear goal and intent - [ ] **Mode selected** - Execution mode and permission level determined -- [ ] **Context gathered** - File references and session memory documented +- [ ] **Context gathered** - File references and session memory documented (default `@**/*`) +- [ ] **Directory navigation** - Determine if `cd` or `cd + --include-directories` needed - [ ] **Gemini analysis** completed for understanding - [ ] **Template selected** - Appropriate template chosen - [ ] **Constraints specified** - File patterns, scope, requirements - [ ] **Implementation approach** - Tool selection and workflow -- [ ] **Quality measures** - Testing and validation plan -- [ ] **Tool configuration** - Review `.gemini/CLAUDE.md` or `.codex/Agent.md` if needed - ---- - -## โš™๏ธ Execution Configuration - -### Core Execution Rules -- **Dynamic Timeout (20-120min)**: Allocate execution time based on task complexity - - Simple tasks (analysis, search): 20-40min (1200000-2400000ms) - - Medium tasks (refactoring, documentation): 40-60min (2400000-3600000ms) - - Complex tasks (implementation, migration): 60-120min (3600000-7200000ms) -- **Codex Multiplier**: Codex commands use 1.5x of allocated time -- **Apply to All Tools**: All bash() wrapped commands including Gemini, Qwen wrapper and Codex executions -- **Command Examples**: `bash(~/.claude/scripts/gemini-wrapper -p "prompt")`, `bash(codex -C directory --full-auto exec "task")` -- **Auto-detect**: Analyze PURPOSE and TASK fields to determine appropriate timeout - -### Permission Framework -- **โš ๏ธ WRITE PROTECTION**: Local codebase write/modify requires EXPLICIT user confirmation - - **Analysis Mode (default)**: Read-only, safe for auto-execution - - **Write Mode**: Requires user explicitly states MODE=write or MODE=auto in prompt - - **Exception**: User provides clear instructions like "modify", "create", "implement" -- **Gemini/Qwen Write Access**: Use `--approval-mode yolo` ONLY when MODE=write explicitly specified - - **Parameter Position**: Place AFTER the wrapper command: `gemini-wrapper --approval-mode yolo -p "..."` -- **Codex Write Access**: Use `-s danger-full-access` and `--skip-git-repo-check` ONLY when MODE=auto explicitly specified - - **Parameter Position**: Place AFTER the prompt string at command END: `codex ... exec "..." --skip-git-repo-check -s danger-full-access` -- **Default Behavior**: All tools default to analysis/read-only mode without explicit write permission diff --git a/.claude/workflows/mcp-tool-strategy.md b/.claude/workflows/mcp-tool-strategy.md index 7b399ade..8e9ae356 100644 --- a/.claude/workflows/mcp-tool-strategy.md +++ b/.claude/workflows/mcp-tool-strategy.md @@ -86,9 +86,9 @@ mcp__code-index__search_code_advanced(pattern="async.*function", file_pattern="* mcp__exa__get_code_context_exa(query="TypeScript async patterns", tokensNum="dynamic") # 3. Analyze with Gemini -cd "src/async" && ~/.claude/scripts/gemini-wrapper -p " +cd "src/async" && gemini " PURPOSE: Understand async patterns -CONTEXT: Code index results + Exa context + @{src/async/**/*} +CONTEXT: Code index results + Exa context + @src/async/**/* EXPECTED: Pattern analysis RULES: Focus on TypeScript best practices " @@ -134,7 +134,7 @@ codex -C src/async --full-auto exec "Apply modern async patterns" -s danger-full mcp__code-index__search_code_advanced(pattern="router|routing", file_pattern="*.ts") mcp__exa__get_code_context_exa(query="Next.js 14 app router", tokensNum="dynamic") mcp__exa__web_search_exa(query="Next.js 14 best practices 2024", numResults=3) -cd "src/app" && ~/.claude/scripts/gemini-wrapper -p "Learn Next.js patterns" +cd "src/app" && gemini "Learn Next.js patterns" ``` ### Debugging @@ -153,7 +153,7 @@ mcp__code-index__refresh_index() # ๅˆทๆ–ฐ็ดขๅผ• mcp__code-index__find_files(pattern="*auth*") # Find auth-related files mcp__code-index__search_code_advanced(pattern="function.*auth", file_pattern="*.ts") # Find auth functions mcp__code-index__get_file_summary(file_path="src/auth/index.ts") # Understand structure -cd "src/auth" && ~/.claude/scripts/gemini-wrapper -p "Analyze auth architecture" +cd "src/auth" && gemini "Analyze auth architecture" ``` ### Project Setup Workflow diff --git a/.claude/workflows/workflow-architecture.md b/.claude/workflows/workflow-architecture.md index 4ab9ea6a..e7e14af3 100644 --- a/.claude/workflows/workflow-architecture.md +++ b/.claude/workflows/workflow-architecture.md @@ -152,7 +152,7 @@ All task files use this unified 5-field schema with optional artifacts enhanceme { "step": "analyze_architecture", "action": "Review system architecture", - "command": "~/.claude/scripts/gemini-wrapper -p \"analyze patterns: [patterns]\"", + "command": "gemini \"analyze patterns: [patterns]\"", "output_to": "design" }, { @@ -416,7 +416,7 @@ The `[FLOW_CONTROL]` marker indicates that a task or prompt contains flow contro - **Bash commands**: `bash(command)` - Any shell command - **Tool calls**: `Read(file)`, `Glob(pattern)`, `Grep(pattern)` - **MCP tools**: `mcp__code-index__find_files()`, `mcp__exa__get_code_context_exa()` -- **CLI wrappers**: `~/.claude/scripts/gemini-wrapper`, `codex --full-auto exec` +- **CLI commands**: `gemini`, `qwen`, `codex --full-auto exec` **Example**: ```json @@ -477,10 +477,10 @@ The `[FLOW_CONTROL]` marker indicates that a task or prompt contains flow contro "command": "codex --full-auto exec \"task\" resume --last --skip-git-repo-check -s danger-full-access" // Gemini (user requested) -"command": "~/.claude/scripts/gemini-wrapper -p \"analyze [context]\"" +"command": "gemini \"analyze [context]\"" // Qwen (fallback for Gemini) -"command": "~/.claude/scripts/qwen-wrapper -p \"analyze [context]\"" +"command": "qwen \"analyze [context]\"" ``` **Example Step**: @@ -517,14 +517,14 @@ The `[FLOW_CONTROL]` marker indicates that a task or prompt contains flow contro **Gemini CLI**: ```bash -~/.claude/scripts/gemini-wrapper -p "prompt" -~/.claude/scripts/gemini-wrapper --approval-mode yolo -p "prompt" # For write mode +gemini "prompt" +gemini --approval-mode yolo "prompt" # For write mode ``` **Qwen CLI** (Gemini fallback): ```bash -~/.claude/scripts/qwen-wrapper -p "prompt" -~/.claude/scripts/qwen-wrapper --approval-mode yolo -p "prompt" # For write mode +qwen "prompt" +qwen --approval-mode yolo "prompt" # For write mode ``` **Codex CLI**: @@ -892,13 +892,13 @@ fi - **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 +- **Tool Strategy**: `gemini` 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 +- **Tool Strategy**: `gemini` 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 From 8ebae76b74bba0c98c4366d4975b08c22f1f0e3c Mon Sep 17 00:00:00 2001 From: catlog22 Date: Tue, 21 Oct 2025 15:07:03 +0800 Subject: [PATCH 2/3] =?UTF-8?q?docs:=20=E7=A7=BB=E9=99=A4=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E6=8E=A7=E5=88=B6=E9=85=8D=E7=BD=AE=E7=9A=84=E5=86=97?= =?UTF-8?q?=E4=BD=99=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CLAUDE.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CLAUDE.md b/CLAUDE.md index 0c4c9c92..f3c1d85f 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -5,7 +5,6 @@ This document defines project-specific coding standards and development principles. ### CLI Tool Context Protocols For all CLI tool usage, command syntax, and integration guidelines: -- **Tool Control Configuration**: @~/.claude/workflows/tool-control.yaml - Controls CLI tool availability for all commands and agent executions (if disabled, use other enabled CLI tools or Claude's own capabilities) - **MCP Tool Strategy**: @~/.claude/workflows/mcp-tool-strategy.md - **Intelligent Context Strategy**: @~/.claude/workflows/intelligent-tools-strategy.md - **Context Search Commands**: @~/.claude/workflows/context-search-strategy.md From 5046565d4cad3cf4e0fbdee9a545a160ab814a0d Mon Sep 17 00:00:00 2001 From: catlog22 Date: Tue, 21 Oct 2025 15:07:37 +0800 Subject: [PATCH 3/3] =?UTF-8?q?chore:=20=E5=88=A0=E9=99=A4=E4=B8=8D?= =?UTF-8?q?=E5=86=8D=E4=BD=BF=E7=94=A8=E7=9A=84=E5=B7=A5=E5=85=B7=E5=8C=85?= =?UTF-8?q?=E8=A3=85=E8=84=9A=E6=9C=AC=E5=92=8C=E9=85=8D=E7=BD=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .claude/scripts/gemini-wrapper | 288 ---------------------------- .claude/scripts/qwen-wrapper | 228 ---------------------- .claude/workflows/tool-control.yaml | 10 - 3 files changed, 526 deletions(-) delete mode 100755 .claude/scripts/gemini-wrapper delete mode 100644 .claude/scripts/qwen-wrapper delete mode 100644 .claude/workflows/tool-control.yaml diff --git a/.claude/scripts/gemini-wrapper b/.claude/scripts/gemini-wrapper deleted file mode 100755 index 47054799..00000000 --- a/.claude/scripts/gemini-wrapper +++ /dev/null @@ -1,288 +0,0 @@ -#!/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 -# and provides intelligent approval mode defaults -# -# Usage: gemini-wrapper [all gemini options] -# -# Approval Mode Options: -# --approval-mode default : Prompt for approval on each tool call (default) -# --approval-mode auto_edit : Auto-approve edit tools, prompt for others -# --approval-mode yolo : Auto-approve all tool calls -# -# Note: Executes in current working directory - -set -e - -# Function to show help -show_help() { - echo "gemini-wrapper - Token-aware wrapper for gemini command" - echo "" - echo "Usage: gemini-wrapper [options] [gemini options]" - echo "" - echo "Options:" - echo " --approval-mode Sets the approval mode for tool calls" - echo " Available modes:" - echo " default : Prompt for approval on each tool call (default)" - echo " auto_edit : Auto-approve edit tools, prompt for others" - echo " yolo : Auto-approve all tool calls" - echo " --help Show this help message" - echo "" - echo "Features:" - echo " - Automatically manages --all-files flag based on project token count" - echo " - Intelligent approval mode detection based on task type" - echo " - Token limit: $DEFAULT_TOKEN_LIMIT (set GEMINI_TOKEN_LIMIT to override)" - echo "" - echo "Examples:" - echo " gemini-wrapper -p \"Analyze the codebase structure\"" - echo " gemini-wrapper --approval-mode yolo -p \"Implement user authentication\"" - echo " gemini-wrapper --approval-mode auto_edit -p \"Fix all linting errors\"" - echo "" -} - -# Configuration -DEFAULT_TOKEN_LIMIT=2000000 -TOKEN_LIMIT=${GEMINI_TOKEN_LIMIT:-$DEFAULT_TOKEN_LIMIT} - -# Colors for output -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[1;33m' -NC='\033[0m' # No Color - -# Respect custom Gemini base URL -if [[ -n "$GOOGLE_GEMINI_BASE_URL" ]]; then - echo -e "${GREEN}๐ŸŒ Using custom Gemini base URL: $GOOGLE_GEMINI_BASE_URL${NC}" >&2 - export GOOGLE_GEMINI_BASE_URL -fi - -# Function to count tokens (approximate: chars/4) - optimized version -count_tokens() { - local total_chars=0 - local file_count=0 - - # Use single find with bulk wc for better performance - # Common source file extensions - 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" - - # Build find command with extension patterns - 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 - 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)) - echo "$estimated_tokens $file_count" -} - -# Function to validate approval mode -validate_approval_mode() { - local mode="$1" - case "$mode" in - "default"|"auto_edit"|"yolo") - return 0 - ;; - *) - echo -e "${RED}โŒ Invalid approval mode: $mode${NC}" >&2 - echo -e "${YELLOW}Valid modes: default, auto_edit, yolo${NC}" >&2 - return 1 - ;; - esac -} - -# Parse arguments to check for flags -has_all_files=false -has_approval_mode=false -approval_mode_value="" -args=() -i=0 - -# Parse arguments with proper handling of --approval-mode value -args=("$@") # Start with all arguments -parsed_args=() -skip_next=false - -for ((i=0; i<${#args[@]}; i++)); do - if [[ "$skip_next" == true ]]; then - skip_next=false - continue - fi - - arg="${args[i]}" - case "$arg" in - "--help"|"-h") - show_help - exit 0 - ;; - "--all-files") - has_all_files=true - parsed_args+=("$arg") - ;; - "--approval-mode") - has_approval_mode=true - # Get the next argument as the mode value - if [[ $((i+1)) -lt ${#args[@]} ]]; then - approval_mode_value="${args[$((i+1))]}" - if validate_approval_mode "$approval_mode_value"; then - parsed_args+=("$arg" "$approval_mode_value") - skip_next=true - else - exit 1 - fi - else - echo -e "${RED}โŒ --approval-mode requires a value${NC}" >&2 - echo -e "${YELLOW}Valid modes: default, auto_edit, yolo${NC}" >&2 - exit 1 - fi - ;; - --approval-mode=*) - has_approval_mode=true - approval_mode_value="${arg#*=}" - if validate_approval_mode "$approval_mode_value"; then - parsed_args+=("$arg") - else - exit 1 - fi - ;; - *) - parsed_args+=("$arg") - ;; - esac -done - -# Replace args with parsed_args -args=("${parsed_args[@]}") - -# Analyze current working directory -echo -e "${GREEN}๐Ÿ“ Analyzing current directory: $(pwd)${NC}" >&2 - -# 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)" - -echo -e "${YELLOW}๐Ÿ“Š Project stats: ~${token_count} tokens across ${file_count} files${NC}" >&2 - -# Decision logic for --all-files flag -if [[ $token_count -lt $TOKEN_LIMIT ]]; then - if [[ "$has_all_files" == false ]]; then - echo -e "${GREEN}โœ… Small project (${token_count} < ${TOKEN_LIMIT} tokens): Adding --all-files${NC}" >&2 - args=("--all-files" "${args[@]}") - else - echo -e "${GREEN}โœ… Small project (${token_count} < ${TOKEN_LIMIT} tokens): Keeping --all-files${NC}" >&2 - fi -else - if [[ "$has_all_files" == true ]]; then - echo -e "${RED}โš ๏ธ Large project (${token_count} >= ${TOKEN_LIMIT} tokens): Removing --all-files to avoid token limits${NC}" >&2 - echo -e "${YELLOW}๐Ÿ’ก Consider using specific @{patterns} for targeted analysis${NC}" >&2 - # Remove --all-files from args - new_args=() - for arg in "${args[@]}"; do - if [[ "$arg" != "--all-files" ]]; then - new_args+=("$arg") - fi - done - args=("${new_args[@]}") - else - echo -e "${RED}โš ๏ธ Large project (${token_count} >= ${TOKEN_LIMIT} tokens): Avoiding --all-files${NC}" >&2 - echo -e "${YELLOW}๐Ÿ’ก Consider using specific @{patterns} for targeted analysis${NC}" >&2 - fi -fi - -# Auto-add approval-mode if not specified -if [[ "$has_approval_mode" == false ]]; then - # Intelligent approval mode detection based on prompt content - prompt_text="${args[*]}" - - # Analysis/Research tasks - use default (prompt for each tool) - if [[ "$prompt_text" =~ (analyze|analysis|review|understand|inspect|examine|research|study|explore|investigate) ]]; then - echo -e "${GREEN}๐Ÿ“‹ Analysis task detected: Adding --approval-mode default${NC}" >&2 - args=("--approval-mode" "default" "${args[@]}") - - # Development/Edit tasks - use auto_edit (auto-approve edits, prompt for others) - elif [[ "$prompt_text" =~ (implement|create|build|develop|code|write|edit|modify|update|fix|refactor|generate) ]]; then - echo -e "${GREEN}๐Ÿ”ง Development task detected: Adding --approval-mode auto_edit${NC}" >&2 - args=("--approval-mode" "auto_edit" "${args[@]}") - - # Automation/Batch tasks - use yolo (auto-approve all) - elif [[ "$prompt_text" =~ (automate|batch|mass|bulk|all|execute|run|deploy|install|setup) ]]; then - echo -e "${YELLOW}โšก Automation task detected: Adding --approval-mode yolo${NC}" >&2 - args=("--approval-mode" "yolo" "${args[@]}") - - # Default fallback - use default mode for safety - else - echo -e "${YELLOW}๐Ÿ” General task detected: Adding --approval-mode default${NC}" >&2 - args=("--approval-mode" "default" "${args[@]}") - fi - - # Show approval mode explanation - case "${args[1]}" in - "default") - echo -e "${YELLOW} โ†’ Will prompt for approval on each tool call${NC}" >&2 - ;; - "auto_edit") - echo -e "${YELLOW} โ†’ Will auto-approve edit tools, prompt for others${NC}" >&2 - ;; - "yolo") - echo -e "${YELLOW} โ†’ Will auto-approve all tool calls${NC}" >&2 - ;; - esac -fi - -# Show final command (for transparency) -echo -e "${YELLOW}๐Ÿš€ Executing: gemini ${args[*]}${NC}" >&2 - -# Execute gemini with adjusted arguments (we're already in the right directory) -gemini "${args[@]}" \ No newline at end of file diff --git a/.claude/scripts/qwen-wrapper b/.claude/scripts/qwen-wrapper deleted file mode 100644 index a38c7683..00000000 --- a/.claude/scripts/qwen-wrapper +++ /dev/null @@ -1,228 +0,0 @@ -#!/bin/bash -# qwen-wrapper - Token-aware wrapper for qwen command -# Location: ~/.claude/scripts/qwen-wrapper -# -# This wrapper automatically manages --all-files flag based on project token count -# and provides intelligent approval mode defaults -# -# Usage: qwen-wrapper [all qwen options] -# -# Approval Mode Options: -# --approval-mode default : Prompt for approval on each tool call (default) -# --approval-mode auto_edit : Auto-approve edit tools, prompt for others -# --approval-mode yolo : Auto-approve all tool calls -# -# Note: Executes in current working directory - -set -e - -# Function to show help -show_help() { - echo "qwen-wrapper - Token-aware wrapper for qwen command" - echo "" - echo "Usage: qwen-wrapper [options] [qwen options]" - echo "" - echo "Options:" - echo " --approval-mode Sets the approval mode for tool calls" - echo " Available modes:" - echo " default : Prompt for approval on each tool call (default)" - echo " auto_edit : Auto-approve edit tools, prompt for others" - echo " yolo : Auto-approve all tool calls" - echo " --help Show this help message" - echo "" - echo "Features:" - echo " - Automatically manages --all-files flag based on project token count" - echo " - Intelligent approval mode detection based on task type" - echo " - Token limit: $DEFAULT_TOKEN_LIMIT (set QWEN_TOKEN_LIMIT to override)" - echo "" - echo "Examples:" - echo " qwen-wrapper -p \"Analyze the codebase structure\"" - echo " qwen-wrapper --approval-mode yolo -p \"Implement user authentication\"" - echo " qwen-wrapper --approval-mode auto_edit -p \"Fix all linting errors\"" - echo "" -} - -# Function to validate approval mode -validate_approval_mode() { - local mode="$1" - case "$mode" in - "default"|"auto_edit"|"yolo") - return 0 - ;; - *) - echo -e "${RED}โŒ Invalid approval mode: $mode${NC}" >&2 - echo -e "${YELLOW}Valid modes: default, auto_edit, yolo${NC}" >&2 - return 1 - ;; - esac -} - -# Configuration -DEFAULT_TOKEN_LIMIT=2000000 -TOKEN_LIMIT=${QWEN_TOKEN_LIMIT:-$DEFAULT_TOKEN_LIMIT} - -# Colors for output -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[1;33m' -NC='\033[0m' # No Color - -# Function to count tokens (approximate: chars/4) -count_tokens() { - local total_chars=0 - local file_count=0 - - # Count characters in common source files - while IFS= read -r -d '' 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 < <(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) - - local estimated_tokens=$((total_chars / 4)) - echo "$estimated_tokens $file_count" -} - -# Parse arguments to check for flags -has_all_files=false -has_approval_mode=false -approval_mode_value="" - -# Parse arguments with proper handling of --approval-mode value -args=("$@") # Start with all arguments -parsed_args=() -skip_next=false - -for ((i=0; i<${#args[@]}; i++)); do - if [[ "$skip_next" == true ]]; then - skip_next=false - continue - fi - - arg="${args[i]}" - case "$arg" in - "--help"|"-h") - show_help - exit 0 - ;; - "--all-files") - has_all_files=true - parsed_args+=("$arg") - ;; - "--approval-mode") - has_approval_mode=true - # Get the next argument as the mode value - if [[ $((i+1)) -lt ${#args[@]} ]]; then - approval_mode_value="${args[$((i+1))]}" - if validate_approval_mode "$approval_mode_value"; then - parsed_args+=("$arg" "$approval_mode_value") - skip_next=true - else - exit 1 - fi - else - echo -e "${RED}โŒ --approval-mode requires a value${NC}" >&2 - echo -e "${YELLOW}Valid modes: default, auto_edit, yolo${NC}" >&2 - exit 1 - fi - ;; - --approval-mode=*) - has_approval_mode=true - approval_mode_value="${arg#*=}" - if validate_approval_mode "$approval_mode_value"; then - parsed_args+=("$arg") - else - exit 1 - fi - ;; - *) - parsed_args+=("$arg") - ;; - esac -done - -# Replace args with parsed_args -args=("${parsed_args[@]}") - -# Analyze current working directory -echo -e "${GREEN}๐Ÿ“ Analyzing current directory: $(pwd)${NC}" >&2 - -# 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)" - -echo -e "${YELLOW}๐Ÿ“Š Project stats: ~${token_count} tokens across ${file_count} files${NC}" >&2 - -# Decision logic for --all-files flag -if [[ $token_count -lt $TOKEN_LIMIT ]]; then - if [[ "$has_all_files" == false ]]; then - echo -e "${GREEN}โœ… Small project (${token_count} < ${TOKEN_LIMIT} tokens): Adding --all-files${NC}" >&2 - args=("--all-files" "${args[@]}") - else - echo -e "${GREEN}โœ… Small project (${token_count} < ${TOKEN_LIMIT} tokens): Keeping --all-files${NC}" >&2 - fi -else - if [[ "$has_all_files" == true ]]; then - echo -e "${RED}โš ๏ธ Large project (${token_count} >= ${TOKEN_LIMIT} tokens): Removing --all-files to avoid token limits${NC}" >&2 - echo -e "${YELLOW}๐Ÿ’ก Consider using specific @{patterns} for targeted analysis${NC}" >&2 - # Remove --all-files from args - new_args=() - for arg in "${args[@]}"; do - if [[ "$arg" != "--all-files" ]]; then - new_args+=("$arg") - fi - done - args=("${new_args[@]}") - else - echo -e "${RED}โš ๏ธ Large project (${token_count} >= ${TOKEN_LIMIT} tokens): Avoiding --all-files${NC}" >&2 - echo -e "${YELLOW}๐Ÿ’ก Consider using specific @{patterns} for targeted analysis${NC}" >&2 - fi -fi - -# Auto-add approval-mode if not specified -if [[ "$has_approval_mode" == false ]]; then - # Intelligent approval mode detection based on prompt content - prompt_text="${args[*]}" - - # Analysis/Research tasks - use default (prompt for each tool) - if [[ "$prompt_text" =~ (analyze|analysis|review|understand|inspect|examine|research|study|explore|investigate) ]]; then - echo -e "${GREEN}๐Ÿ“‹ Analysis task detected: Adding --approval-mode default${NC}" >&2 - args=("--approval-mode" "default" "${args[@]}") - - # Development/Edit tasks - use auto_edit (auto-approve edits, prompt for others) - elif [[ "$prompt_text" =~ (implement|create|build|develop|code|write|edit|modify|update|fix|refactor|generate) ]]; then - echo -e "${GREEN}๐Ÿ”ง Development task detected: Adding --approval-mode auto_edit${NC}" >&2 - args=("--approval-mode" "auto_edit" "${args[@]}") - - # Automation/Batch tasks - use yolo (auto-approve all) - elif [[ "$prompt_text" =~ (automate|batch|mass|bulk|all|execute|run|deploy|install|setup) ]]; then - echo -e "${YELLOW}โšก Automation task detected: Adding --approval-mode yolo${NC}" >&2 - args=("--approval-mode" "yolo" "${args[@]}") - - # Default fallback - use default mode for safety - else - echo -e "${YELLOW}๐Ÿ” General task detected: Adding --approval-mode default${NC}" >&2 - args=("--approval-mode" "default" "${args[@]}") - fi - - # Show approval mode explanation - case "${args[1]}" in - "default") - echo -e "${YELLOW} โ†’ Will prompt for approval on each tool call${NC}" >&2 - ;; - "auto_edit") - echo -e "${YELLOW} โ†’ Will auto-approve edit tools, prompt for others${NC}" >&2 - ;; - "yolo") - echo -e "${YELLOW} โ†’ Will auto-approve all tool calls${NC}" >&2 - ;; - esac -fi - -# Show final command (for transparency) -echo -e "${YELLOW}๐Ÿš€ Executing: qwen ${args[*]}${NC}" >&2 - -# Execute qwen with adjusted arguments (we're already in the right directory) -qwen "${args[@]}" \ No newline at end of file diff --git a/.claude/workflows/tool-control.yaml b/.claude/workflows/tool-control.yaml deleted file mode 100644 index c4d76bf2..00000000 --- a/.claude/workflows/tool-control.yaml +++ /dev/null @@ -1,10 +0,0 @@ -# Tool Control Configuration -# Controls whether CLI tools (Gemini, Qwen, Codex) are enabled in the workspace - -tools: - gemini: - enabled: true - qwen: - enabled: true - codex: - enabled: true