Files
Claude-Code-Workflow/.claude/commands/cli/analyze.md
catlog22 2dbf550420 docs: clarify CLI command intent and add output routing
- **Intent Clarification**: Distinguished analysis (read-only) from execution (modifies code) commands
- **Output Routing**: Added comprehensive output destination logic for all CLI commands
- **Scratchpad Integration**: Introduced `.workflow/.scratchpad/` for non-session-specific outputs

## Analysis Commands (Read-Only)
- `/cli:analyze`, `/cli:chat`, `/cli:mode:*`: Added "Core Behavior" emphasizing read-only nature
- Added "MODE: analysis" in command templates
- Examples clearly show recommendations vs. code changes

## Execution Commands (Modifies Code)
- `/cli:execute`: Added ⚠️ warnings about code modification
- `/cli:codex-execute`: Clarified multi-stage execution with detailed output structure
- Both commands now have "Output Routing" sections

## Workflow Architecture Updates
- Added `.workflow/.scratchpad/` directory definition
- Output routing logic: session-relevant → `.chat/`, otherwise → `.scratchpad/`
- File naming pattern: `[command-type]-[brief-description]-[timestamp].md`
- Examples for both analysis and implementation commands

## Key Improvements
- Prevents confusion between analysis and implementation operations
- Solves output loss when no active session exists
- Prevents unrelated analyses from cluttering session history
- Provides centralized location for ad-hoc outputs

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-05 12:22:23 +08:00

4.0 KiB

name, description, usage, argument-hint, examples, allowed-tools
name description usage argument-hint examples allowed-tools
analyze Quick codebase analysis using CLI tools (codex/gemini/qwen) /cli:analyze [--tool <codex|gemini|qwen>] [--enhance] <analysis-target> [--tool codex|gemini|qwen] [--enhance] analysis target
/cli:analyze "authentication patterns"
/cli:analyze --tool qwen "API security"
/cli:analyze --tool codex --enhance "performance bottlenecks"
SlashCommand(*), Bash(*), TodoWrite(*), Read(*), Glob(*)

CLI Analyze Command (/cli:analyze)

Purpose

Quick codebase analysis using CLI tools. Analysis only - does NOT modify code.

Intent: Understand code patterns, architecture, and provide insights/recommendations Supported Tools: codex, gemini (default), qwen

Core Behavior

  1. Read-Only Analysis: This command ONLY analyzes code and provides insights
  2. No Code Modification: Results are recommendations and analysis reports
  3. Template-Based: Automatically selects appropriate analysis template
  4. Smart Pattern Detection: Infers relevant files based on analysis target

Parameters

  • --tool <codex|gemini|qwen> - Tool selection (default: gemini)
  • --enhance - Use /enhance-prompt for context-aware enhancement
  • <analysis-target> - Description of what to analyze

Execution Flow

  1. Parse tool selection (default: gemini)
  2. If --enhance: Execute /enhance-prompt first to expand user intent
  3. Auto-detect analysis type from keywords → select template
  4. Build command with auto-detected file patterns and MODE: analysis
  5. Execute analysis (read-only, no code changes)
  6. Return analysis report with insights and recommendations

File Pattern Auto-Detection

Keywords trigger specific file patterns:

  • "auth" → @{**/*auth*,**/*user*}
  • "component" → @{src/components/**/*,**/*.component.*}
  • "API" → @{**/api/**/*,**/routes/**/*}
  • "test" → @{**/*.test.*,**/*.spec.*}
  • "config" → @{*.config.*,**/config/**/*}
  • Generic → @{src/**/*}

For complex patterns, use rg or MCP tools to discover files first, then execute CLI with precise file references.

Command Template

cd . && ~/.claude/scripts/gemini-wrapper -p "
PURPOSE: [analysis goal from target]
TASK: [auto-detected analysis type]
MODE: analysis
CONTEXT: @{CLAUDE.md} [auto-detected file patterns]
EXPECTED: Insights, patterns, recommendations (NO code modification)
RULES: [auto-selected template] | Focus on [analysis aspect]
"

Examples

Basic Analysis:

/cli:analyze "authentication patterns"
# Executes: Gemini analysis with auth file patterns
# Returns: Pattern analysis, architecture insights, recommendations

Architecture Analysis:

/cli:analyze --tool qwen "component architecture"
# Executes: Qwen with component file patterns
# Returns: Architecture review, design patterns, improvement suggestions

Performance Analysis:

/cli:analyze --tool codex "performance bottlenecks"
# Executes: Codex deep analysis with performance focus
# Returns: Bottleneck identification, optimization recommendations

Enhanced Analysis:

/cli:analyze --enhance "fix auth issues"
# Step 1: Enhance prompt to expand context
# Step 2: Analysis with expanded context
# Returns: Root cause analysis, fix recommendations (NO automatic fixes)

Output Routing

Output Destination Logic:

  • Active session exists AND analysis is session-relevant:
    • Save to .workflow/WFS-[id]/.chat/analyze-[timestamp].md
  • No active session OR one-off analysis:
    • Save to .workflow/.scratchpad/analyze-[description]-[timestamp].md

Examples:

  • During active session WFS-auth-system, analyzing auth patterns → .chat/analyze-20250105-143022.md
  • No session, quick security check → .scratchpad/analyze-security-20250105-143045.md

Notes

  • Command templates, file patterns, and best practices: see intelligent-tools-strategy.md (loaded in memory)
  • Scratchpad directory details: see workflow-architecture.md
  • Scratchpad files can be promoted to workflow sessions if analysis proves valuable