From 029f3a3c122c8e870693da788720d86edb37113e Mon Sep 17 00:00:00 2001 From: catlog22 Date: Tue, 30 Sep 2025 15:52:26 +0800 Subject: [PATCH] refactor: consolidate CLI commands and templates structure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Consolidate Gemini, Qwen, and Codex commands into unified CLI commands - Add new code-analysis mode template - Update context-gather documentation - Remove redundant tool-specific command files 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .claude/commands/cli/analyze.md | 201 ++++++++++++ .claude/commands/cli/chat.md | 161 ++++++++++ .../gemini-init.md => cli/cli-init.md} | 222 ++++++++++---- .claude/commands/cli/execute.md | 235 +++++++++++++++ .claude/commands/cli/mode/bug-index.md | 114 +++++++ .claude/commands/cli/mode/code-analysis.md | 204 +++++++++++++ .claude/commands/cli/mode/plan.md | 104 +++++++ .claude/commands/codex/analyze.md | 155 ---------- .claude/commands/codex/chat.md | 189 ------------ .claude/commands/codex/execute.md | 223 -------------- .claude/commands/codex/mode/auto.md | 285 ------------------ .claude/commands/codex/mode/bug-index.md | 269 ----------------- .claude/commands/codex/mode/plan.md | 260 ---------------- .claude/commands/gemini/analyze.md | 96 ------ .claude/commands/gemini/chat.md | 93 ------ .claude/commands/gemini/execute.md | 168 ----------- .claude/commands/gemini/mode/bug-index.md | 76 ----- .claude/commands/gemini/mode/plan.md | 62 ---- .claude/commands/qwen/analyze.md | 96 ------ .claude/commands/qwen/chat.md | 93 ------ .claude/commands/qwen/execute.md | 168 ----------- .claude/commands/qwen/mode/bug-index.md | 76 ----- .claude/commands/qwen/mode/plan.md | 62 ---- .../commands/workflow/tools/context-gather.md | 2 +- .claude/prompt-templates/code-analysis.md | 115 +++++++ 25 files changed, 1306 insertions(+), 2423 deletions(-) create mode 100644 .claude/commands/cli/analyze.md create mode 100644 .claude/commands/cli/chat.md rename .claude/commands/{gemini/gemini-init.md => cli/cli-init.md} (54%) create mode 100644 .claude/commands/cli/execute.md create mode 100644 .claude/commands/cli/mode/bug-index.md create mode 100644 .claude/commands/cli/mode/code-analysis.md create mode 100644 .claude/commands/cli/mode/plan.md delete mode 100644 .claude/commands/codex/analyze.md delete mode 100644 .claude/commands/codex/chat.md delete mode 100644 .claude/commands/codex/execute.md delete mode 100644 .claude/commands/codex/mode/auto.md delete mode 100644 .claude/commands/codex/mode/bug-index.md delete mode 100644 .claude/commands/codex/mode/plan.md delete mode 100644 .claude/commands/gemini/analyze.md delete mode 100644 .claude/commands/gemini/chat.md delete mode 100644 .claude/commands/gemini/execute.md delete mode 100644 .claude/commands/gemini/mode/bug-index.md delete mode 100644 .claude/commands/gemini/mode/plan.md delete mode 100644 .claude/commands/qwen/analyze.md delete mode 100644 .claude/commands/qwen/chat.md delete mode 100644 .claude/commands/qwen/execute.md delete mode 100644 .claude/commands/qwen/mode/bug-index.md delete mode 100644 .claude/commands/qwen/mode/plan.md create mode 100644 .claude/prompt-templates/code-analysis.md diff --git a/.claude/commands/cli/analyze.md b/.claude/commands/cli/analyze.md new file mode 100644 index 00000000..686b386b --- /dev/null +++ b/.claude/commands/cli/analyze.md @@ -0,0 +1,201 @@ +--- +name: analyze +description: Quick codebase analysis using CLI tools (codex/gemini/qwen) +usage: /cli:analyze [--tool ] [--enhance] +argument-hint: "[--tool codex|gemini|qwen] [--enhance] analysis target" +examples: + - /cli:analyze "authentication patterns" + - /cli:analyze --tool qwen "API security" + - /cli:analyze --tool codex --enhance "performance bottlenecks" +allowed-tools: SlashCommand(*), Bash(*), TodoWrite(*), Read(*), Glob(*) +--- + +# CLI Analyze Command (/cli:analyze) + +## Purpose + +Execute CLI tool analysis on codebase patterns, architecture, or code quality. + +**Supported Tools**: codex, gemini (default), qwen + +## Execution Flow + +1. **Parse tool selection**: Extract `--tool` flag (default: gemini) +2. **If `--enhance` flag present**: Execute `/enhance-prompt "[analysis-target]"` and use enhanced output +3. Parse analysis target (original or enhanced) +4. Detect analysis type (pattern/architecture/security/quality) +5. Build command for selected tool with template +6. Execute analysis +7. Return results + +## Core Rules + +1. **Tool Selection**: Use `--tool` value or default to gemini +2. **Enhance First (if flagged)**: Execute `/enhance-prompt` before analysis when `--enhance` present +3. **Execute Immediately**: Build and run command without preliminary analysis +4. **Template Selection**: Auto-select template based on keywords +5. **Context Inclusion**: Always include CLAUDE.md in context +6. **Direct Output**: Return tool output directly to user + +## Tool Selection + +| Tool | Wrapper | Best For | Permissions | +|------|---------|----------|-------------| +| **gemini** (default) | `~/.claude/scripts/gemini-wrapper` | Analysis, exploration, documentation | Read-only | +| **qwen** | `~/.claude/scripts/qwen-wrapper` | Architecture, code generation | Read-only for analyze | +| **codex** | `codex --full-auto exec` | Development analysis, deep inspection | `-s danger-full-access --skip-git-repo-check` | + +## Enhancement Integration + +**When `--enhance` flag present**: +```bash +# Step 1: Enhance the prompt +SlashCommand(command="/enhance-prompt \"[analysis-target]\"") + +# Step 2: Use enhanced output as analysis target +# Enhanced output provides: +# - INTENT: Clear technical goal +# - CONTEXT: Session memory + patterns +# - ACTION: Implementation steps +# - ATTENTION: Critical constraints +``` + +**Example**: +```bash +# User: /gemini:analyze --enhance "fix auth issues" + +# Step 1: Enhance +/enhance-prompt "fix auth issues" +# Returns: +# INTENT: Debug authentication failures +# CONTEXT: JWT implementation in src/auth/, known token expiry issue +# ACTION: Analyze token lifecycle → verify refresh flow → check middleware +# ATTENTION: Preserve existing session management + +# Step 2: Analyze with enhanced context +cd . && ~/.claude/scripts/gemini-wrapper -p " +PURPOSE: Debug authentication failures (from enhanced: JWT token lifecycle) +TASK: Analyze token lifecycle, refresh flow, and middleware integration +CONTEXT: @{src/auth/**/*} @{CLAUDE.md} Session context: known token expiry issue +EXPECTED: Root cause analysis with file references +RULES: $(cat ~/.claude/workflows/cli-templates/prompts/analysis/security.txt) | Focus on JWT token handling +" +``` + +## Analysis Types + +| Type | Keywords | Template | Context | +|------|----------|----------|---------| +| **pattern** | pattern, hooks, usage | analysis/pattern.txt | Matched files + CLAUDE.md | +| **architecture** | architecture, structure, design | analysis/architecture.txt | Full codebase + CLAUDE.md | +| **security** | security, vulnerability, auth | analysis/security.txt | Matched files + CLAUDE.md | +| **quality** | quality, test, coverage | analysis/quality.txt | Source + test files + CLAUDE.md | + +## Command Templates + +### Gemini (Default) +```bash +cd [target-dir] && ~/.claude/scripts/gemini-wrapper -p " +PURPOSE: [analysis goal from user input] +TASK: [specific analysis task] +CONTEXT: @{[file-patterns]} @{CLAUDE.md} +EXPECTED: [expected output format] +RULES: $(cat ~/.claude/workflows/cli-templates/prompts/[category]/[template].txt) | [constraints] +" +``` + +### Qwen +```bash +cd [target-dir] && ~/.claude/scripts/qwen-wrapper -p " +PURPOSE: [analysis goal from user input] +TASK: [specific analysis task] +CONTEXT: @{[file-patterns]} @{CLAUDE.md} +EXPECTED: [expected output format] +RULES: $(cat ~/.claude/workflows/cli-templates/prompts/[category]/[template].txt) | [constraints] +" +``` + +### Codex +```bash +codex -C [target-dir] --full-auto exec " +PURPOSE: [analysis goal from user input] +TASK: [specific analysis task] +CONTEXT: @{[file-patterns]} @{CLAUDE.md} +EXPECTED: [expected output format] +RULES: $(cat ~/.claude/workflows/cli-templates/prompts/[category]/[template].txt) | [constraints] +" --skip-git-repo-check -s danger-full-access +``` + +## Examples + +**Pattern Analysis (Gemini - default)**: +```bash +cd . && ~/.claude/scripts/gemini-wrapper -p " +PURPOSE: Analyze authentication patterns +TASK: Identify auth implementation patterns and conventions +CONTEXT: @{**/*auth*} @{CLAUDE.md} +EXPECTED: Pattern summary with file references +RULES: $(cat ~/.claude/workflows/cli-templates/prompts/analysis/pattern.txt) | Focus on security +" +``` + +**Architecture Review (Qwen)**: +```bash +# User: /cli:analyze --tool qwen "component architecture" + +cd . && ~/.claude/scripts/qwen-wrapper -p " +PURPOSE: Review component architecture +TASK: Analyze component structure and dependencies +CONTEXT: @{src/**/*} @{CLAUDE.md} +EXPECTED: Architecture diagram and integration points +RULES: $(cat ~/.claude/workflows/cli-templates/prompts/analysis/architecture.txt) | Focus on modularity +" +``` + +**Deep Inspection (Codex)**: +```bash +# User: /cli:analyze --tool codex "performance bottlenecks" + +codex -C . --full-auto exec " +PURPOSE: Identify performance bottlenecks +TASK: Deep analysis of performance issues +CONTEXT: @{src/**/*} @{CLAUDE.md} +EXPECTED: Performance metrics and optimization recommendations +RULES: Focus on computational complexity and memory usage +" --skip-git-repo-check -s danger-full-access +``` + +## File Pattern Logic + +**Keyword Matching**: +- "auth" → `@{**/*auth*}` +- "component" → `@{src/components/**/*}` +- "API" → `@{**/api/**/*}` +- "test" → `@{**/*.test.*}` +- Generic → `@{src/**/*}` or `@{**/*}` + +## Session Integration + +**Detect Active Session**: Check for `.workflow/.active-*` marker file + +**If Session Active**: +- Save results to `.workflow/WFS-[id]/.chat/analysis-[timestamp].md` +- Include session context in analysis + +**If No Session**: +- Return results directly to user + +## Output Format + +Return Gemini's output directly, which includes: +- File references (file:line format) +- Code snippets +- Pattern analysis +- Recommendations + +## Error Handling + +- **Missing Template**: Use generic analysis prompt +- **No Context**: Use `@{**/*}` as fallback +- **Command Failure**: Report error and suggest manual command + diff --git a/.claude/commands/cli/chat.md b/.claude/commands/cli/chat.md new file mode 100644 index 00000000..08a105d3 --- /dev/null +++ b/.claude/commands/cli/chat.md @@ -0,0 +1,161 @@ +--- +name: chat + +description: Simple CLI interaction command for direct codebase analysis +usage: /cli:chat [--tool ] [--enhance] "inquiry" +argument-hint: "[--tool codex|gemini|qwen] [--enhance] inquiry" +examples: + - /cli:chat "analyze the authentication flow" + - /cli:chat --tool qwen --enhance "optimize React component" + - /cli:chat --tool codex "review security vulnerabilities" +allowed-tools: SlashCommand(*), Bash(*) +model: sonnet +--- + +### 🚀 **Command Overview: `/cli:chat`** + +- **Type**: CLI Tool Wrapper for Interactive Analysis +- **Purpose**: Direct interaction with CLI tools for codebase analysis +- **Supported Tools**: codex, gemini (default), qwen + +### 📥 **Parameters & Usage** + +- **`` (Required)**: Your question or analysis request +- **`--tool ` (Optional)**: Select CLI tool (default: gemini) +- **`--enhance` (Optional)**: Enhance inquiry with `/enhance-prompt` before execution +- **`--all-files` (Optional)**: Includes the entire codebase in the analysis context +- **`--save-session` (Optional)**: Saves the interaction to current workflow session directory +- **File References**: Specify files or patterns using `@{path/to/file}` syntax + +### 🔄 **Execution Workflow** + +`Parse Tool` **->** `Parse Input` **->** `[Optional] Enhance` **->** `Assemble Context` **->** `Construct Prompt` **->** `Execute CLI Tool` **->** `(Optional) Save Session` + +### 🛠️ **Tool Selection** + +| Tool | Best For | Wrapper | +|------|----------|---------| +| **gemini** (default) | General analysis, exploration | `~/.claude/scripts/gemini-wrapper` | +| **qwen** | Architecture, design patterns | `~/.claude/scripts/qwen-wrapper` | +| **codex** | Development queries, deep analysis | `codex --full-auto exec` | + +### 🔄 **Original Execution Workflow** + +`Parse Input` **->** `[Optional] Enhance` **->** `Assemble Context` **->** `Construct Prompt` **->** `Execute Gemini CLI` **->** `(Optional) Save Session` + +### 🎯 **Enhancement Integration** + +**When `--enhance` flag present**: +```bash +# Step 1: Enhance the inquiry +SlashCommand(command="/enhance-prompt \"[inquiry]\"") + +# Step 2: Use enhanced output for chat +# Enhanced output provides enriched context and structured intent +``` + +**Example**: +```bash +# User: /gemini:chat --enhance "fix the login" + +# Step 1: Enhance +/enhance-prompt "fix the login" +# Returns: +# INTENT: Debug login authentication failure +# CONTEXT: JWT auth in src/auth/, session state issue +# ACTION: Check token validation → verify middleware → test flow + +# Step 2: Chat with enhanced context +gemini -p "Debug login authentication failure. Focus on JWT token validation +in src/auth/, verify middleware integration, and test authentication flow. +Known issue: session state management" +``` + +### 📚 **Context Assembly** + +Context is gathered from: +1. **Project Guidelines**: Always includes `@{CLAUDE.md,**/*CLAUDE.md}` +2. **User-Explicit Files**: Files specified by the user (e.g., `@{src/auth/*.js}`) +3. **All Files Flag**: The `--all-files` flag includes the entire codebase + +### 📝 **Prompt Format** + +**Core Guidelines**: @~/.claude/workflows/intelligent-tools-strategy.md + +```bash +cd [directory] && ~/.claude/scripts/gemini-wrapper -p " +PURPOSE: [clear analysis/inquiry goal] +TASK: [specific analysis or question] +CONTEXT: @{CLAUDE.md,**/*CLAUDE.md} @{target_files} +EXPECTED: [expected response format] +RULES: [constraints or focus areas] +" +``` + +### ⚙️ **Execution Implementation** + +**Standard Template**: +```bash +cd . && ~/.claude/scripts/gemini-wrapper -p " +PURPOSE: [user inquiry goal] +TASK: [specific question or analysis] +CONTEXT: @{CLAUDE.md,**/*CLAUDE.md} @{inferred_or_specified_files} +EXPECTED: Analysis with file references and code examples +RULES: [focus areas based on inquiry] +" +``` + +**With --all-files flag**: +```bash +cd . && ~/.claude/scripts/gemini-wrapper --all-files -p " +PURPOSE: [user inquiry goal] +TASK: [specific question or analysis] +CONTEXT: @{CLAUDE.md,**/*CLAUDE.md} [entire codebase] +EXPECTED: Comprehensive analysis across all files +RULES: [focus areas based on inquiry] +" +``` + +**Example - Authentication Analysis**: +```bash +cd . && ~/.claude/scripts/gemini-wrapper -p " +PURPOSE: Understand authentication flow implementation +TASK: Analyze authentication flow and identify patterns +CONTEXT: @{**/*auth*,**/*login*} @{CLAUDE.md} +EXPECTED: Flow diagram, security assessment, integration points +RULES: Focus on security patterns and JWT handling +" +``` + +**Example - Performance Optimization**: +```bash +cd src/components && ~/.claude/scripts/gemini-wrapper -p " +PURPOSE: Optimize React component performance +TASK: Identify performance bottlenecks in component rendering +CONTEXT: @{**/*.{jsx,tsx}} @{CLAUDE.md} +EXPECTED: Specific optimization recommendations with file:line references +RULES: Focus on re-render patterns and memoization opportunities +" +``` + +### 💾 **Session Persistence** + +When `--save-session` flag is used: +- Check for existing active session (`.workflow/.active-*` markers) +- Save to existing session's `.chat/` directory or create new session +- File format: `chat-YYYYMMDD-HHMMSS.md` +- Include query, context, and response in saved file + +**Session Template:** +```markdown +# Chat Session: [Timestamp] + +## Query +[Original user inquiry] + +## Context +[Files and patterns included in analysis] + +## Gemini Response +[Complete response from Gemini CLI] +``` \ No newline at end of file diff --git a/.claude/commands/gemini/gemini-init.md b/.claude/commands/cli/cli-init.md similarity index 54% rename from .claude/commands/gemini/gemini-init.md rename to .claude/commands/cli/cli-init.md index e7e51f25..6657c478 100644 --- a/.claude/commands/gemini/gemini-init.md +++ b/.claude/commands/cli/cli-init.md @@ -1,43 +1,61 @@ --- -name: gemini-init -description: Initialize Gemini CLI configuration with .gemini config and .geminiignore based on workspace analysis -usage: /gemini:gemini-init [--output=] [--preview] -argument-hint: [optional: output path, preview flag] +name: cli-init +description: Initialize CLI tool configurations (Gemini and Qwen) based on workspace analysis +usage: /cli:cli-init [--tool ] [--output=] [--preview] +argument-hint: "[--tool gemini|qwen|all] [--output path] [--preview]" examples: - - /gemini:gemini-init - - /gemini:gemini-init --output=.config/ - - /gemini:gemini-init --preview + - /cli:cli-init + - /cli:cli-init --tool qwen + - /cli:cli-init --tool all --preview + - /cli:cli-init --output=.config/ +allowed-tools: Bash(*), Read(*), Write(*), Glob(*) --- -# Gemini Initialization Command +# CLI Initialization Command (/cli:cli-init) ## Overview -Initializes Gemini CLI configuration for the workspace by: +Initializes CLI tool configurations for the workspace by: 1. Analyzing current workspace using `get_modules_by_depth.sh` to identify technology stacks -2. Generating `.geminiignore` file with filtering rules optimized for detected technologies -3. Creating `.gemini` configuration file with contextfilename and other settings +2. Generating ignore files (`.geminiignore` and `.qwenignore`) with filtering rules optimized for detected technologies +3. Creating configuration directories (`.gemini/` and `.qwen/`) with settings.json files + +**Supported Tools**: gemini, qwen, all (default: all) ## Core Functionality ### Configuration Generation 1. **Workspace Analysis**: Runs `get_modules_by_depth.sh` to analyze project structure 2. **Technology Stack Detection**: Identifies tech stacks based on file extensions, directories, and configuration files -3. **Gemini Config Creation**: Generates `.gemini` file with contextfilename and workspace-specific settings -4. **Ignore Rules Generation**: Creates `.geminiignore` file with filtering patterns for detected technologies +3. **Config Creation**: Generates tool-specific configuration directories and settings files +4. **Ignore Rules Generation**: Creates ignore files with filtering patterns for detected technologies ### Generated Files -#### .gemini Configuration Directory -Creates `.gemini/` directory containing configuration files: -- `.gemini/settings.json` - Main configuration with contextfilename setting: +#### Configuration Directories +Creates tool-specific configuration directories: + +**For Gemini** (`.gemini/`): +- `.gemini/settings.json`: ```json { "contextfilename": "CLAUDE.md" } ``` -#### .geminiignore Filter File -Uses gitignore syntax to filter files from Gemini CLI analysis +**For Qwen** (`.qwen/`): +- `.qwen/settings.json`: +```json +{ + "contextfilename": "CLAUDE.md" +} +``` + +#### Ignore Files +Uses gitignore syntax to filter files from CLI tool analysis: +- `.geminiignore` - For Gemini CLI +- `.qwenignore` - For Qwen CLI + +Both files have identical content based on detected technologies. ### Supported Technology Stacks @@ -124,39 +142,65 @@ target/ ## Command Options -### Basic Usage +### Tool Selection + +**Initialize All Tools (default)**: ```bash -/gemini:gemini-init +/cli:cli-init ``` -- Analyzes workspace and generates `.gemini/` directory with `settings.json` and `.geminiignore` in current directory -- Creates backup of existing files if present -- Sets contextfilename to "CLAUDE.md" by default +- Creates `.gemini/`, `.qwen/` directories with settings.json +- Creates `.geminiignore` and `.qwenignore` files +- Sets contextfilename to "CLAUDE.md" for both + +**Initialize Gemini Only**: +```bash +/cli:cli-init --tool gemini +``` +- Creates only `.gemini/` directory and `.geminiignore` file + +**Initialize Qwen Only**: +```bash +/cli:cli-init --tool qwen +``` +- Creates only `.qwen/` directory and `.qwenignore` file ### Preview Mode ```bash -/gemini:gemini-init --preview +/cli:cli-init --preview ``` - Shows what would be generated without creating files - Displays detected technologies, configuration, and ignore rules ### Custom Output Path ```bash -/gemini:gemini-init --output=.config/ +/cli:cli-init --output=.config/ ``` - Generates files in specified directory - Creates directories if they don't exist +### Combined Options +```bash +/cli:cli-init --tool qwen --preview +/cli:cli-init --tool all --output=.config/ +``` + ## EXECUTION INSTRUCTIONS ⚡ START HERE **When this command is triggered, follow these exact steps:** -### Step 1: Workspace Analysis (MANDATORY FIRST) +### Step 1: Parse Tool Selection +```bash +# Extract --tool flag (default: all) +# Options: gemini, qwen, all +``` + +### Step 2: Workspace Analysis (MANDATORY FIRST) ```bash # Analyze workspace structure bash(~/.claude/scripts/get_modules_by_depth.sh json) ``` -### Step 2: Technology Detection +### Step 3: Technology Detection ```bash # Check for common tech stack indicators bash(find . -name "package.json" -not -path "*/node_modules/*" | head -1) @@ -165,22 +209,44 @@ bash(find . -name "pom.xml" -o -name "build.gradle" | head -1) bash(find . -name "Dockerfile" | head -1) ``` -### Step 3: Generate Configuration Files +### Step 4: Generate Configuration Files + +**For Gemini** (if --tool is gemini or all): ```bash -# Create .gemini/ directory and settings.json config file +# Create .gemini/ directory and settings.json +mkdir -p .gemini +echo '{"contextfilename": "CLAUDE.md"}' > .gemini/settings.json + # Create .geminiignore file with detected technology rules # Backup existing files if present ``` -### Step 4: Validation +**For Qwen** (if --tool is qwen or all): +```bash +# Create .qwen/ directory and settings.json +mkdir -p .qwen +echo '{"contextfilename": "CLAUDE.md"}' > .qwen/settings.json + +# Create .qwenignore file with detected technology rules +# Backup existing files if present +``` + +### Step 5: Validation ```bash # Verify generated files are valid -bash(ls -la .gemini* 2>/dev/null || echo "Configuration files created") +bash(ls -la .gemini* .qwen* 2>/dev/null || echo "Configuration files created") ``` ## Implementation Process (Technical Details) -### Phase 1: Workspace Analysis +### Phase 1: Tool Selection +1. Parse `--tool` flag from command arguments +2. Determine which configurations to generate: + - `gemini`: Generate .gemini/ and .geminiignore only + - `qwen`: Generate .qwen/ and .qwenignore only + - `all` (default): Generate both sets of files + +### Phase 2: Workspace Analysis 1. Execute `get_modules_by_depth.sh json` to get structured project data 2. Parse JSON output to identify directories and files 3. Scan for technology indicators: @@ -189,7 +255,7 @@ bash(ls -la .gemini* 2>/dev/null || echo "Configuration files created") - File extensions (.js, .py, .java, etc.) 4. Detect project name from directory name or package.json -### Phase 2: Technology Detection +### Phase 3: Technology Detection ```bash # Technology detection logic detect_nodejs() { @@ -207,33 +273,52 @@ detect_java() { } ``` -### Phase 3: Configuration Generation -1. **Gemini Config (.gemini/ directory)**: - - Create `.gemini/` directory if it doesn't exist +### Phase 4: Configuration Generation +**For each selected tool**, create: + +1. **Config Directory**: + - Create `.gemini/` or `.qwen/` directory if it doesn't exist - Generate `settings.json` with contextfilename setting - Set contextfilename to "CLAUDE.md" by default -### Phase 4: Ignore Rules Generation +2. **Settings.json Format** (identical for both tools): +```json +{ + "contextfilename": "CLAUDE.md" +} +``` + +### Phase 5: Ignore Rules Generation 1. Start with base rules (always included) 2. Add technology-specific rules based on detection 3. Add workspace-specific patterns if found 4. Sort and deduplicate rules +5. Generate identical content for both `.geminiignore` and `.qwenignore` -### Phase 5: File Creation -1. **Generate .gemini/ directory and settings.json**: Create directory structure and JSON configuration file -2. **Generate .geminiignore**: Create organized ignore file with sections +### Phase 6: File Creation +1. **Generate config directories**: Create `.gemini/` and/or `.qwen/` directories with settings.json +2. **Generate ignore files**: Create organized ignore files with sections 3. **Create backups**: Backup existing files if present 4. **Validate**: Check generated files are valid ## Generated File Format +### Configuration Files +```json +// .gemini/settings.json or .qwen/settings.json +{ + "contextfilename": "CLAUDE.md" +} ``` -# .geminiignore -# Generated by Claude Code gemini:gemini-ignore command + +### Ignore Files +``` +# .geminiignore / .qwenignore +# Generated by Claude Code /cli:cli-init command # Creation date: 2024-01-15 10:30:00 # Detected technologies: Node.js, Python, Docker # -# This file uses gitignore syntax to filter files for Gemini CLI analysis +# This file uses gitignore syntax to filter files for CLI tool analysis # Edit this file to customize filtering rules for your project # ============================================================================ @@ -290,13 +375,15 @@ docker-compose.override.yml ### Backup Existing Files - If `.gemini/` directory exists, create backup as `.gemini.backup/` +- If `.qwen/` directory exists, create backup as `.qwen.backup/` - If `.geminiignore` exists, create backup as `.geminiignore.backup` +- If `.qwenignore` exists, create backup as `.qwenignore.backup` - Include timestamp in backup filename ## Integration Points ### Workflow Commands -- **After `/gemini:plan`**: Suggest running gemini-ignore for better analysis +- **After `/cli:plan`**: Suggest running cli-init for better analysis - **Before analysis**: Recommend updating ignore patterns for cleaner results ### CLI Tool Integration @@ -307,29 +394,62 @@ docker-compose.override.yml ### Basic Project Setup ```bash -# New project - initialize Gemini configuration -/gemini:gemini-init +# Initialize all CLI tools (Gemini + Qwen) +/cli:cli-init + +# Initialize only Gemini +/cli:cli-init --tool gemini + +# Initialize only Qwen +/cli:cli-init --tool qwen # Preview what would be generated -/gemini:gemini-init --preview +/cli:cli-init --preview # Generate in subdirectory -/gemini:gemini-init --output=.config/ +/cli:cli-init --output=.config/ ``` ### Technology Migration ```bash # After adding new tech stack (e.g., Docker) -/gemini:gemini-init # Regenerates both config and ignore files with new rules +/cli:cli-init # Regenerates all config and ignore files with new rules # Check what changed -/gemini:gemini-init --preview # Compare with existing configuration +/cli:cli-init --preview # Compare with existing configuration + +# Update only Qwen configuration +/cli:cli-init --tool qwen +``` + +### Tool-Specific Initialization +```bash +# Setup for Gemini-only workflow +/cli:cli-init --tool gemini + +# Setup for Qwen-only workflow +/cli:cli-init --tool qwen + +# Setup both with preview +/cli:cli-init --tool all --preview ``` ## Key Benefits - **Automatic Detection**: No manual configuration needed +- **Multi-Tool Support**: Configure Gemini and Qwen simultaneously - **Technology Aware**: Rules adapted to actual project stack - **Maintainable**: Clear sections for easy customization - **Consistent**: Follows gitignore syntax standards -- **Safe**: Creates backups of existing files \ No newline at end of file +- **Safe**: Creates backups of existing files +- **Flexible**: Initialize specific tools or all at once + +## Tool Selection Guide + +| Scenario | Command | Result | +|----------|---------|--------| +| **New project, using both tools** | `/cli:cli-init` | Creates .gemini/, .qwen/, .geminiignore, .qwenignore | +| **Gemini-only workflow** | `/cli:cli-init --tool gemini` | Creates .gemini/ and .geminiignore only | +| **Qwen-only workflow** | `/cli:cli-init --tool qwen` | Creates .qwen/ and .qwenignore only | +| **Preview before commit** | `/cli:cli-init --preview` | Shows what would be generated | +| **Update configurations** | `/cli:cli-init` | Regenerates all files with backups | \ No newline at end of file diff --git a/.claude/commands/cli/execute.md b/.claude/commands/cli/execute.md new file mode 100644 index 00000000..6e635b74 --- /dev/null +++ b/.claude/commands/cli/execute.md @@ -0,0 +1,235 @@ +--- +name: execute +description: Auto-execution of implementation tasks with YOLO permissions and intelligent context inference +usage: /cli:execute [--tool ] [--enhance] +argument-hint: "[--tool codex|gemini|qwen] [--enhance] description or task-id" +examples: + - /cli:execute "implement user authentication system" + - /cli:execute --tool qwen --enhance "optimize React component" + - /cli:execute --tool codex IMPL-001 + - /cli:execute --enhance "fix API performance issues" +allowed-tools: SlashCommand(*), Bash(*) +model: sonnet +--- + +# CLI Execute Command (/cli:execute) + +## Overview + +**⚡ YOLO-enabled execution**: Auto-approves all confirmations for streamlined implementation workflow. + +**Purpose**: Execute implementation tasks using intelligent context inference and CLI tools with full permissions. + +**Supported Tools**: codex, gemini (default), qwen + +**Core Guidelines**: @~/.claude/workflows/intelligent-tools-strategy.md + +## 🚨 YOLO Permissions + +**All confirmations auto-approved by default:** +- ✅ File pattern inference confirmation +- ✅ Gemini execution confirmation +- ✅ File modification confirmation +- ✅ Implementation summary generation + +## 🎯 Enhancement Integration + +**When `--enhance` flag present** (for Description Mode only): +```bash +# Step 1: Enhance the description +SlashCommand(command="/enhance-prompt \"[description]\"") + +# Step 2: Use enhanced output for execution +# Enhanced output provides: +# - INTENT: Clear technical goal +# - CONTEXT: Session memory + codebase patterns +# - ACTION: Specific implementation steps +# - ATTENTION: Critical constraints +``` + +**Example**: +```bash +# User: /gemini:execute --enhance "fix login" + +# Step 1: Enhance +/enhance-prompt "fix login" +# Returns: +# INTENT: Debug authentication failure in login flow +# CONTEXT: JWT auth in src/auth/, known token expiry issue +# ACTION: Fix token validation → update refresh logic → test flow +# ATTENTION: Preserve existing session management + +# Step 2: Execute with enhanced context +gemini --all-files -p "@{src/auth/**/*} @{CLAUDE.md} +Implementation: Debug authentication failure in login flow +Focus: Token validation, refresh logic, test flow +Constraints: Preserve existing session management" +``` + +**Note**: `--enhance` only applies to Description Mode. Task ID Mode uses task JSON directly. + +## Execution Modes + +### 1. Description Mode (supports --enhance) +**Input**: Natural language description +```bash +/gemini:execute "implement JWT authentication with middleware" +/gemini:execute --enhance "implement JWT authentication with middleware" +``` +**Process**: [Optional: Enhance] → Keyword analysis → Pattern inference → Context collection → Execution + +### 2. Task ID Mode (no --enhance) +**Input**: Workflow task identifier +```bash +/gemini:execute IMPL-001 +``` +**Process**: Task JSON parsing → Scope analysis → Context integration → Execution + +## Context Inference Logic + +**Auto-selects relevant files based on:** +- **Keywords**: "auth" → `@{**/*auth*,**/*user*}` +- **Technology**: "React" → `@{src/**/*.{jsx,tsx}}` +- **Task Type**: "api" → `@{**/api/**/*,**/routes/**/*}` +- **Always includes**: `@{CLAUDE.md,**/*CLAUDE.md}` + +## Command Options + +| Option | Purpose | +|--------|---------| +| `--debug` | Verbose execution logging | +| `--save-session` | Save complete execution session to workflow | + +## Workflow Integration + +### Session Management +⚠️ **Auto-detects active session**: Checks `.workflow/.active-*` marker file + +**Session storage:** +- **Active session exists**: Saves to `.workflow/WFS-[topic]/.chat/execute-[timestamp].md` +- **No active session**: Creates new session directory + +### Task Integration +```bash +# Execute specific workflow task +/gemini:execute IMPL-001 + +# Loads from: .task/IMPL-001.json +# Uses: task context, brainstorming refs, scope definitions +# Updates: workflow status, generates summary +``` + +## Execution Templates + +**Core Guidelines**: @~/.claude/workflows/intelligent-tools-strategy.md + +### Permission Requirements + +**Gemini Write Access** (when file modifications needed): +- Add `--approval-mode yolo` flag for auto-approval +- Required for: file creation, modification, deletion + +### User Description Template +```bash +cd [target-directory] && ~/.claude/scripts/gemini-wrapper --approval-mode yolo -p " +PURPOSE: [clear implementation goal from description] +TASK: [specific implementation task] +CONTEXT: @{inferred_patterns} @{CLAUDE.md,**/*CLAUDE.md} +EXPECTED: Implementation code with file:line locations, test cases, integration guidance +RULES: [template reference if applicable] | [constraints] +" +``` + +**Example**: +```bash +cd . && ~/.claude/scripts/gemini-wrapper --approval-mode yolo -p " +PURPOSE: Implement JWT authentication with middleware +TASK: Create authentication system with token validation +CONTEXT: @{**/*auth*,**/*middleware*} @{CLAUDE.md} +EXPECTED: Auth service, middleware, tests with file modifications +RULES: Follow existing auth patterns | Security best practices +" +``` + +### Task ID Template +```bash +cd [task-directory] && ~/.claude/scripts/gemini-wrapper --approval-mode yolo -p " +PURPOSE: [task_title] +TASK: Execute [task-id] implementation +CONTEXT: @{task_files} @{brainstorming_refs} @{CLAUDE.md,**/*CLAUDE.md} +EXPECTED: Complete implementation following acceptance criteria +RULES: $(cat [task_template]) | Task type: [task_type], Scope: [task_scope] +" +``` + +**Example**: +```bash +cd .workflow/WFS-123 && ~/.claude/scripts/gemini-wrapper --approval-mode yolo -p " +PURPOSE: Implement user profile editing +TASK: Execute IMPL-001 implementation +CONTEXT: @{src/user/**/*} @{.brainstorming/feature-planner/analysis.md} @{CLAUDE.md} +EXPECTED: Profile edit API, UI components, validation, tests +RULES: $(cat ~/.claude/workflows/cli-templates/prompts/development/feature.txt) | Type: feature, Scope: user module +" +``` + +## Auto-Generated Outputs + +### 1. Implementation Summary +**Location**: `.summaries/[TASK-ID]-summary.md` or auto-generated ID + +```markdown +# Task Summary: [Task-ID] [Description] + +## Implementation +- **Files Modified**: [file:line references] +- **Features Added**: [specific functionality] +- **Context Used**: [inferred patterns] + +## Integration +- [Links to workflow documents] +``` + +### 2. Execution Session +**Location**: `.chat/execute-[timestamp].md` + +```markdown +# Execution Session: [Timestamp] + +## Input +[User description or Task ID] + +## Context Inference +[File patterns used with rationale] + +## Implementation Results +[Generated code and modifications] + +## Status Updates +[Workflow integration updates] +``` + +## Error Handling + +- **Task ID not found**: Lists available tasks +- **Pattern inference failure**: Uses generic `src/**/*` pattern +- **Execution failure**: Attempts fallback with simplified context +- **File modification errors**: Reports specific file/permission issues + +## Performance Features + +- **Smart caching**: Frequently used pattern mappings +- **Progressive inference**: Precise → broad pattern fallback +- **Parallel execution**: When multiple contexts needed +- **Directory optimization**: Switches to optimal execution path + +## Integration Workflow + +**Typical sequence:** +1. `workflow:plan` → Creates tasks +2. `/gemini:execute IMPL-001` → Executes with YOLO permissions +3. Auto-updates workflow status and generates summaries +4. `workflow:review` → Final validation + +**vs. `/gemini:analyze`**: Execute performs analysis **and implementation**, analyze is read-only. + diff --git a/.claude/commands/cli/mode/bug-index.md b/.claude/commands/cli/mode/bug-index.md new file mode 100644 index 00000000..45e5c7d7 --- /dev/null +++ b/.claude/commands/cli/mode/bug-index.md @@ -0,0 +1,114 @@ +--- +name: bug-index +description: Bug analysis and fix suggestions using CLI tools +usage: /cli:mode:bug-index [--tool ] [--enhance] [--cd "path"] "bug description" +argument-hint: "[--tool codex|gemini|qwen] [--enhance] [--cd path] bug description" +examples: + - /cli:mode:bug-index "authentication null pointer error" + - /cli:mode:bug-index --tool qwen --enhance "login not working" + - /cli:mode:bug-index --tool codex --cd "src/auth" "token validation fails" +allowed-tools: SlashCommand(*), Bash(*) +model: sonnet +--- + +# CLI Mode: Bug Index (/cli:mode:bug-index) + +## Purpose + +Execute systematic bug analysis and fix suggestions using CLI tools with diagnostic template. + +**Supported Tools**: codex, gemini (default), qwen + +## Execution Flow + +1. **Parse tool selection**: Extract `--tool` flag (default: gemini) +2. **If `--enhance` flag present**: Execute `/enhance-prompt "[bug-description]"` first +3. Parse bug description (original or enhanced) +4. Detect target directory (from `--cd` or auto-infer) +5. Build command for selected tool with bug-fix template +6. Execute analysis +7. Save to session (if active) + +## Core Rules + +1. **Enhance First (if flagged)**: Execute `/enhance-prompt` before analysis +2. **Directory Context**: Use `cd` when `--cd` provided or auto-detected +3. **Template Required**: Always use bug-fix template +4. **Session Output**: Save to `.workflow/WFS-[id]/.chat/bug-index-[timestamp].md` + +## Command Template + +**Core Guidelines**: @~/.claude/workflows/intelligent-tools-strategy.md + +```bash +cd [directory] && ~/.claude/scripts/gemini-wrapper --all-files -p " +PURPOSE: [bug analysis goal] +TASK: Systematic bug analysis and fix recommendations +CONTEXT: @{CLAUDE.md,**/*CLAUDE.md} [entire codebase in directory] +EXPECTED: Root cause analysis, code path tracing, targeted fixes +RULES: $(cat ~/.claude/prompt-templates/bug-fix.md) | Bug: [description] +" +``` + +## Examples + +**Basic Bug Analysis**: +```bash +cd . && ~/.claude/scripts/gemini-wrapper --all-files -p " +PURPOSE: Debug authentication null pointer error +TASK: Identify root cause and provide fix +CONTEXT: @{CLAUDE.md,**/*CLAUDE.md} +EXPECTED: Root cause, code path, minimal fix, impact assessment +RULES: $(cat ~/.claude/prompt-templates/bug-fix.md) | Bug: null pointer in login flow +" +``` + +**Directory-Specific**: +```bash +cd src/auth && ~/.claude/scripts/gemini-wrapper --all-files -p " +PURPOSE: Fix token validation failure +TASK: Analyze token validation bug in auth module +CONTEXT: @{CLAUDE.md,**/*CLAUDE.md} +EXPECTED: Validation logic analysis, fix recommendation +RULES: $(cat ~/.claude/prompt-templates/bug-fix.md) | Bug: token validation fails intermittently +" +``` + +**With Enhancement**: +```bash +# User: /gemini:mode:bug-index --enhance "login broken" + +# Step 1: Enhance +/enhance-prompt "login broken" +# Returns: +# INTENT: Debug login authentication failure +# CONTEXT: Known session state issue +# ACTION: Check session management → verify token → test flow + +# Step 2: Analyze with enhanced context +cd . && ~/.claude/scripts/gemini-wrapper --all-files -p " +PURPOSE: Debug login authentication failure +TASK: Analyze session management, token handling, auth flow +CONTEXT: @{CLAUDE.md,**/*CLAUDE.md} Known: session state issue +EXPECTED: Root cause in session/token, targeted fix +RULES: $(cat ~/.claude/prompt-templates/bug-fix.md) | Focus on session management +" +``` + +## Analysis Focus + +**Template provides**: +- **Root Cause Analysis**: Systematic investigation +- **Code Path Tracing**: Execution flow analysis +- **Targeted Solutions**: Minimal, specific fixes +- **Impact Assessment**: Side effect evaluation + +## Session Output + +**Location**: `.workflow/WFS-[topic]/.chat/bug-index-[timestamp].md` + +**Includes**: +- Bug description +- Template used +- Analysis results +- Recommended actions \ No newline at end of file diff --git a/.claude/commands/cli/mode/code-analysis.md b/.claude/commands/cli/mode/code-analysis.md new file mode 100644 index 00000000..31e50a7a --- /dev/null +++ b/.claude/commands/cli/mode/code-analysis.md @@ -0,0 +1,204 @@ +--- +name: code-analysis +description: Deep code analysis and debugging using CLI tools with specialized template +usage: /cli:mode:code-analysis [--tool ] [--enhance] [--cd "path"] "analysis target" +argument-hint: "[--tool codex|gemini|qwen] [--enhance] [--cd path] analysis target" +examples: + - /cli:mode:code-analysis "analyze authentication flow logic" + - /cli:mode:code-analysis --tool qwen --enhance "explain data transformation pipeline" + - /cli:mode:code-analysis --tool codex --cd "src/core" "trace execution path for user registration" +allowed-tools: SlashCommand(*), Bash(*) +model: sonnet +--- + +# CLI Mode: Code Analysis (/cli:mode:code-analysis) + +## Purpose + +Execute systematic code analysis and debugging using CLI tools with specialized code analysis template. + +**Supported Tools**: codex, gemini (default), qwen + +## Execution Flow + +1. **Parse tool selection**: Extract `--tool` flag (default: gemini) +2. **If `--enhance` flag present**: Execute `/enhance-prompt "[analysis-target]"` first +3. Parse analysis target (original or enhanced) +4. Detect target directory (from `--cd` or auto-infer) +5. Build command for selected tool with code-analysis template +6. Execute deep analysis +7. Save to session (if active) + +## Core Rules + +1. **Tool Selection**: Use `--tool` value or default to gemini +2. **Enhance First (if flagged)**: Execute `/enhance-prompt` before analysis +3. **Directory Context**: Use `cd` when `--cd` provided or auto-detected +4. **Template Required**: Always use code-analysis template +5. **Session Output**: Save to `.workflow/WFS-[id]/.chat/code-analysis-[timestamp].md` + +## Analysis Capabilities + +The code-analysis template provides: +- **Systematic Code Analysis**: Break down complex code into manageable parts +- **Execution Path Tracing**: Track variable states and call stacks +- **Control & Data Flow**: Understand code logic and data transformations +- **Call Flow Visualization**: Diagram function calling sequences +- **Logical Reasoning**: Explain "why" behind code behavior +- **Debugging Insights**: Identify potential bugs or inefficiencies + +## Command Templates + +**Core Guidelines**: @~/.claude/workflows/intelligent-tools-strategy.md + +### Gemini (Default) +```bash +cd [directory] && ~/.claude/scripts/gemini-wrapper --all-files -p " +PURPOSE: [analysis goal from target] +TASK: Deep code analysis with execution path tracing +CONTEXT: @{CLAUDE.md,**/*CLAUDE.md} [entire codebase in directory] +EXPECTED: Systematic analysis, call flow diagram, data transformations, logical explanation +RULES: $(cat ~/.claude/prompt-templates/code-analysis.md) | Focus on [specific aspect] +" +``` + +### Qwen +```bash +cd [directory] && ~/.claude/scripts/qwen-wrapper --all-files -p " +PURPOSE: [analysis goal from target] +TASK: Architecture-level code analysis and pattern recognition +CONTEXT: @{CLAUDE.md,**/*CLAUDE.md} [entire codebase in directory] +EXPECTED: Architectural insights, design patterns, code structure analysis +RULES: $(cat ~/.claude/prompt-templates/code-analysis.md) | Focus on [specific aspect] +" +``` + +### Codex +```bash +codex -C [directory] --full-auto exec " +PURPOSE: [analysis goal from target] +TASK: Deep code inspection with debugging insights +CONTEXT: @{CLAUDE.md,**/*CLAUDE.md} [entire codebase in directory] +EXPECTED: Execution trace, bug identification, optimization opportunities +RULES: $(cat ~/.claude/prompt-templates/code-analysis.md) | Focus on [specific aspect] +" --skip-git-repo-check -s danger-full-access +``` + +## Examples + +**Basic Code Analysis (Gemini)**: +```bash +cd . && ~/.claude/scripts/gemini-wrapper --all-files -p " +PURPOSE: Analyze authentication flow logic +TASK: Trace authentication execution path and identify key functions +CONTEXT: @{CLAUDE.md,**/*CLAUDE.md} +EXPECTED: Step-by-step flow, call diagram, data passing between functions +RULES: $(cat ~/.claude/prompt-templates/code-analysis.md) | Focus on control flow and security +" +``` + +**Architecture Analysis (Qwen)**: +```bash +# User: /cli:mode:code-analysis --tool qwen "explain data transformation pipeline" + +cd . && ~/.claude/scripts/qwen-wrapper --all-files -p " +PURPOSE: Explain data transformation pipeline architecture +TASK: Analyze data flow and transformation patterns +CONTEXT: @{CLAUDE.md,**/*CLAUDE.md} +EXPECTED: Pipeline structure, transformation stages, data format changes +RULES: $(cat ~/.claude/prompt-templates/code-analysis.md) | Focus on data flow and patterns +" +``` + +**Deep Debugging (Codex)**: +```bash +# User: /cli:mode:code-analysis --tool codex --cd "src/core" "trace execution path for user registration" + +codex -C src/core --full-auto exec " +PURPOSE: Trace execution path for user registration +TASK: Deep analysis of registration flow with debugging insights +CONTEXT: @{CLAUDE.md,**/*CLAUDE.md} +EXPECTED: Complete execution trace, variable states, potential issues +RULES: $(cat ~/.claude/prompt-templates/code-analysis.md) | Focus on edge cases and error handling +" --skip-git-repo-check -s danger-full-access +``` + +**With Enhancement**: +```bash +# User: /cli:mode:code-analysis --enhance "why is login slow" + +# Step 1: Enhance +/enhance-prompt "why is login slow" +# Returns: +# INTENT: Identify performance bottlenecks in login flow +# CONTEXT: Authentication module, database queries +# ACTION: Trace execution path → identify slow operations → suggest optimizations + +# Step 2: Analyze with enhanced context +cd . && ~/.claude/scripts/gemini-wrapper --all-files -p " +PURPOSE: Identify performance bottlenecks in login flow +TASK: Trace login execution path and measure operation costs +CONTEXT: @{CLAUDE.md,**/*CLAUDE.md} @{**/*auth*,**/*login*} +EXPECTED: Performance analysis, bottleneck identification, optimization recommendations +RULES: $(cat ~/.claude/prompt-templates/code-analysis.md) | Focus on performance and database queries +" +``` + +## Analysis Output Structure + +Based on code-analysis.md template, output includes: + +### 1. 思考过程 (Thinking Process) +- Analysis strategy and approach +- Key assumptions about code behavior + +### 2. 对问题的理解 (Understanding) +- Restate analysis target +- Confirm understanding of requirements + +### 3. 核心解答 (Core Answer) +- Direct, concise answer to analysis question + +### 4. 详细分析与调用逻辑 (Detailed Analysis) +- **代码段识别**: Relevant code sections +- **执行流程**: Step-by-step execution flow +- **调用图**: Visual call flow diagram with symbols: + - `───►` Function call + - `◄───` Return + - `│` Continuation + - `├─` Intermediate step + - `└─` Last step in block +- **数据传递**: Data passing and state changes +- **逻辑解释**: Why code behaves this way + +### 5. 总结 (Summary) +- Key findings and recommendations + +## Session Output + +**Location**: `.workflow/WFS-[topic]/.chat/code-analysis-[timestamp].md` + +**Includes**: +- Analysis target +- Template used +- Complete structured analysis +- Call flow diagrams +- Debugging insights +- Recommendations + +## Use Cases + +| Use Case | Best Tool | Focus | +|----------|-----------|-------| +| **Understand execution flow** | gemini | Call sequences, data flow | +| **Architectural patterns** | qwen | Design patterns, structure | +| **Performance debugging** | codex | Bottlenecks, optimizations | +| **Bug investigation** | codex | Error paths, edge cases | +| **Code review** | gemini | Logic correctness, clarity | +| **Refactoring planning** | qwen | Structure improvements | + +## Tool Selection Guide + +- **Gemini**: Best for general code understanding and tracing +- **Qwen**: Best for architectural analysis and pattern recognition +- **Codex**: Best for deep debugging and performance analysis \ No newline at end of file diff --git a/.claude/commands/cli/mode/plan.md b/.claude/commands/cli/mode/plan.md new file mode 100644 index 00000000..a675627c --- /dev/null +++ b/.claude/commands/cli/mode/plan.md @@ -0,0 +1,104 @@ +--- +name: plan +description: Project planning and architecture analysis using CLI tools +usage: /cli:mode:plan [--tool ] [--enhance] [--cd "path"] "topic" +argument-hint: "[--tool codex|gemini|qwen] [--enhance] [--cd path] topic" +examples: + - /cli:mode:plan "design user dashboard" + - /cli:mode:plan --tool qwen --enhance "plan microservices migration" + - /cli:mode:plan --tool codex --cd "src/auth" "authentication system" +allowed-tools: SlashCommand(*), Bash(*) +model: sonnet +--- + +# CLI Mode: Plan (/cli:mode:plan) + +## Purpose + +Execute planning and architecture analysis using CLI tools with specialized template. + +**Supported Tools**: codex, gemini (default), qwen + +## Execution Flow + +1. **Parse tool selection**: Extract `--tool` flag (default: gemini) +2. **If `--enhance` flag present**: Execute `/enhance-prompt "[topic]"` first +3. Parse topic (original or enhanced) +4. Detect target directory (from `--cd` or auto-infer) +5. Build command for selected tool with planning template +6. Execute analysis +7. Save to session (if active) + +## Core Rules + +1. **Enhance First (if flagged)**: Execute `/enhance-prompt` before planning +2. **Directory Context**: Use `cd` when `--cd` provided or auto-detected +3. **Template Required**: Always use planning template +4. **Session Output**: Save to `.workflow/WFS-[id]/.chat/plan-[timestamp].md` + +## Command Template + +**Core Guidelines**: @~/.claude/workflows/intelligent-tools-strategy.md + +```bash +cd [directory] && ~/.claude/scripts/gemini-wrapper --all-files -p " +PURPOSE: [planning goal from topic] +TASK: Comprehensive planning and architecture analysis +CONTEXT: @{CLAUDE.md,**/*CLAUDE.md} [entire codebase in directory] +EXPECTED: Strategic insights, implementation roadmap, key decisions +RULES: $(cat ~/.claude/prompt-templates/plan.md) | Focus on [topic area] +" +``` + +## Examples + +**Basic Planning**: +```bash +cd . && ~/.claude/scripts/gemini-wrapper --all-files -p " +PURPOSE: Design user dashboard feature architecture +TASK: Comprehensive architecture planning for dashboard +CONTEXT: @{CLAUDE.md,**/*CLAUDE.md} +EXPECTED: Architecture design, component structure, implementation roadmap +RULES: $(cat ~/.claude/prompt-templates/plan.md) | Focus on scalability and UX +" +``` + +**Directory-Specific**: +```bash +cd src/auth && ~/.claude/scripts/gemini-wrapper --all-files -p " +PURPOSE: Plan authentication system redesign +TASK: Analyze current auth and plan improvements +CONTEXT: @{CLAUDE.md,**/*CLAUDE.md} +EXPECTED: Migration strategy, security improvements, timeline +RULES: $(cat ~/.claude/prompt-templates/plan.md) | Focus on security and backward compatibility +" +``` + +**With Enhancement**: +```bash +# User: /gemini:mode:plan --enhance "fix auth issues" + +# Step 1: Enhance +/enhance-prompt "fix auth issues" +# Returns structured planning context + +# Step 2: Plan with enhanced input +cd . && ~/.claude/scripts/gemini-wrapper --all-files -p " +PURPOSE: [enhanced goal] +TASK: [enhanced task description] +CONTEXT: @{CLAUDE.md,**/*CLAUDE.md} [enhanced context] +EXPECTED: Strategic plan with enhanced requirements +RULES: $(cat ~/.claude/prompt-templates/plan.md) | [enhanced constraints] +" +``` + +## Session Output + +**Location**: `.workflow/WFS-[topic]/.chat/plan-[timestamp].md` + +**Includes**: +- Planning topic +- Template used +- Analysis results +- Implementation roadmap +- Key decisions \ No newline at end of file diff --git a/.claude/commands/codex/analyze.md b/.claude/commands/codex/analyze.md deleted file mode 100644 index 5db3f1aa..00000000 --- a/.claude/commands/codex/analyze.md +++ /dev/null @@ -1,155 +0,0 @@ ---- -name: analyze -description: Quick analysis of codebase patterns, architecture, and code quality using Codex CLI -usage: /codex:analyze -argument-hint: "analysis target or type" -examples: - - /codex:analyze "React hooks patterns" - - /codex:analyze "authentication security" - - /codex:analyze "performance bottlenecks" - - /codex:analyze "API design patterns" -model: haiku ---- - -# Codex Analysis Command (/codex:analyze) - -## Overview -Quick analysis tool for codebase insights using intelligent pattern detection and template-driven analysis with Codex CLI. - -**Core Guidelines**: @~/.claude/workflows/tools-implementation-guide.md - -⚠️ **Critical Difference**: Codex has **NO `--all-files` flag** - you MUST use `@` patterns to reference files. - -## Analysis Types - -| Type | Purpose | Example | -|------|---------|---------| -| **pattern** | Code pattern detection | "React hooks usage patterns" | -| **architecture** | System structure analysis | "component hierarchy structure" | -| **security** | Security vulnerabilities | "authentication vulnerabilities" | -| **performance** | Performance bottlenecks | "rendering performance issues" | -| **quality** | Code quality assessment | "testing coverage analysis" | -| **dependencies** | Third-party analysis | "outdated package dependencies" | - -## Quick Usage - -### Basic Analysis -```bash -/codex:analyze "authentication patterns" -``` -**Executes**: `codex --full-auto exec "@{**/*auth*} @{CLAUDE.md} $(cat ~/.claude/workflows/cli-templates/prompts/analysis/pattern.txt)" -s danger-full-access` - -### Targeted Analysis -```bash -/codex:analyze "React component architecture" -``` -**Executes**: `codex --full-auto exec "@{src/components/**/*} @{CLAUDE.md} $(cat ~/.claude/workflows/cli-templates/prompts/analysis/architecture.txt)" -s danger-full-access` - -### Security Focus -```bash -/codex:analyze "API security vulnerabilities" -``` -**Executes**: `codex --full-auto exec "@{**/api/**/*} @{CLAUDE.md} $(cat ~/.claude/workflows/cli-templates/prompts/analysis/security.txt)" -s danger-full-access` - -## Codex-Specific Patterns - -**Essential File Patterns** (Required for Codex): -```bash -@{**/*} # All files recursively -@{src/**/*} # All source files -@{*.ts,*.js} # Specific file types -@{CLAUDE.md,**/*CLAUDE.md} # Documentation hierarchy -@{package.json,*.config.*} # Configuration files -``` - -## Templates Used - -Templates are automatically selected based on analysis type: -- **Pattern Analysis**: `~/.claude/workflows/cli-templates/prompts/analysis/pattern.txt` -- **Architecture Analysis**: `~/.claude/workflows/cli-templates/prompts/analysis/architecture.txt` -- **Security Analysis**: `~/.claude/workflows/cli-templates/prompts/analysis/security.txt` -- **Performance Analysis**: `~/.claude/workflows/cli-templates/prompts/analysis/performance.txt` - -## Workflow Integration - -⚠️ **Session Check**: Automatically detects active workflow session via `.workflow/.active-*` marker file. - -**Analysis results saved to:** -- Active session: `.workflow/WFS-[topic]/.chat/analysis-[timestamp].md` -- No session: Temporary analysis output - -## Common Patterns - -### Technology Stack Analysis -```bash -/codex:analyze "project technology stack" -# Executes: codex --full-auto exec "@{package.json,*.config.*,CLAUDE.md} [analysis prompt]" -s danger-full-access -``` - -### Code Quality Review -```bash -/codex:analyze "code quality and standards" -# Executes: codex --full-auto exec "@{src/**/*,test/**/*,CLAUDE.md} [analysis prompt]" -s danger-full-access -``` - -### Migration Planning -```bash -/codex:analyze "legacy code modernization" -# Executes: codex --full-auto exec "@{**/*.{js,jsx,ts,tsx},CLAUDE.md} [analysis prompt]" -s danger-full-access -``` - -### Module-Specific Analysis -```bash -/codex:analyze "authentication module patterns" -# Executes: codex --full-auto exec "@{src/auth/**/*,**/*auth*,CLAUDE.md} [analysis prompt]" -s danger-full-access -``` - -## Output Format - -Analysis results include: -- **File References**: Specific file:line locations -- **Code Examples**: Relevant code snippets -- **Patterns Found**: Common patterns and anti-patterns -- **Recommendations**: Actionable improvements -- **Integration Points**: How components connect - -## Execution Templates - -### Basic Analysis Template -```bash -codex --full-auto exec "@{inferred_patterns} @{CLAUDE.md,**/*CLAUDE.md} - -Analysis Type: [analysis_type] - -Provide: -- Pattern identification and analysis -- Code quality assessment -- Architecture insights -- Specific recommendations with file:line references" -s danger-full-access -``` - -### Template-Enhanced Analysis -```bash -codex --full-auto exec "@{inferred_patterns} @{CLAUDE.md,**/*CLAUDE.md} $(cat ~/.claude/workflows/cli-templates/prompts/analysis/[template].txt) - -Focus: [analysis_type] -Context: [user_description]" -s danger-full-access -``` - -## Error Prevention - -- **Always include @ patterns**: Commands without file references will fail -- **Test patterns first**: Validate @ patterns match existing files -- **Use comprehensive patterns**: `@{**/*}` when unsure of file structure -- **Include documentation**: Always add `@{CLAUDE.md,**/*CLAUDE.md}` for context - -## Codex vs Gemini - -| Feature | Codex | Gemini | -|---------|-------|--------| -| File Loading | `@` patterns **required** | `--all-files` available | -| Command Structure | `codex exec "@{patterns}"` | `gemini --all-files -p` | -| Pattern Flexibility | Must be explicit | Auto-includes with flag | - -For detailed syntax, patterns, and advanced usage see: -**@~/.claude/workflows/tools-implementation-guide.md** \ No newline at end of file diff --git a/.claude/commands/codex/chat.md b/.claude/commands/codex/chat.md deleted file mode 100644 index 6057a0da..00000000 --- a/.claude/commands/codex/chat.md +++ /dev/null @@ -1,189 +0,0 @@ ---- -name: chat - -description: Simple Codex CLI interaction command for direct codebase analysis and development -usage: /codex:chat "inquiry" -argument-hint: "your question or development request" -examples: - - /codex:chat "analyze the authentication flow" - - /codex:chat "how can I optimize this React component performance?" - - /codex:chat "implement user profile editing functionality" -allowed-tools: Bash(codex:*) -model: sonnet ---- - -### 🚀 **Command Overview: `/codex:chat`** - -- **Type**: Basic Codex CLI Wrapper -- **Purpose**: Direct interaction with the `codex` CLI for simple codebase analysis and development -- **Core Tool**: `Bash(codex:*)` - Executes the external Codex CLI tool - -⚠️ **Critical Difference**: Codex has **NO `--all-files` flag** - you MUST use `@` patterns to reference files. - -### 📥 **Parameters & Usage** - -- **`` (Required)**: Your question or development request -- **`@{patterns}` (Required)**: File patterns must be explicitly specified -- **`--save-session` (Optional)**: Saves the interaction to current workflow session directory -- **`--full-auto` (Optional)**: Enable autonomous development mode - -### 🔄 **Execution Workflow** - -`Parse Input` **->** `Infer File Patterns` **->** `Construct Prompt` **->** `Execute Codex CLI` **->** `(Optional) Save Session` - -### 📚 **Context Assembly** - -Context is gathered from: -1. **Project Guidelines**: Always includes `@{CLAUDE.md,**/*CLAUDE.md}` -2. **Inferred Patterns**: Auto-detects relevant files based on inquiry keywords -3. **Comprehensive Fallback**: Uses `@{**/*}` when pattern inference unclear - -### 📝 **Prompt Format** - -``` -=== CONTEXT === -@{CLAUDE.md,**/*CLAUDE.md} [Project guidelines] -@{inferred_patterns} [Auto-detected or comprehensive patterns] - -=== USER INPUT === -[The user inquiry text] -``` - -### ⚙️ **Execution Implementation** - -```pseudo -FUNCTION execute_codex_chat(user_inquiry, flags): - // Always include project guidelines - patterns = "@{CLAUDE.md,**/*CLAUDE.md}" - - // Infer relevant file patterns from inquiry keywords - inferred_patterns = infer_file_patterns(user_inquiry) - IF inferred_patterns: - patterns += "," + inferred_patterns - ELSE: - patterns += ",@{**/*}" // Fallback to all files - - // Construct prompt - prompt = "=== CONTEXT ===\n" + patterns + "\n" - prompt += "\n=== USER INPUT ===\n" + user_inquiry - - // Execute codex CLI - IF flags contain "--full-auto": - result = execute_tool("Bash(codex:*)", "--full-auto", prompt) - ELSE: - result = execute_tool("Bash(codex:*)", "exec", prompt) - - // Save session if requested - IF flags contain "--save-session": - save_chat_session(user_inquiry, patterns, result) - - RETURN result -END FUNCTION -``` - -### 🎯 **Pattern Inference Logic** - -**Auto-detects file patterns based on keywords:** - -| Keywords | Inferred Pattern | Purpose | -|----------|-----------------|---------| -| "auth", "login", "user" | `@{**/*auth*,**/*user*}` | Authentication code | -| "React", "component" | `@{src/**/*.{jsx,tsx}}` | React components | -| "API", "endpoint", "route" | `@{**/api/**/*,**/routes/**/*}` | API code | -| "test", "spec" | `@{test/**/*,**/*.test.*,**/*.spec.*}` | Test files | -| "config", "setup" | `@{*.config.*,package.json}` | Configuration | -| "database", "db", "model" | `@{**/models/**/*,**/db/**/*}` | Database code | -| "style", "css" | `@{**/*.{css,scss,sass}}` | Styling files | - -**Fallback**: If no keywords match, uses `@{**/*}` for comprehensive analysis. - -### 💾 **Session Persistence** - -When `--save-session` flag is used: -- Check for existing active session (`.workflow/.active-*` markers) -- Save to existing session's `.chat/` directory or create new session -- File format: `chat-YYYYMMDD-HHMMSS.md` -- Include query, context patterns, and response in saved file - -**Session Template:** -```markdown -# Chat Session: [Timestamp] - -## Query -[Original user inquiry] - -## Context Patterns -[File patterns used in analysis] - -## Codex Response -[Complete response from Codex CLI] - -## Pattern Inference -[How file patterns were determined] -``` - -### 🔧 **Usage Examples** - -#### Basic Development Chat -```bash -/codex:chat "implement password reset functionality" -# Executes: codex --full-auto exec "@{CLAUDE.md,**/*CLAUDE.md,**/*auth*,**/*user*} implement password reset functionality" -s danger-full-access -``` - -#### Architecture Discussion -```bash -/codex:chat "how should I structure the user management module?" -# Executes: codex --full-auto exec "@{CLAUDE.md,**/*CLAUDE.md,**/*user*,src/**/*} how should I structure the user management module?" -s danger-full-access -``` - -#### Performance Optimization -```bash -/codex:chat "optimize React component rendering performance" -# Executes: codex --full-auto exec "@{CLAUDE.md,**/*CLAUDE.md,src/**/*.{jsx,tsx}} optimize React component rendering performance" -s danger-full-access -``` - -#### Full Auto Mode -```bash -/codex:chat "create a complete user dashboard with charts" --full-auto -# Executes: codex --full-auto exec "@{CLAUDE.md,**/*CLAUDE.md,**/*user*,**/*dashboard*} create a complete user dashboard with charts" -s danger-full-access -``` - -### ⚠️ **Error Prevention** - -- **Pattern validation**: Ensures @ patterns match existing files -- **Fallback patterns**: Uses comprehensive `@{**/*}` when inference fails -- **Context verification**: Always includes project guidelines -- **Session handling**: Graceful handling of missing workflow directories - -### 📊 **Codex vs Gemini Chat** - -| Feature | Codex Chat | Gemini Chat | -|---------|------------|-------------| -| File Loading | `@` patterns **required** | `--all-files` available | -| Pattern Inference | Automatic keyword-based | Manual or --all-files | -| Development Focus | Code generation & implementation | Analysis & exploration | -| Automation | `--full-auto` mode available | Interactive only | -| Command Structure | `codex exec "@{patterns}"` | `gemini --all-files -p` | - -### 🚀 **Advanced Features** - -#### Multi-Pattern Inference -```bash -/codex:chat "implement React authentication with API integration" -# Infers: @{CLAUDE.md,**/*CLAUDE.md,src/**/*.{jsx,tsx},**/*auth*,**/api/**/*} -``` - -#### Context-Aware Development -```bash -/codex:chat "add unit tests for the payment processing module" -# Infers: @{CLAUDE.md,**/*CLAUDE.md,**/*payment*,test/**/*,**/*.test.*} -``` - -#### Configuration Analysis -```bash -/codex:chat "review and optimize build configuration" -# Infers: @{CLAUDE.md,**/*CLAUDE.md,*.config.*,package.json,webpack.*,vite.*} -``` - -For detailed syntax, patterns, and advanced usage see: -**@~/.claude/workflows/tools-implementation-guide.md** \ No newline at end of file diff --git a/.claude/commands/codex/execute.md b/.claude/commands/codex/execute.md deleted file mode 100644 index 1a1f7221..00000000 --- a/.claude/commands/codex/execute.md +++ /dev/null @@ -1,223 +0,0 @@ ---- -name: execute -description: Auto-execution of implementation tasks with YOLO permissions and intelligent context inference using Codex CLI -usage: /codex:execute -argument-hint: "implementation description or task-id" -examples: - - /codex:execute "implement user authentication system" - - /codex:execute "optimize React component performance" - - /codex:execute IMPL-001 - - /codex:execute "fix API performance issues" -allowed-tools: Bash(codex:*) -model: sonnet ---- - -# Codex Execute Command (/codex:execute) - -## Overview - -**⚡ YOLO-enabled execution**: Auto-approves all confirmations for streamlined implementation workflow. - -**Purpose**: Execute implementation tasks using intelligent context inference and Codex CLI with full permissions. - -**Core Guidelines**: @~/.claude/workflows/tools-implementation-guide.md - -⚠️ **Critical Difference**: Codex has **NO `--all-files` flag** - you MUST use `@` patterns to reference files. - -## 🚨 YOLO Permissions - -**All confirmations auto-approved by default:** -- ✅ File pattern inference confirmation -- ✅ Codex execution confirmation -- ✅ File modification confirmation -- ✅ Implementation summary generation - -## Execution Modes - -### 1. Description Mode -**Input**: Natural language description -```bash -/codex:execute "implement JWT authentication with middleware" -``` -**Process**: Keyword analysis → Pattern inference → Context collection → Execution - -### 2. Task ID Mode -**Input**: Workflow task identifier -```bash -/codex:execute IMPL-001 -``` -**Process**: Task JSON parsing → Scope analysis → Context integration → Execution - -### 3. Full Auto Mode -**Input**: Complex development tasks -```bash -/codex:execute "create complete todo application with React and TypeScript" -``` -**Process**: Uses `codex --full-auto ... -s danger-full-access` for autonomous implementation - -## Context Inference Logic - -**Auto-selects relevant files based on:** -- **Keywords**: "auth" → `@{**/*auth*,**/*user*}` -- **Technology**: "React" → `@{src/**/*.{jsx,tsx}}` -- **Task Type**: "api" → `@{**/api/**/*,**/routes/**/*}` -- **Always includes**: `@{CLAUDE.md,**/*CLAUDE.md}` - -## Essential Codex Patterns - -**Required File Patterns** (No --all-files available): -```bash -@{**/*} # All files recursively (equivalent to --all-files) -@{src/**/*} # All source files -@{*.ts,*.js} # Specific file types -@{CLAUDE.md,**/*CLAUDE.md} # Documentation hierarchy -@{package.json,*.config.*} # Configuration files -``` - -## Command Options - -| Option | Purpose | -|--------|---------| -| `--debug` | Verbose execution logging | -| `--save-session` | Save complete execution session to workflow | -| `--full-auto` | Enable autonomous development mode | - -## Workflow Integration - -### Session Management -⚠️ **Auto-detects active session**: Checks `.workflow/.active-*` marker file - -**Session storage:** -- **Active session exists**: Saves to `.workflow/WFS-[topic]/.chat/execute-[timestamp].md` -- **No active session**: Creates new session directory - -### Task Integration -```bash -# Execute specific workflow task -/codex:execute IMPL-001 - -# Loads from: .task/impl-001.json -# Uses: task context, brainstorming refs, scope definitions -# Updates: workflow status, generates summary -``` - -## Execution Templates - -### User Description Template -```bash -codex --full-auto exec "@{inferred_patterns} @{CLAUDE.md,**/*CLAUDE.md} - -Implementation Task: [user_description] - -Provide: -- Specific implementation code -- File modification locations (file:line) -- Test cases -- Integration guidance" -s danger-full-access -``` - -### Task ID Template -```bash -codex --full-auto exec "@{task_files} @{brainstorming_refs} @{CLAUDE.md,**/*CLAUDE.md} - -Task: [task_title] (ID: [task-id]) -Type: [task_type] -Scope: [task_scope] - -Execute implementation following task acceptance criteria." -s danger-full-access -``` - -### Full Auto Template -```bash -codex --full-auto exec "@{**/*} @{CLAUDE.md,**/*CLAUDE.md} - -Development Task: [user_description] - -Autonomous implementation with: -- Architecture decisions -- Code generation -- Testing -- Documentation" -s danger-full-access -``` - -## Auto-Generated Outputs - -### 1. Implementation Summary -**Location**: `.summaries/[TASK-ID]-summary.md` or auto-generated ID - -```markdown -# Task Summary: [Task-ID] [Description] - -## Implementation -- **Files Modified**: [file:line references] -- **Features Added**: [specific functionality] -- **Context Used**: [inferred patterns] - -## Integration -- [Links to workflow documents] -``` - -### 2. Execution Session -**Location**: `.chat/execute-[timestamp].md` - -```markdown -# Execution Session: [Timestamp] - -## Input -[User description or Task ID] - -## Context Inference -[File patterns used with rationale] - -## Implementation Results -[Generated code and modifications] - -## Status Updates -[Workflow integration updates] -``` - -## Development Templates Used - -Based on task type, automatically selects: -- **Feature Development**: `~/.claude/workflows/cli-templates/prompts/development/feature.txt` -- **Component Creation**: `~/.claude/workflows/cli-templates/prompts/development/component.txt` -- **Code Refactoring**: `~/.claude/workflows/cli-templates/prompts/development/refactor.txt` -- **Bug Fixing**: `~/.claude/workflows/cli-templates/prompts/development/debugging.txt` -- **Test Generation**: `~/.claude/workflows/cli-templates/prompts/development/testing.txt` - -## Error Handling - -- **Task ID not found**: Lists available tasks -- **Pattern inference failure**: Uses generic `@{src/**/*}` pattern -- **Execution failure**: Attempts fallback with simplified context -- **File modification errors**: Reports specific file/permission issues -- **Missing @ patterns**: Auto-adds `@{**/*}` for comprehensive context - -## Performance Features - -- **Smart caching**: Frequently used pattern mappings -- **Progressive inference**: Precise → broad pattern fallback -- **Parallel execution**: When multiple contexts needed -- **Directory optimization**: Uses `--cd` flag when beneficial - -## Integration Workflow - -**Typical sequence:** -1. `workflow:plan` → Creates tasks -2. `/codex:execute IMPL-001` → Executes with YOLO permissions -3. Auto-updates workflow status and generates summaries -4. `workflow:review` → Final validation - -**vs. `/codex:analyze`**: Execute performs analysis **and implementation**, analyze is read-only. - -## Codex vs Gemini Execution - -| Feature | Codex | Gemini | -|---------|-------|--------| -| File Loading | `@` patterns **required** | `--all-files` available | -| Automation Level | Full autonomous with `--full-auto` | Manual implementation | -| Command Structure | `codex exec "@{patterns}"` | `gemini --all-files -p` | -| Development Focus | Code generation & implementation | Analysis & planning | - -For detailed patterns, syntax, and templates see: -**@~/.claude/workflows/tools-implementation-guide.md** \ No newline at end of file diff --git a/.claude/commands/codex/mode/auto.md b/.claude/commands/codex/mode/auto.md deleted file mode 100644 index 58d5d7b0..00000000 --- a/.claude/commands/codex/mode/auto.md +++ /dev/null @@ -1,285 +0,0 @@ ---- -name: auto -description: Full autonomous development mode with intelligent template selection and execution -usage: /codex:mode:auto "description of development task" -argument-hint: "description of what you want to develop or implement" -examples: - - /codex:mode:auto "create user authentication system with JWT" - - /codex:mode:auto "build real-time chat application with React" - - /codex:mode:auto "implement payment processing with Stripe integration" - - /codex:mode:auto "develop REST API with user management features" -allowed-tools: Bash(ls:*), Bash(codex:*) -model: sonnet ---- - -# Full Auto Development Mode (/codex:mode:auto) - -## Overview -Leverages Codex's `--full-auto` mode for autonomous development with intelligent template selection and comprehensive context gathering. - -**Process**: Analyze Input → Select Templates → Gather Context → Execute Autonomous Development - -⚠️ **Critical Feature**: Uses `codex --full-auto ... -s danger-full-access` for maximum autonomous capability with mandatory `@` pattern requirements. - -## Usage - -### Autonomous Development Examples -```bash -# Complete application development -/codex:mode:auto "create todo application with React and TypeScript" - -# Feature implementation -/codex:mode:auto "implement user authentication with JWT and refresh tokens" - -# System integration -/codex:mode:auto "add payment processing with Stripe to existing e-commerce system" - -# Architecture implementation -/codex:mode:auto "build microservices API with user management and notification system" -``` - -## Template Selection Logic - -### Dynamic Template Discovery -**Templates auto-discovered from**: `~/.claude/workflows/cli-templates/prompts/` - -Templates are dynamically read from development-focused directories: -- `development/` - Feature implementation, component creation, refactoring -- `automation/` - Project scaffolding, migration, deployment -- `analysis/` - Architecture analysis, pattern detection -- `integration/` - API design, database operations - -### Template Metadata Parsing - -Each template contains YAML frontmatter with: -```yaml ---- -name: template-name -description: Template purpose description -category: development|automation|analysis|integration -keywords: [keyword1, keyword2, keyword3] -development_type: feature|component|refactor|debug|testing ---- -``` - -**Auto-selection based on:** -- **Development keywords**: Matches user input against development-specific keywords -- **Template type**: Direct matching for development types -- **Architecture patterns**: Semantic matching for system design -- **Technology stack**: Framework and library detection - -## Command Execution - -### Step 1: Template Discovery -```bash -# Dynamically discover development templates -cd "~/.claude/workflows/cli-templates/prompts" && echo "Discovering development templates..." && for dir in development automation analysis integration; do if [ -d "$dir" ]; then echo "=== $dir templates ==="; for template_file in "$dir"/*.txt; do if [ -f "$template_file" ]; then echo "Template: $(basename "$template_file")"; head -10 "$template_file" 2>/dev/null | grep -E "^(name|description|keywords):" || echo "No metadata"; echo; fi; done; fi; done -``` - -### Step 2: Dynamic Template Analysis & Selection -```pseudo -FUNCTION select_development_template(user_input): - template_dirs = ["development", "automation", "analysis", "integration"] - template_metadata = {} - - # Parse all development templates for metadata - FOR each dir in template_dirs: - templates = list_files("~/.claude/workflows/cli-templates/prompts/" + dir + "/*.txt") - FOR each template_file in templates: - content = read_file(template_file) - yaml_front = extract_yaml_frontmatter(content) - template_metadata[template_file] = { - "name": yaml_front.name, - "description": yaml_front.description, - "keywords": yaml_front.keywords || [], - "category": yaml_front.category || dir, - "development_type": yaml_front.development_type || "general" - } - - input_lower = user_input.toLowerCase() - best_match = null - highest_score = 0 - - # Score each template against user input - FOR each template, metadata in template_metadata: - score = 0 - - # Development keyword matching (highest weight) - development_keywords = ["implement", "create", "build", "develop", "add", "generate"] - FOR each dev_keyword in development_keywords: - IF input_lower.contains(dev_keyword): - score += 5 - - # Template-specific keyword matching - FOR each keyword in metadata.keywords: - IF input_lower.contains(keyword.toLowerCase()): - score += 3 - - # Development type matching - IF input_lower.contains(metadata.development_type.toLowerCase()): - score += 4 - - # Technology stack detection - tech_keywords = ["react", "vue", "angular", "node", "express", "api", "database", "auth"] - FOR each tech in tech_keywords: - IF input_lower.contains(tech): - score += 2 - - IF score > highest_score: - highest_score = score - best_match = template - - # Default to feature.txt for development tasks - RETURN best_match || "development/feature.txt" -END FUNCTION -``` - -### Step 3: Execute with Full Auto Mode -```bash -# Autonomous development execution with comprehensive context -codex --full-auto "@{**/*} @{CLAUDE.md,**/*CLAUDE.md} $(cat ~/.claude/workflows/cli-templates/prompts/[selected_template]) - -Development Task: [user_input] - -Autonomous Implementation Requirements: -- Complete feature development -- Code generation with best practices -- Automatic testing integration -- Documentation updates -- Error handling and validation" -s danger-full-access -``` - -## Essential Codex Auto Patterns - -**Required File Patterns** (Comprehensive context for autonomous development): -```bash -@{**/*} # All files for full context understanding -@{src/**/*} # Source code for pattern detection -@{package.json,*.config.*} # Configuration and dependencies -@{CLAUDE.md,**/*CLAUDE.md} # Project guidelines and standards -@{test/**/*,**/*.test.*} # Existing tests for pattern matching -@{docs/**/*,README.*} # Documentation for context -``` - -## Development Template Categories - -### Feature Development Templates -- **feature.txt**: Complete feature implementation with integration -- **component.txt**: Reusable component creation with props and state -- **refactor.txt**: Code improvement and optimization - -### Automation Templates -- **scaffold.txt**: Project structure and boilerplate generation -- **migration.txt**: System upgrades and data migrations -- **deployment.txt**: CI/CD and deployment automation - -### Analysis Templates (for context) -- **architecture.txt**: System structure understanding -- **pattern.txt**: Code pattern detection for consistency -- **security.txt**: Security analysis for safe development - -### Integration Templates -- **api-design.txt**: RESTful API development -- **database.txt**: Database schema and operations - -## Options - -| Option | Purpose | -|--------|---------| -| `--list-templates` | Show available development templates and exit | -| `--template ` | Force specific template (overrides auto-selection) | -| `--debug` | Show template selection reasoning and context patterns | -| `--save-session` | Save complete development session to workflow | -| `--no-auto` | Use `codex exec` instead of `--full-auto` mode | - -### Manual Template Override -```bash -# Force specific development template -/codex:mode:auto "user authentication" --template component.txt -/codex:mode:auto "fix login issues" --template debugging.txt -``` - -### Development Template Listing -```bash -# List all available development templates -/codex:mode:auto --list-templates -# Output: -# Development templates in ~/.claude/workflows/cli-templates/prompts/: -# - development/feature.txt (Complete feature implementation) [Keywords: implement, feature, integration] -# - development/component.txt (Reusable component creation) [Keywords: component, react, vue] -# - automation/scaffold.txt (Project structure generation) [Keywords: scaffold, setup, boilerplate] -# - [any-new-template].txt (Auto-discovered from any category) -``` - -## Auto-Selection Examples - -### Development Task Detection -```bash -# Feature development → development/feature.txt -"implement user dashboard with analytics charts" - -# Component creation → development/component.txt -"create reusable button component with multiple variants" - -# System architecture → automation/scaffold.txt -"build complete e-commerce platform with React and Node.js" - -# API development → integration/api-design.txt -"develop REST API for user management with authentication" - -# Performance optimization → development/refactor.txt -"optimize React application performance and bundle size" -``` - -## Autonomous Development Workflow - -### Full Context Gathering -1. **Project Analysis**: `@{**/*}` provides complete codebase context -2. **Pattern Detection**: Understands existing code patterns and conventions -3. **Dependency Analysis**: Reviews package.json and configuration files -4. **Test Pattern Recognition**: Follows existing test structures - -### Intelligent Implementation -1. **Architecture Decisions**: Makes informed choices based on existing patterns -2. **Code Generation**: Creates code matching project style and conventions -3. **Integration**: Ensures new code integrates seamlessly with existing system -4. **Quality Assurance**: Includes error handling, validation, and testing - -### Autonomous Features -- **Smart File Creation**: Creates necessary files and directories -- **Dependency Management**: Adds required packages automatically -- **Test Generation**: Creates comprehensive test suites -- **Documentation Updates**: Updates relevant documentation files -- **Configuration Updates**: Modifies config files as needed - -## Session Integration - -When `--save-session` used, saves to: -`.workflow/WFS-[topic]/.chat/auto-[template]-[timestamp].md` - -**Session includes:** -- Original development request -- Template selection reasoning -- Complete context patterns used -- Autonomous development results -- Files created/modified -- Integration guidance - -## Performance Features - -- **Parallel Context Loading**: Loads multiple file patterns simultaneously -- **Smart Caching**: Caches template selections for similar requests -- **Progressive Development**: Builds features incrementally with validation -- **Rollback Capability**: Can revert changes if issues detected - -## Codex vs Gemini Auto Mode - -| Feature | Codex Auto | Gemini Auto | -|---------|------------|-------------| -| Primary Purpose | Autonomous development | Analysis and planning | -| File Loading | `@{**/*}` required | `--all-files` available | -| Output | Complete implementations | Analysis and recommendations | -| Template Focus | Development-oriented | Analysis-oriented | -| Execution Mode | `--full-auto` autonomous | Interactive guidance | - -This command maximizes Codex's autonomous development capabilities while ensuring comprehensive context and intelligent template selection for optimal results. \ No newline at end of file diff --git a/.claude/commands/codex/mode/bug-index.md b/.claude/commands/codex/mode/bug-index.md deleted file mode 100644 index 1e331051..00000000 --- a/.claude/commands/codex/mode/bug-index.md +++ /dev/null @@ -1,269 +0,0 @@ ---- -name: bug-index -description: Bug analysis, debugging, and automated fix implementation using Codex -usage: /codex:mode:bug-index "bug description" -argument-hint: "description of the bug or error you're experiencing" -examples: - - /codex:mode:bug-index "authentication null pointer error in login flow" - - /codex:mode:bug-index "React component not re-rendering after state change" - - /codex:mode:bug-index "database connection timeout in production" - - /codex:mode:bug-index "API endpoints returning 500 errors randomly" -allowed-tools: Bash(codex:*) -model: sonnet ---- - -# Bug Analysis & Fix Command (/codex:mode:bug-index) - -## Overview -Systematic bug analysis, debugging, and automated fix implementation using expert diagnostic templates with Codex CLI. - -**Core Guidelines**: @~/.claude/workflows/tools-implementation-guide.md - -⚠️ **Critical Difference**: Codex has **NO `--all-files` flag** - you MUST use `@` patterns to reference files. - -**Enhancement over Gemini**: Codex can **analyze AND implement fixes**, not just provide recommendations. - -## Usage - -### Basic Bug Analysis & Fix -```bash -/codex:mode:bug-index "authentication error during login" -``` -**Executes**: `codex --full-auto exec "@{**/*auth*,**/*login*} @{CLAUDE.md} $(cat ~/.claude/workflows/cli-templates/prompts/development/debugging.txt)" -s danger-full-access` - -### Comprehensive Bug Investigation -```bash -/codex:mode:bug-index "React state not updating in dashboard" -``` -**Executes**: `codex --full-auto exec "@{src/**/*.{jsx,tsx},**/*dashboard*} @{CLAUDE.md} $(cat ~/.claude/workflows/cli-templates/prompts/development/debugging.txt)" -s danger-full-access` - -### Production Error Analysis -```bash -/codex:mode:bug-index "API timeout issues in production environment" -``` -**Executes**: `codex --full-auto exec "@{**/api/**/*,*.config.*} @{CLAUDE.md} $(cat ~/.claude/workflows/cli-templates/prompts/development/debugging.txt)" -s danger-full-access` - -## Codex-Specific Debugging Patterns - -**Essential File Patterns** (Required for effective debugging): -```bash -@{**/*error*,**/*bug*} # Error-related files -@{src/**/*} # Source code for bug analysis -@{**/logs/**/*} # Log files for error traces -@{test/**/*,**/*.test.*} # Tests to understand expected behavior -@{CLAUDE.md,**/*CLAUDE.md} # Project guidelines -@{*.config.*,package.json} # Configuration for environment issues -``` - -## Command Execution - -**Debugging Template Used**: `~/.claude/workflows/cli-templates/prompts/development/debugging.txt` - -**Executes**: -```bash -codex exec "@{inferred_bug_patterns} @{CLAUDE.md,**/*CLAUDE.md} $(cat ~/.claude/workflows/cli-templates/prompts/development/debugging.txt) - -Context: Comprehensive codebase analysis for bug investigation -Bug Description: [user_description] -Fix Implementation: Provide working code solutions" -s danger-full-access -``` - -## Bug Pattern Inference - -**Auto-detects relevant files based on bug description:** - -| Bug Keywords | Inferred Patterns | Focus Area | -|-------------|------------------|------------| -| "auth", "login", "token" | `@{**/*auth*,**/*user*,**/*login*}` | Authentication code | -| "React", "component", "render" | `@{src/**/*.{jsx,tsx}}` | React components | -| "API", "endpoint", "server" | `@{**/api/**/*,**/routes/**/*}` | Backend code | -| "database", "db", "query" | `@{**/models/**/*,**/db/**/*}` | Database code | -| "timeout", "connection" | `@{*.config.*,**/*config*}` | Configuration issues | -| "test", "spec" | `@{test/**/*,**/*.test.*}` | Test-related bugs | -| "build", "compile" | `@{*.config.*,package.json,webpack.*}` | Build issues | -| "style", "css", "layout" | `@{**/*.{css,scss,sass}}` | Styling bugs | - -## Analysis & Fix Focus - -### Comprehensive Bug Analysis Provides: -- **Root Cause Analysis**: Systematic investigation with file:line references -- **Code Path Tracing**: Following execution flow through the codebase -- **Error Pattern Detection**: Identifying similar issues across the codebase -- **Context Understanding**: Leveraging existing code patterns -- **Impact Assessment**: Understanding potential side effects of fixes - -### Codex Enhancement - Automated Fixes: -- **Working Code Solutions**: Actual implementation fixes -- **Multiple Fix Options**: Different approaches with trade-offs -- **Test Case Generation**: Tests to prevent regression -- **Configuration Updates**: Environment and config fixes -- **Documentation Updates**: Updated comments and documentation - -## Debugging Templates & Approaches - -### Error Investigation -```bash -# Uses: debugging.txt template for systematic analysis -/codex:mode:bug-index "null pointer exception in user service" -# Provides: Stack trace analysis, variable state inspection, fix implementation -``` - -### Performance Bug Analysis -```bash -# Uses: debugging.txt + performance.txt combination -/codex:mode:bug-index "slow database queries causing timeout" -# Provides: Query optimization, indexing suggestions, connection pool fixes -``` - -### Integration Bug Fixes -```bash -# Uses: debugging.txt + integration/api-design.txt -/codex:mode:bug-index "third-party API integration failing randomly" -# Provides: Error handling, retry logic, fallback implementations -``` - -## Options - -| Option | Purpose | -|--------|---------| -| `--comprehensive` | Use `@{**/*}` for complete codebase analysis | -| `--save-session` | Save bug analysis and fixes to workflow session | -| `--implement-fix` | Auto-implement the recommended fix (default in Codex) | -| `--generate-tests` | Create tests to prevent regression | -| `--debug-mode` | Verbose debugging output with pattern explanations | - -### Comprehensive Debugging -```bash -/codex:mode:bug-index "intermittent authentication failures" --comprehensive -# Uses: @{**/*} for complete system analysis -``` - -### Bug Fix with Testing -```bash -/codex:mode:bug-index "user registration validation errors" --generate-tests -# Provides: Bug fix + comprehensive test suite -``` - -## Session Output - -When `--save-session` used, saves to: -`.workflow/WFS-[topic]/.chat/bug-index-[timestamp].md` - -**Session includes:** -- Bug description and symptoms -- File patterns used for analysis -- Root cause analysis with evidence -- Implemented fix with code changes -- Test cases to prevent regression -- Monitoring and prevention recommendations - -## Debugging Output Structure - -### Bug Analysis Template Output: -```markdown -# Bug Analysis: [Description] - -## Problem Investigation -- Symptoms and error messages -- Affected components and files -- Reproduction steps - -## Root Cause Analysis -- Code path analysis with file:line references -- Variable states and data flow -- Configuration and environment factors - -## Implemented Fixes -- Primary solution with code changes -- Alternative approaches considered -- Trade-offs and design decisions - -## Testing & Validation -- Test cases to verify fix -- Regression prevention tests -- Performance impact assessment - -## Monitoring & Prevention -- Error handling improvements -- Logging enhancements -- Code quality improvements -``` - -## Context-Aware Bug Fixing - -### Existing Pattern Integration -```bash -/codex:mode:bug-index "authentication middleware not working" -# Analyzes existing auth patterns in codebase -# Implements fix consistent with current architecture -# Updates related middleware to match patterns -``` - -### Technology Stack Compatibility -```bash -/codex:mode:bug-index "React hooks causing infinite renders" -# Reviews current React version and patterns -# Implements fix using appropriate hooks API -# Updates other components with similar issues -``` - -## Advanced Debugging Features - -### Multi-File Bug Tracking -```bash -/codex:mode:bug-index "user data inconsistency between frontend and backend" -# Analyzes both frontend and backend code -# Identifies data flow discrepancies -# Implements synchronized fixes across stack -``` - -### Production Issue Investigation -```bash -/codex:mode:bug-index "memory leak in production server" -# Reviews server code and configuration -# Analyzes log patterns and resource usage -# Implements monitoring and leak prevention -``` - -### Error Handling Enhancement -```bash -/codex:mode:bug-index "unhandled promise rejections causing crashes" -# Identifies all async operations without error handling -# Implements comprehensive error handling strategy -# Adds logging and monitoring for similar issues -``` - -## Bug Prevention Features - -- **Pattern Analysis**: Identifies similar bugs across codebase -- **Code Quality Improvements**: Suggests structural improvements -- **Error Handling Enhancement**: Adds robust error handling -- **Test Coverage**: Creates tests to prevent similar issues -- **Documentation Updates**: Improves code documentation - -## Codex vs Gemini Bug Analysis - -| Feature | Codex Bug-Index | Gemini Bug-Index | -|---------|-----------------|------------------| -| File Context | `@` patterns **required** | `--all-files` available | -| Output | Analysis + working fixes | Analysis + recommendations | -| Implementation | Automatic code changes | Manual implementation needed | -| Testing | Auto-generates test cases | Suggests testing approach | -| Integration | Updates related code | Focuses on specific bug | - -## Workflow Integration - -### Bug Fixing Workflow -```bash -# 1. Analyze and fix the bug -/codex:mode:bug-index "user login failing with token errors" - -# 2. Review the implemented changes -/workflow:review - -# 3. Execute any additional tasks identified -/codex:execute "implement additional error handling for edge cases" -``` - -For detailed syntax, patterns, and advanced usage see: -**@~/.claude/workflows/tools-implementation-guide.md** \ No newline at end of file diff --git a/.claude/commands/codex/mode/plan.md b/.claude/commands/codex/mode/plan.md deleted file mode 100644 index 26fc571a..00000000 --- a/.claude/commands/codex/mode/plan.md +++ /dev/null @@ -1,260 +0,0 @@ ---- -name: plan -description: Development planning and implementation strategy using specialized templates with Codex -usage: /codex:mode:plan "planning topic" -argument-hint: "development planning topic or implementation challenge" -examples: - - /codex:mode:plan "design user dashboard feature architecture" - - /codex:mode:plan "plan microservices migration with implementation" - - /codex:mode:plan "implement real-time notification system with React" -allowed-tools: Bash(codex:*) -model: sonnet ---- - -# Development Planning Command (/codex:mode:plan) - -## Overview -Comprehensive development planning and implementation strategy using expert planning templates with Codex CLI. -- **Directory Analysis Rule**: When user intends to analyze specific directory (cd XXX), use: `codex --cd XXX --full-auto exec "prompt" -s danger-full-access` or `cd "XXX" && codex --full-auto exec "@{**/*} prompt" -s danger-full-access` -- **Default Mode**: `--full-auto exec` autonomous development mode (RECOMMENDED for all tasks). - - -⚠️ **Critical Difference**: Codex has **NO `--all-files` flag** - you MUST use `@` patterns to reference files. - -## Usage - -### Basic Development Planning -```bash -/codex:mode:plan "design authentication system with implementation" -``` -**Executes**: `codex --full-auto exec "@{**/*} @{CLAUDE.md} $(cat ~/.claude/workflows/cli-templates/prompts/planning/task-breakdown.txt) design authentication system with implementation" -s danger-full-access` - -### Architecture Planning with Context -```bash -/codex:mode:plan "microservices migration strategy" -``` -**Executes**: `codex --full-auto exec "@{src/**/*,*.config.*,CLAUDE.md} $(cat ~/.claude/workflows/cli-templates/prompts/planning/migration.txt) microservices migration strategy" -s danger-full-access` - -### Feature Implementation Planning -```bash -/codex:mode:plan "real-time notifications with WebSocket integration" -``` - -**Executes**: `codex --full-auto exec "@{**/*} @{CLAUDE.md} $(cat ~/.claude/workflows/cli-templates/prompts/development/feature.txt) Additional Planning Context:$(cat ~/.claude/workflows/cli-templates/prompts/planning/task-breakdown.txt) real-time notifications with WebSocket integration" -s danger-full-access` - -## Codex-Specific Planning Patterns - -**Essential File Patterns** (Required for comprehensive planning): -```bash -@{**/*} # All files for complete context -@{src/**/*} # Source code architecture -@{*.config.*,package.json} # Configuration and dependencies -@{CLAUDE.md,**/*CLAUDE.md} # Project guidelines -@{docs/**/*,README.*} # Documentation for context -@{test/**/*} # Testing patterns -``` - -## Command Execution - -**Planning Templates Used**: -- Primary: `~/.claude/workflows/cli-templates/prompts/planning/task-breakdown.txt` -- Migration: `~/.claude/workflows/cli-templates/prompts/planning/migration.txt` -- Combined with development templates for implementation guidance - -**Executes**: -```bash -codex exec "@{**/*} @{CLAUDE.md,**/*CLAUDE.md} $(cat ~/.claude/workflows/cli-templates/prompts/planning/task-breakdown.txt) - -Context: Complete codebase analysis for informed planning -Planning Topic: [user_description] -Implementation Focus: Development strategy with code generation guidance" -``` - -## Planning Focus Areas - -### Development Planning Provides: -- **Requirements Analysis**: Functional and technical requirements -- **Architecture Design**: System structure with implementation details -- **Implementation Strategy**: Step-by-step development approach with code examples -- **Technology Selection**: Framework and library recommendations -- **Task Decomposition**: Detailed task breakdown with dependencies -- **Code Structure Planning**: File organization and module design -- **Testing Strategy**: Test planning and coverage approach -- **Integration Planning**: API design and data flow - -### Codex Enhancement: -- **Implementation Guidance**: Actual code patterns and examples -- **Automated Scaffolding**: Template generation for planned components -- **Dependency Analysis**: Required packages and configurations -- **Pattern Detection**: Leverages existing codebase patterns - -## Planning Templates - -### Task Breakdown Planning -```bash -# Uses: planning/task-breakdown.txt -/codex:mode:plan "implement user authentication system" -# Provides: Detailed task list, dependencies, implementation order -``` - -### Migration Planning -```bash -# Uses: planning/migration.txt -/codex:mode:plan "migrate from REST to GraphQL API" -# Provides: Migration strategy, compatibility planning, rollout approach -``` - -### Feature Planning with Implementation -```bash -# Uses: development/feature.txt + planning/task-breakdown.txt -/codex:mode:plan "build real-time chat application" -# Provides: Architecture + implementation roadmap + code examples -``` - -## Options - -| Option | Purpose | -|--------|---------| -| `--comprehensive` | Use `@{**/*}` for complete codebase context | -| `--save-session` | Save planning analysis to workflow session | -| `--with-implementation` | Include code generation in planning | -| `--template ` | Force specific planning template | - -### Comprehensive Planning -```bash -/codex:mode:plan "design payment system architecture" --comprehensive -# Uses: @{**/*} pattern for maximum context -``` - -### Planning with Implementation -```bash -/codex:mode:plan "implement user dashboard" --with-implementation -# Combines planning templates with development templates for actionable output -``` - -## Session Output - -When `--save-session` used, saves to: -`.workflow/WFS-[topic]/.chat/plan-[timestamp].md` - -**Session includes:** -- Planning topic and requirements -- Template combination used -- Complete architecture analysis -- Implementation roadmap with tasks -- Code structure recommendations -- Technology stack decisions -- Integration strategies -- Next steps and action items - -## Planning Template Structure - -### Task Breakdown Template Output: -```markdown -# Development Plan: [Topic] - -## Requirements Analysis -- Functional requirements -- Technical requirements -- Constraints and dependencies - -## Architecture Design -- System components -- Data flow -- Integration points - -## Implementation Strategy -- Development phases -- Task breakdown -- Dependencies and blockers -- Estimated effort - -## Code Structure -- File organization -- Module design -- Component hierarchy - -## Technology Decisions -- Framework selection -- Library recommendations -- Configuration requirements - -## Testing Approach -- Testing strategy -- Coverage requirements -- Test automation - -## Action Items -- [ ] Detailed task list with priorities -- [ ] Implementation order -- [ ] Review checkpoints -``` - -## Context-Aware Planning - -### Existing Codebase Integration -```bash -/codex:mode:plan "add user roles and permissions system" -# Analyzes existing authentication patterns -# Plans integration with current user management -# Suggests compatible implementation approach -``` - -### Technology Stack Analysis -```bash -/codex:mode:plan "implement real-time features" -# Reviews current tech stack (React, Node.js, etc.) -# Recommends compatible WebSocket/SSE solutions -# Plans integration with existing architecture -``` - -## Planning Workflow Integration - -### Pre-Development Planning -1. **Architecture Analysis**: Understand current system structure -2. **Requirement Planning**: Define scope and objectives -3. **Implementation Strategy**: Create detailed development plan -4. **Task Creation**: Generate actionable tasks for execution - -### Planning to Execution Flow -```bash -# 1. Plan the implementation -/codex:mode:plan "implement user dashboard with analytics" - -# 2. Execute the plan -/codex:execute "implement user dashboard based on planning analysis" - -# 3. Review and iterate -/workflow:review -``` - -## Codex vs Gemini Planning - -| Feature | Codex Planning | Gemini Planning | -|---------|----------------|-----------------| -| File Context | `@` patterns **required** | `--all-files` available | -| Output Focus | Implementation-ready plans | Analysis and strategy | -| Code Examples | Includes actual code patterns | Conceptual guidance | -| Integration | Direct execution pathway | Planning only | -| Templates | Development + planning combined | Planning focused | - -## Advanced Planning Features - -### Multi-Phase Planning -```bash -/codex:mode:plan "modernize legacy application architecture" -# Provides: Phase-by-phase migration strategy -# Includes: Compatibility planning, risk assessment -# Generates: Implementation timeline with milestones -``` - -### Cross-System Integration Planning -```bash -/codex:mode:plan "integrate third-party payment system with existing e-commerce" -# Analyzes: Current system architecture -# Plans: Integration approach and data flow -# Recommends: Security and error handling strategies -``` - -For detailed syntax, patterns, and advanced usage see: -**@~/.claude/workflows/intelligent-tools-strategy.md** \ No newline at end of file diff --git a/.claude/commands/gemini/analyze.md b/.claude/commands/gemini/analyze.md deleted file mode 100644 index 06624888..00000000 --- a/.claude/commands/gemini/analyze.md +++ /dev/null @@ -1,96 +0,0 @@ ---- -name: analyze -description: Quick analysis of codebase patterns, architecture, and code quality using Gemini CLI -usage: /gemini:analyze -argument-hint: "analysis target or type" -examples: - - /gemini:analyze "React hooks patterns" - - /gemini:analyze "authentication security" - - /gemini:analyze "performance bottlenecks" - - /gemini:analyze "API design patterns" -model: haiku ---- - -# Gemini Analysis Command (/gemini:analyze) - -## Overview -Quick analysis tool for codebase insights using intelligent pattern detection and template-driven analysis. - -**Core Guidelines**: @~/.claude/workflows/intelligent-tools-strategy.md - -## Analysis Types - -| Type | Purpose | Example | -|------|---------|---------| -| **pattern** | Code pattern detection | "React hooks usage patterns" | -| **architecture** | System structure analysis | "component hierarchy structure" | -| **security** | Security vulnerabilities | "authentication vulnerabilities" | -| **performance** | Performance bottlenecks | "rendering performance issues" | -| **quality** | Code quality assessment | "testing coverage analysis" | -| **dependencies** | Third-party analysis | "outdated package dependencies" | - -## Quick Usage - -### Basic Analysis -```bash -/gemini:analyze "authentication patterns" -``` -**Executes**: `gemini -p -a "@{**/*auth*} @{CLAUDE.md} $(template:analysis/pattern.txt)"` - -### Targeted Analysis -```bash -/gemini:analyze "React component architecture" -``` -**Executes**: `gemini -p -a "@{src/components/**/*} @{CLAUDE.md} $(template:analysis/architecture.txt)"` - -### Security Focus -```bash -/gemini:analyze "API security vulnerabilities" -``` -**Executes**: `gemini -p -a "@{**/api/**/*} @{CLAUDE.md} $(template:analysis/security.txt)"` - -## Templates Used - -Templates are automatically selected based on analysis type: -- **Pattern Analysis**: `~/.claude/workflows/cli-templates/prompts/analysis/pattern.txt` -- **Architecture Analysis**: `~/.claude/workflows/cli-templates/prompts/analysis/architecture.txt` -- **Security Analysis**: `~/.claude/workflows/cli-templates/prompts/analysis/security.txt` -- **Performance Analysis**: `~/.claude/workflows/cli-templates/prompts/analysis/performance.txt` - -## Workflow Integration - -⚠️ **Session Check**: Automatically detects active workflow session via `.workflow/.active-*` marker file. - -**Analysis results saved to:** -- Active session: `.workflow/WFS-[topic]/.chat/analysis-[timestamp].md` -- No session: Temporary analysis output - -## Common Patterns - -### Technology Stack Analysis -```bash -/gemini:analyze "project technology stack" -# Auto-detects: package.json, config files, dependencies -``` - -### Code Quality Review -```bash -/gemini:analyze "code quality and standards" -# Auto-targets: source files, test files, CLAUDE.md -``` - -### Migration Planning -```bash -/gemini:analyze "legacy code modernization" -# Focuses: older patterns, deprecated APIs, upgrade paths -``` - -## Output Format - -Analysis results include: -- **File References**: Specific file:line locations -- **Code Examples**: Relevant code snippets -- **Patterns Found**: Common patterns and anti-patterns -- **Recommendations**: Actionable improvements -- **Integration Points**: How components connect - diff --git a/.claude/commands/gemini/chat.md b/.claude/commands/gemini/chat.md deleted file mode 100644 index fbb78db8..00000000 --- a/.claude/commands/gemini/chat.md +++ /dev/null @@ -1,93 +0,0 @@ ---- -name: chat - -description: Simple Gemini CLI interaction command for direct codebase analysis -usage: /gemini:chat "inquiry" -argument-hint: "your question or analysis request" -examples: - - /gemini:chat "analyze the authentication flow" - - /gemini:chat "how can I optimize this React component performance?" - - /gemini:chat "review security vulnerabilities in src/auth/" -allowed-tools: Bash(gemini:*) -model: sonnet ---- - -### 🚀 **Command Overview: `/gemini:chat`** - -- **Type**: Basic Gemini CLI Wrapper -- **Purpose**: Direct interaction with the `gemini` CLI for simple codebase analysis -- **Core Tool**: `Bash(gemini:*)` - Executes the external Gemini CLI tool - -### 📥 **Parameters & Usage** - -- **`` (Required)**: Your question or analysis request -- **`--all-files` (Optional)**: Includes the entire codebase in the analysis context -- **`--save-session` (Optional)**: Saves the interaction to current workflow session directory -- **File References**: Specify files or patterns using `@{path/to/file}` syntax - -### 🔄 **Execution Workflow** - -`Parse Input` **->** `Assemble Context` **->** `Construct Prompt` **->** `Execute Gemini CLI` **->** `(Optional) Save Session` - -### 📚 **Context Assembly** - -Context is gathered from: -1. **Project Guidelines**: Always includes `@{CLAUDE.md,**/*CLAUDE.md}` -2. **User-Explicit Files**: Files specified by the user (e.g., `@{src/auth/*.js}`) -3. **All Files Flag**: The `--all-files` flag includes the entire codebase - -### 📝 **Prompt Format** - -``` -=== CONTEXT === -@{CLAUDE.md,**/*CLAUDE.md} [Project guidelines] -@{target_files} [User-specified files or all files if --all-files is used] - -=== USER INPUT === -[The user inquiry text] -``` - -### ⚙️ **Execution Implementation** - -```pseudo -FUNCTION execute_gemini_chat(user_inquiry, flags): - // Construct basic prompt - prompt = "=== CONTEXT ===\n" - prompt += "@{CLAUDE.md,**/*CLAUDE.md}\n" - - // Add user-specified files or all files - IF flags contain "--all-files": - result = execute_tool("Bash(gemini:*)", "--all-files", "-p", prompt + user_inquiry) - ELSE: - prompt += "\n=== USER INPUT ===\n" + user_inquiry - result = execute_tool("Bash(gemini:*)", "-p", prompt) - - // Save session if requested - IF flags contain "--save-session": - save_chat_session(user_inquiry, result) - - RETURN result -END FUNCTION -``` - -### 💾 **Session Persistence** - -When `--save-session` flag is used: -- Check for existing active session (`.workflow/.active-*` markers) -- Save to existing session's `.chat/` directory or create new session -- File format: `chat-YYYYMMDD-HHMMSS.md` -- Include query, context, and response in saved file - -**Session Template:** -```markdown -# Chat Session: [Timestamp] - -## Query -[Original user inquiry] - -## Context -[Files and patterns included in analysis] - -## Gemini Response -[Complete response from Gemini CLI] -``` \ No newline at end of file diff --git a/.claude/commands/gemini/execute.md b/.claude/commands/gemini/execute.md deleted file mode 100644 index 0369c099..00000000 --- a/.claude/commands/gemini/execute.md +++ /dev/null @@ -1,168 +0,0 @@ ---- -name: execute -description: Auto-execution of implementation tasks with YOLO permissions and intelligent context inference -usage: /gemini:execute -argument-hint: "implementation description or task-id" -examples: - - /gemini:execute "implement user authentication system" - - /gemini:execute "optimize React component performance" - - /gemini:execute IMPL-001 - - /gemini:execute "fix API performance issues" -allowed-tools: Bash(gemini:*) -model: sonnet ---- - -# Gemini Execute Command (/gemini:execute) - -## Overview - -**⚡ YOLO-enabled execution**: Auto-approves all confirmations for streamlined implementation workflow. - -**Purpose**: Execute implementation tasks using intelligent context inference and Gemini CLI with full permissions. - -**Core Guidelines**: @~/.claude/workflows/intelligent-tools-strategy.md - -## 🚨 YOLO Permissions - -**All confirmations auto-approved by default:** -- ✅ File pattern inference confirmation -- ✅ Gemini execution confirmation -- ✅ File modification confirmation -- ✅ Implementation summary generation - -## Execution Modes - -### 1. Description Mode -**Input**: Natural language description -```bash -/gemini:execute "implement JWT authentication with middleware" -``` -**Process**: Keyword analysis → Pattern inference → Context collection → Execution - -### 2. Task ID Mode -**Input**: Workflow task identifier -```bash -/gemini:execute IMPL-001 -``` -**Process**: Task JSON parsing → Scope analysis → Context integration → Execution - -## Context Inference Logic - -**Auto-selects relevant files based on:** -- **Keywords**: "auth" → `@{**/*auth*,**/*user*}` -- **Technology**: "React" → `@{src/**/*.{jsx,tsx}}` -- **Task Type**: "api" → `@{**/api/**/*,**/routes/**/*}` -- **Always includes**: `@{CLAUDE.md,**/*CLAUDE.md}` - -## Command Options - -| Option | Purpose | -|--------|---------| -| `--debug` | Verbose execution logging | -| `--save-session` | Save complete execution session to workflow | - -## Workflow Integration - -### Session Management -⚠️ **Auto-detects active session**: Checks `.workflow/.active-*` marker file - -**Session storage:** -- **Active session exists**: Saves to `.workflow/WFS-[topic]/.chat/execute-[timestamp].md` -- **No active session**: Creates new session directory - -### Task Integration -```bash -# Execute specific workflow task -/gemini:execute IMPL-001 - -# Loads from: .task/IMPL-001.json -# Uses: task context, brainstorming refs, scope definitions -# Updates: workflow status, generates summary -``` - -## Execution Templates - -### User Description Template -```bash -gemini --all-files -p "@{inferred_patterns} @{CLAUDE.md,**/*CLAUDE.md} - -Implementation Task: [user_description] - -Provide: -- Specific implementation code -- File modification locations (file:line) -- Test cases -- Integration guidance" -``` - -### Task ID Template -```bash -gemini --all-files -p "@{task_files} @{brainstorming_refs} @{CLAUDE.md,**/*CLAUDE.md} - -Task: [task_title] (ID: [task-id]) -Type: [task_type] -Scope: [task_scope] - -Execute implementation following task acceptance criteria." -``` - -## Auto-Generated Outputs - -### 1. Implementation Summary -**Location**: `.summaries/[TASK-ID]-summary.md` or auto-generated ID - -```markdown -# Task Summary: [Task-ID] [Description] - -## Implementation -- **Files Modified**: [file:line references] -- **Features Added**: [specific functionality] -- **Context Used**: [inferred patterns] - -## Integration -- [Links to workflow documents] -``` - -### 2. Execution Session -**Location**: `.chat/execute-[timestamp].md` - -```markdown -# Execution Session: [Timestamp] - -## Input -[User description or Task ID] - -## Context Inference -[File patterns used with rationale] - -## Implementation Results -[Generated code and modifications] - -## Status Updates -[Workflow integration updates] -``` - -## Error Handling - -- **Task ID not found**: Lists available tasks -- **Pattern inference failure**: Uses generic `src/**/*` pattern -- **Execution failure**: Attempts fallback with simplified context -- **File modification errors**: Reports specific file/permission issues - -## Performance Features - -- **Smart caching**: Frequently used pattern mappings -- **Progressive inference**: Precise → broad pattern fallback -- **Parallel execution**: When multiple contexts needed -- **Directory optimization**: Switches to optimal execution path - -## Integration Workflow - -**Typical sequence:** -1. `workflow:plan` → Creates tasks -2. `/gemini:execute IMPL-001` → Executes with YOLO permissions -3. Auto-updates workflow status and generates summaries -4. `workflow:review` → Final validation - -**vs. `/gemini:analyze`**: Execute performs analysis **and implementation**, analyze is read-only. - diff --git a/.claude/commands/gemini/mode/bug-index.md b/.claude/commands/gemini/mode/bug-index.md deleted file mode 100644 index 5e99cbe7..00000000 --- a/.claude/commands/gemini/mode/bug-index.md +++ /dev/null @@ -1,76 +0,0 @@ ---- -name: bug-index -description: Bug analysis and fix suggestions using specialized template -usage: /gemini:mode:bug-index "bug description" -argument-hint: "description of the bug or error you're experiencing" -examples: - - /gemini:mode:bug-index "authentication null pointer error in login flow" - - /gemini:mode:bug-index "React component not re-rendering after state change" - - /gemini:mode:bug-index "database connection timeout in production" -allowed-tools: Bash(gemini:*) -model: sonnet ---- - -# Bug Analysis Command (/gemini:mode:bug-index) - -## Overview -Systematic bug analysis and fix suggestions using expert diagnostic template. - -**Directory Analysis Rule**: Intelligent detection of directory context intent - automatically navigate to target directory when analysis scope is directory-specific. - -**--cd Parameter Rule**: When `--cd` parameter is provided, always execute `cd "[path]" && gemini --all-files -p "prompt"` to ensure analysis occurs in the specified directory context. - -## Usage - -### Basic Bug Analysis -```bash -/gemini:mode:bug-index "authentication null pointer error" -``` - -### Bug Analysis with Directory Context -```bash -/gemini:mode:bug-index "authentication error" --cd "src/auth" -``` - - -### Save to Workflow Session -```bash -/gemini:mode:bug-index "API timeout issues" --save-session -``` - -## Command Execution - -**Template Used**: `~/.claude/prompt-templates/bug-fix.md` - -**Executes**: -```bash -# Basic usage -gemini --all-files -p "$(cat ~/.claude/prompt-templates/bug-fix.md) - -Bug Description: [user_description]" - -# With --cd parameter -cd "[specified_directory]" && gemini --all-files -p "$(cat ~/.claude/prompt-templates/bug-fix.md) - -Bug Description: [user_description]" -``` - -## Analysis Focus - -The bug-fix template provides: -- **Root Cause Analysis**: Systematic investigation -- **Code Path Tracing**: Following execution flow -- **Targeted Solutions**: Specific, minimal fixes -- **Impact Assessment**: Understanding side effects - - -## Session Output - -saves to: -`.workflow/WFS-[topic]/.chat/bug-index-[timestamp].md` - -**Includes:** -- Bug description -- Template used -- Analysis results -- Recommended actions \ No newline at end of file diff --git a/.claude/commands/gemini/mode/plan.md b/.claude/commands/gemini/mode/plan.md deleted file mode 100644 index 474f371a..00000000 --- a/.claude/commands/gemini/mode/plan.md +++ /dev/null @@ -1,62 +0,0 @@ ---- -name: plan -description: Project planning and architecture analysis using Gemini CLI with specialized template -usage: /gemini:mode:plan "planning topic" -argument-hint: "planning topic or architectural challenge to analyze" -examples: - - /gemini:mode:plan "design user dashboard feature architecture" - - /gemini:mode:plan "plan microservices migration strategy" - - /gemini:mode:plan "implement real-time notification system" -allowed-tools: Bash(gemini:*) -model: sonnet ---- - -# Planning Analysis Command (/gemini:mode:plan) - -## Overview -**This command uses Gemini CLI for comprehensive project planning and architecture analysis.** It leverages Gemini CLI's powerful codebase analysis capabilities combined with expert planning templates to provide strategic insights and implementation roadmaps. - -### Key Features -- **Gemini CLI Integration**: Utilizes Gemini CLI's deep codebase analysis for informed planning decisions - -**--cd Parameter Rule**: When `--cd` parameter is provided, always execute `cd "[path]" && gemini --all-files -p "prompt"` to ensure analysis occurs in the specified directory context. - -## Usage - -### Basic Usage -```bash -/gemini:mode:plan "design authentication system" -``` - -### Directory-Specific Analysis -```bash -/gemini:mode:plan "design authentication system" --cd "src/auth" -``` - -## Command Execution - -**Smart Directory Detection**: Auto-detects relevant directories based on topic keywords - -**Executes**: -```bash -# Project-wide analysis -gemini --all-files -p "$(cat ~/.claude/prompt-templates/plan.md) -Planning Topic: [user_description]" - -# Directory-specific analysis -cd "[directory]" && gemini --all-files -p "$(cat ~/.claude/prompt-templates/plan.md) -Planning Topic: [user_description]" -``` - - -## Session Output - -saves to: -`.workflow/WFS-[topic]/.chat/plan-[timestamp].md` - -**Includes:** -- Planning topic -- Template used -- Analysis results -- Implementation roadmap -- Key decisions \ No newline at end of file diff --git a/.claude/commands/qwen/analyze.md b/.claude/commands/qwen/analyze.md deleted file mode 100644 index 594d2dfd..00000000 --- a/.claude/commands/qwen/analyze.md +++ /dev/null @@ -1,96 +0,0 @@ ---- -name: analyze -description: Quick analysis of codebase patterns, architecture, and code quality using qwen CLI -usage: /qwen:analyze -argument-hint: "analysis target or type" -examples: - - /qwen:analyze "React hooks patterns" - - /qwen:analyze "authentication security" - - /qwen:analyze "performance bottlenecks" - - /qwen:analyze "API design patterns" -model: haiku ---- - -# qwen Analysis Command (/qwen:analyze) - -## Overview -Quick analysis tool for codebase insights using intelligent pattern detection and template-driven analysis. - -**Core Guidelines**: @~/.claude/workflows/intelligent-tools-strategy.md - -## Analysis Types - -| Type | Purpose | Example | -|------|---------|---------| -| **pattern** | Code pattern detection | "React hooks usage patterns" | -| **architecture** | System structure analysis | "component hierarchy structure" | -| **security** | Security vulnerabilities | "authentication vulnerabilities" | -| **performance** | Performance bottlenecks | "rendering performance issues" | -| **quality** | Code quality assessment | "testing coverage analysis" | -| **dependencies** | Third-party analysis | "outdated package dependencies" | - -## Quick Usage - -### Basic Analysis -```bash -/qwen:analyze "authentication patterns" -``` -**Executes**: `qwen -p -a "@{**/*auth*} @{CLAUDE.md} $(template:analysis/pattern.txt)"` - -### Targeted Analysis -```bash -/qwen:analyze "React component architecture" -``` -**Executes**: `qwen -p -a "@{src/components/**/*} @{CLAUDE.md} $(template:analysis/architecture.txt)"` - -### Security Focus -```bash -/qwen:analyze "API security vulnerabilities" -``` -**Executes**: `qwen -p -a "@{**/api/**/*} @{CLAUDE.md} $(template:analysis/security.txt)"` - -## Templates Used - -Templates are automatically selected based on analysis type: -- **Pattern Analysis**: `~/.claude/workflows/cli-templates/prompts/analysis/pattern.txt` -- **Architecture Analysis**: `~/.claude/workflows/cli-templates/prompts/analysis/architecture.txt` -- **Security Analysis**: `~/.claude/workflows/cli-templates/prompts/analysis/security.txt` -- **Performance Analysis**: `~/.claude/workflows/cli-templates/prompts/analysis/performance.txt` - -## Workflow Integration - -⚠️ **Session Check**: Automatically detects active workflow session via `.workflow/.active-*` marker file. - -**Analysis results saved to:** -- Active session: `.workflow/WFS-[topic]/.chat/analysis-[timestamp].md` -- No session: Temporary analysis output - -## Common Patterns - -### Technology Stack Analysis -```bash -/qwen:analyze "project technology stack" -# Auto-detects: package.json, config files, dependencies -``` - -### Code Quality Review -```bash -/qwen:analyze "code quality and standards" -# Auto-targets: source files, test files, CLAUDE.md -``` - -### Migration Planning -```bash -/qwen:analyze "legacy code modernization" -# Focuses: older patterns, deprecated APIs, upgrade paths -``` - -## Output Format - -Analysis results include: -- **File References**: Specific file:line locations -- **Code Examples**: Relevant code snippets -- **Patterns Found**: Common patterns and anti-patterns -- **Recommendations**: Actionable improvements -- **Integration Points**: How components connect - diff --git a/.claude/commands/qwen/chat.md b/.claude/commands/qwen/chat.md deleted file mode 100644 index e6096ce2..00000000 --- a/.claude/commands/qwen/chat.md +++ /dev/null @@ -1,93 +0,0 @@ ---- -name: chat - -description: Simple qwen CLI interaction command for direct codebase analysis -usage: /qwen:chat "inquiry" -argument-hint: "your question or analysis request" -examples: - - /qwen:chat "analyze the authentication flow" - - /qwen:chat "how can I optimize this React component performance?" - - /qwen:chat "review security vulnerabilities in src/auth/" -allowed-tools: Bash(qwen:*) -model: sonnet ---- - -### 🚀 **Command Overview: `/qwen:chat`** - -- **Type**: Basic qwen CLI Wrapper -- **Purpose**: Direct interaction with the `qwen` CLI for simple codebase analysis -- **Core Tool**: `Bash(qwen:*)` - Executes the external qwen CLI tool - -### 📥 **Parameters & Usage** - -- **`` (Required)**: Your question or analysis request -- **`--all-files` (Optional)**: Includes the entire codebase in the analysis context -- **`--save-session` (Optional)**: Saves the interaction to current workflow session directory -- **File References**: Specify files or patterns using `@{path/to/file}` syntax - -### 🔄 **Execution Workflow** - -`Parse Input` **->** `Assemble Context` **->** `Construct Prompt` **->** `Execute qwen CLI` **->** `(Optional) Save Session` - -### 📚 **Context Assembly** - -Context is gathered from: -1. **Project Guidelines**: Always includes `@{CLAUDE.md,**/*CLAUDE.md}` -2. **User-Explicit Files**: Files specified by the user (e.g., `@{src/auth/*.js}`) -3. **All Files Flag**: The `--all-files` flag includes the entire codebase - -### 📝 **Prompt Format** - -``` -=== CONTEXT === -@{CLAUDE.md,**/*CLAUDE.md} [Project guidelines] -@{target_files} [User-specified files or all files if --all-files is used] - -=== USER INPUT === -[The user inquiry text] -``` - -### ⚙️ **Execution Implementation** - -```pseudo -FUNCTION execute_qwen_chat(user_inquiry, flags): - // Construct basic prompt - prompt = "=== CONTEXT ===\n" - prompt += "@{CLAUDE.md,**/*CLAUDE.md}\n" - - // Add user-specified files or all files - IF flags contain "--all-files": - result = execute_tool("Bash(qwen:*)", "--all-files", "-p", prompt + user_inquiry) - ELSE: - prompt += "\n=== USER INPUT ===\n" + user_inquiry - result = execute_tool("Bash(qwen:*)", "-p", prompt) - - // Save session if requested - IF flags contain "--save-session": - save_chat_session(user_inquiry, result) - - RETURN result -END FUNCTION -``` - -### 💾 **Session Persistence** - -When `--save-session` flag is used: -- Check for existing active session (`.workflow/.active-*` markers) -- Save to existing session's `.chat/` directory or create new session -- File format: `chat-YYYYMMDD-HHMMSS.md` -- Include query, context, and response in saved file - -**Session Template:** -```markdown -# Chat Session: [Timestamp] - -## Query -[Original user inquiry] - -## Context -[Files and patterns included in analysis] - -## qwen Response -[Complete response from qwen CLI] -``` \ No newline at end of file diff --git a/.claude/commands/qwen/execute.md b/.claude/commands/qwen/execute.md deleted file mode 100644 index d9eb43ed..00000000 --- a/.claude/commands/qwen/execute.md +++ /dev/null @@ -1,168 +0,0 @@ ---- -name: execute -description: Auto-execution of implementation tasks with YOLO permissions and intelligent context inference -usage: /qwen:execute -argument-hint: "implementation description or task-id" -examples: - - /qwen:execute "implement user authentication system" - - /qwen:execute "optimize React component performance" - - /qwen:execute IMPL-001 - - /qwen:execute "fix API performance issues" -allowed-tools: Bash(qwen:*) -model: sonnet ---- - -# qwen Execute Command (/qwen:execute) - -## Overview - -**⚡ YOLO-enabled execution**: Auto-approves all confirmations for streamlined implementation workflow. - -**Purpose**: Execute implementation tasks using intelligent context inference and qwen CLI with full permissions. - -**Core Guidelines**: @~/.claude/workflows/intelligent-tools-strategy.md - -## 🚨 YOLO Permissions - -**All confirmations auto-approved by default:** -- ✅ File pattern inference confirmation -- ✅ qwen execution confirmation -- ✅ File modification confirmation -- ✅ Implementation summary generation - -## Execution Modes - -### 1. Description Mode -**Input**: Natural language description -```bash -/qwen:execute "implement JWT authentication with middleware" -``` -**Process**: Keyword analysis → Pattern inference → Context collection → Execution - -### 2. Task ID Mode -**Input**: Workflow task identifier -```bash -/qwen:execute IMPL-001 -``` -**Process**: Task JSON parsing → Scope analysis → Context integration → Execution - -## Context Inference Logic - -**Auto-selects relevant files based on:** -- **Keywords**: "auth" → `@{**/*auth*,**/*user*}` -- **Technology**: "React" → `@{src/**/*.{jsx,tsx}}` -- **Task Type**: "api" → `@{**/api/**/*,**/routes/**/*}` -- **Always includes**: `@{CLAUDE.md,**/*CLAUDE.md}` - -## Command Options - -| Option | Purpose | -|--------|---------| -| `--debug` | Verbose execution logging | -| `--save-session` | Save complete execution session to workflow | - -## Workflow Integration - -### Session Management -⚠️ **Auto-detects active session**: Checks `.workflow/.active-*` marker file - -**Session storage:** -- **Active session exists**: Saves to `.workflow/WFS-[topic]/.chat/execute-[timestamp].md` -- **No active session**: Creates new session directory - -### Task Integration -```bash -# Execute specific workflow task -/qwen:execute IMPL-001 - -# Loads from: .task/IMPL-001.json -# Uses: task context, brainstorming refs, scope definitions -# Updates: workflow status, generates summary -``` - -## Execution Templates - -### User Description Template -```bash -qwen --all-files -p "@{inferred_patterns} @{CLAUDE.md,**/*CLAUDE.md} - -Implementation Task: [user_description] - -Provide: -- Specific implementation code -- File modification locations (file:line) -- Test cases -- Integration guidance" -``` - -### Task ID Template -```bash -qwen --all-files -p "@{task_files} @{brainstorming_refs} @{CLAUDE.md,**/*CLAUDE.md} - -Task: [task_title] (ID: [task-id]) -Type: [task_type] -Scope: [task_scope] - -Execute implementation following task acceptance criteria." -``` - -## Auto-Generated Outputs - -### 1. Implementation Summary -**Location**: `.summaries/[TASK-ID]-summary.md` or auto-generated ID - -```markdown -# Task Summary: [Task-ID] [Description] - -## Implementation -- **Files Modified**: [file:line references] -- **Features Added**: [specific functionality] -- **Context Used**: [inferred patterns] - -## Integration -- [Links to workflow documents] -``` - -### 2. Execution Session -**Location**: `.chat/execute-[timestamp].md` - -```markdown -# Execution Session: [Timestamp] - -## Input -[User description or Task ID] - -## Context Inference -[File patterns used with rationale] - -## Implementation Results -[Generated code and modifications] - -## Status Updates -[Workflow integration updates] -``` - -## Error Handling - -- **Task ID not found**: Lists available tasks -- **Pattern inference failure**: Uses generic `src/**/*` pattern -- **Execution failure**: Attempts fallback with simplified context -- **File modification errors**: Reports specific file/permission issues - -## Performance Features - -- **Smart caching**: Frequently used pattern mappings -- **Progressive inference**: Precise → broad pattern fallback -- **Parallel execution**: When multiple contexts needed -- **Directory optimization**: Switches to optimal execution path - -## Integration Workflow - -**Typical sequence:** -1. `workflow:plan` → Creates tasks -2. `/qwen:execute IMPL-001` → Executes with YOLO permissions -3. Auto-updates workflow status and generates summaries -4. `workflow:review` → Final validation - -**vs. `/qwen:analyze`**: Execute performs analysis **and implementation**, analyze is read-only. - diff --git a/.claude/commands/qwen/mode/bug-index.md b/.claude/commands/qwen/mode/bug-index.md deleted file mode 100644 index 3a5b2456..00000000 --- a/.claude/commands/qwen/mode/bug-index.md +++ /dev/null @@ -1,76 +0,0 @@ ---- -name: bug-index -description: Bug analysis and fix suggestions using specialized template -usage: /qwen:mode:bug-index "bug description" -argument-hint: "description of the bug or error you're experiencing" -examples: - - /qwen:mode:bug-index "authentication null pointer error in login flow" - - /qwen:mode:bug-index "React component not re-rendering after state change" - - /qwen:mode:bug-index "database connection timeout in production" -allowed-tools: Bash(qwen:*) -model: sonnet ---- - -# Bug Analysis Command (/qwen:mode:bug-index) - -## Overview -Systematic bug analysis and fix suggestions using expert diagnostic template. - -**Directory Analysis Rule**: Intelligent detection of directory context intent - automatically navigate to target directory when analysis scope is directory-specific. - -**--cd Parameter Rule**: When `--cd` parameter is provided, always execute `cd "[path]" && qwen --all-files -p "prompt"` to ensure analysis occurs in the specified directory context. - -## Usage - -### Basic Bug Analysis -```bash -/qwen:mode:bug-index "authentication null pointer error" -``` - -### Bug Analysis with Directory Context -```bash -/qwen:mode:bug-index "authentication error" --cd "src/auth" -``` - - -### Save to Workflow Session -```bash -/qwen:mode:bug-index "API timeout issues" --save-session -``` - -## Command Execution - -**Template Used**: `~/.claude/prompt-templates/bug-fix.md` - -**Executes**: -```bash -# Basic usage -qwen --all-files -p "$(cat ~/.claude/prompt-templates/bug-fix.md) - -Bug Description: [user_description]" - -# With --cd parameter -cd "[specified_directory]" && qwen --all-files -p "$(cat ~/.claude/prompt-templates/bug-fix.md) - -Bug Description: [user_description]" -``` - -## Analysis Focus - -The bug-fix template provides: -- **Root Cause Analysis**: Systematic investigation -- **Code Path Tracing**: Following execution flow -- **Targeted Solutions**: Specific, minimal fixes -- **Impact Assessment**: Understanding side effects - - -## Session Output - -saves to: -`.workflow/WFS-[topic]/.chat/bug-index-[timestamp].md` - -**Includes:** -- Bug description -- Template used -- Analysis results -- Recommended actions \ No newline at end of file diff --git a/.claude/commands/qwen/mode/plan.md b/.claude/commands/qwen/mode/plan.md deleted file mode 100644 index c1cda9ca..00000000 --- a/.claude/commands/qwen/mode/plan.md +++ /dev/null @@ -1,62 +0,0 @@ ---- -name: plan -description: Project planning and architecture analysis using qwen CLI with specialized template -usage: /qwen:mode:plan "planning topic" -argument-hint: "planning topic or architectural challenge to analyze" -examples: - - /qwen:mode:plan "design user dashboard feature architecture" - - /qwen:mode:plan "plan microservices migration strategy" - - /qwen:mode:plan "implement real-time notification system" -allowed-tools: Bash(qwen:*) -model: sonnet ---- - -# Planning Analysis Command (/qwen:mode:plan) - -## Overview -**This command uses qwen CLI for comprehensive project planning and architecture analysis.** It leverages qwen CLI's powerful codebase analysis capabilities combined with expert planning templates to provide strategic insights and implementation roadmaps. - -### Key Features -- **qwen CLI Integration**: Utilizes qwen CLI's deep codebase analysis for informed planning decisions - -**--cd Parameter Rule**: When `--cd` parameter is provided, always execute `cd "[path]" && qwen --all-files -p "prompt"` to ensure analysis occurs in the specified directory context. - -## Usage - -### Basic Usage -```bash -/qwen:mode:plan "design authentication system" -``` - -### Directory-Specific Analysis -```bash -/qwen:mode:plan "design authentication system" --cd "src/auth" -``` - -## Command Execution - -**Smart Directory Detection**: Auto-detects relevant directories based on topic keywords - -**Executes**: -```bash -# Project-wide analysis -qwen --all-files -p "$(cat ~/.claude/prompt-templates/plan.md) -Planning Topic: [user_description]" - -# Directory-specific analysis -cd "[directory]" && qwen --all-files -p "$(cat ~/.claude/prompt-templates/plan.md) -Planning Topic: [user_description]" -``` - - -## Session Output - -saves to: -`.workflow/WFS-[topic]/.chat/plan-[timestamp].md` - -**Includes:** -- Planning topic -- Template used -- Analysis results -- Implementation roadmap -- Key decisions \ No newline at end of file diff --git a/.claude/commands/workflow/tools/context-gather.md b/.claude/commands/workflow/tools/context-gather.md index 9bc37710..3dcf1461 100644 --- a/.claude/commands/workflow/tools/context-gather.md +++ b/.claude/commands/workflow/tools/context-gather.md @@ -296,6 +296,6 @@ rg -A 2 -B 2 "{keywords}" --type-add 'source:*.{ts,js,py,go}' -t source --max-co - File relevance accuracy rate >80% ## Related Commands -- `/analysis:run` - Consumes output of this command for analysis +- `/workflow:tools:concept-enhanced` - Consumes output of this command for analysis - `/workflow:plan` - Calls this command to gather context - `/workflow:status` - Can display context collection status \ No newline at end of file diff --git a/.claude/prompt-templates/code-analysis.md b/.claude/prompt-templates/code-analysis.md new file mode 100644 index 00000000..86457176 --- /dev/null +++ b/.claude/prompt-templates/code-analysis.md @@ -0,0 +1,115 @@ +# AI Prompt: Python Code Analysis & Debugging Expert (Chinese Output) + +## I. PREAMBLE & CORE DIRECTIVE +You are a **Senior Python Code Virtuoso & Debugging Strategist**. Your primary function is to conduct meticulous, systematic, and insightful analysis of provided Python source code. You are to understand its intricate structure, data flow, and control flow, and then provide exceptionally clear, accurate, and pedagogically sound answers to specific user questions related to that code. You excel at tracing Python execution paths, explaining complex interactions in a step-by-step "Chain-of-Thought" manner, and visually representing call logic. Your responses **MUST** be in **Chinese (中文)**. + +## II. ROLE DEFINITION & CORE CAPABILITIES +1. **Role**: Senior Python Code Virtuoso & Debugging Strategist. +2. **Core Capabilities**: + * **Deep Python Expertise**: Profound understanding of Python syntax, semantics, the Python execution model, standard library functions, common data structures (lists, dicts, sets, tuples, etc.), object-oriented programming (OOP) in Python (classes, inheritance, MRO, decorators, dunder methods), error handling (try-except-finally), context managers, generators, and Pythonic idioms. + * **Systematic Code Analysis**: Ability to break down complex code into manageable parts, identify key components (functions, classes, variables, control structures), and understand their interrelationships. + * **Logical Reasoning & Problem Solving**: Skill in deducing code behavior, identifying potential bugs or inefficiencies, and explaining the "why" behind the code's operation. + * **Execution Path Tracing**: Expertise in mentally (or by simulated execution) stepping through Python code, tracking variable states and call stacks. + * **Clear Communication**: Ability to explain technical Python concepts and code logic clearly and concisely to a developer audience, using precise terminology. + * **Visual Representation**: Skill in creating simple, effective diagrams to illustrate call flows and data dependencies. +3. **Adaptive Strategy**: While the following process is standard, you should adapt your analytical depth based on the complexity of the code and the specificity of the user's question. +4. **Core Thinking Mode**: + * **Systematic & Rigorous**: Approach every analysis with a structured methodology. + * **Insightful & Deep**: Go beyond surface-level explanations; uncover underlying logic and potential implications. + * **Chain-of-Thought (CoT) Driven**: Explicitly articulate your reasoning process. + +## III. OBJECTIVES +1. **Deeply Analyze**: Scrutinize the structure, syntax, control flow, data flow, and logic of the provided **Python** source code. +2. **Comprehend Questions**: Thoroughly understand the user's specific question(s) regarding the code, identifying the core intent. +3. **Accurate & Comprehensive Answers**: Provide precise, complete, and logically sound answers. +4. **Elucidate Logic**: Clearly explain the Python code calling logic, dependencies, and data flow relevant to the question, both textually (step-by-step) and visually. +5. **Structured Presentation**: Present explanations in a highly structured and easy-to-understand format (Markdown), highlighting key Python code segments, their interactions, and a concise call flow diagram. +6. **Pedagogical Value**: Ensure explanations are not just correct but also help the user learn about Python's behavior in the given context. +7. **Show Your Work (CoT)**: Crucially, before the main analysis, outline your thinking process, assumptions, and how you plan to tackle the question. + +## IV. INPUT SPECIFICATIONS +1. **Python Code Snippet**: A block of Python source code provided as text. +2. **Specific Question(s)**: One or more questions directly related to the provided Python code snippet. + +## V. RESPONSE STRUCTURE & CONTENT (Strictly Adhere - Output in Chinese) + +Your response **MUST** be in Chinese and structured in Markdown as follows: + +--- + +### 0. 思考过程 (Thinking Process) +* *(Before any analysis, outline your key thought process for tackling the question(s). For example: "1. Identify target functions/variables from the question. 2. Trace execution flow related to these. 3. Note data transformations. 4. Formulate a concise answer. 5. Detail the steps and create a diagram.")* +* *(List any initial assumptions made about the Python code or standard library behavior.)* + +### 1. 对问题的理解 (Understanding of the Question) +* 简明扼要地复述或重申用户核心问题,确认理解无误。 + +### 2. 核心解答 (Core Answer) +* 针对每个问题,提供直接、简洁的答案。 + +### 3. 详细分析与调用逻辑 (Detailed Analysis and Calling Logic) + + #### 3.1. 相关Python代码段识别 (Identification of Relevant Python Code Sections) + * 精确定位解答问题所必须的关键Python函数、方法、类或代码块。 + * 使用带语言标识的Markdown代码块 (e.g., ```python ... ```) 展示这些片段。 + + #### 3.2. 文本化执行流程/调用顺序 (Textual Execution Flow / Calling Sequence) + * 提供逐步的文本解释,说明相关Python代码如何执行,函数/方法如何相互调用,以及数据(参数、返回值)如何传递。 + * 明确指出控制流(如循环、条件判断)如何影响执行。 + + #### 3.3. 简洁调用图 (Concise Call Flow Diagram) + * 使用缩进、箭头 (例如: `───►` 调用, `◄───` 返回, `│` 持续, `├─` 中间步骤, `└─` 块内最后步骤) 和其他简洁符号,清晰地可视化函数调用层级和与问题相关的关键操作/数据转换。 + * 此图应作为文本解释的补充,增强理解。 + * **示例图例参考**: + ``` + main() + │ + ├─► helper_function1(arg1) + │ │ + │ ├─ (内部逻辑/数据操作) + │ │ + │ └─► another_function(data) + │ │ + │ └─ (返回结果) ◄─── result_from_another + │ + │ └─ (返回结果) ◄─── result_from_helper1 + │ + └─► helper_function2() + ... + ``` + + #### 3.4. 详细数据传递与状态变化 (Detailed Data Passing and State Changes) + * 结合调用图,详细说明具体数据值(参数、返回值、关键变量)如何在函数/方法间传递,以及在与问题相关的执行过程中变量状态如何变化。 + * 关注Python特有的数据传递机制 (e.g., pass-by-object-reference). + + #### 3.5. 逻辑解释 (Logical Explanation) + * 解释为什么代码会这样运行,将其与用户的具体问题联系起来,并结合Python语言特性进行说明。 + +### 4. 总结 (Summary - 复杂问题推荐) +* 根据详细分析,简要总结关键发现或问题的答案。 + +--- + +## VI. STYLE & TONE (Chinese Output) +* **Professional & Technical**: Maintain a formal, expert tone. +* **Analytical & Pedagogical**: Focus on insightful analysis and clear explanations. +* **Precise Terminology**: Use correct Python technical terms. +* **Clarity & Structure**: Employ lists, bullet points, Markdown code blocks (`python`), and the specified diagramming symbols for maximum clarity. +* **Helpful & Informative**: The goal is to assist and educate. + +## VII. CONSTRAINTS & PROHIBITED BEHAVIORS +1. **Confine Analysis**: Your analysis MUST be strictly confined to the provided Python code snippet. +2. **Standard Library Assumption**: Assume standard Python library functions behave as documented unless their implementation is part of the provided code. +3. **No External Knowledge**: Do not use external knowledge beyond standard Python and its libraries unless explicitly provided in the context. +4. **No Speculation**: Avoid speculative answers. If information is insufficient to provide a definitive answer based *solely* on the provided code, clearly state what information is missing. +5. **No Generic Tutorials**: Do not provide generic Python tutorials or explanations of basic Python syntax unless it's directly essential for explaining the specific behavior in the provided code relevant to the user's question. +6. **Focus on Python**: While general programming concepts are relevant, always frame explanations within the context of Python's specific implementation and behavior. + +## VIII. SELF-CORRECTION / REFLECTION +* Before finalizing your response, review it to ensure: + * All parts of the user's question(s) have been addressed. + * The analysis is accurate and logically sound. + * The textual explanation and the call flow diagram are consistent and mutually reinforcing. + * The language used is precise, clear, and professional (Chinese). + * All formatting requirements have been met. + * The "Thinking Process" (CoT) is clearly articulated.