mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-05 01:50:27 +08:00
- **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>
4.9 KiB
4.9 KiB
name, description, usage, argument-hint, examples, allowed-tools
| name | description | usage | argument-hint | examples | allowed-tools | |||
|---|---|---|---|---|---|---|---|---|
| code-analysis | Deep code analysis and debugging using CLI tools with specialized template | /cli:mode:code-analysis [--tool <codex|gemini|qwen>] [--enhance] [--cd "path"] "analysis target" | [--tool codex|gemini|qwen] [--enhance] [--cd path] analysis target |
|
SlashCommand(*), Bash(*) |
CLI Mode: Code Analysis (/cli:mode:code-analysis)
Purpose
Systematic code analysis with execution path tracing template (~/.claude/prompt-templates/code-analysis.md).
Supported Tools: codex, gemini (default), qwen
Key Feature: --cd flag for directory-scoped analysis
Parameters
--tool <codex|gemini|qwen>- Tool selection (default: gemini)--enhance- Enhance analysis target with/enhance-promptfirst--cd "path"- Target directory for focused analysis<analysis-target>(Required) - Code analysis target or question
Execution Flow
- Parse tool selection: Extract
--toolflag (default: gemini) - If
--enhanceflag present: Execute/enhance-prompt "[analysis-target]"first - Parse analysis target (original or enhanced)
- Detect target directory (from
--cdor auto-infer) - Build command for selected tool with code-analysis template
- Execute deep analysis (read-only, no code modification)
- Save to
.workflow/WFS-[id]/.chat/code-analysis-[timestamp].md
Core Rules
- Analysis Only: This command analyzes code and provides insights - it does NOT modify code
- Tool Selection: Use
--toolvalue or default to gemini - Enhance First (if flagged): Execute
/enhance-promptbefore analysis - Directory Context: Use
cdwhen--cdprovided or auto-detected - Template Required: Always use code-analysis template
- Session Output: Save analysis results to session chat
Analysis Capabilities (via Template)
- 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 Template
cd [directory] && ~/.claude/scripts/gemini-wrapper --all-files -p "
PURPOSE: [analysis goal]
TASK: Systematic code analysis and execution path tracing
MODE: analysis
CONTEXT: @{CLAUDE.md,**/*CLAUDE.md} [entire codebase in directory]
EXPECTED: Execution trace, call flow diagram, debugging insights
RULES: $(cat ~/.claude/prompt-templates/code-analysis.md) | Focus on [aspect]
"
Examples
Basic Code Analysis:
cd . && ~/.claude/scripts/gemini-wrapper --all-files -p "
PURPOSE: Trace authentication execution flow
TASK: Analyze complete auth flow from request to response
MODE: analysis
CONTEXT: @{CLAUDE.md,**/*CLAUDE.md}
EXPECTED: Step-by-step execution trace with call diagram, variable states
RULES: $(cat ~/.claude/prompt-templates/code-analysis.md) | Focus on control flow
"
Directory-Specific Analysis:
cd src/auth && ~/.claude/scripts/gemini-wrapper --all-files -p "
PURPOSE: Understand JWT token validation logic
TASK: Trace JWT validation from middleware to service layer
MODE: analysis
CONTEXT: @{CLAUDE.md,**/*CLAUDE.md}
EXPECTED: Validation flow diagram, token lifecycle analysis
RULES: $(cat ~/.claude/prompt-templates/code-analysis.md) | Focus on security
"
Code Tracing Workflow
# 1. Find entry points and related files
rg "function.*authenticate|class.*AuthService" --files-with-matches
mcp__code-index__search_code_advanced(pattern="authenticate|login", file_pattern="*.ts")
# 2. Build call graph understanding
# entry → middleware → service → repository
# 3. Execute deep analysis (analysis only, no code changes)
/cli:mode:code-analysis --cd "src" "trace execution from entry point"
Output Routing
Output Destination Logic:
- Active session exists AND analysis is session-relevant:
- Save to
.workflow/WFS-[id]/.chat/code-analysis-[timestamp].md
- Save to
- No active session OR standalone analysis:
- Save to
.workflow/.scratchpad/code-analysis-[description]-[timestamp].md
- Save to
Examples:
- During active session
WFS-auth-refactor, analyzing auth flow →.chat/code-analysis-20250105-143022.md - No session, tracing request lifecycle →
.scratchpad/code-analysis-request-flow-20250105-143045.md
Notes
- Command templates and file patterns: see intelligent-tools-strategy.md (loaded in memory)
- Scratchpad directory details: see workflow-architecture.md
- Template path:
~/.claude/prompt-templates/code-analysis.md - Always uses
--all-filesfor comprehensive code context