mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-10 02:24:35 +08:00
Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e3a6c885db | ||
|
|
eb9b10c96b | ||
|
|
804617d8cd | ||
|
|
b6c1880abf | ||
|
|
7783ee0ac5 | ||
|
|
de3dc35c5b | ||
|
|
c640cfefe8 | ||
|
|
d3ddfadf16 | ||
|
|
2072ddfa6e | ||
|
|
9e584d911b | ||
|
|
b30a5269d2 | ||
|
|
5046565d4c | ||
|
|
8ebae76b74 | ||
|
|
83664cb777 | ||
|
|
360a2b9edc | ||
|
|
5123675fbf | ||
|
|
967490dcf6 | ||
|
|
e15da0e461 | ||
|
|
51a0cb3a3c | ||
|
|
436c7909b0 |
@@ -174,7 +174,7 @@ score = 0
|
|||||||
|
|
||||||
**2. Context Assembly**:
|
**2. Context Assembly**:
|
||||||
```bash
|
```bash
|
||||||
CONTEXT: @{CLAUDE.md} @{discovered_file1} @{discovered_file2} ...
|
CONTEXT: @CLAUDE.md @{discovered_file1} @{discovered_file2} ...
|
||||||
|
|
||||||
## Discovered Context
|
## Discovered Context
|
||||||
- **Project Structure**: {module_summary}
|
- **Project Structure**: {module_summary}
|
||||||
|
|||||||
@@ -53,8 +53,7 @@ You are an expert technical documentation specialist. Your responsibility is to
|
|||||||
{
|
{
|
||||||
"step": "analyze_module_structure",
|
"step": "analyze_module_structure",
|
||||||
"action": "Deep analysis of module structure and API",
|
"action": "Deep analysis of module structure and API",
|
||||||
"command": "bash(cd src/auth && ~/.claude/scripts/gemini-wrapper -p \"PURPOSE: Document module comprehensively\nTASK: Extract module purpose, architecture, public API, dependencies\nMODE: analysis\nCONTEXT: @{**/*}
|
"command": "bash(cd src/auth && gemini \"PURPOSE: Document module comprehensively\nTASK: Extract module purpose, architecture, public API, dependencies\nMODE: analysis\nCONTEXT: @**/* System: [system_context]\nEXPECTED: Complete module analysis for documentation\nRULES: $(cat ~/.claude/workflows/cli-templates/prompts/documentation/module-documentation.txt)\")",
|
||||||
System: [system_context]\nEXPECTED: Complete module analysis for documentation\nRULES: $(cat ~/.claude/workflows/cli-templates/prompts/documentation/module-documentation.txt)\")",
|
|
||||||
"output_to": "module_analysis",
|
"output_to": "module_analysis",
|
||||||
"on_error": "fail"
|
"on_error": "fail"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ You will receive:
|
|||||||
```
|
```
|
||||||
- Total modules: [count]
|
- Total modules: [count]
|
||||||
- Tool: [gemini|qwen|codex]
|
- Tool: [gemini|qwen|codex]
|
||||||
- Mode: [full|related]
|
|
||||||
- Module list (depth|path|files|types|has_claude format)
|
- Module list (depth|path|files|types|has_claude format)
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -42,9 +41,13 @@ TodoWrite([
|
|||||||
# 2. Extract module paths for current depth
|
# 2. Extract module paths for current depth
|
||||||
# 3. Launch parallel jobs (max 4)
|
# 3. Launch parallel jobs (max 4)
|
||||||
|
|
||||||
# Depth 5 example:
|
# Depth 5 example (Layer 3 - use multi-layer):
|
||||||
~/.claude/scripts/update_module_claude.sh "./.claude/workflows/cli-templates/prompts/analysis" "full" "gemini" &
|
~/.claude/scripts/update_module_claude.sh "multi-layer" "./.claude/workflows/cli-templates/prompts/analysis" "gemini" &
|
||||||
~/.claude/scripts/update_module_claude.sh "./.claude/workflows/cli-templates/prompts/development" "full" "gemini" &
|
~/.claude/scripts/update_module_claude.sh "multi-layer" "./.claude/workflows/cli-templates/prompts/development" "gemini" &
|
||||||
|
|
||||||
|
# Depth 1 example (Layer 2 - use single-layer):
|
||||||
|
~/.claude/scripts/update_module_claude.sh "single-layer" "./src/auth" "gemini" &
|
||||||
|
~/.claude/scripts/update_module_claude.sh "single-layer" "./src/api" "gemini" &
|
||||||
# ... up to 4 concurrent jobs
|
# ... up to 4 concurrent jobs
|
||||||
|
|
||||||
# 4. Wait for all depth jobs to complete
|
# 4. Wait for all depth jobs to complete
|
||||||
@@ -63,21 +66,24 @@ git status --short
|
|||||||
|
|
||||||
## Tool Parameter Flow
|
## Tool Parameter Flow
|
||||||
|
|
||||||
**Command Format**: `update_module_claude.sh <path> <mode> <tool>`
|
**Command Format**: `update_module_claude.sh <strategy> <path> <tool>`
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
- Gemini: `update_module_claude.sh "./.claude/agents" "full" "gemini" &`
|
- Layer 3 (depth ≥3): `update_module_claude.sh "multi-layer" "./.claude/agents" "gemini" &`
|
||||||
- Qwen: `update_module_claude.sh "./src/api" "full" "qwen" &`
|
- Layer 2 (depth 1-2): `update_module_claude.sh "single-layer" "./src/api" "qwen" &`
|
||||||
- Codex: `update_module_claude.sh "./tests" "full" "codex" &`
|
- Layer 1 (depth 0): `update_module_claude.sh "single-layer" "./tests" "codex" &`
|
||||||
|
|
||||||
## Execution Rules
|
## Execution Rules
|
||||||
|
|
||||||
1. **Task Tracking**: Create TodoWrite entry for each depth before execution
|
1. **Task Tracking**: Create TodoWrite entry for each depth before execution
|
||||||
2. **Parallelism**: Max 4 jobs per depth, sequential across depths
|
2. **Parallelism**: Max 4 jobs per depth, sequential across depths
|
||||||
3. **Tool Passing**: Always pass tool parameter as 3rd argument
|
3. **Strategy Assignment**: Assign strategy based on depth:
|
||||||
4. **Path Accuracy**: Extract exact path from `depth:N|path:X|...` format
|
- Depth ≥3 (Layer 3): Use "multi-layer" strategy
|
||||||
5. **Completion**: Mark todo completed only after all depth jobs finish
|
- Depth 0-2 (Layers 1-2): Use "single-layer" strategy
|
||||||
6. **No Skipping**: Process every module from input list
|
4. **Tool Passing**: Always pass tool parameter as 3rd argument
|
||||||
|
5. **Path Accuracy**: Extract exact path from `depth:N|path:X|...` format
|
||||||
|
6. **Completion**: Mark todo completed only after all depth jobs finish
|
||||||
|
7. **No Skipping**: Process every module from input list
|
||||||
|
|
||||||
## Concise Output
|
## Concise Output
|
||||||
|
|
||||||
|
|||||||
@@ -67,24 +67,24 @@ The agent handles all phases internally (understanding, discovery, enhancement,
|
|||||||
|
|
||||||
## File Pattern Auto-Detection
|
## File Pattern Auto-Detection
|
||||||
|
|
||||||
Keywords trigger specific file patterns:
|
Keywords trigger specific file patterns (each @ references one pattern):
|
||||||
- "auth" → `@{**/*auth*,**/*user*}`
|
- "auth" → `@**/*auth* @**/*user*`
|
||||||
- "component" → `@{src/components/**/*,**/*.component.*}`
|
- "component" → `@src/components/**/* @**/*.component.*`
|
||||||
- "API" → `@{**/api/**/*,**/routes/**/*}`
|
- "API" → `@**/api/**/* @**/routes/**/*`
|
||||||
- "test" → `@{**/*.test.*,**/*.spec.*}`
|
- "test" → `@**/*.test.* @**/*.spec.*`
|
||||||
- "config" → `@{*.config.*,**/config/**/*}`
|
- "config" → `@*.config.* @**/config/**/*`
|
||||||
- Generic → `@{src/**/*}`
|
- Generic → `@src/**/*`
|
||||||
|
|
||||||
For complex patterns, use `rg` or MCP tools to discover files first, then execute CLI with precise file references.
|
For complex patterns, use `rg` or MCP tools to discover files first, then execute CLI with precise file references.
|
||||||
|
|
||||||
## Command Template
|
## Command Template
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd . && ~/.claude/scripts/gemini-wrapper -p "
|
cd . && gemini -p "
|
||||||
PURPOSE: [analysis goal from target]
|
PURPOSE: [analysis goal from target]
|
||||||
TASK: [auto-detected analysis type]
|
TASK: [auto-detected analysis type]
|
||||||
MODE: analysis
|
MODE: analysis
|
||||||
CONTEXT: @{CLAUDE.md} [auto-detected file patterns]
|
CONTEXT: @CLAUDE.md [auto-detected file patterns]
|
||||||
EXPECTED: Insights, patterns, recommendations (NO code modification)
|
EXPECTED: Insights, patterns, recommendations (NO code modification)
|
||||||
RULES: [auto-selected template] | Focus on [analysis aspect]
|
RULES: [auto-selected template] | Focus on [analysis aspect]
|
||||||
"
|
"
|
||||||
@@ -112,7 +112,7 @@ RULES: [auto-selected template] | Focus on [analysis aspect]
|
|||||||
|
|
||||||
**Architecture Analysis**:
|
**Architecture Analysis**:
|
||||||
```bash
|
```bash
|
||||||
/cli:analyze --tool qwen "component architecture"
|
/cli:analyze --tool qwen -p "component architecture"
|
||||||
# Executes: Qwen with component file patterns
|
# Executes: Qwen with component file patterns
|
||||||
# Returns: Architecture review, design patterns, improvement suggestions
|
# Returns: Architecture review, design patterns, improvement suggestions
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ Direct Q&A interaction with CLI tools for codebase analysis. **Analysis only - d
|
|||||||
- `--agent` - Use cli-execution-agent for automated context discovery (5-phase intelligent mode)
|
- `--agent` - Use cli-execution-agent for automated context discovery (5-phase intelligent mode)
|
||||||
- `--tool <codex|gemini|qwen>` - Select CLI tool (default: gemini, ignored in agent mode)
|
- `--tool <codex|gemini|qwen>` - Select CLI tool (default: gemini, ignored in agent mode)
|
||||||
- `--enhance` - Enhance inquiry with `/enhance-prompt` first
|
- `--enhance` - Enhance inquiry with `/enhance-prompt` first
|
||||||
- `--all-files` - Include entire codebase in context
|
|
||||||
- `--save-session` - Save interaction to workflow session
|
- `--save-session` - Save interaction to workflow session
|
||||||
|
|
||||||
## Execution Flow
|
## Execution Flow
|
||||||
@@ -36,7 +35,7 @@ Direct Q&A interaction with CLI tools for codebase analysis. **Analysis only - d
|
|||||||
|
|
||||||
1. Parse tool selection (default: gemini)
|
1. Parse tool selection (default: gemini)
|
||||||
2. If `--enhance`: Execute `/enhance-prompt` to expand user intent
|
2. If `--enhance`: Execute `/enhance-prompt` to expand user intent
|
||||||
3. Assemble context: `@{CLAUDE.md}` + user-specified files or `--all-files`
|
3. Assemble context: `@CLAUDE.md` + user-specified files or `@**/*` for entire codebase
|
||||||
4. Execute CLI tool with assembled context (read-only, analysis mode)
|
4. Execute CLI tool with assembled context (read-only, analysis mode)
|
||||||
5. Return explanations and insights (NO code changes)
|
5. Return explanations and insights (NO code changes)
|
||||||
6. Optionally save to workflow session
|
6. Optionally save to workflow session
|
||||||
@@ -54,7 +53,6 @@ Task(
|
|||||||
Task: ${inquiry}
|
Task: ${inquiry}
|
||||||
Mode: analyze (Q&A)
|
Mode: analyze (Q&A)
|
||||||
Tool Preference: ${tool_flag || 'auto-select'}
|
Tool Preference: ${tool_flag || 'auto-select'}
|
||||||
${all_files_flag ? 'Scope: all-files' : ''}
|
|
||||||
|
|
||||||
Agent will autonomously:
|
Agent will autonomously:
|
||||||
- Discover files relevant to the question
|
- Discover files relevant to the question
|
||||||
@@ -69,22 +67,24 @@ The agent handles all phases internally.
|
|||||||
|
|
||||||
## Context Assembly
|
## Context Assembly
|
||||||
|
|
||||||
**Always included**: `@{CLAUDE.md,**/*CLAUDE.md}` (project guidelines)
|
**Always included**: `@CLAUDE.md @**/*CLAUDE.md` (project guidelines, space-separated)
|
||||||
|
|
||||||
**Optional**:
|
**Optional**:
|
||||||
- User-explicit files from inquiry keywords
|
- User-explicit files from inquiry keywords
|
||||||
- `--all-files` flag includes entire codebase (`--all-files` wrapper parameter)
|
- Use `@**/*` in CONTEXT for entire codebase
|
||||||
|
|
||||||
For targeted analysis, use `rg` or MCP tools to discover relevant files first, then build precise CONTEXT field.
|
For targeted analysis, use `rg` or MCP tools to discover relevant files first, then build precise CONTEXT field.
|
||||||
|
|
||||||
## Command Template
|
## Command Template
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd . && ~/.claude/scripts/gemini-wrapper -p "
|
cd . && gemini -p "
|
||||||
INQUIRY: [user question]
|
PURPOSE: Answer user inquiry about codebase
|
||||||
CONTEXT: @{CLAUDE.md,**/*CLAUDE.md} [inferred or --all-files]
|
TASK: [user question]
|
||||||
MODE: analysis
|
MODE: analysis
|
||||||
RESPONSE: Direct answer, explanation, insights (NO code modification)
|
CONTEXT: @CLAUDE.md @**/*CLAUDE.md [inferred files or @**/* for all files]
|
||||||
|
EXPECTED: Direct answer, explanation, insights (NO code modification)
|
||||||
|
RULES: Focus on clarity and accuracy
|
||||||
"
|
"
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -110,7 +110,7 @@ RESPONSE: Direct answer, explanation, insights (NO code modification)
|
|||||||
|
|
||||||
**Architecture Question**:
|
**Architecture Question**:
|
||||||
```bash
|
```bash
|
||||||
/cli:chat --tool qwen "how does React component optimization work here"
|
/cli:chat --tool qwen -p "how does React component optimization work here"
|
||||||
# Executes: Qwen architecture analysis
|
# Executes: Qwen architecture analysis
|
||||||
# Returns: Component structure explanation, optimization patterns used
|
# Returns: Component structure explanation, optimization patterns used
|
||||||
```
|
```
|
||||||
@@ -130,13 +130,6 @@ RESPONSE: Direct answer, explanation, insights (NO code modification)
|
|||||||
# Returns: Detailed explanation of login flow and potential issues
|
# Returns: Detailed explanation of login flow and potential issues
|
||||||
```
|
```
|
||||||
|
|
||||||
**Broad Context**:
|
|
||||||
```bash
|
|
||||||
/cli:chat --all-files "find all API endpoints"
|
|
||||||
# Executes: Analysis across entire codebase
|
|
||||||
# Returns: List and explanation of API endpoints (NO code generation)
|
|
||||||
```
|
|
||||||
|
|
||||||
## Output Routing
|
## Output Routing
|
||||||
|
|
||||||
**Output Destination Logic**:
|
**Output Destination Logic**:
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ git status --short
|
|||||||
codex -C [dir] --full-auto exec "
|
codex -C [dir] --full-auto exec "
|
||||||
PURPOSE: [group goal]
|
PURPOSE: [group goal]
|
||||||
TASK: [subtask description - first in group]
|
TASK: [subtask description - first in group]
|
||||||
CONTEXT: @{relevant_files} @{CLAUDE.md}
|
CONTEXT: @{relevant_files} @CLAUDE.md
|
||||||
EXPECTED: [specific deliverables]
|
EXPECTED: [specific deliverables]
|
||||||
RULES: [constraints]
|
RULES: [constraints]
|
||||||
Group [X]: [group name] - Subtask 1 of N in this group
|
Group [X]: [group name] - Subtask 1 of N in this group
|
||||||
@@ -164,7 +164,7 @@ git add -A
|
|||||||
codex -C [dir] --full-auto exec "
|
codex -C [dir] --full-auto exec "
|
||||||
PURPOSE: [new group goal]
|
PURPOSE: [new group goal]
|
||||||
TASK: [subtask description - first in new group]
|
TASK: [subtask description - first in new group]
|
||||||
CONTEXT: @{different_files} @{CLAUDE.md}
|
CONTEXT: @{different_files} @CLAUDE.md
|
||||||
EXPECTED: [specific deliverables]
|
EXPECTED: [specific deliverables]
|
||||||
RULES: [constraints]
|
RULES: [constraints]
|
||||||
Group [Y]: [new group name] - Subtask 1 of N in this group
|
Group [Y]: [new group name] - Subtask 1 of N in this group
|
||||||
|
|||||||
@@ -69,11 +69,11 @@ Gemini analyzes the topic and proposes preliminary plan.
|
|||||||
```bash
|
```bash
|
||||||
# Round 1: CONTEXT_INPUT is the initial topic
|
# Round 1: CONTEXT_INPUT is the initial topic
|
||||||
# Subsequent rounds: CONTEXT_INPUT is the synthesis from previous round
|
# Subsequent rounds: CONTEXT_INPUT is the synthesis from previous round
|
||||||
~/.claude/scripts/gemini-wrapper -p "
|
gemini -p "
|
||||||
PURPOSE: Analyze and propose a plan for '[topic]'
|
PURPOSE: Analyze and propose a plan for '[topic]'
|
||||||
TASK: Provide initial analysis, identify key modules, and draft implementation plan
|
TASK: Provide initial analysis, identify key modules, and draft implementation plan
|
||||||
MODE: analysis
|
MODE: analysis
|
||||||
CONTEXT: @{CLAUDE.md} [auto-detected files]
|
CONTEXT: @CLAUDE.md [auto-detected files]
|
||||||
INPUT: [CONTEXT_INPUT]
|
INPUT: [CONTEXT_INPUT]
|
||||||
EXPECTED: Structured analysis and draft plan for discussion
|
EXPECTED: Structured analysis and draft plan for discussion
|
||||||
RULES: Focus on technical depth and practical considerations
|
RULES: Focus on technical depth and practical considerations
|
||||||
@@ -90,7 +90,7 @@ codex --full-auto exec "
|
|||||||
PURPOSE: Critically review technical plan
|
PURPOSE: Critically review technical plan
|
||||||
TASK: Review the provided plan, identify weaknesses, suggest alternatives, reason about trade-offs
|
TASK: Review the provided plan, identify weaknesses, suggest alternatives, reason about trade-offs
|
||||||
MODE: analysis
|
MODE: analysis
|
||||||
CONTEXT: @{CLAUDE.md} [relevant files]
|
CONTEXT: @CLAUDE.md [relevant files]
|
||||||
INPUT_PLAN: [Output from Gemini's analysis]
|
INPUT_PLAN: [Output from Gemini's analysis]
|
||||||
EXPECTED: Critical review with alternative ideas and risk analysis
|
EXPECTED: Critical review with alternative ideas and risk analysis
|
||||||
RULES: Focus on architectural soundness and implementation feasibility
|
RULES: Focus on architectural soundness and implementation feasibility
|
||||||
|
|||||||
@@ -45,11 +45,11 @@ Auto-approves: file pattern inference, execution, **file modifications**, summar
|
|||||||
|
|
||||||
### Context Inference
|
### Context Inference
|
||||||
|
|
||||||
Auto-selects files based on keywords and technology:
|
Auto-selects files based on keywords and technology (each @ references one pattern):
|
||||||
- "auth" → `@{**/*auth*,**/*user*}`
|
- "auth" → `@**/*auth* @**/*user*`
|
||||||
- "React" → `@{src/**/*.{jsx,tsx}}`
|
- "React" → `@src/**/*.jsx @src/**/*.tsx`
|
||||||
- "api" → `@{**/api/**/*,**/routes/**/*}`
|
- "api" → `@**/api/**/* @**/routes/**/*`
|
||||||
- Always includes: `@{CLAUDE.md,**/*CLAUDE.md}`
|
- Always includes: `@CLAUDE.md @**/*CLAUDE.md`
|
||||||
|
|
||||||
For precise file targeting, use `rg` or MCP tools to discover files first.
|
For precise file targeting, use `rg` or MCP tools to discover files first.
|
||||||
|
|
||||||
@@ -111,11 +111,11 @@ Use `resume --last` when current task extends/relates to previous execution. See
|
|||||||
### Standard Mode (Default)
|
### Standard Mode (Default)
|
||||||
```bash
|
```bash
|
||||||
# Gemini/Qwen: MODE=write with --approval-mode yolo
|
# Gemini/Qwen: MODE=write with --approval-mode yolo
|
||||||
cd . && ~/.claude/scripts/gemini-wrapper --approval-mode yolo -p "
|
cd . && gemini --approval-mode yolo "
|
||||||
PURPOSE: [implementation goal]
|
PURPOSE: [implementation goal]
|
||||||
TASK: [specific implementation]
|
TASK: [specific implementation]
|
||||||
MODE: write
|
MODE: write
|
||||||
CONTEXT: @{CLAUDE.md} [auto-detected files]
|
CONTEXT: @CLAUDE.md [auto-detected files]
|
||||||
EXPECTED: Working implementation with code changes
|
EXPECTED: Working implementation with code changes
|
||||||
RULES: [constraints] | Auto-approve all changes
|
RULES: [constraints] | Auto-approve all changes
|
||||||
"
|
"
|
||||||
|
|||||||
@@ -79,11 +79,11 @@ The agent handles all phases internally.
|
|||||||
## Command Template
|
## Command Template
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd [directory] && ~/.claude/scripts/gemini-wrapper --all-files -p "
|
cd [directory] && gemini -p "
|
||||||
PURPOSE: [bug analysis goal]
|
PURPOSE: [bug analysis goal]
|
||||||
TASK: Systematic bug analysis and fix recommendations
|
TASK: Systematic bug analysis and fix recommendations
|
||||||
MODE: analysis
|
MODE: analysis
|
||||||
CONTEXT: @{CLAUDE.md,**/*CLAUDE.md} [entire codebase in directory]
|
CONTEXT: @CLAUDE.md @**/*CLAUDE.md [entire codebase in directory]
|
||||||
EXPECTED: Root cause analysis, code path tracing, targeted fix suggestions
|
EXPECTED: Root cause analysis, code path tracing, targeted fix suggestions
|
||||||
RULES: $(cat ~/.claude/prompt-templates/bug-fix.md) | Bug: [description]
|
RULES: $(cat ~/.claude/prompt-templates/bug-fix.md) | Bug: [description]
|
||||||
"
|
"
|
||||||
@@ -111,11 +111,11 @@ RULES: $(cat ~/.claude/prompt-templates/bug-fix.md) | Bug: [description]
|
|||||||
|
|
||||||
**Standard Template Example**:
|
**Standard Template Example**:
|
||||||
```bash
|
```bash
|
||||||
cd . && ~/.claude/scripts/gemini-wrapper --all-files -p "
|
cd . && gemini -p "
|
||||||
PURPOSE: Debug authentication null pointer error
|
PURPOSE: Debug authentication null pointer error
|
||||||
TASK: Identify root cause and provide fix recommendations
|
TASK: Identify root cause and provide fix recommendations
|
||||||
MODE: analysis
|
MODE: analysis
|
||||||
CONTEXT: @{CLAUDE.md,**/*CLAUDE.md}
|
CONTEXT: @CLAUDE.md @**/*CLAUDE.md
|
||||||
EXPECTED: Root cause, code path, minimal fix suggestion, impact assessment
|
EXPECTED: Root cause, code path, minimal fix suggestion, impact assessment
|
||||||
RULES: $(cat ~/.claude/prompt-templates/bug-fix.md) | Bug: null pointer in login flow
|
RULES: $(cat ~/.claude/prompt-templates/bug-fix.md) | Bug: null pointer in login flow
|
||||||
"
|
"
|
||||||
@@ -123,11 +123,11 @@ RULES: $(cat ~/.claude/prompt-templates/bug-fix.md) | Bug: null pointer in login
|
|||||||
|
|
||||||
**Directory-Specific**:
|
**Directory-Specific**:
|
||||||
```bash
|
```bash
|
||||||
cd src/auth && ~/.claude/scripts/gemini-wrapper --all-files -p "
|
cd src/auth && gemini -p "
|
||||||
PURPOSE: Fix token validation failure
|
PURPOSE: Fix token validation failure
|
||||||
TASK: Analyze token validation bug in auth module
|
TASK: Analyze token validation bug in auth module
|
||||||
MODE: analysis
|
MODE: analysis
|
||||||
CONTEXT: @{CLAUDE.md,**/*CLAUDE.md}
|
CONTEXT: @CLAUDE.md @**/*CLAUDE.md
|
||||||
EXPECTED: Validation logic analysis, fix recommendation with minimal changes
|
EXPECTED: Validation logic analysis, fix recommendation with minimal changes
|
||||||
RULES: $(cat ~/.claude/prompt-templates/bug-fix.md) | Bug: token validation fails intermittently
|
RULES: $(cat ~/.claude/prompt-templates/bug-fix.md) | Bug: token validation fails intermittently
|
||||||
"
|
"
|
||||||
@@ -161,4 +161,4 @@ mcp__code-index__search_code_advanced(pattern="error|exception", file_pattern="*
|
|||||||
- Command templates and file patterns: see intelligent-tools-strategy.md (loaded in memory)
|
- Command templates and file patterns: see intelligent-tools-strategy.md (loaded in memory)
|
||||||
- Scratchpad directory details: see workflow-architecture.md
|
- Scratchpad directory details: see workflow-architecture.md
|
||||||
- Template path: `~/.claude/prompt-templates/bug-fix.md`
|
- Template path: `~/.claude/prompt-templates/bug-fix.md`
|
||||||
- Always uses `--all-files` for comprehensive codebase context
|
- Uses `@**/*` for in CONTEXT field for comprehensive codebase context
|
||||||
|
|||||||
@@ -82,11 +82,11 @@ The agent handles all phases internally.
|
|||||||
## Command Template
|
## Command Template
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd [directory] && ~/.claude/scripts/gemini-wrapper --all-files -p "
|
cd [directory] && gemini -p "
|
||||||
PURPOSE: [analysis goal]
|
PURPOSE: [analysis goal]
|
||||||
TASK: Systematic code analysis and execution path tracing
|
TASK: Systematic code analysis and execution path tracing
|
||||||
MODE: analysis
|
MODE: analysis
|
||||||
CONTEXT: @{CLAUDE.md,**/*CLAUDE.md} [entire codebase in directory]
|
CONTEXT: @CLAUDE.md @**/*CLAUDE.md [entire codebase in directory]
|
||||||
EXPECTED: Execution trace, call flow diagram, debugging insights
|
EXPECTED: Execution trace, call flow diagram, debugging insights
|
||||||
RULES: $(cat ~/.claude/prompt-templates/code-analysis.md) | Focus on [aspect]
|
RULES: $(cat ~/.claude/prompt-templates/code-analysis.md) | Focus on [aspect]
|
||||||
"
|
"
|
||||||
@@ -114,11 +114,11 @@ RULES: $(cat ~/.claude/prompt-templates/code-analysis.md) | Focus on [aspect]
|
|||||||
|
|
||||||
**Standard Template Example**:
|
**Standard Template Example**:
|
||||||
```bash
|
```bash
|
||||||
cd . && ~/.claude/scripts/gemini-wrapper --all-files -p "
|
cd . && gemini -p "
|
||||||
PURPOSE: Trace authentication execution flow
|
PURPOSE: Trace authentication execution flow
|
||||||
TASK: Analyze complete auth flow from request to response
|
TASK: Analyze complete auth flow from request to response
|
||||||
MODE: analysis
|
MODE: analysis
|
||||||
CONTEXT: @{CLAUDE.md,**/*CLAUDE.md}
|
CONTEXT: @CLAUDE.md @**/*CLAUDE.md
|
||||||
EXPECTED: Step-by-step execution trace with call diagram, variable states
|
EXPECTED: Step-by-step execution trace with call diagram, variable states
|
||||||
RULES: $(cat ~/.claude/prompt-templates/code-analysis.md) | Focus on control flow
|
RULES: $(cat ~/.claude/prompt-templates/code-analysis.md) | Focus on control flow
|
||||||
"
|
"
|
||||||
@@ -126,11 +126,11 @@ RULES: $(cat ~/.claude/prompt-templates/code-analysis.md) | Focus on control flo
|
|||||||
|
|
||||||
**Directory-Specific Analysis**:
|
**Directory-Specific Analysis**:
|
||||||
```bash
|
```bash
|
||||||
cd src/auth && ~/.claude/scripts/gemini-wrapper --all-files -p "
|
cd src/auth && gemini -p "
|
||||||
PURPOSE: Understand JWT token validation logic
|
PURPOSE: Understand JWT token validation logic
|
||||||
TASK: Trace JWT validation from middleware to service layer
|
TASK: Trace JWT validation from middleware to service layer
|
||||||
MODE: analysis
|
MODE: analysis
|
||||||
CONTEXT: @{CLAUDE.md,**/*CLAUDE.md}
|
CONTEXT: @CLAUDE.md @**/*CLAUDE.md
|
||||||
EXPECTED: Validation flow diagram, token lifecycle analysis
|
EXPECTED: Validation flow diagram, token lifecycle analysis
|
||||||
RULES: $(cat ~/.claude/prompt-templates/code-analysis.md) | Focus on security
|
RULES: $(cat ~/.claude/prompt-templates/code-analysis.md) | Focus on security
|
||||||
"
|
"
|
||||||
@@ -167,4 +167,4 @@ mcp__code-index__search_code_advanced(pattern="authenticate|login", file_pattern
|
|||||||
- Command templates and file patterns: see intelligent-tools-strategy.md (loaded in memory)
|
- Command templates and file patterns: see intelligent-tools-strategy.md (loaded in memory)
|
||||||
- Scratchpad directory details: see workflow-architecture.md
|
- Scratchpad directory details: see workflow-architecture.md
|
||||||
- Template path: `~/.claude/prompt-templates/code-analysis.md`
|
- Template path: `~/.claude/prompt-templates/code-analysis.md`
|
||||||
- Always uses `--all-files` for comprehensive code context
|
- Uses `@**/*` for in CONTEXT field for comprehensive code context
|
||||||
|
|||||||
@@ -80,11 +80,11 @@ The agent handles all phases internally.
|
|||||||
## Command Template
|
## Command Template
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd [directory] && ~/.claude/scripts/gemini-wrapper --all-files -p "
|
cd [directory] && gemini -p "
|
||||||
PURPOSE: [planning goal from topic]
|
PURPOSE: [planning goal from topic]
|
||||||
TASK: Comprehensive planning and architecture analysis
|
TASK: Comprehensive planning and architecture analysis
|
||||||
MODE: analysis
|
MODE: analysis
|
||||||
CONTEXT: @{CLAUDE.md,**/*CLAUDE.md} [entire codebase in directory]
|
CONTEXT: @CLAUDE.md @**/*CLAUDE.md [entire codebase in directory]
|
||||||
EXPECTED: Strategic insights, implementation recommendations, key decisions
|
EXPECTED: Strategic insights, implementation recommendations, key decisions
|
||||||
RULES: $(cat ~/.claude/prompt-templates/plan.md) | Focus on [topic area]
|
RULES: $(cat ~/.claude/prompt-templates/plan.md) | Focus on [topic area]
|
||||||
"
|
"
|
||||||
@@ -112,11 +112,11 @@ RULES: $(cat ~/.claude/prompt-templates/plan.md) | Focus on [topic area]
|
|||||||
|
|
||||||
**Standard Template Example**:
|
**Standard Template Example**:
|
||||||
```bash
|
```bash
|
||||||
cd . && ~/.claude/scripts/gemini-wrapper --all-files -p "
|
cd . && gemini -p "
|
||||||
PURPOSE: Design user dashboard architecture
|
PURPOSE: Design user dashboard architecture
|
||||||
TASK: Plan dashboard component structure and data flow
|
TASK: Plan dashboard component structure and data flow
|
||||||
MODE: analysis
|
MODE: analysis
|
||||||
CONTEXT: @{CLAUDE.md,**/*CLAUDE.md}
|
CONTEXT: @CLAUDE.md @**/*CLAUDE.md
|
||||||
EXPECTED: Architecture recommendations, component design, data flow diagram
|
EXPECTED: Architecture recommendations, component design, data flow diagram
|
||||||
RULES: $(cat ~/.claude/prompt-templates/plan.md) | Focus on scalability
|
RULES: $(cat ~/.claude/prompt-templates/plan.md) | Focus on scalability
|
||||||
"
|
"
|
||||||
@@ -124,11 +124,11 @@ RULES: $(cat ~/.claude/prompt-templates/plan.md) | Focus on scalability
|
|||||||
|
|
||||||
**Directory-Specific Planning**:
|
**Directory-Specific Planning**:
|
||||||
```bash
|
```bash
|
||||||
cd src/api && ~/.claude/scripts/gemini-wrapper --all-files -p "
|
cd src/api && gemini -p "
|
||||||
PURPOSE: Plan API refactoring strategy
|
PURPOSE: Plan API refactoring strategy
|
||||||
TASK: Analyze current API structure and recommend improvements
|
TASK: Analyze current API structure and recommend improvements
|
||||||
MODE: analysis
|
MODE: analysis
|
||||||
CONTEXT: @{CLAUDE.md,**/*CLAUDE.md}
|
CONTEXT: @CLAUDE.md @**/*CLAUDE.md
|
||||||
EXPECTED: Refactoring roadmap, breaking change analysis, migration plan
|
EXPECTED: Refactoring roadmap, breaking change analysis, migration plan
|
||||||
RULES: $(cat ~/.claude/prompt-templates/plan.md) | Maintain backward compatibility
|
RULES: $(cat ~/.claude/prompt-templates/plan.md) | Maintain backward compatibility
|
||||||
"
|
"
|
||||||
@@ -165,4 +165,4 @@ rg "architecture|design" --files-with-matches
|
|||||||
- Command templates and file patterns: see intelligent-tools-strategy.md (loaded in memory)
|
- Command templates and file patterns: see intelligent-tools-strategy.md (loaded in memory)
|
||||||
- Scratchpad directory details: see workflow-architecture.md
|
- Scratchpad directory details: see workflow-architecture.md
|
||||||
- Template path: `~/.claude/prompt-templates/plan.md`
|
- Template path: `~/.claude/prompt-templates/plan.md`
|
||||||
- Always uses `--all-files` for comprehensive project context
|
- Uses `@**/*` for in CONTEXT field for comprehensive project context
|
||||||
|
|||||||
@@ -129,9 +129,11 @@ EOF
|
|||||||
|
|
||||||
### Phase 2: Analyze Structure
|
### Phase 2: Analyze Structure
|
||||||
|
|
||||||
|
**Smart filter**: Auto-detect and skip tests/build/config/vendor based on project tech stack (Node.js/Python/Go/Rust/etc).
|
||||||
|
|
||||||
#### Step 1: Discover and Classify Folders
|
#### Step 1: Discover and Classify Folders
|
||||||
```bash
|
```bash
|
||||||
# Run analysis pipeline (module discovery + folder classification)
|
# Run analysis pipeline (module discovery + folder classification + smart filtering)
|
||||||
bash(~/.claude/scripts/get_modules_by_depth.sh | ~/.claude/scripts/classify-folders.sh > .workflow/WFS-docs-20240120/.process/folder-analysis.txt)
|
bash(~/.claude/scripts/get_modules_by_depth.sh | ~/.claude/scripts/classify-folders.sh > .workflow/WFS-docs-20240120/.process/folder-analysis.txt)
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -142,6 +144,12 @@ bash(~/.claude/scripts/get_modules_by_depth.sh | ~/.claude/scripts/classify-fold
|
|||||||
./src/utils|navigation|code:0|dirs:4
|
./src/utils|navigation|code:0|dirs:4
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Auto-skipped**:
|
||||||
|
- Tests: `**/test/**`, `**/*.test.*`, `**/__tests__/**`
|
||||||
|
- Build: `**/node_modules/**`, `**/dist/**`, `**/build/**`
|
||||||
|
- Config: Root-level config files (package.json, tsconfig.json, etc)
|
||||||
|
- Vendor: Language-specific dependency directories
|
||||||
|
|
||||||
#### Step 2: Extract Top-Level Directories
|
#### Step 2: Extract Top-Level Directories
|
||||||
```bash
|
```bash
|
||||||
# Group folders by top-level directory
|
# Group folders by top-level directory
|
||||||
@@ -394,7 +402,7 @@ bash(
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"step": "analyze_module_tree",
|
"step": "analyze_module_tree",
|
||||||
"command": "bash(cd src/modules && ~/.claude/scripts/gemini-wrapper -p \"PURPOSE: Analyze module structure\\nTASK: Generate documentation outline\\nMODE: analysis\\nCONTEXT: @{**/*} [target_folders]\\nEXPECTED: Structure outline\\nRULES: Analyze only\")",
|
"command": "bash(cd src/modules && gemini \"PURPOSE: Analyze module structure\\nTASK: Generate documentation outline\\nMODE: analysis\\nCONTEXT: @**/* [target_folders]\\nEXPECTED: Structure outline\\nRULES: Analyze only\")",
|
||||||
"output_to": "tree_outline",
|
"output_to": "tree_outline",
|
||||||
"note": "CLI for analysis only"
|
"note": "CLI for analysis only"
|
||||||
}
|
}
|
||||||
@@ -490,7 +498,7 @@ bash(
|
|||||||
"CLI writes documentation to .workflow/docs/src/modules/",
|
"CLI writes documentation to .workflow/docs/src/modules/",
|
||||||
"Maintains directory structure mirroring"
|
"Maintains directory structure mirroring"
|
||||||
],
|
],
|
||||||
"command": "bash(cd src/modules && ~/.claude/scripts/gemini-wrapper --approval-mode yolo -p \"PURPOSE: Generate module docs\\nTASK: Create documentation files in .workflow/docs/src/modules/\\nMODE: write\\nCONTEXT: @{**/*} [target_folders] [existing_module_docs]\\nEXPECTED: API.md and README.md in .workflow/docs/src/modules/\\nRULES: Mirror source structure, generate complete docs\")",
|
"command": "bash(cd src/modules && gemini --approval-mode yolo \"PURPOSE: Generate module docs\\nTASK: Create documentation files in .workflow/docs/src/modules/\\nMODE: write\\nCONTEXT: @**/* [target_folders] [existing_module_docs]\\nEXPECTED: API.md and README.md in .workflow/docs/src/modules/\\nRULES: Mirror source structure, generate complete docs\")",
|
||||||
"depends_on": [1],
|
"depends_on": [1],
|
||||||
"output": "generated_docs"
|
"output": "generated_docs"
|
||||||
}
|
}
|
||||||
@@ -533,7 +541,7 @@ bash(
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"step": "analyze_project",
|
"step": "analyze_project",
|
||||||
"command": "bash(~/.claude/scripts/gemini-wrapper -p \"PURPOSE: Analyze project structure\\nTASK: Extract overview from modules\\nMODE: analysis\\nCONTEXT: [all_module_docs]\\nEXPECTED: Project outline\")",
|
"command": "bash(gemini \"PURPOSE: Analyze project structure\\nTASK: Extract overview from modules\\nMODE: analysis\\nCONTEXT: [all_module_docs]\\nEXPECTED: Project outline\")",
|
||||||
"output_to": "project_outline"
|
"output_to": "project_outline"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -583,7 +591,7 @@ bash(
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"step": "analyze_architecture_and_examples",
|
"step": "analyze_architecture_and_examples",
|
||||||
"command": "bash(~/.claude/scripts/gemini-wrapper -p \"PURPOSE: Analyze system architecture and generate examples\\nTASK: Synthesize architectural overview and usage patterns\\nMODE: analysis\\nCONTEXT: [all_docs]\\nEXPECTED: Architecture outline + Examples outline\")",
|
"command": "bash(gemini \"PURPOSE: Analyze system architecture and generate examples\\nTASK: Synthesize architectural overview and usage patterns\\nMODE: analysis\\nCONTEXT: [all_docs]\\nEXPECTED: Architecture outline + Examples outline\")",
|
||||||
"output_to": "arch_examples_outline"
|
"output_to": "arch_examples_outline"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -645,7 +653,7 @@ bash(
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"step": "analyze_api",
|
"step": "analyze_api",
|
||||||
"command": "bash(~/.claude/scripts/gemini-wrapper -p \"PURPOSE: Document HTTP API\\nTASK: Analyze API endpoints\\nMODE: analysis\\nCONTEXT: @{src/api/**/*} [endpoint_discovery]\\nEXPECTED: API outline\")",
|
"command": "bash(gemini \"PURPOSE: Document HTTP API\\nTASK: Analyze API endpoints\\nMODE: analysis\\nCONTEXT: @src/api/**/* [endpoint_discovery]\\nEXPECTED: API outline\")",
|
||||||
"output_to": "api_outline"
|
"output_to": "api_outline"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
240
.claude/commands/memory/load.md
Normal file
240
.claude/commands/memory/load.md
Normal file
@@ -0,0 +1,240 @@
|
|||||||
|
---
|
||||||
|
name: load
|
||||||
|
description: Load project memory by delegating to agent, returns structured core content package for subsequent operations
|
||||||
|
argument-hint: "[--tool gemini|qwen] \"task context description\""
|
||||||
|
allowed-tools: Task(*), Bash(*)
|
||||||
|
examples:
|
||||||
|
- /memory:load "在当前前端基础上开发用户认证功能"
|
||||||
|
- /memory:load --tool qwen -p "重构支付模块API"
|
||||||
|
---
|
||||||
|
|
||||||
|
# Memory Load Command (/memory:load)
|
||||||
|
|
||||||
|
## 1. Overview
|
||||||
|
|
||||||
|
The `memory:load` command **delegates to a general-purpose agent** to analyze the project and return a structured "Core Content Pack". This pack is loaded into the main thread's memory, providing essential context for subsequent agent operations while minimizing token consumption.
|
||||||
|
|
||||||
|
**Core Philosophy**:
|
||||||
|
- **Agent-Driven**: Fully delegates execution to general-purpose agent
|
||||||
|
- **Read-Only Analysis**: Does not modify code, only extracts context
|
||||||
|
- **Structured Output**: Returns standardized JSON content package
|
||||||
|
- **Memory Optimization**: Package loaded directly into main thread memory
|
||||||
|
- **Token Efficiency**: CLI analysis executed within agent to save tokens
|
||||||
|
|
||||||
|
## 2. Parameters
|
||||||
|
|
||||||
|
- `"task context description"` (Required): Task description to guide context extraction
|
||||||
|
- Example: "在当前前端基础上开发用户认证功能"
|
||||||
|
- Example: "重构支付模块API"
|
||||||
|
- Example: "修复数据库查询性能问题"
|
||||||
|
|
||||||
|
- `--tool <gemini|qwen>` (Optional): Specify CLI tool for agent to use (default: gemini)
|
||||||
|
- gemini: Large context window, suitable for complex project analysis
|
||||||
|
- qwen: Alternative to Gemini with similar capabilities
|
||||||
|
|
||||||
|
## 3. Agent-Driven Execution Flow
|
||||||
|
|
||||||
|
The command fully delegates to **general-purpose agent**, which autonomously:
|
||||||
|
|
||||||
|
1. **Analyzes Project Structure**: Executes `get_modules_by_depth.sh` to understand architecture
|
||||||
|
2. **Loads Documentation**: Reads CLAUDE.md, README.md and other key docs
|
||||||
|
3. **Extracts Keywords**: Derives core keywords from task description
|
||||||
|
4. **Discovers Files**: Uses MCP code-index or rg/find to locate relevant files
|
||||||
|
5. **CLI Deep Analysis**: Executes Gemini/Qwen CLI for deep context analysis
|
||||||
|
6. **Generates Content Package**: Returns structured JSON core content package
|
||||||
|
|
||||||
|
## 4. Core Content Package Structure
|
||||||
|
|
||||||
|
**Output Format** - Loaded into main thread memory for subsequent use:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"task_context": "在当前前端基础上开发用户认证功能",
|
||||||
|
"keywords": ["前端", "用户", "认证", "auth", "login"],
|
||||||
|
"project_summary": {
|
||||||
|
"architecture": "TypeScript + React frontend with Vite build system",
|
||||||
|
"tech_stack": ["React", "TypeScript", "Vite", "TailwindCSS"],
|
||||||
|
"key_patterns": [
|
||||||
|
"State management via Context API",
|
||||||
|
"Functional components with Hooks pattern",
|
||||||
|
"API calls encapsulated in custom hooks"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"relevant_files": [
|
||||||
|
{
|
||||||
|
"path": "src/components/Auth/LoginForm.tsx",
|
||||||
|
"relevance": "Existing login form component",
|
||||||
|
"priority": "high"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "src/contexts/AuthContext.tsx",
|
||||||
|
"relevance": "Authentication state management context",
|
||||||
|
"priority": "high"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "CLAUDE.md",
|
||||||
|
"relevance": "Project development standards",
|
||||||
|
"priority": "high"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"integration_points": [
|
||||||
|
"Must integrate with existing AuthContext",
|
||||||
|
"Follow component organization pattern: src/components/[Feature]/",
|
||||||
|
"API calls should use src/hooks/useApi.ts wrapper"
|
||||||
|
],
|
||||||
|
"constraints": [
|
||||||
|
"Maintain backward compatibility",
|
||||||
|
"Follow TypeScript strict mode",
|
||||||
|
"Use existing UI component library"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## 5. Agent Invocation
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
Task(
|
||||||
|
subagent_type="general-purpose",
|
||||||
|
description="Load project memory: ${task_description}",
|
||||||
|
prompt=`
|
||||||
|
## Mission: Load Project Memory Context
|
||||||
|
|
||||||
|
**Task Context**: "${task_description}"
|
||||||
|
**Mode**: Read-only analysis
|
||||||
|
**Tool**: ${tool || 'gemini'}
|
||||||
|
|
||||||
|
## Execution Steps
|
||||||
|
|
||||||
|
### Step 1: Foundation Analysis
|
||||||
|
|
||||||
|
1. **Project Structure**
|
||||||
|
\`\`\`bash
|
||||||
|
bash(~/.claude/scripts/get_modules_by_depth.sh)
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
|
2. **Core Documentation**
|
||||||
|
\`\`\`javascript
|
||||||
|
Read(CLAUDE.md)
|
||||||
|
Read(README.md)
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
|
### Step 2: Keyword Extraction & File Discovery
|
||||||
|
|
||||||
|
1. Extract core keywords from task description
|
||||||
|
2. Discover relevant files using MCP code-index or rg:
|
||||||
|
\`\`\`javascript
|
||||||
|
// Prefer MCP tools
|
||||||
|
mcp__code-index__find_files(pattern="*{keyword}*")
|
||||||
|
mcp__code-index__search_code_advanced(pattern="{keyword}", context_lines=2)
|
||||||
|
|
||||||
|
// Fallback: use rg
|
||||||
|
bash(rg -l "{keyword}" --type ts --type md)
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
|
### Step 3: Deep Analysis via CLI
|
||||||
|
|
||||||
|
Execute Gemini/Qwen CLI for deep analysis (saves main thread tokens):
|
||||||
|
|
||||||
|
\`\`\`bash
|
||||||
|
cd . && ~/.claude/scripts/${tool}-wrapper -p "
|
||||||
|
PURPOSE: Extract project core context for task: ${task_description}
|
||||||
|
TASK: Analyze project architecture, tech stack, key patterns, relevant files
|
||||||
|
MODE: analysis
|
||||||
|
CONTEXT: @CLAUDE.md,README.md @${discovered_files}
|
||||||
|
EXPECTED: Structured project summary and integration point analysis
|
||||||
|
RULES:
|
||||||
|
- Focus on task-relevant core information
|
||||||
|
- Identify key architecture patterns and technical constraints
|
||||||
|
- Extract integration points and development standards
|
||||||
|
- Output concise, structured format
|
||||||
|
"
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
|
### Step 4: Generate Core Content Package
|
||||||
|
|
||||||
|
Generate structured JSON content package (format shown above)
|
||||||
|
|
||||||
|
**Required Fields**:
|
||||||
|
- task_context: Original task description
|
||||||
|
- keywords: Extracted keyword array
|
||||||
|
- project_summary: Architecture, tech stack, key patterns
|
||||||
|
- relevant_files: File list with path, relevance, priority
|
||||||
|
- integration_points: Integration guidance
|
||||||
|
- constraints: Development constraints
|
||||||
|
|
||||||
|
### Step 5: Return Content Package
|
||||||
|
|
||||||
|
Return JSON content package as final output for main thread to load into memory.
|
||||||
|
|
||||||
|
## Quality Checklist
|
||||||
|
|
||||||
|
Before returning:
|
||||||
|
- [ ] Valid JSON format
|
||||||
|
- [ ] All required fields complete
|
||||||
|
- [ ] relevant_files contains 3-10 files minimum
|
||||||
|
- [ ] project_summary accurately reflects architecture
|
||||||
|
- [ ] integration_points clearly specify integration paths
|
||||||
|
- [ ] keywords accurately extracted (3-8 keywords)
|
||||||
|
- [ ] Content concise, avoiding redundancy (< 5KB total)
|
||||||
|
|
||||||
|
`
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
## 6. Usage Examples
|
||||||
|
|
||||||
|
### Example 1: Load Context for New Feature
|
||||||
|
|
||||||
|
```bash
|
||||||
|
/memory:load "在当前前端基础上开发用户认证功能"
|
||||||
|
```
|
||||||
|
|
||||||
|
**Agent Execution**:
|
||||||
|
1. Analyzes project structure (`get_modules_by_depth.sh`)
|
||||||
|
2. Reads CLAUDE.md, README.md
|
||||||
|
3. Extracts keywords: ["前端", "用户", "认证", "auth"]
|
||||||
|
4. Uses MCP to search relevant files
|
||||||
|
5. Executes Gemini CLI for deep analysis
|
||||||
|
6. Returns core content package
|
||||||
|
|
||||||
|
**Returned Package** (loaded into memory):
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"task_context": "在当前前端基础上开发用户认证功能",
|
||||||
|
"keywords": ["前端", "认证", "auth", "login"],
|
||||||
|
"project_summary": { ... },
|
||||||
|
"relevant_files": [ ... ],
|
||||||
|
"integration_points": [ ... ],
|
||||||
|
"constraints": [ ... ]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Example 2: Using Qwen Tool
|
||||||
|
|
||||||
|
```bash
|
||||||
|
/memory:load --tool qwen -p "重构支付模块API"
|
||||||
|
```
|
||||||
|
|
||||||
|
Agent uses Qwen CLI for analysis, returns same structured package.
|
||||||
|
|
||||||
|
### Example 3: Bug Fix Context
|
||||||
|
|
||||||
|
```bash
|
||||||
|
/memory:load "修复登录验证错误"
|
||||||
|
```
|
||||||
|
|
||||||
|
Returns core context related to login validation, including test files and validation logic.
|
||||||
|
|
||||||
|
### Memory Persistence
|
||||||
|
|
||||||
|
- **Session-Scoped**: Content package valid for current session
|
||||||
|
- **Subsequent Reference**: All subsequent agents/commands can access
|
||||||
|
- **Reload Required**: New sessions need to re-execute /memory:load
|
||||||
|
|
||||||
|
## 8. Notes
|
||||||
|
|
||||||
|
- **Read-Only**: Does not modify any code, pure analysis
|
||||||
|
- **Token Optimization**: CLI analysis executed within agent, saves main thread tokens
|
||||||
|
- **Memory Loading**: Returned JSON loaded directly into main thread memory
|
||||||
|
- **Subsequent Use**: Other commands/agents can reference this package for development
|
||||||
|
- **Session-Level**: Content package valid for current session
|
||||||
329
.claude/commands/memory/update-full.md
Normal file
329
.claude/commands/memory/update-full.md
Normal file
@@ -0,0 +1,329 @@
|
|||||||
|
---
|
||||||
|
name: update-full
|
||||||
|
description: Complete project-wide CLAUDE.md documentation update with agent-based parallel execution and tool fallback
|
||||||
|
argument-hint: "[--tool gemini|qwen|codex] [--path <directory>]"
|
||||||
|
---
|
||||||
|
|
||||||
|
# Full Documentation Update (/memory:update-full)
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
Orchestrates project-wide CLAUDE.md updates using batched agent execution with automatic tool fallback and 3-layer architecture support.
|
||||||
|
|
||||||
|
**Parameters**:
|
||||||
|
- `--tool <gemini|qwen|codex>`: Primary tool (default: gemini)
|
||||||
|
- `--path <directory>`: Target specific directory (default: entire project)
|
||||||
|
|
||||||
|
**Execution Flow**: Discovery → Plan Presentation → Execution → Safety Verification
|
||||||
|
|
||||||
|
## 3-Layer Architecture & Auto-Strategy Selection
|
||||||
|
|
||||||
|
### Layer Definition & Strategy Assignment
|
||||||
|
|
||||||
|
| Layer | Depth | Strategy | Purpose | Context Pattern |
|
||||||
|
|-------|-------|----------|---------|----------------|
|
||||||
|
| **Layer 3** (Deepest) | ≥3 | `multi-layer` | Handle unstructured files, generate docs for all subdirectories | `@**/*` (all files) |
|
||||||
|
| **Layer 2** (Middle) | 1-2 | `single-layer` | Aggregate from children + current code | `@*/CLAUDE.md @*.{ts,tsx,js,...}` |
|
||||||
|
| **Layer 1** (Top) | 0 | `single-layer` | Aggregate from children + current code | `@*/CLAUDE.md @*.{ts,tsx,js,...}` |
|
||||||
|
|
||||||
|
**Update Direction**: Layer 3 → Layer 2 → Layer 1 (bottom-up dependency flow)
|
||||||
|
|
||||||
|
**Strategy Auto-Selection**: Strategies are automatically determined by directory depth - no user configuration needed.
|
||||||
|
|
||||||
|
### Strategy Details
|
||||||
|
|
||||||
|
#### Multi-Layer Strategy (Layer 3 Only)
|
||||||
|
- **Use Case**: Deepest directories with unstructured file layouts
|
||||||
|
- **Behavior**: Generates CLAUDE.md for current directory AND each subdirectory containing files
|
||||||
|
- **Context**: All files in current directory tree (`@**/*`)
|
||||||
|
- **Benefits**: Creates foundation documentation for upper layers to reference
|
||||||
|
|
||||||
|
#### Single-Layer Strategy (Layers 1-2)
|
||||||
|
- **Use Case**: Upper layers that aggregate from existing documentation
|
||||||
|
- **Behavior**: Generates CLAUDE.md only for current directory
|
||||||
|
- **Context**: Direct children CLAUDE.md files + current directory code files
|
||||||
|
- **Benefits**: Minimal context consumption, clear layer separation
|
||||||
|
|
||||||
|
### Example Flow
|
||||||
|
```
|
||||||
|
src/auth/handlers/ (depth 3) → MULTI-LAYER STRATEGY
|
||||||
|
CONTEXT: @**/* (all files in handlers/ and subdirs)
|
||||||
|
GENERATES: ./CLAUDE.md + CLAUDE.md in each subdir with files
|
||||||
|
↓
|
||||||
|
src/auth/ (depth 2) → SINGLE-LAYER STRATEGY
|
||||||
|
CONTEXT: @*/CLAUDE.md @*.ts (handlers/CLAUDE.md + current code)
|
||||||
|
GENERATES: ./CLAUDE.md only
|
||||||
|
↓
|
||||||
|
src/ (depth 1) → SINGLE-LAYER STRATEGY
|
||||||
|
CONTEXT: @*/CLAUDE.md (auth/CLAUDE.md, utils/CLAUDE.md)
|
||||||
|
GENERATES: ./CLAUDE.md only
|
||||||
|
↓
|
||||||
|
./ (depth 0) → SINGLE-LAYER STRATEGY
|
||||||
|
CONTEXT: @*/CLAUDE.md (src/CLAUDE.md, tests/CLAUDE.md)
|
||||||
|
GENERATES: ./CLAUDE.md only
|
||||||
|
```
|
||||||
|
|
||||||
|
## Core Execution Rules
|
||||||
|
|
||||||
|
1. **Analyze First**: Git cache + module discovery before updates
|
||||||
|
2. **Wait for Approval**: Present plan, no execution without user confirmation
|
||||||
|
3. **Execution Strategy**:
|
||||||
|
- **<20 modules**: Direct parallel execution (max 4 concurrent per layer)
|
||||||
|
- **≥20 modules**: Agent batch processing (4 modules/agent, 73% overhead reduction)
|
||||||
|
4. **Tool Fallback**: Auto-retry with fallback tools on failure
|
||||||
|
5. **Layer Sequential**: Process layers 3→2→1 (bottom-up), parallel batches within layer
|
||||||
|
6. **Safety Check**: Verify only CLAUDE.md files modified
|
||||||
|
7. **Layer-based Grouping**: Group modules by LAYER (not depth) for execution
|
||||||
|
|
||||||
|
## Tool Fallback Hierarchy
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
--tool gemini → [gemini, qwen, codex] // default
|
||||||
|
--tool qwen → [qwen, gemini, codex]
|
||||||
|
--tool codex → [codex, gemini, qwen]
|
||||||
|
```
|
||||||
|
|
||||||
|
**Trigger**: Non-zero exit code from update script
|
||||||
|
|
||||||
|
| Tool | Best For | Fallback To |
|
||||||
|
|--------|--------------------------------|----------------|
|
||||||
|
| gemini | Documentation, patterns | qwen → codex |
|
||||||
|
| qwen | Architecture, system design | gemini → codex |
|
||||||
|
| codex | Implementation, code quality | gemini → qwen |
|
||||||
|
|
||||||
|
## Execution Phases
|
||||||
|
|
||||||
|
### Phase 1: Discovery & Analysis
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Cache git changes
|
||||||
|
bash(git add -A 2>/dev/null || true)
|
||||||
|
|
||||||
|
# Get module structure
|
||||||
|
bash(~/.claude/scripts/get_modules_by_depth.sh list)
|
||||||
|
# OR with --path
|
||||||
|
bash(cd <target-path> && ~/.claude/scripts/get_modules_by_depth.sh list)
|
||||||
|
```
|
||||||
|
|
||||||
|
**Parse output** `depth:N|path:<PATH>|...` to extract module paths and count.
|
||||||
|
|
||||||
|
**Smart filter**: Auto-detect and skip tests/build/config/docs based on project tech stack.
|
||||||
|
|
||||||
|
### Phase 2: Plan Presentation
|
||||||
|
|
||||||
|
**For <20 modules**:
|
||||||
|
```
|
||||||
|
Update Plan:
|
||||||
|
Tool: gemini (fallback: qwen → codex)
|
||||||
|
Total: 7 modules
|
||||||
|
Execution: Direct parallel (< 20 modules threshold)
|
||||||
|
|
||||||
|
Will update:
|
||||||
|
- ./core/interfaces (12 files) - depth 2 [Layer 2] - single-layer strategy
|
||||||
|
- ./core (22 files) - depth 1 [Layer 2] - single-layer strategy
|
||||||
|
- ./models (9 files) - depth 1 [Layer 2] - single-layer strategy
|
||||||
|
- ./utils (12 files) - depth 1 [Layer 2] - single-layer strategy
|
||||||
|
- . (5 files) - depth 0 [Layer 1] - single-layer strategy
|
||||||
|
|
||||||
|
Context Strategy (Auto-Selected):
|
||||||
|
- Layer 2 (depth 1-2): @*/CLAUDE.md + current code files
|
||||||
|
- Layer 1 (depth 0): @*/CLAUDE.md + current code files
|
||||||
|
|
||||||
|
Auto-skipped: ./tests, __pycache__, setup.py (15 paths)
|
||||||
|
Execution order: Layer 2 → Layer 1
|
||||||
|
Estimated time: ~5-10 minutes
|
||||||
|
|
||||||
|
Confirm execution? (y/n)
|
||||||
|
```
|
||||||
|
|
||||||
|
**For ≥20 modules**:
|
||||||
|
```
|
||||||
|
Update Plan:
|
||||||
|
Tool: gemini (fallback: qwen → codex)
|
||||||
|
Total: 31 modules
|
||||||
|
Execution: Agent batch processing (4 modules/agent)
|
||||||
|
|
||||||
|
Will update:
|
||||||
|
- ./src/features/auth (12 files) - depth 3 [Layer 3] - multi-layer strategy
|
||||||
|
- ./.claude/commands/cli (6 files) - depth 3 [Layer 3] - multi-layer strategy
|
||||||
|
- ./src/utils (8 files) - depth 2 [Layer 2] - single-layer strategy
|
||||||
|
...
|
||||||
|
|
||||||
|
Context Strategy (Auto-Selected):
|
||||||
|
- Layer 3 (depth ≥3): @**/* (all files)
|
||||||
|
- Layer 2 (depth 1-2): @*/CLAUDE.md + current code files
|
||||||
|
- Layer 1 (depth 0): @*/CLAUDE.md + current code files
|
||||||
|
|
||||||
|
Agent allocation (by LAYER):
|
||||||
|
- Layer 3 (14 modules, depth ≥3): 4 agents [4, 4, 4, 2]
|
||||||
|
- Layer 2 (15 modules, depth 1-2): 4 agents [4, 4, 4, 3]
|
||||||
|
- Layer 1 (2 modules, depth 0): 1 agent [2]
|
||||||
|
|
||||||
|
Estimated time: ~15-25 minutes
|
||||||
|
|
||||||
|
Confirm execution? (y/n)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Phase 3A: Direct Execution (<20 modules)
|
||||||
|
|
||||||
|
**Strategy**: Parallel execution within layer (max 4 concurrent), no agent overhead.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
// Group modules by LAYER (not depth)
|
||||||
|
let modules_by_layer = group_by_layer(module_list);
|
||||||
|
let tool_order = construct_tool_order(primary_tool);
|
||||||
|
|
||||||
|
// Process by LAYER (3 → 2 → 1), not by depth
|
||||||
|
for (let layer of [3, 2, 1]) {
|
||||||
|
if (modules_by_layer[layer].length === 0) continue;
|
||||||
|
|
||||||
|
let batches = batch_modules(modules_by_layer[layer], 4);
|
||||||
|
|
||||||
|
for (let batch of batches) {
|
||||||
|
let parallel_tasks = batch.map(module => {
|
||||||
|
return async () => {
|
||||||
|
// Auto-determine strategy based on depth
|
||||||
|
let strategy = module.depth >= 3 ? "multi-layer" : "single-layer";
|
||||||
|
|
||||||
|
for (let tool of tool_order) {
|
||||||
|
let exit_code = bash(`cd ${module.path} && ~/.claude/scripts/update_module_claude.sh "${strategy}" "." "${tool}"`);
|
||||||
|
if (exit_code === 0) {
|
||||||
|
report(`✅ ${module.path} (Layer ${layer}) updated with ${tool}`);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
report(`❌ FAILED: ${module.path} (Layer ${layer}) failed all tools`);
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
await Promise.all(parallel_tasks.map(task => task()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Phase 3B: Agent Batch Execution (≥20 modules)
|
||||||
|
|
||||||
|
**Strategy**: Batch modules into groups of 4, spawn memory-bridge agents per batch.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
// Group modules by LAYER and batch within each layer
|
||||||
|
let modules_by_layer = group_by_layer(module_list);
|
||||||
|
let tool_order = construct_tool_order(primary_tool);
|
||||||
|
|
||||||
|
for (let layer of [3, 2, 1]) {
|
||||||
|
if (modules_by_layer[layer].length === 0) continue;
|
||||||
|
|
||||||
|
let batches = batch_modules(modules_by_layer[layer], 4);
|
||||||
|
let worker_tasks = [];
|
||||||
|
|
||||||
|
for (let batch of batches) {
|
||||||
|
worker_tasks.push(
|
||||||
|
Task(
|
||||||
|
subagent_type="memory-bridge",
|
||||||
|
description=`Update ${batch.length} modules in Layer ${layer}`,
|
||||||
|
prompt=generate_batch_worker_prompt(batch, tool_order, layer)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
await parallel_execute(worker_tasks);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Batch Worker Prompt Template**:
|
||||||
|
```
|
||||||
|
PURPOSE: Update CLAUDE.md for assigned modules with tool fallback
|
||||||
|
|
||||||
|
TASK: Update documentation for assigned modules using specified strategies.
|
||||||
|
|
||||||
|
MODULES:
|
||||||
|
{{module_path_1}} (strategy: {{strategy_1}})
|
||||||
|
{{module_path_2}} (strategy: {{strategy_2}})
|
||||||
|
...
|
||||||
|
|
||||||
|
TOOLS (try in order): {{tool_1}}, {{tool_2}}, {{tool_3}}
|
||||||
|
|
||||||
|
EXECUTION SCRIPT: ~/.claude/scripts/update_module_claude.sh
|
||||||
|
- Accepts strategy parameter: multi-layer | single-layer
|
||||||
|
- Tool execution via CLI wrapper (gemini/qwen/codex)
|
||||||
|
|
||||||
|
EXECUTION FLOW (for each module):
|
||||||
|
1. Tool fallback loop (exit on first success):
|
||||||
|
for tool in {{tool_1}} {{tool_2}} {{tool_3}}; do
|
||||||
|
bash(cd "{{module_path}}" && ~/.claude/scripts/update_module_claude.sh "{{strategy}}" "." "${tool}")
|
||||||
|
exit_code=$?
|
||||||
|
|
||||||
|
if [ $exit_code -eq 0 ]; then
|
||||||
|
report "✅ {{module_path}} updated with $tool"
|
||||||
|
break
|
||||||
|
else
|
||||||
|
report "⚠️ {{module_path}} failed with $tool, trying next..."
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
2. Handle complete failure (all tools failed):
|
||||||
|
if [ $exit_code -ne 0 ]; then
|
||||||
|
report "❌ FAILED: {{module_path}} - all tools exhausted"
|
||||||
|
# Continue to next module (do not abort batch)
|
||||||
|
fi
|
||||||
|
|
||||||
|
FAILURE HANDLING:
|
||||||
|
- Module-level isolation: One module's failure does not affect others
|
||||||
|
- Exit code detection: Non-zero exit code triggers next tool
|
||||||
|
- Exhaustion reporting: Log modules where all tools failed
|
||||||
|
- Batch continuation: Always process remaining modules
|
||||||
|
|
||||||
|
REPORTING FORMAT:
|
||||||
|
Per-module status:
|
||||||
|
✅ path/to/module updated with {tool}
|
||||||
|
⚠️ path/to/module failed with {tool}, trying next...
|
||||||
|
❌ FAILED: path/to/module - all tools exhausted
|
||||||
|
```
|
||||||
|
### Phase 4: Safety Verification
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Check only CLAUDE.md modified
|
||||||
|
bash(git diff --cached --name-only | grep -v "CLAUDE.md" || echo "Only CLAUDE.md files modified")
|
||||||
|
|
||||||
|
# Display status
|
||||||
|
bash(git status --short)
|
||||||
|
```
|
||||||
|
|
||||||
|
**Result Summary**:
|
||||||
|
```
|
||||||
|
Update Summary:
|
||||||
|
Total: 31 | Success: 29 | Failed: 2
|
||||||
|
Tool usage: gemini: 25, qwen: 4, codex: 0
|
||||||
|
Failed: path1, path2
|
||||||
|
```
|
||||||
|
|
||||||
|
## Error Handling
|
||||||
|
|
||||||
|
**Batch Worker**: Tool fallback per module, batch isolation, clear status reporting
|
||||||
|
**Coordinator**: Invalid path abort, user decline handling, safety check with auto-revert
|
||||||
|
**Fallback Triggers**: Non-zero exit code, script timeout, unexpected output
|
||||||
|
|
||||||
|
## Usage Examples
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Full project update (auto-strategy selection)
|
||||||
|
/memory:update-full
|
||||||
|
|
||||||
|
# Target specific directory
|
||||||
|
/memory:update-full --path .claude
|
||||||
|
/memory:update-full --path src/features/auth
|
||||||
|
|
||||||
|
# Use specific tool
|
||||||
|
/memory:update-full --tool qwen
|
||||||
|
/memory:update-full --path .claude --tool qwen
|
||||||
|
```
|
||||||
|
|
||||||
|
## Key Advantages
|
||||||
|
|
||||||
|
- **Efficiency**: 30 modules → 8 agents (73% reduction from sequential)
|
||||||
|
- **Resilience**: 3-tier tool fallback per module
|
||||||
|
- **Performance**: Parallel batches, no concurrency limits
|
||||||
|
- **Observability**: Per-module tool usage, batch-level metrics
|
||||||
|
- **Automation**: Zero configuration - strategy auto-selected by directory depth
|
||||||
@@ -1,330 +0,0 @@
|
|||||||
---
|
|
||||||
name: update-full
|
|
||||||
description: Complete project-wide CLAUDE.md documentation update
|
|
||||||
argument-hint: "[--tool gemini|qwen|codex] [--path <directory>]"
|
|
||||||
---
|
|
||||||
|
|
||||||
# Full Documentation Update (/memory:update-full)
|
|
||||||
|
|
||||||
## Coordinator Role
|
|
||||||
|
|
||||||
**This command orchestrates project-wide CLAUDE.md updates** using depth-parallel execution strategy with intelligent complexity detection.
|
|
||||||
|
|
||||||
**Execution Model**:
|
|
||||||
|
|
||||||
1. **Initial Analysis**: Cache git changes, discover module structure
|
|
||||||
2. **Complexity Detection**: Analyze module count, determine strategy
|
|
||||||
3. **Plan Presentation**: Show user exactly what will be updated
|
|
||||||
4. **Depth-Parallel Execution**: Update modules by depth (highest to lowest)
|
|
||||||
5. **Safety Verification**: Ensure only CLAUDE.md files modified
|
|
||||||
|
|
||||||
**Tool Selection**:
|
|
||||||
- `--tool gemini` (default): Documentation generation, pattern recognition
|
|
||||||
- `--tool qwen`: Architecture analysis, system design docs
|
|
||||||
- `--tool codex`: Implementation validation, code quality analysis
|
|
||||||
|
|
||||||
**Path Parameter**:
|
|
||||||
- `--path <directory>` (optional): Target specific directory for updates
|
|
||||||
- If not specified: Updates entire project from current directory
|
|
||||||
- If specified: Changes to target directory before discovery
|
|
||||||
|
|
||||||
## Core Rules
|
|
||||||
|
|
||||||
1. **Analyze First**: Run git cache and module discovery before any updates
|
|
||||||
2. **Scope Control**: Use --path to target specific directories, default is entire project
|
|
||||||
3. **Wait for Approval**: Present plan, no execution without user confirmation
|
|
||||||
4. **Depth-Parallel**: Same depth runs parallel (max 4 jobs), different depths sequential
|
|
||||||
5. **Safety Check**: Verify only CLAUDE.md files modified, revert if source files touched
|
|
||||||
6. **Independent Commands**: Each update is a separate bash() call
|
|
||||||
7. **No Background Bash Tool**: Never use `run_in_background` parameter in bash() calls; use shell `&` for parallelism
|
|
||||||
|
|
||||||
## Execution Workflow
|
|
||||||
|
|
||||||
### Phase 1: Discovery & Analysis
|
|
||||||
|
|
||||||
**Cache git changes:**
|
|
||||||
```bash
|
|
||||||
bash(git add -A 2>/dev/null || true)
|
|
||||||
```
|
|
||||||
|
|
||||||
**Get module structure:**
|
|
||||||
|
|
||||||
*If no --path parameter:*
|
|
||||||
```bash
|
|
||||||
bash(~/.claude/scripts/get_modules_by_depth.sh list)
|
|
||||||
```
|
|
||||||
|
|
||||||
*If --path parameter specified:*
|
|
||||||
```bash
|
|
||||||
bash(cd <target-path> && ~/.claude/scripts/get_modules_by_depth.sh list)
|
|
||||||
```
|
|
||||||
|
|
||||||
**Example with path:**
|
|
||||||
```bash
|
|
||||||
# Update only .claude directory
|
|
||||||
bash(cd .claude && ~/.claude/scripts/get_modules_by_depth.sh list)
|
|
||||||
|
|
||||||
# Update specific feature directory
|
|
||||||
bash(cd src/features/auth && ~/.claude/scripts/get_modules_by_depth.sh list)
|
|
||||||
```
|
|
||||||
|
|
||||||
**Parse Output**:
|
|
||||||
- Extract module paths from `depth:N|path:<PATH>|...` format
|
|
||||||
- Count total modules
|
|
||||||
- Identify which modules have/need CLAUDE.md
|
|
||||||
|
|
||||||
**Example output:**
|
|
||||||
```
|
|
||||||
depth:5|path:./.claude/workflows/cli-templates/prompts/analysis|files:5|has_claude:no
|
|
||||||
depth:4|path:./.claude/commands/cli/mode|files:3|has_claude:no
|
|
||||||
depth:3|path:./.claude/commands/cli|files:6|has_claude:no
|
|
||||||
depth:0|path:.|files:14|has_claude:yes
|
|
||||||
```
|
|
||||||
|
|
||||||
**Validation**:
|
|
||||||
- If --path specified, directory exists and is accessible
|
|
||||||
- Module list contains depth and path information
|
|
||||||
- At least one module exists
|
|
||||||
- All paths are relative to target directory (if --path used)
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
### Phase 2: Plan Presentation
|
|
||||||
|
|
||||||
**Decision Logic**:
|
|
||||||
- **Simple projects (≤20 modules)**: Present plan to user, wait for approval
|
|
||||||
- **Complex projects (>20 modules)**: Delegate to memory-bridge agent
|
|
||||||
|
|
||||||
**Plan format:**
|
|
||||||
```
|
|
||||||
📋 Update Plan:
|
|
||||||
Tool: gemini
|
|
||||||
Total modules: 31
|
|
||||||
|
|
||||||
NEW CLAUDE.md files (30):
|
|
||||||
- ./.claude/workflows/cli-templates/prompts/analysis/CLAUDE.md
|
|
||||||
- ./.claude/commands/cli/mode/CLAUDE.md
|
|
||||||
- ... (28 more)
|
|
||||||
|
|
||||||
UPDATE existing CLAUDE.md files (1):
|
|
||||||
- ./CLAUDE.md
|
|
||||||
|
|
||||||
⚠️ Confirm execution? (y/n)
|
|
||||||
```
|
|
||||||
|
|
||||||
**User Confirmation Required**: No execution without explicit approval
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
### Phase 3: Depth-Parallel Execution
|
|
||||||
|
|
||||||
**Pattern**: Process highest depth first, parallel within depth, sequential across depths.
|
|
||||||
|
|
||||||
**Command structure:**
|
|
||||||
```bash
|
|
||||||
bash(cd <module-path> && ~/.claude/scripts/update_module_claude.sh "." "full" "<tool>" &)
|
|
||||||
```
|
|
||||||
|
|
||||||
**Example - Depth 5 (8 modules):**
|
|
||||||
```bash
|
|
||||||
bash(cd ./.claude/workflows/cli-templates/prompts/analysis && ~/.claude/scripts/update_module_claude.sh "." "full" "gemini" &)
|
|
||||||
```
|
|
||||||
```bash
|
|
||||||
bash(cd ./.claude/workflows/cli-templates/prompts/development && ~/.claude/scripts/update_module_claude.sh "." "full" "gemini" &)
|
|
||||||
```
|
|
||||||
```bash
|
|
||||||
bash(cd ./.claude/workflows/cli-templates/prompts/documentation && ~/.claude/scripts/update_module_claude.sh "." "full" "gemini" &)
|
|
||||||
```
|
|
||||||
```bash
|
|
||||||
bash(cd ./.claude/workflows/cli-templates/prompts/implementation && ~/.claude/scripts/update_module_claude.sh "." "full" "gemini" &)
|
|
||||||
```
|
|
||||||
|
|
||||||
*Wait for depth 5 completion...*
|
|
||||||
|
|
||||||
**Example - Depth 4 (7 modules):**
|
|
||||||
```bash
|
|
||||||
bash(cd ./.claude/commands/cli/mode && ~/.claude/scripts/update_module_claude.sh "." "full" "gemini" &)
|
|
||||||
```
|
|
||||||
```bash
|
|
||||||
bash(cd ./.claude/commands/workflow/brainstorm && ~/.claude/scripts/update_module_claude.sh "." "full" "gemini" &)
|
|
||||||
```
|
|
||||||
|
|
||||||
*Continue for remaining depths (3 → 2 → 1 → 0)...*
|
|
||||||
|
|
||||||
**Execution Rules**:
|
|
||||||
- Each command is separate bash() call
|
|
||||||
- Up to 4 concurrent jobs per depth
|
|
||||||
- Wait for all jobs in current depth before proceeding
|
|
||||||
- Extract path from `depth:N|path:<PATH>|...` format
|
|
||||||
- All paths relative to target directory (current dir or --path value)
|
|
||||||
|
|
||||||
**Path Context**:
|
|
||||||
- Without --path: Paths relative to current directory
|
|
||||||
- With --path: Paths relative to specified target directory
|
|
||||||
- Module discovery runs in target directory context
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
### Phase 4: Safety Verification
|
|
||||||
|
|
||||||
**Check modified files:**
|
|
||||||
```bash
|
|
||||||
bash(git diff --cached --name-only | grep -v "CLAUDE.md" || echo "✅ Only CLAUDE.md files modified")
|
|
||||||
```
|
|
||||||
|
|
||||||
**Expected output:**
|
|
||||||
```
|
|
||||||
✅ Only CLAUDE.md files modified
|
|
||||||
```
|
|
||||||
|
|
||||||
**If non-CLAUDE.md files detected:**
|
|
||||||
```
|
|
||||||
⚠️ Warning: Non-CLAUDE.md files were modified
|
|
||||||
Modified files: src/index.ts, package.json
|
|
||||||
→ Run: git restore --staged .
|
|
||||||
```
|
|
||||||
|
|
||||||
**Display final status:**
|
|
||||||
```bash
|
|
||||||
bash(git status --short)
|
|
||||||
```
|
|
||||||
|
|
||||||
**Example output:**
|
|
||||||
```
|
|
||||||
A .claude/workflows/cli-templates/prompts/analysis/CLAUDE.md
|
|
||||||
A .claude/commands/cli/mode/CLAUDE.md
|
|
||||||
M CLAUDE.md
|
|
||||||
... (30 more files)
|
|
||||||
```
|
|
||||||
|
|
||||||
## Command Pattern Reference
|
|
||||||
|
|
||||||
**Single module update:**
|
|
||||||
```bash
|
|
||||||
bash(cd <module-path> && ~/.claude/scripts/update_module_claude.sh "." "full" "<tool>" &)
|
|
||||||
```
|
|
||||||
|
|
||||||
**Components**:
|
|
||||||
- `cd <module-path>` - Navigate to module (from `path:` field)
|
|
||||||
- `&&` - Ensure cd succeeds
|
|
||||||
- `update_module_claude.sh` - Update script
|
|
||||||
- `"."` - Current directory
|
|
||||||
- `"full"` - Full update mode
|
|
||||||
- `"<tool>"` - gemini/qwen/codex
|
|
||||||
- `&` - Background execution
|
|
||||||
|
|
||||||
**Path extraction:**
|
|
||||||
```bash
|
|
||||||
# From: depth:5|path:./src/auth|files:10|has_claude:no
|
|
||||||
# Extract: ./src/auth
|
|
||||||
# Command: bash(cd ./src/auth && ~/.claude/scripts/update_module_claude.sh "." "full" "gemini" &)
|
|
||||||
```
|
|
||||||
|
|
||||||
## Complex Projects Strategy
|
|
||||||
|
|
||||||
For projects >20 modules, delegate to memory-bridge agent:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
Task(
|
|
||||||
subagent_type="memory-bridge",
|
|
||||||
description="Complex project full update",
|
|
||||||
prompt=`
|
|
||||||
CONTEXT:
|
|
||||||
- Total modules: ${module_count}
|
|
||||||
- Tool: ${tool}
|
|
||||||
- Mode: full
|
|
||||||
|
|
||||||
MODULE LIST:
|
|
||||||
${modules_output}
|
|
||||||
|
|
||||||
REQUIREMENTS:
|
|
||||||
1. Use TodoWrite to track each depth level
|
|
||||||
2. Process depths N→0 sequentially, max 4 parallel per depth
|
|
||||||
3. Command: cd "<path>" && update_module_claude.sh "." "full" "${tool}" &
|
|
||||||
4. Extract path from "depth:N|path:<PATH>|..." format
|
|
||||||
5. Verify all modules processed
|
|
||||||
6. Run safety check
|
|
||||||
7. Display git status
|
|
||||||
`
|
|
||||||
)
|
|
||||||
```
|
|
||||||
|
|
||||||
## Error Handling
|
|
||||||
|
|
||||||
- **Invalid path parameter**: Report error if --path directory doesn't exist, abort execution
|
|
||||||
- **Module discovery failure**: Report error, abort execution
|
|
||||||
- **User declines approval**: Abort execution, no changes made
|
|
||||||
- **Safety check failure**: Automatic staging revert, report modified files
|
|
||||||
- **Update script failure**: Report failed modules, continue with remaining
|
|
||||||
|
|
||||||
## Coordinator Checklist
|
|
||||||
|
|
||||||
✅ Parse `--tool` parameter (default: gemini)
|
|
||||||
✅ Parse `--path` parameter (optional, default: current directory)
|
|
||||||
✅ Execute git cache in current directory
|
|
||||||
✅ Execute module discovery (with cd if --path specified)
|
|
||||||
✅ Parse module list, count total modules
|
|
||||||
✅ Determine strategy based on module count (≤20 vs >20)
|
|
||||||
✅ Present plan with exact file paths
|
|
||||||
✅ **Wait for user confirmation** (simple projects only)
|
|
||||||
✅ Organize modules by depth
|
|
||||||
✅ For each depth (highest to lowest):
|
|
||||||
- Launch up to 5 parallel updates
|
|
||||||
- Wait for depth completion
|
|
||||||
- Proceed to next depth
|
|
||||||
✅ Run safety check after all updates
|
|
||||||
✅ Display git status
|
|
||||||
✅ Report completion summary
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Tool Parameter Reference
|
|
||||||
|
|
||||||
**Gemini** (default):
|
|
||||||
- Best for: Documentation generation, pattern recognition, architecture review
|
|
||||||
- Context window: Large, handles complex codebases
|
|
||||||
- Output style: Comprehensive, detailed explanations
|
|
||||||
|
|
||||||
**Qwen**:
|
|
||||||
- Best for: Architecture analysis, system design documentation
|
|
||||||
- Context window: Large, similar to Gemini
|
|
||||||
- Output style: Structured, systematic analysis
|
|
||||||
|
|
||||||
**Codex**:
|
|
||||||
- Best for: Implementation validation, code quality analysis
|
|
||||||
- Capabilities: Mathematical reasoning, autonomous development
|
|
||||||
- Output style: Technical, implementation-focused
|
|
||||||
|
|
||||||
## Path Parameter Reference
|
|
||||||
|
|
||||||
**Use Cases**:
|
|
||||||
|
|
||||||
**Update configuration directory only:**
|
|
||||||
```bash
|
|
||||||
/memory:update-full --path .claude
|
|
||||||
```
|
|
||||||
- Updates only .claude directory and subdirectories
|
|
||||||
- Useful after workflow or command modifications
|
|
||||||
- Faster than full project update
|
|
||||||
|
|
||||||
**Update specific feature module:**
|
|
||||||
```bash
|
|
||||||
/memory:update-full --path src/features/auth
|
|
||||||
```
|
|
||||||
- Updates authentication feature and sub-modules
|
|
||||||
- Ideal for feature-specific documentation
|
|
||||||
- Isolates scope for targeted updates
|
|
||||||
|
|
||||||
**Update nested structure:**
|
|
||||||
```bash
|
|
||||||
/memory:update-full --path .claude/workflows/cli-templates
|
|
||||||
```
|
|
||||||
- Updates deeply nested directory tree
|
|
||||||
- Maintains relative path structure in output
|
|
||||||
- All module paths relative to specified directory
|
|
||||||
|
|
||||||
**Best Practices**:
|
|
||||||
- Use `--path` when working on specific features/modules
|
|
||||||
- Omit `--path` for project-wide architectural changes
|
|
||||||
- Combine with `--tool` for specialized documentation needs
|
|
||||||
- Verify directory exists before execution (automatic validation)
|
|
||||||
@@ -1,306 +0,0 @@
|
|||||||
---
|
|
||||||
name: update-related
|
|
||||||
description: Context-aware CLAUDE.md documentation updates based on recent changes
|
|
||||||
argument-hint: "[--tool gemini|qwen|codex]"
|
|
||||||
---
|
|
||||||
|
|
||||||
# Related Documentation Update (/memory:update-related)
|
|
||||||
|
|
||||||
## Coordinator Role
|
|
||||||
|
|
||||||
**This command orchestrates context-aware CLAUDE.md updates** for modules affected by recent changes using intelligent change detection.
|
|
||||||
|
|
||||||
**Execution Model**:
|
|
||||||
|
|
||||||
1. **Change Detection**: Analyze git changes to identify affected modules
|
|
||||||
2. **Complexity Analysis**: Evaluate change count and determine strategy
|
|
||||||
3. **Plan Presentation**: Show user which modules need updates
|
|
||||||
4. **Depth-Parallel Execution**: Update affected modules by depth (highest to lowest)
|
|
||||||
5. **Safety Verification**: Ensure only CLAUDE.md files modified
|
|
||||||
|
|
||||||
**Tool Selection**:
|
|
||||||
- `--tool gemini` (default): Documentation generation, pattern recognition
|
|
||||||
- `--tool qwen`: Architecture analysis, system design docs
|
|
||||||
- `--tool codex`: Implementation validation, code quality analysis
|
|
||||||
|
|
||||||
## Core Rules
|
|
||||||
|
|
||||||
1. **Detect Changes First**: Use git diff to identify affected modules before updates
|
|
||||||
2. **Wait for Approval**: Present plan, no execution without user confirmation
|
|
||||||
3. **Related Mode**: Update only changed modules and their parent contexts
|
|
||||||
4. **Depth-Parallel**: Same depth runs parallel (max 4 jobs), different depths sequential
|
|
||||||
5. **Safety Check**: Verify only CLAUDE.md files modified, revert if source files touched
|
|
||||||
6. **No Background Bash Tool**: Never use `run_in_background` parameter in bash() calls; use shell `&` for parallelism
|
|
||||||
|
|
||||||
## Execution Workflow
|
|
||||||
|
|
||||||
### Phase 1: Change Detection & Analysis
|
|
||||||
|
|
||||||
**Refresh code index:**
|
|
||||||
```bash
|
|
||||||
bash(mcp__code-index__refresh_index)
|
|
||||||
```
|
|
||||||
|
|
||||||
**Detect changed modules:**
|
|
||||||
```bash
|
|
||||||
bash(~/.claude/scripts/detect_changed_modules.sh list)
|
|
||||||
```
|
|
||||||
|
|
||||||
**Cache git changes:**
|
|
||||||
```bash
|
|
||||||
bash(git add -A 2>/dev/null || true)
|
|
||||||
```
|
|
||||||
|
|
||||||
**Parse Output**:
|
|
||||||
- Extract changed module paths from `depth:N|path:<PATH>|...` format
|
|
||||||
- Count affected modules
|
|
||||||
- Identify which modules have/need CLAUDE.md updates
|
|
||||||
|
|
||||||
**Example output:**
|
|
||||||
```
|
|
||||||
depth:3|path:./src/api/auth|files:5|types:[ts]|has_claude:no|change:new
|
|
||||||
depth:2|path:./src/api|files:12|types:[ts]|has_claude:yes|change:modified
|
|
||||||
depth:1|path:./src|files:8|types:[ts]|has_claude:yes|change:parent
|
|
||||||
depth:0|path:.|files:14|has_claude:yes|change:parent
|
|
||||||
```
|
|
||||||
|
|
||||||
**Fallback behavior**:
|
|
||||||
- If no git changes detected, use recent modules (first 10 by depth)
|
|
||||||
|
|
||||||
**Validation**:
|
|
||||||
- Changed module list contains valid paths
|
|
||||||
- At least one affected module exists
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
### Phase 2: Plan Presentation
|
|
||||||
|
|
||||||
**Decision Logic**:
|
|
||||||
- **Simple changes (≤15 modules)**: Present plan to user, wait for approval
|
|
||||||
- **Complex changes (>15 modules)**: Delegate to memory-bridge agent
|
|
||||||
|
|
||||||
**Plan format:**
|
|
||||||
```
|
|
||||||
📋 Related Update Plan:
|
|
||||||
Tool: gemini
|
|
||||||
Changed modules: 4
|
|
||||||
|
|
||||||
NEW CLAUDE.md files (1):
|
|
||||||
- ./src/api/auth/CLAUDE.md [new module]
|
|
||||||
|
|
||||||
UPDATE existing CLAUDE.md files (3):
|
|
||||||
- ./src/api/CLAUDE.md [parent of changed auth/]
|
|
||||||
- ./src/CLAUDE.md [parent context]
|
|
||||||
- ./CLAUDE.md [root level]
|
|
||||||
|
|
||||||
⚠️ Confirm execution? (y/n)
|
|
||||||
```
|
|
||||||
|
|
||||||
**User Confirmation Required**: No execution without explicit approval
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
### Phase 3: Depth-Parallel Execution
|
|
||||||
|
|
||||||
**Pattern**: Process highest depth first, parallel within depth, sequential across depths.
|
|
||||||
|
|
||||||
**Command structure:**
|
|
||||||
```bash
|
|
||||||
bash(cd <module-path> && ~/.claude/scripts/update_module_claude.sh "." "related" "<tool>" &)
|
|
||||||
```
|
|
||||||
|
|
||||||
**Example - Depth 3 (new module):**
|
|
||||||
```bash
|
|
||||||
bash(cd ./src/api/auth && ~/.claude/scripts/update_module_claude.sh "." "related" "gemini" &)
|
|
||||||
```
|
|
||||||
|
|
||||||
*Wait for depth 3 completion...*
|
|
||||||
|
|
||||||
**Example - Depth 2 (modified parent):**
|
|
||||||
```bash
|
|
||||||
bash(cd ./src/api && ~/.claude/scripts/update_module_claude.sh "." "related" "gemini" &)
|
|
||||||
```
|
|
||||||
|
|
||||||
*Wait for depth 2 completion...*
|
|
||||||
|
|
||||||
**Example - Depth 1 & 0 (parent contexts):**
|
|
||||||
```bash
|
|
||||||
bash(cd ./src && ~/.claude/scripts/update_module_claude.sh "." "related" "gemini" &)
|
|
||||||
```
|
|
||||||
```bash
|
|
||||||
bash(cd . && ~/.claude/scripts/update_module_claude.sh "." "related" "gemini" &)
|
|
||||||
```
|
|
||||||
|
|
||||||
*Wait for all depths completion...*
|
|
||||||
|
|
||||||
**Execution Rules**:
|
|
||||||
- Each command is separate bash() call
|
|
||||||
- Up to 4 concurrent jobs per depth
|
|
||||||
- Wait for all jobs in current depth before proceeding
|
|
||||||
- Use "related" mode (not "full") for context-aware updates
|
|
||||||
- Extract path from `depth:N|path:<PATH>|...` format
|
|
||||||
|
|
||||||
**Related Mode Behavior**:
|
|
||||||
- Updates module based on recent git changes
|
|
||||||
- Includes parent context for better documentation coherence
|
|
||||||
- More efficient than full updates for iterative development
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
### Phase 4: Safety Verification
|
|
||||||
|
|
||||||
**Check modified files:**
|
|
||||||
```bash
|
|
||||||
bash(git diff --cached --name-only | grep -v "CLAUDE.md" || echo "✅ Only CLAUDE.md files modified")
|
|
||||||
```
|
|
||||||
|
|
||||||
**Expected output:**
|
|
||||||
```
|
|
||||||
✅ Only CLAUDE.md files modified
|
|
||||||
```
|
|
||||||
|
|
||||||
**If non-CLAUDE.md files detected:**
|
|
||||||
```
|
|
||||||
⚠️ Warning: Non-CLAUDE.md files were modified
|
|
||||||
Modified files: src/api/auth/index.ts, package.json
|
|
||||||
→ Run: git restore --staged .
|
|
||||||
```
|
|
||||||
|
|
||||||
**Display final statistics:**
|
|
||||||
```bash
|
|
||||||
bash(git diff --stat)
|
|
||||||
```
|
|
||||||
|
|
||||||
**Example output:**
|
|
||||||
```
|
|
||||||
.claude/workflows/cli-templates/prompts/analysis/CLAUDE.md | 45 +++++++++++++++++++++
|
|
||||||
src/api/CLAUDE.md | 23 +++++++++--
|
|
||||||
src/CLAUDE.md | 12 ++++--
|
|
||||||
CLAUDE.md | 8 ++--
|
|
||||||
4 files changed, 82 insertions(+), 6 deletions(-)
|
|
||||||
```
|
|
||||||
|
|
||||||
## Command Pattern Reference
|
|
||||||
|
|
||||||
**Single module update:**
|
|
||||||
```bash
|
|
||||||
bash(cd <module-path> && ~/.claude/scripts/update_module_claude.sh "." "related" "<tool>" &)
|
|
||||||
```
|
|
||||||
|
|
||||||
**Components**:
|
|
||||||
- `cd <module-path>` - Navigate to module (from `path:` field)
|
|
||||||
- `&&` - Ensure cd succeeds
|
|
||||||
- `update_module_claude.sh` - Update script
|
|
||||||
- `"."` - Current directory
|
|
||||||
- `"related"` - Related mode (context-aware, change-based)
|
|
||||||
- `"<tool>"` - gemini/qwen/codex
|
|
||||||
- `&` - Background execution
|
|
||||||
|
|
||||||
**Path extraction:**
|
|
||||||
```bash
|
|
||||||
# From: depth:3|path:./src/api/auth|files:5|change:new|has_claude:no
|
|
||||||
# Extract: ./src/api/auth
|
|
||||||
# Command: bash(cd ./src/api/auth && ~/.claude/scripts/update_module_claude.sh "." "related" "gemini" &)
|
|
||||||
```
|
|
||||||
|
|
||||||
**Mode comparison:**
|
|
||||||
- `"full"` - Complete module documentation regeneration
|
|
||||||
- `"related"` - Context-aware update based on recent changes (faster)
|
|
||||||
|
|
||||||
## Complex Changes Strategy
|
|
||||||
|
|
||||||
For changes affecting >15 modules, delegate to memory-bridge agent:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
Task(
|
|
||||||
subagent_type="memory-bridge",
|
|
||||||
description="Complex project related update",
|
|
||||||
prompt=`
|
|
||||||
CONTEXT:
|
|
||||||
- Total modules: ${change_count}
|
|
||||||
- Tool: ${tool}
|
|
||||||
- Mode: related
|
|
||||||
|
|
||||||
MODULE LIST:
|
|
||||||
${changed_modules_output}
|
|
||||||
|
|
||||||
REQUIREMENTS:
|
|
||||||
1. Use TodoWrite to track each depth level
|
|
||||||
2. Process depths N→0 sequentially, max 4 parallel per depth
|
|
||||||
3. Command: cd "<path>" && update_module_claude.sh "." "related" "${tool}" &
|
|
||||||
4. Extract path from "depth:N|path:<PATH>|..." format
|
|
||||||
5. Verify all ${change_count} modules processed
|
|
||||||
6. Run safety check
|
|
||||||
7. Display git diff --stat
|
|
||||||
`
|
|
||||||
)
|
|
||||||
```
|
|
||||||
|
|
||||||
## Error Handling
|
|
||||||
|
|
||||||
- **No changes detected**: Use fallback mode (recent 10 modules)
|
|
||||||
- **Change detection failure**: Report error, abort execution
|
|
||||||
- **User declines approval**: Abort execution, no changes made
|
|
||||||
- **Safety check failure**: Automatic staging revert, report modified files
|
|
||||||
- **Update script failure**: Report failed modules, continue with remaining
|
|
||||||
|
|
||||||
## Coordinator Checklist
|
|
||||||
|
|
||||||
✅ Parse `--tool` parameter (default: gemini)
|
|
||||||
✅ Refresh code index for accurate change detection
|
|
||||||
✅ Detect changed modules via detect_changed_modules.sh
|
|
||||||
✅ Cache git changes to protect current state
|
|
||||||
✅ Parse changed module list, count affected modules
|
|
||||||
✅ Apply fallback if no changes detected (recent 10 modules)
|
|
||||||
✅ Determine strategy based on change count (≤15 vs >15)
|
|
||||||
✅ Present plan with exact file paths and change types
|
|
||||||
✅ **Wait for user confirmation** (simple changes only)
|
|
||||||
✅ Organize modules by depth
|
|
||||||
✅ For each depth (highest to lowest):
|
|
||||||
- Launch up to 4 parallel updates with "related" mode
|
|
||||||
- Wait for depth completion
|
|
||||||
- Proceed to next depth
|
|
||||||
✅ Run safety check after all updates
|
|
||||||
✅ Display git diff statistics
|
|
||||||
✅ Report completion summary
|
|
||||||
|
|
||||||
## Usage Examples
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Daily development update (default: gemini)
|
|
||||||
/memory:update-related
|
|
||||||
|
|
||||||
# After feature work with specific tool
|
|
||||||
/memory:update-related --tool qwen
|
|
||||||
|
|
||||||
# Code quality review after implementation
|
|
||||||
/memory:update-related --tool codex
|
|
||||||
```
|
|
||||||
|
|
||||||
## Tool Parameter Reference
|
|
||||||
|
|
||||||
**Gemini** (default):
|
|
||||||
- Best for: Documentation generation, pattern recognition
|
|
||||||
- Use case: Daily development updates, feature documentation
|
|
||||||
- Output style: Comprehensive, contextual explanations
|
|
||||||
|
|
||||||
**Qwen**:
|
|
||||||
- Best for: Architecture analysis, system design
|
|
||||||
- Use case: Structural changes, API design updates
|
|
||||||
- Output style: Structured, systematic documentation
|
|
||||||
|
|
||||||
**Codex**:
|
|
||||||
- Best for: Implementation validation, code quality
|
|
||||||
- Use case: After implementation, refactoring work
|
|
||||||
- Output style: Technical, implementation-focused
|
|
||||||
|
|
||||||
## Comparison with Full Update
|
|
||||||
|
|
||||||
| Aspect | Related Update | Full Update |
|
|
||||||
|--------|----------------|-------------|
|
|
||||||
| **Scope** | Changed modules only | All project modules |
|
|
||||||
| **Speed** | Fast (minutes) | Slower (10-30 min) |
|
|
||||||
| **Use case** | Daily development | Major refactoring |
|
|
||||||
| **Mode** | `"related"` | `"full"` |
|
|
||||||
| **Trigger** | After commits | After major changes |
|
|
||||||
| **Complexity threshold** | ≤15 modules | ≤20 modules |
|
|
||||||
352
.claude/commands/memory/update-related.md
Normal file
352
.claude/commands/memory/update-related.md
Normal file
@@ -0,0 +1,352 @@
|
|||||||
|
---
|
||||||
|
name: update-related
|
||||||
|
description: Context-aware CLAUDE.md documentation updates based on recent changes with agent-based execution and tool fallback
|
||||||
|
argument-hint: "[--tool gemini|qwen|codex]"
|
||||||
|
---
|
||||||
|
|
||||||
|
# Related Documentation Update (/memory:update-related)
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
Orchestrates context-aware CLAUDE.md updates for changed modules using batched agent execution with automatic tool fallback (gemini→qwen→codex).
|
||||||
|
|
||||||
|
**Parameters**:
|
||||||
|
- `--tool <gemini|qwen|codex>`: Primary tool (default: gemini)
|
||||||
|
|
||||||
|
**Execution Flow**:
|
||||||
|
1. Change Detection → 2. Plan Presentation → 3. Batched Agent Execution → 4. Safety Verification
|
||||||
|
|
||||||
|
## Core Rules
|
||||||
|
|
||||||
|
1. **Detect Changes First**: Use git diff to identify affected modules
|
||||||
|
2. **Wait for Approval**: Present plan, no execution without user confirmation
|
||||||
|
3. **Execution Strategy**:
|
||||||
|
- <15 modules: Direct parallel execution (max 4 concurrent per depth, no agent overhead)
|
||||||
|
- ≥15 modules: Agent batch processing (4 modules/agent, 73% overhead reduction)
|
||||||
|
4. **Tool Fallback**: Auto-retry with fallback tools on failure
|
||||||
|
5. **Depth Sequential**: Process depths N→0, parallel batches within depth (both modes)
|
||||||
|
6. **Related Mode**: Update only changed modules and their parent contexts
|
||||||
|
|
||||||
|
## Tool Fallback Hierarchy
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
--tool gemini → [gemini, qwen, codex] // default
|
||||||
|
--tool qwen → [qwen, gemini, codex]
|
||||||
|
--tool codex → [codex, gemini, qwen]
|
||||||
|
```
|
||||||
|
|
||||||
|
**Trigger**: Non-zero exit code from update script
|
||||||
|
|
||||||
|
## Phase 1: Change Detection & Analysis
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Refresh code index
|
||||||
|
bash(mcp__code-index__refresh_index)
|
||||||
|
|
||||||
|
# Detect changed modules
|
||||||
|
bash(~/.claude/scripts/detect_changed_modules.sh list)
|
||||||
|
|
||||||
|
# Cache git changes
|
||||||
|
bash(git add -A 2>/dev/null || true)
|
||||||
|
```
|
||||||
|
|
||||||
|
**Parse output** `depth:N|path:<PATH>|change:<TYPE>` to extract affected modules.
|
||||||
|
|
||||||
|
**Smart filter**: Auto-detect and skip tests/build/config/docs based on project tech stack (Node.js/Python/Go/Rust/etc).
|
||||||
|
|
||||||
|
**Fallback**: If no changes detected, use recent modules (first 10 by depth).
|
||||||
|
|
||||||
|
## Phase 2: Plan Presentation
|
||||||
|
|
||||||
|
**Present filtered plan**:
|
||||||
|
```
|
||||||
|
Related Update Plan:
|
||||||
|
Tool: gemini (fallback: qwen → codex)
|
||||||
|
Changed: 4 modules | Batching: 4 modules/agent
|
||||||
|
|
||||||
|
Will update:
|
||||||
|
- ./src/api/auth (5 files) [new module]
|
||||||
|
- ./src/api (12 files) [parent of changed auth/]
|
||||||
|
- ./src (8 files) [parent context]
|
||||||
|
- . (14 files) [root level]
|
||||||
|
|
||||||
|
Auto-skipped (12 paths):
|
||||||
|
- Tests: ./src/api/auth.test.ts (8 paths)
|
||||||
|
- Config: tsconfig.json (3 paths)
|
||||||
|
- Other: node_modules (1 path)
|
||||||
|
|
||||||
|
Agent allocation:
|
||||||
|
- Depth 3 (1 module): 1 agent [1]
|
||||||
|
- Depth 2 (1 module): 1 agent [1]
|
||||||
|
- Depth 1 (1 module): 1 agent [1]
|
||||||
|
- Depth 0 (1 module): 1 agent [1]
|
||||||
|
|
||||||
|
Confirm execution? (y/n)
|
||||||
|
```
|
||||||
|
|
||||||
|
**Decision logic**:
|
||||||
|
- User confirms "y": Proceed with execution
|
||||||
|
- User declines "n": Abort, no changes
|
||||||
|
- <15 modules: Direct execution
|
||||||
|
- ≥15 modules: Agent batch execution
|
||||||
|
|
||||||
|
## Phase 3A: Direct Execution (<15 modules)
|
||||||
|
|
||||||
|
**Strategy**: Parallel execution within depth (max 4 concurrent), no agent overhead, tool fallback per module.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
let modules_by_depth = group_by_depth(changed_modules);
|
||||||
|
let tool_order = construct_tool_order(primary_tool);
|
||||||
|
|
||||||
|
for (let depth of sorted_depths.reverse()) { // N → 0
|
||||||
|
let modules = modules_by_depth[depth];
|
||||||
|
let batches = batch_modules(modules, 4); // Split into groups of 4
|
||||||
|
|
||||||
|
for (let batch of batches) {
|
||||||
|
// Execute batch in parallel (max 4 concurrent)
|
||||||
|
let parallel_tasks = batch.map(module => {
|
||||||
|
return async () => {
|
||||||
|
let success = false;
|
||||||
|
for (let tool of tool_order) {
|
||||||
|
let exit_code = bash(cd ${module.path} && ~/.claude/scripts/update_module_claude.sh "single-layer" "." "${tool}");
|
||||||
|
if (exit_code === 0) {
|
||||||
|
report("${module.path} updated with ${tool}");
|
||||||
|
success = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!success) {
|
||||||
|
report("FAILED: ${module.path} failed all tools");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
await Promise.all(parallel_tasks.map(task => task())); // Run batch in parallel
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Benefits**:
|
||||||
|
- No agent startup overhead
|
||||||
|
- Parallel execution within depth (max 4 concurrent)
|
||||||
|
- Tool fallback still applies per module
|
||||||
|
- Faster for small changesets (<15 modules)
|
||||||
|
- Same batching strategy as Phase 3B but without agent layer
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Phase 3B: Agent Batch Execution (≥15 modules)
|
||||||
|
|
||||||
|
### Batching Strategy
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
// Batch modules into groups of 4
|
||||||
|
function batch_modules(modules, batch_size = 4) {
|
||||||
|
let batches = [];
|
||||||
|
for (let i = 0; i < modules.length; i += batch_size) {
|
||||||
|
batches.push(modules.slice(i, i + batch_size));
|
||||||
|
}
|
||||||
|
return batches;
|
||||||
|
}
|
||||||
|
// Examples: 10→[4,4,2] | 8→[4,4] | 3→[3]
|
||||||
|
```
|
||||||
|
|
||||||
|
### Coordinator Orchestration
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
let modules_by_depth = group_by_depth(changed_modules);
|
||||||
|
let tool_order = construct_tool_order(primary_tool);
|
||||||
|
|
||||||
|
for (let depth of sorted_depths.reverse()) { // N → 0
|
||||||
|
let batches = batch_modules(modules_by_depth[depth], 4);
|
||||||
|
let worker_tasks = [];
|
||||||
|
|
||||||
|
for (let batch of batches) {
|
||||||
|
worker_tasks.push(
|
||||||
|
Task(
|
||||||
|
subagent_type="memory-bridge",
|
||||||
|
description=`Update ${batch.length} modules at depth ${depth}`,
|
||||||
|
prompt=generate_batch_worker_prompt(batch, tool_order, "related")
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
await parallel_execute(worker_tasks); // Batches run in parallel
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Batch Worker Prompt Template
|
||||||
|
|
||||||
|
```
|
||||||
|
PURPOSE: Update CLAUDE.md for assigned modules with tool fallback (related mode)
|
||||||
|
|
||||||
|
TASK:
|
||||||
|
Update documentation for the following modules based on recent changes. For each module, try tools in order until success.
|
||||||
|
|
||||||
|
MODULES:
|
||||||
|
{{module_path_1}}
|
||||||
|
{{module_path_2}}
|
||||||
|
{{module_path_3}}
|
||||||
|
{{module_path_4}}
|
||||||
|
|
||||||
|
TOOLS (try in order):
|
||||||
|
1. {{tool_1}}
|
||||||
|
2. {{tool_2}}
|
||||||
|
3. {{tool_3}}
|
||||||
|
|
||||||
|
EXECUTION:
|
||||||
|
For each module above:
|
||||||
|
1. cd "{{module_path}}"
|
||||||
|
2. Try tool 1:
|
||||||
|
bash(cd "{{module_path}}" && ~/.claude/scripts/update_module_claude.sh "single-layer" "." "{{tool_1}}")
|
||||||
|
→ Success: Report "{{module_path}} updated with {{tool_1}}", proceed to next module
|
||||||
|
→ Failure: Try tool 2
|
||||||
|
3. Try tool 2:
|
||||||
|
bash(cd "{{module_path}}" && ~/.claude/scripts/update_module_claude.sh "single-layer" "." "{{tool_2}}")
|
||||||
|
→ Success: Report "{{module_path}} updated with {{tool_2}}", proceed to next module
|
||||||
|
→ Failure: Try tool 3
|
||||||
|
4. Try tool 3:
|
||||||
|
bash(cd "{{module_path}}" && ~/.claude/scripts/update_module_claude.sh "single-layer" "." "{{tool_3}}")
|
||||||
|
→ Success: Report "{{module_path}} updated with {{tool_3}}", proceed to next module
|
||||||
|
→ Failure: Report "FAILED: {{module_path}} failed all tools", proceed to next module
|
||||||
|
|
||||||
|
REPORTING:
|
||||||
|
Report final summary with:
|
||||||
|
- Total processed: X modules
|
||||||
|
- Successful: Y modules
|
||||||
|
- Failed: Z modules
|
||||||
|
- Tool usage: {{tool_1}}:X, {{tool_2}}:Y, {{tool_3}}:Z
|
||||||
|
- Detailed results for each module
|
||||||
|
```
|
||||||
|
|
||||||
|
### Example Execution
|
||||||
|
|
||||||
|
**Depth 3 (new module)**:
|
||||||
|
```javascript
|
||||||
|
Task(subagent_type="memory-bridge", batch=[./src/api/auth], mode="related")
|
||||||
|
```
|
||||||
|
|
||||||
|
**Benefits**:
|
||||||
|
- 4 modules → 1 agent (75% reduction)
|
||||||
|
- Parallel batches, sequential within batch
|
||||||
|
- Each module gets full fallback chain
|
||||||
|
- Context-aware updates based on git changes
|
||||||
|
|
||||||
|
## Phase 4: Safety Verification
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Check only CLAUDE.md modified
|
||||||
|
bash(git diff --cached --name-only | grep -v "CLAUDE.md" || echo "Only CLAUDE.md files modified")
|
||||||
|
|
||||||
|
# Display statistics
|
||||||
|
bash(git diff --stat)
|
||||||
|
```
|
||||||
|
|
||||||
|
**Aggregate results**:
|
||||||
|
```
|
||||||
|
Update Summary:
|
||||||
|
Total: 4 | Success: 4 | Failed: 0
|
||||||
|
|
||||||
|
Tool usage:
|
||||||
|
- gemini: 4 modules
|
||||||
|
- qwen: 0 modules (fallback)
|
||||||
|
- codex: 0 modules
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
src/api/auth/CLAUDE.md | 45 +++++++++++++++++++++
|
||||||
|
src/api/CLAUDE.md | 23 +++++++++--
|
||||||
|
src/CLAUDE.md | 12 ++++--
|
||||||
|
CLAUDE.md | 8 ++--
|
||||||
|
4 files changed, 82 insertions(+), 6 deletions(-)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Execution Summary
|
||||||
|
|
||||||
|
**Module Count Threshold**:
|
||||||
|
- **<15 modules**: Coordinator executes Phase 3A (Direct Execution)
|
||||||
|
- **≥15 modules**: Coordinator executes Phase 3B (Agent Batch Execution)
|
||||||
|
|
||||||
|
**Agent Hierarchy** (for ≥15 modules):
|
||||||
|
- **Coordinator**: Handles batch division, spawns worker agents per depth
|
||||||
|
- **Worker Agents**: Each processes 4 modules with tool fallback (related mode)
|
||||||
|
|
||||||
|
## Error Handling
|
||||||
|
|
||||||
|
**Batch Worker**:
|
||||||
|
- Tool fallback per module (auto-retry)
|
||||||
|
- Batch isolation (failures don't propagate)
|
||||||
|
- Clear per-module status reporting
|
||||||
|
|
||||||
|
**Coordinator**:
|
||||||
|
- No changes: Use fallback (recent 10 modules)
|
||||||
|
- User decline: No execution
|
||||||
|
- Safety check fail: Auto-revert staging
|
||||||
|
- Partial failures: Continue execution, report failed modules
|
||||||
|
|
||||||
|
**Fallback Triggers**:
|
||||||
|
- Non-zero exit code
|
||||||
|
- Script timeout
|
||||||
|
- Unexpected output
|
||||||
|
|
||||||
|
## Tool Reference
|
||||||
|
|
||||||
|
| Tool | Best For | Fallback To |
|
||||||
|
|--------|--------------------------------|----------------|
|
||||||
|
| gemini | Documentation, patterns | qwen → codex |
|
||||||
|
| qwen | Architecture, system design | gemini → codex |
|
||||||
|
| codex | Implementation, code quality | gemini → qwen |
|
||||||
|
|
||||||
|
## Usage Examples
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Daily development update
|
||||||
|
/memory:update-related
|
||||||
|
|
||||||
|
# After feature work with specific tool
|
||||||
|
/memory:update-related --tool qwen
|
||||||
|
|
||||||
|
# Code quality review after implementation
|
||||||
|
/memory:update-related --tool codex
|
||||||
|
```
|
||||||
|
|
||||||
|
## Key Advantages
|
||||||
|
|
||||||
|
**Efficiency**: 30 modules → 8 agents (73% reduction)
|
||||||
|
**Resilience**: 3-tier fallback per module
|
||||||
|
**Performance**: Parallel batches, no concurrency limits
|
||||||
|
**Context-aware**: Updates based on actual git changes
|
||||||
|
**Fast**: Only affected modules, not entire project
|
||||||
|
|
||||||
|
## Coordinator Checklist
|
||||||
|
|
||||||
|
- Parse `--tool` (default: gemini)
|
||||||
|
- Refresh code index for accurate change detection
|
||||||
|
- Detect changed modules via detect_changed_modules.sh
|
||||||
|
- **Smart filter modules** (auto-detect tech stack, skip tests/build/config/docs)
|
||||||
|
- Cache git changes
|
||||||
|
- Apply fallback if no changes (recent 10 modules)
|
||||||
|
- Construct tool fallback order
|
||||||
|
- **Present filtered plan** with skip reasons and change types
|
||||||
|
- **Wait for y/n confirmation**
|
||||||
|
- Determine execution mode:
|
||||||
|
- **<15 modules**: Direct execution (Phase 3A)
|
||||||
|
- For each depth (N→0): Sequential module updates with tool fallback
|
||||||
|
- **≥15 modules**: Agent batch execution (Phase 3B)
|
||||||
|
- For each depth (N→0): Batch modules (4 per batch), spawn batch workers in parallel
|
||||||
|
- Wait for depth/batch completion
|
||||||
|
- Aggregate results
|
||||||
|
- Safety check (only CLAUDE.md modified)
|
||||||
|
- Display git diff statistics + summary
|
||||||
|
|
||||||
|
## Comparison with Full Update
|
||||||
|
|
||||||
|
| Aspect | Related Update | Full Update |
|
||||||
|
|--------|----------------|-------------|
|
||||||
|
| **Scope** | Changed modules only | All project modules |
|
||||||
|
| **Speed** | Fast (minutes) | Slower (10-30 min) |
|
||||||
|
| **Use case** | Daily development | Major refactoring |
|
||||||
|
| **Mode** | `"related"` | `"full"` |
|
||||||
|
| **Trigger** | After commits | After major changes |
|
||||||
|
| **Batching** | 4 modules/agent | 4 modules/agent |
|
||||||
|
| **Fallback** | gemini→qwen→codex | gemini→qwen→codex |
|
||||||
|
| **Complexity threshold** | ≤15 modules | ≤20 modules |
|
||||||
@@ -99,10 +99,10 @@ After bash validation, the model takes control to:
|
|||||||
```
|
```
|
||||||
- Use Gemini for security analysis:
|
- Use Gemini for security analysis:
|
||||||
```bash
|
```bash
|
||||||
cd .workflow/${sessionId} && ~/.claude/scripts/gemini-wrapper -p "
|
cd .workflow/${sessionId} && gemini -p "
|
||||||
PURPOSE: Security audit of completed implementation
|
PURPOSE: Security audit of completed implementation
|
||||||
TASK: Review code for security vulnerabilities, insecure patterns, auth/authz issues
|
TASK: Review code for security vulnerabilities, insecure patterns, auth/authz issues
|
||||||
CONTEXT: @{.summaries/IMPL-*.md,../..,../../CLAUDE.md}
|
CONTEXT: @.summaries/IMPL-*.md,../.. @../../CLAUDE.md
|
||||||
EXPECTED: Security findings report with severity levels
|
EXPECTED: Security findings report with severity levels
|
||||||
RULES: Focus on OWASP Top 10, authentication, authorization, data validation, injection risks
|
RULES: Focus on OWASP Top 10, authentication, authorization, data validation, injection risks
|
||||||
" --approval-mode yolo
|
" --approval-mode yolo
|
||||||
@@ -111,10 +111,10 @@ After bash validation, the model takes control to:
|
|||||||
**Architecture Review** (`--type=architecture`):
|
**Architecture Review** (`--type=architecture`):
|
||||||
- Use Qwen for architecture analysis:
|
- Use Qwen for architecture analysis:
|
||||||
```bash
|
```bash
|
||||||
cd .workflow/${sessionId} && ~/.claude/scripts/qwen-wrapper -p "
|
cd .workflow/${sessionId} && qwen -p "
|
||||||
PURPOSE: Architecture compliance review
|
PURPOSE: Architecture compliance review
|
||||||
TASK: Evaluate adherence to architectural patterns, identify technical debt, review design decisions
|
TASK: Evaluate adherence to architectural patterns, identify technical debt, review design decisions
|
||||||
CONTEXT: @{.summaries/IMPL-*.md,../..,../../CLAUDE.md}
|
CONTEXT: @.summaries/IMPL-*.md,../.. @../../CLAUDE.md
|
||||||
EXPECTED: Architecture assessment with recommendations
|
EXPECTED: Architecture assessment with recommendations
|
||||||
RULES: Check for patterns, separation of concerns, modularity, scalability
|
RULES: Check for patterns, separation of concerns, modularity, scalability
|
||||||
" --approval-mode yolo
|
" --approval-mode yolo
|
||||||
@@ -123,10 +123,10 @@ After bash validation, the model takes control to:
|
|||||||
**Quality Review** (`--type=quality`):
|
**Quality Review** (`--type=quality`):
|
||||||
- Use Gemini for code quality:
|
- Use Gemini for code quality:
|
||||||
```bash
|
```bash
|
||||||
cd .workflow/${sessionId} && ~/.claude/scripts/gemini-wrapper -p "
|
cd .workflow/${sessionId} && gemini -p "
|
||||||
PURPOSE: Code quality and best practices review
|
PURPOSE: Code quality and best practices review
|
||||||
TASK: Assess code readability, maintainability, adherence to best practices
|
TASK: Assess code readability, maintainability, adherence to best practices
|
||||||
CONTEXT: @{.summaries/IMPL-*.md,../..,../../CLAUDE.md}
|
CONTEXT: @.summaries/IMPL-*.md,../.. @../../CLAUDE.md
|
||||||
EXPECTED: Quality assessment with improvement suggestions
|
EXPECTED: Quality assessment with improvement suggestions
|
||||||
RULES: Check for code smells, duplication, complexity, naming conventions
|
RULES: Check for code smells, duplication, complexity, naming conventions
|
||||||
" --approval-mode yolo
|
" --approval-mode yolo
|
||||||
@@ -143,10 +143,10 @@ After bash validation, the model takes control to:
|
|||||||
' {} \;
|
' {} \;
|
||||||
|
|
||||||
# Check implementation summaries against requirements
|
# Check implementation summaries against requirements
|
||||||
cd .workflow/${sessionId} && ~/.claude/scripts/gemini-wrapper -p "
|
cd .workflow/${sessionId} && gemini -p "
|
||||||
PURPOSE: Verify all requirements and acceptance criteria are met
|
PURPOSE: Verify all requirements and acceptance criteria are met
|
||||||
TASK: Cross-check implementation summaries against original requirements
|
TASK: Cross-check implementation summaries against original requirements
|
||||||
CONTEXT: @{.task/IMPL-*.json,.summaries/IMPL-*.md,../..,../../CLAUDE.md}
|
CONTEXT: @.task/IMPL-*.json,.summaries/IMPL-*.md,../.. @../../CLAUDE.md
|
||||||
EXPECTED:
|
EXPECTED:
|
||||||
- Requirements coverage matrix
|
- Requirements coverage matrix
|
||||||
- Acceptance criteria verification
|
- Acceptance criteria verification
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ name: tdd-verify
|
|||||||
description: Verify TDD workflow compliance and generate quality report
|
description: Verify TDD workflow compliance and generate quality report
|
||||||
|
|
||||||
argument-hint: "[optional: WFS-session-id]"
|
argument-hint: "[optional: WFS-session-id]"
|
||||||
allowed-tools: SlashCommand(*), TodoWrite(*), Read(*), Bash(gemini-wrapper:*)
|
allowed-tools: SlashCommand(*), TodoWrite(*), Read(*), Bash(gemini:*)
|
||||||
---
|
---
|
||||||
|
|
||||||
# TDD Verification Command (/workflow:tdd-verify)
|
# TDD Verification Command (/workflow:tdd-verify)
|
||||||
@@ -94,7 +94,7 @@ find .workflow/{sessionId}/.task/ -name '*.json' -exec jq -r '.meta.agent' {} \;
|
|||||||
**Gemini analysis for comprehensive TDD compliance report**
|
**Gemini analysis for comprehensive TDD compliance report**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd project-root && ~/.claude/scripts/gemini-wrapper -p "
|
cd project-root && gemini -p "
|
||||||
PURPOSE: Generate TDD compliance report
|
PURPOSE: Generate TDD compliance report
|
||||||
TASK: Analyze TDD workflow execution and generate quality report
|
TASK: Analyze TDD workflow execution and generate quality report
|
||||||
CONTEXT: @{.workflow/{sessionId}/.task/*.json,.workflow/{sessionId}/.summaries/*,.workflow/{sessionId}/.process/tdd-cycle-report.md}
|
CONTEXT: @{.workflow/{sessionId}/.task/*.json,.workflow/{sessionId}/.summaries/*,.workflow/{sessionId}/.process/tdd-cycle-report.md}
|
||||||
|
|||||||
@@ -226,11 +226,11 @@ Iteration N (managed by test-cycle-execute orchestrator):
|
|||||||
|
|
||||||
#### CLI Analysis Command (executed by orchestrator)
|
#### CLI Analysis Command (executed by orchestrator)
|
||||||
```bash
|
```bash
|
||||||
cd {project_root} && ~/.claude/scripts/gemini-wrapper -p "
|
cd {project_root} && gemini -p "
|
||||||
PURPOSE: Analyze test failures and generate fix strategy
|
PURPOSE: Analyze test failures and generate fix strategy
|
||||||
TASK: Review test failures and identify root causes
|
TASK: Review test failures and identify root causes
|
||||||
MODE: analysis
|
MODE: analysis
|
||||||
CONTEXT: @{test files, implementation files}
|
CONTEXT: @test files @ implementation files
|
||||||
|
|
||||||
[Test failure context and requirements...]
|
[Test failure context and requirements...]
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
name: task-generate-tdd
|
name: task-generate-tdd
|
||||||
description: Generate TDD task chains with Red-Green-Refactor dependencies
|
description: Generate TDD task chains with Red-Green-Refactor dependencies
|
||||||
argument-hint: "--session WFS-session-id [--agent]"
|
argument-hint: "--session WFS-session-id [--agent]"
|
||||||
allowed-tools: Read(*), Write(*), Bash(gemini-wrapper:*), TodoWrite(*)
|
allowed-tools: Read(*), Write(*), Bash(gemini:*), TodoWrite(*)
|
||||||
---
|
---
|
||||||
|
|
||||||
# TDD Task Generation Command
|
# TDD Task Generation Command
|
||||||
|
|||||||
@@ -256,7 +256,7 @@ This enhanced 5-field schema embeds all necessary context, artifacts, and execut
|
|||||||
"action": "Analyze existing code patterns and identify modification targets",
|
"action": "Analyze existing code patterns and identify modification targets",
|
||||||
"commands": [
|
"commands": [
|
||||||
"bash(cd \"[focus_paths]\")",
|
"bash(cd \"[focus_paths]\")",
|
||||||
"bash(~/.claude/scripts/gemini-wrapper -p \"PURPOSE: Identify modification targets TASK: Analyze '[title]' and locate specific files/functions/lines to modify CONTEXT: [synthesis_specification] [individual_artifacts] EXPECTED: Code locations in format 'file:function:lines' RULES: Prioritize synthesis-specification.md, identify exact modification points\")"
|
"bash(gemini \"PURPOSE: Identify modification targets TASK: Analyze '[title]' and locate specific files/functions/lines to modify CONTEXT: [synthesis_specification] [individual_artifacts] EXPECTED: Code locations in format 'file:function:lines' RULES: Prioritize synthesis-specification.md, identify exact modification points\")"
|
||||||
],
|
],
|
||||||
"output_to": "task_context_with_targets",
|
"output_to": "task_context_with_targets",
|
||||||
"on_error": "fail"
|
"on_error": "fail"
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ Specialized analysis tool for test generation workflows that uses Gemini to anal
|
|||||||
|
|
||||||
**Tool Configuration**:
|
**Tool Configuration**:
|
||||||
```bash
|
```bash
|
||||||
cd .workflow/{test_session_id}/.process && ~/.claude/scripts/gemini-wrapper -p "
|
cd .workflow/{test_session_id}/.process && gemini -p "
|
||||||
PURPOSE: Analyze test coverage gaps and design comprehensive test generation strategy
|
PURPOSE: Analyze test coverage gaps and design comprehensive test generation strategy
|
||||||
TASK: Study implementation context, existing tests, and generate test requirements for missing coverage
|
TASK: Study implementation context, existing tests, and generate test requirements for missing coverage
|
||||||
MODE: analysis
|
MODE: analysis
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ Generate **TWO task JSON files**:
|
|||||||
"Codex generates comprehensive test suite",
|
"Codex generates comprehensive test suite",
|
||||||
"Codex validates test syntax and executability"
|
"Codex validates test syntax and executability"
|
||||||
],
|
],
|
||||||
"command": "bash(codex -C [focus_paths] --full-auto exec \"PURPOSE: Generate comprehensive test suite TASK: Create test files based on TEST_ANALYSIS_RESULTS.md section 5 MODE: write CONTEXT: @{.workflow/WFS-test-[session]/.process/TEST_ANALYSIS_RESULTS.md,.workflow/WFS-test-[session]/.process/test-context-package.json} EXPECTED: All test files with happy path, error handling, edge cases, integration tests RULES: Follow test framework conventions, ensure tests are executable\" --skip-git-repo-check -s danger-full-access)",
|
"command": "bash(codex -C [focus_paths] --full-auto exec \"PURPOSE: Generate comprehensive test suite TASK: Create test files based on TEST_ANALYSIS_RESULTS.md section 5 MODE: write CONTEXT: @.workflow/WFS-test-[session]/.process/TEST_ANALYSIS_RESULTS.md @.workflow/WFS-test-[session]/.process/test-context-package.json EXPECTED: All test files with happy path, error handling, edge cases, integration tests RULES: Follow test framework conventions, ensure tests are executable\" --skip-git-repo-check -s danger-full-access)",
|
||||||
"depends_on": [],
|
"depends_on": [],
|
||||||
"output": "test_generation"
|
"output": "test_generation"
|
||||||
}],
|
}],
|
||||||
@@ -323,7 +323,7 @@ Generate **TWO task JSON files**:
|
|||||||
"cycle_pattern": "test → gemini_diagnose → manual_fix (or codex if needed) → retest",
|
"cycle_pattern": "test → gemini_diagnose → manual_fix (or codex if needed) → retest",
|
||||||
"tools": {
|
"tools": {
|
||||||
"test_execution": "bash(test_command)",
|
"test_execution": "bash(test_command)",
|
||||||
"diagnosis": "gemini-wrapper (MODE: analysis, uses bug-fix template)",
|
"diagnosis": "gemini (MODE: analysis, uses bug-fix template)",
|
||||||
"fix_application": "manual (default) or codex exec resume --last (if explicitly needed)",
|
"fix_application": "manual (default) or codex exec resume --last (if explicitly needed)",
|
||||||
"verification": "bash(test_command) + regression_check"
|
"verification": "bash(test_command) + regression_check"
|
||||||
},
|
},
|
||||||
@@ -354,11 +354,11 @@ Generate **TWO task JSON files**:
|
|||||||
" * Source files from focus_paths",
|
" * Source files from focus_paths",
|
||||||
" * Implementation summaries from source session",
|
" * Implementation summaries from source session",
|
||||||
" - Execute Gemini analysis with bug-fix template:",
|
" - Execute Gemini analysis with bug-fix template:",
|
||||||
" bash(cd .workflow/WFS-test-[session]/.process && ~/.claude/scripts/gemini-wrapper --all-files -p \"",
|
" bash(cd .workflow/WFS-test-[session]/.process && gemini \"",
|
||||||
" PURPOSE: Diagnose test failure iteration [N] and propose minimal fix",
|
" PURPOSE: Diagnose test failure iteration [N] and propose minimal fix",
|
||||||
" TASK: Systematic bug analysis and fix recommendations for test failure",
|
" TASK: Systematic bug analysis and fix recommendations for test failure",
|
||||||
" MODE: analysis",
|
" MODE: analysis",
|
||||||
" CONTEXT: @{CLAUDE.md,**/*CLAUDE.md}",
|
" CONTEXT: @CLAUDE.md,**/*CLAUDE.md",
|
||||||
" Test output: [test_failures]",
|
" Test output: [test_failures]",
|
||||||
" Source files: [focus_paths]",
|
" Source files: [focus_paths]",
|
||||||
" Implementation: [implementation_context]",
|
" Implementation: [implementation_context]",
|
||||||
|
|||||||
@@ -1,288 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# gemini-wrapper - Token-aware wrapper for gemini command
|
|
||||||
# Location: ~/.claude/scripts/gemini-wrapper
|
|
||||||
#
|
|
||||||
# This wrapper automatically manages --all-files flag based on project token count
|
|
||||||
# and provides intelligent approval mode defaults
|
|
||||||
#
|
|
||||||
# Usage: gemini-wrapper [all gemini options]
|
|
||||||
#
|
|
||||||
# Approval Mode Options:
|
|
||||||
# --approval-mode default : Prompt for approval on each tool call (default)
|
|
||||||
# --approval-mode auto_edit : Auto-approve edit tools, prompt for others
|
|
||||||
# --approval-mode yolo : Auto-approve all tool calls
|
|
||||||
#
|
|
||||||
# Note: Executes in current working directory
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# Function to show help
|
|
||||||
show_help() {
|
|
||||||
echo "gemini-wrapper - Token-aware wrapper for gemini command"
|
|
||||||
echo ""
|
|
||||||
echo "Usage: gemini-wrapper [options] [gemini options]"
|
|
||||||
echo ""
|
|
||||||
echo "Options:"
|
|
||||||
echo " --approval-mode <mode> Sets the approval mode for tool calls"
|
|
||||||
echo " Available modes:"
|
|
||||||
echo " default : Prompt for approval on each tool call (default)"
|
|
||||||
echo " auto_edit : Auto-approve edit tools, prompt for others"
|
|
||||||
echo " yolo : Auto-approve all tool calls"
|
|
||||||
echo " --help Show this help message"
|
|
||||||
echo ""
|
|
||||||
echo "Features:"
|
|
||||||
echo " - Automatically manages --all-files flag based on project token count"
|
|
||||||
echo " - Intelligent approval mode detection based on task type"
|
|
||||||
echo " - Token limit: $DEFAULT_TOKEN_LIMIT (set GEMINI_TOKEN_LIMIT to override)"
|
|
||||||
echo ""
|
|
||||||
echo "Examples:"
|
|
||||||
echo " gemini-wrapper -p \"Analyze the codebase structure\""
|
|
||||||
echo " gemini-wrapper --approval-mode yolo -p \"Implement user authentication\""
|
|
||||||
echo " gemini-wrapper --approval-mode auto_edit -p \"Fix all linting errors\""
|
|
||||||
echo ""
|
|
||||||
}
|
|
||||||
|
|
||||||
# Configuration
|
|
||||||
DEFAULT_TOKEN_LIMIT=2000000
|
|
||||||
TOKEN_LIMIT=${GEMINI_TOKEN_LIMIT:-$DEFAULT_TOKEN_LIMIT}
|
|
||||||
|
|
||||||
# Colors for output
|
|
||||||
RED='\033[0;31m'
|
|
||||||
GREEN='\033[0;32m'
|
|
||||||
YELLOW='\033[1;33m'
|
|
||||||
NC='\033[0m' # No Color
|
|
||||||
|
|
||||||
# Respect custom Gemini base URL
|
|
||||||
if [[ -n "$GOOGLE_GEMINI_BASE_URL" ]]; then
|
|
||||||
echo -e "${GREEN}🌐 Using custom Gemini base URL: $GOOGLE_GEMINI_BASE_URL${NC}" >&2
|
|
||||||
export GOOGLE_GEMINI_BASE_URL
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Function to count tokens (approximate: chars/4) - optimized version
|
|
||||||
count_tokens() {
|
|
||||||
local total_chars=0
|
|
||||||
local file_count=0
|
|
||||||
|
|
||||||
# Use single find with bulk wc for better performance
|
|
||||||
# Common source file extensions
|
|
||||||
local extensions="py js ts tsx jsx java cpp c h rs go md txt json yaml yml xml html css scss sass php rb sh bash"
|
|
||||||
|
|
||||||
# Build find command with extension patterns
|
|
||||||
local find_cmd="find . -type f \("
|
|
||||||
local first=true
|
|
||||||
for ext in $extensions; do
|
|
||||||
if [[ "$first" == true ]]; then
|
|
||||||
find_cmd+=" -name \"*.$ext\""
|
|
||||||
first=false
|
|
||||||
else
|
|
||||||
find_cmd+=" -o -name \"*.$ext\""
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
find_cmd+=" \)"
|
|
||||||
|
|
||||||
# Exclude common build/cache directories
|
|
||||||
find_cmd+=" -not -path \"*/node_modules/*\""
|
|
||||||
find_cmd+=" -not -path \"*/.git/*\""
|
|
||||||
find_cmd+=" -not -path \"*/dist/*\""
|
|
||||||
find_cmd+=" -not -path \"*/build/*\""
|
|
||||||
find_cmd+=" -not -path \"*/.next/*\""
|
|
||||||
find_cmd+=" -not -path \"*/.nuxt/*\""
|
|
||||||
find_cmd+=" -not -path \"*/target/*\""
|
|
||||||
find_cmd+=" -not -path \"*/vendor/*\""
|
|
||||||
find_cmd+=" -not -path \"*/__pycache__/*\""
|
|
||||||
find_cmd+=" -not -path \"*/.cache/*\""
|
|
||||||
find_cmd+=" 2>/dev/null"
|
|
||||||
|
|
||||||
# Use efficient bulk processing with wc
|
|
||||||
if command -v wc >/dev/null 2>&1; then
|
|
||||||
# Try bulk wc first - much faster for many files
|
|
||||||
local wc_output
|
|
||||||
wc_output=$(eval "$find_cmd" | xargs wc -c 2>/dev/null | tail -n 1)
|
|
||||||
|
|
||||||
# Parse the total line (last line of wc output when processing multiple files)
|
|
||||||
if [[ -n "$wc_output" && "$wc_output" =~ ^[[:space:]]*([0-9]+)[[:space:]]+total[[:space:]]*$ ]]; then
|
|
||||||
total_chars="${BASH_REMATCH[1]}"
|
|
||||||
file_count=$(eval "$find_cmd" | wc -l 2>/dev/null || echo 0)
|
|
||||||
else
|
|
||||||
# Fallback: single file processing
|
|
||||||
while IFS= read -r file; do
|
|
||||||
if [[ -f "$file" && -r "$file" ]]; then
|
|
||||||
local chars=$(wc -c < "$file" 2>/dev/null || echo 0)
|
|
||||||
total_chars=$((total_chars + chars))
|
|
||||||
file_count=$((file_count + 1))
|
|
||||||
fi
|
|
||||||
done < <(eval "$find_cmd")
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
# No wc available - fallback method
|
|
||||||
while IFS= read -r file; do
|
|
||||||
if [[ -f "$file" && -r "$file" ]]; then
|
|
||||||
local chars=$(stat -c%s "$file" 2>/dev/null || echo 0)
|
|
||||||
total_chars=$((total_chars + chars))
|
|
||||||
file_count=$((file_count + 1))
|
|
||||||
fi
|
|
||||||
done < <(eval "$find_cmd")
|
|
||||||
fi
|
|
||||||
|
|
||||||
local estimated_tokens=$((total_chars / 4))
|
|
||||||
echo "$estimated_tokens $file_count"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to validate approval mode
|
|
||||||
validate_approval_mode() {
|
|
||||||
local mode="$1"
|
|
||||||
case "$mode" in
|
|
||||||
"default"|"auto_edit"|"yolo")
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo -e "${RED}❌ Invalid approval mode: $mode${NC}" >&2
|
|
||||||
echo -e "${YELLOW}Valid modes: default, auto_edit, yolo${NC}" >&2
|
|
||||||
return 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
# Parse arguments to check for flags
|
|
||||||
has_all_files=false
|
|
||||||
has_approval_mode=false
|
|
||||||
approval_mode_value=""
|
|
||||||
args=()
|
|
||||||
i=0
|
|
||||||
|
|
||||||
# Parse arguments with proper handling of --approval-mode value
|
|
||||||
args=("$@") # Start with all arguments
|
|
||||||
parsed_args=()
|
|
||||||
skip_next=false
|
|
||||||
|
|
||||||
for ((i=0; i<${#args[@]}; i++)); do
|
|
||||||
if [[ "$skip_next" == true ]]; then
|
|
||||||
skip_next=false
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
arg="${args[i]}"
|
|
||||||
case "$arg" in
|
|
||||||
"--help"|"-h")
|
|
||||||
show_help
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
"--all-files")
|
|
||||||
has_all_files=true
|
|
||||||
parsed_args+=("$arg")
|
|
||||||
;;
|
|
||||||
"--approval-mode")
|
|
||||||
has_approval_mode=true
|
|
||||||
# Get the next argument as the mode value
|
|
||||||
if [[ $((i+1)) -lt ${#args[@]} ]]; then
|
|
||||||
approval_mode_value="${args[$((i+1))]}"
|
|
||||||
if validate_approval_mode "$approval_mode_value"; then
|
|
||||||
parsed_args+=("$arg" "$approval_mode_value")
|
|
||||||
skip_next=true
|
|
||||||
else
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo -e "${RED}❌ --approval-mode requires a value${NC}" >&2
|
|
||||||
echo -e "${YELLOW}Valid modes: default, auto_edit, yolo${NC}" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
--approval-mode=*)
|
|
||||||
has_approval_mode=true
|
|
||||||
approval_mode_value="${arg#*=}"
|
|
||||||
if validate_approval_mode "$approval_mode_value"; then
|
|
||||||
parsed_args+=("$arg")
|
|
||||||
else
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
parsed_args+=("$arg")
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
# Replace args with parsed_args
|
|
||||||
args=("${parsed_args[@]}")
|
|
||||||
|
|
||||||
# Analyze current working directory
|
|
||||||
echo -e "${GREEN}📁 Analyzing current directory: $(pwd)${NC}" >&2
|
|
||||||
|
|
||||||
# Count tokens (in the target directory if -c was used)
|
|
||||||
echo -e "${YELLOW}🔍 Analyzing project size...${NC}" >&2
|
|
||||||
read -r token_count file_count <<< "$(count_tokens)"
|
|
||||||
|
|
||||||
echo -e "${YELLOW}📊 Project stats: ~${token_count} tokens across ${file_count} files${NC}" >&2
|
|
||||||
|
|
||||||
# Decision logic for --all-files flag
|
|
||||||
if [[ $token_count -lt $TOKEN_LIMIT ]]; then
|
|
||||||
if [[ "$has_all_files" == false ]]; then
|
|
||||||
echo -e "${GREEN}✅ Small project (${token_count} < ${TOKEN_LIMIT} tokens): Adding --all-files${NC}" >&2
|
|
||||||
args=("--all-files" "${args[@]}")
|
|
||||||
else
|
|
||||||
echo -e "${GREEN}✅ Small project (${token_count} < ${TOKEN_LIMIT} tokens): Keeping --all-files${NC}" >&2
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
if [[ "$has_all_files" == true ]]; then
|
|
||||||
echo -e "${RED}⚠️ Large project (${token_count} >= ${TOKEN_LIMIT} tokens): Removing --all-files to avoid token limits${NC}" >&2
|
|
||||||
echo -e "${YELLOW}💡 Consider using specific @{patterns} for targeted analysis${NC}" >&2
|
|
||||||
# Remove --all-files from args
|
|
||||||
new_args=()
|
|
||||||
for arg in "${args[@]}"; do
|
|
||||||
if [[ "$arg" != "--all-files" ]]; then
|
|
||||||
new_args+=("$arg")
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
args=("${new_args[@]}")
|
|
||||||
else
|
|
||||||
echo -e "${RED}⚠️ Large project (${token_count} >= ${TOKEN_LIMIT} tokens): Avoiding --all-files${NC}" >&2
|
|
||||||
echo -e "${YELLOW}💡 Consider using specific @{patterns} for targeted analysis${NC}" >&2
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Auto-add approval-mode if not specified
|
|
||||||
if [[ "$has_approval_mode" == false ]]; then
|
|
||||||
# Intelligent approval mode detection based on prompt content
|
|
||||||
prompt_text="${args[*]}"
|
|
||||||
|
|
||||||
# Analysis/Research tasks - use default (prompt for each tool)
|
|
||||||
if [[ "$prompt_text" =~ (analyze|analysis|review|understand|inspect|examine|research|study|explore|investigate) ]]; then
|
|
||||||
echo -e "${GREEN}📋 Analysis task detected: Adding --approval-mode default${NC}" >&2
|
|
||||||
args=("--approval-mode" "default" "${args[@]}")
|
|
||||||
|
|
||||||
# Development/Edit tasks - use auto_edit (auto-approve edits, prompt for others)
|
|
||||||
elif [[ "$prompt_text" =~ (implement|create|build|develop|code|write|edit|modify|update|fix|refactor|generate) ]]; then
|
|
||||||
echo -e "${GREEN}🔧 Development task detected: Adding --approval-mode auto_edit${NC}" >&2
|
|
||||||
args=("--approval-mode" "auto_edit" "${args[@]}")
|
|
||||||
|
|
||||||
# Automation/Batch tasks - use yolo (auto-approve all)
|
|
||||||
elif [[ "$prompt_text" =~ (automate|batch|mass|bulk|all|execute|run|deploy|install|setup) ]]; then
|
|
||||||
echo -e "${YELLOW}⚡ Automation task detected: Adding --approval-mode yolo${NC}" >&2
|
|
||||||
args=("--approval-mode" "yolo" "${args[@]}")
|
|
||||||
|
|
||||||
# Default fallback - use default mode for safety
|
|
||||||
else
|
|
||||||
echo -e "${YELLOW}🔍 General task detected: Adding --approval-mode default${NC}" >&2
|
|
||||||
args=("--approval-mode" "default" "${args[@]}")
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Show approval mode explanation
|
|
||||||
case "${args[1]}" in
|
|
||||||
"default")
|
|
||||||
echo -e "${YELLOW} → Will prompt for approval on each tool call${NC}" >&2
|
|
||||||
;;
|
|
||||||
"auto_edit")
|
|
||||||
echo -e "${YELLOW} → Will auto-approve edit tools, prompt for others${NC}" >&2
|
|
||||||
;;
|
|
||||||
"yolo")
|
|
||||||
echo -e "${YELLOW} → Will auto-approve all tool calls${NC}" >&2
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Show final command (for transparency)
|
|
||||||
echo -e "${YELLOW}🚀 Executing: gemini ${args[*]}${NC}" >&2
|
|
||||||
|
|
||||||
# Execute gemini with adjusted arguments (we're already in the right directory)
|
|
||||||
gemini "${args[@]}"
|
|
||||||
@@ -1,228 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# qwen-wrapper - Token-aware wrapper for qwen command
|
|
||||||
# Location: ~/.claude/scripts/qwen-wrapper
|
|
||||||
#
|
|
||||||
# This wrapper automatically manages --all-files flag based on project token count
|
|
||||||
# and provides intelligent approval mode defaults
|
|
||||||
#
|
|
||||||
# Usage: qwen-wrapper [all qwen options]
|
|
||||||
#
|
|
||||||
# Approval Mode Options:
|
|
||||||
# --approval-mode default : Prompt for approval on each tool call (default)
|
|
||||||
# --approval-mode auto_edit : Auto-approve edit tools, prompt for others
|
|
||||||
# --approval-mode yolo : Auto-approve all tool calls
|
|
||||||
#
|
|
||||||
# Note: Executes in current working directory
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# Function to show help
|
|
||||||
show_help() {
|
|
||||||
echo "qwen-wrapper - Token-aware wrapper for qwen command"
|
|
||||||
echo ""
|
|
||||||
echo "Usage: qwen-wrapper [options] [qwen options]"
|
|
||||||
echo ""
|
|
||||||
echo "Options:"
|
|
||||||
echo " --approval-mode <mode> Sets the approval mode for tool calls"
|
|
||||||
echo " Available modes:"
|
|
||||||
echo " default : Prompt for approval on each tool call (default)"
|
|
||||||
echo " auto_edit : Auto-approve edit tools, prompt for others"
|
|
||||||
echo " yolo : Auto-approve all tool calls"
|
|
||||||
echo " --help Show this help message"
|
|
||||||
echo ""
|
|
||||||
echo "Features:"
|
|
||||||
echo " - Automatically manages --all-files flag based on project token count"
|
|
||||||
echo " - Intelligent approval mode detection based on task type"
|
|
||||||
echo " - Token limit: $DEFAULT_TOKEN_LIMIT (set QWEN_TOKEN_LIMIT to override)"
|
|
||||||
echo ""
|
|
||||||
echo "Examples:"
|
|
||||||
echo " qwen-wrapper -p \"Analyze the codebase structure\""
|
|
||||||
echo " qwen-wrapper --approval-mode yolo -p \"Implement user authentication\""
|
|
||||||
echo " qwen-wrapper --approval-mode auto_edit -p \"Fix all linting errors\""
|
|
||||||
echo ""
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to validate approval mode
|
|
||||||
validate_approval_mode() {
|
|
||||||
local mode="$1"
|
|
||||||
case "$mode" in
|
|
||||||
"default"|"auto_edit"|"yolo")
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo -e "${RED}❌ Invalid approval mode: $mode${NC}" >&2
|
|
||||||
echo -e "${YELLOW}Valid modes: default, auto_edit, yolo${NC}" >&2
|
|
||||||
return 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
# Configuration
|
|
||||||
DEFAULT_TOKEN_LIMIT=2000000
|
|
||||||
TOKEN_LIMIT=${QWEN_TOKEN_LIMIT:-$DEFAULT_TOKEN_LIMIT}
|
|
||||||
|
|
||||||
# Colors for output
|
|
||||||
RED='\033[0;31m'
|
|
||||||
GREEN='\033[0;32m'
|
|
||||||
YELLOW='\033[1;33m'
|
|
||||||
NC='\033[0m' # No Color
|
|
||||||
|
|
||||||
# Function to count tokens (approximate: chars/4)
|
|
||||||
count_tokens() {
|
|
||||||
local total_chars=0
|
|
||||||
local file_count=0
|
|
||||||
|
|
||||||
# Count characters in common source files
|
|
||||||
while IFS= read -r -d '' file; do
|
|
||||||
if [[ -f "$file" && -r "$file" ]]; then
|
|
||||||
local chars=$(wc -c < "$file" 2>/dev/null || echo 0)
|
|
||||||
total_chars=$((total_chars + chars))
|
|
||||||
file_count=$((file_count + 1))
|
|
||||||
fi
|
|
||||||
done < <(find . -type f \( -name "*.py" -o -name "*.js" -o -name "*.ts" -o -name "*.tsx" -o -name "*.jsx" -o -name "*.java" -o -name "*.cpp" -o -name "*.c" -o -name "*.h" -o -name "*.rs" -o -name "*.go" -o -name "*.md" -o -name "*.txt" -o -name "*.json" -o -name "*.yaml" -o -name "*.yml" -o -name "*.xml" -o -name "*.html" -o -name "*.css" -o -name "*.scss" -o -name "*.sass" -o -name "*.php" -o -name "*.rb" -o -name "*.sh" -o -name "*.bash" \) -not -path "*/node_modules/*" -not -path "*/.git/*" -not -path "*/dist/*" -not -path "*/build/*" -not -path "*/.next/*" -not -path "*/.nuxt/*" -not -path "*/target/*" -not -path "*/vendor/*" -print0 2>/dev/null)
|
|
||||||
|
|
||||||
local estimated_tokens=$((total_chars / 4))
|
|
||||||
echo "$estimated_tokens $file_count"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Parse arguments to check for flags
|
|
||||||
has_all_files=false
|
|
||||||
has_approval_mode=false
|
|
||||||
approval_mode_value=""
|
|
||||||
|
|
||||||
# Parse arguments with proper handling of --approval-mode value
|
|
||||||
args=("$@") # Start with all arguments
|
|
||||||
parsed_args=()
|
|
||||||
skip_next=false
|
|
||||||
|
|
||||||
for ((i=0; i<${#args[@]}; i++)); do
|
|
||||||
if [[ "$skip_next" == true ]]; then
|
|
||||||
skip_next=false
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
arg="${args[i]}"
|
|
||||||
case "$arg" in
|
|
||||||
"--help"|"-h")
|
|
||||||
show_help
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
"--all-files")
|
|
||||||
has_all_files=true
|
|
||||||
parsed_args+=("$arg")
|
|
||||||
;;
|
|
||||||
"--approval-mode")
|
|
||||||
has_approval_mode=true
|
|
||||||
# Get the next argument as the mode value
|
|
||||||
if [[ $((i+1)) -lt ${#args[@]} ]]; then
|
|
||||||
approval_mode_value="${args[$((i+1))]}"
|
|
||||||
if validate_approval_mode "$approval_mode_value"; then
|
|
||||||
parsed_args+=("$arg" "$approval_mode_value")
|
|
||||||
skip_next=true
|
|
||||||
else
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo -e "${RED}❌ --approval-mode requires a value${NC}" >&2
|
|
||||||
echo -e "${YELLOW}Valid modes: default, auto_edit, yolo${NC}" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
--approval-mode=*)
|
|
||||||
has_approval_mode=true
|
|
||||||
approval_mode_value="${arg#*=}"
|
|
||||||
if validate_approval_mode "$approval_mode_value"; then
|
|
||||||
parsed_args+=("$arg")
|
|
||||||
else
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
parsed_args+=("$arg")
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
# Replace args with parsed_args
|
|
||||||
args=("${parsed_args[@]}")
|
|
||||||
|
|
||||||
# Analyze current working directory
|
|
||||||
echo -e "${GREEN}📁 Analyzing current directory: $(pwd)${NC}" >&2
|
|
||||||
|
|
||||||
# Count tokens (in the target directory if -c was used)
|
|
||||||
echo -e "${YELLOW}🔍 Analyzing project size...${NC}" >&2
|
|
||||||
read -r token_count file_count <<< "$(count_tokens)"
|
|
||||||
|
|
||||||
echo -e "${YELLOW}📊 Project stats: ~${token_count} tokens across ${file_count} files${NC}" >&2
|
|
||||||
|
|
||||||
# Decision logic for --all-files flag
|
|
||||||
if [[ $token_count -lt $TOKEN_LIMIT ]]; then
|
|
||||||
if [[ "$has_all_files" == false ]]; then
|
|
||||||
echo -e "${GREEN}✅ Small project (${token_count} < ${TOKEN_LIMIT} tokens): Adding --all-files${NC}" >&2
|
|
||||||
args=("--all-files" "${args[@]}")
|
|
||||||
else
|
|
||||||
echo -e "${GREEN}✅ Small project (${token_count} < ${TOKEN_LIMIT} tokens): Keeping --all-files${NC}" >&2
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
if [[ "$has_all_files" == true ]]; then
|
|
||||||
echo -e "${RED}⚠️ Large project (${token_count} >= ${TOKEN_LIMIT} tokens): Removing --all-files to avoid token limits${NC}" >&2
|
|
||||||
echo -e "${YELLOW}💡 Consider using specific @{patterns} for targeted analysis${NC}" >&2
|
|
||||||
# Remove --all-files from args
|
|
||||||
new_args=()
|
|
||||||
for arg in "${args[@]}"; do
|
|
||||||
if [[ "$arg" != "--all-files" ]]; then
|
|
||||||
new_args+=("$arg")
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
args=("${new_args[@]}")
|
|
||||||
else
|
|
||||||
echo -e "${RED}⚠️ Large project (${token_count} >= ${TOKEN_LIMIT} tokens): Avoiding --all-files${NC}" >&2
|
|
||||||
echo -e "${YELLOW}💡 Consider using specific @{patterns} for targeted analysis${NC}" >&2
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Auto-add approval-mode if not specified
|
|
||||||
if [[ "$has_approval_mode" == false ]]; then
|
|
||||||
# Intelligent approval mode detection based on prompt content
|
|
||||||
prompt_text="${args[*]}"
|
|
||||||
|
|
||||||
# Analysis/Research tasks - use default (prompt for each tool)
|
|
||||||
if [[ "$prompt_text" =~ (analyze|analysis|review|understand|inspect|examine|research|study|explore|investigate) ]]; then
|
|
||||||
echo -e "${GREEN}📋 Analysis task detected: Adding --approval-mode default${NC}" >&2
|
|
||||||
args=("--approval-mode" "default" "${args[@]}")
|
|
||||||
|
|
||||||
# Development/Edit tasks - use auto_edit (auto-approve edits, prompt for others)
|
|
||||||
elif [[ "$prompt_text" =~ (implement|create|build|develop|code|write|edit|modify|update|fix|refactor|generate) ]]; then
|
|
||||||
echo -e "${GREEN}🔧 Development task detected: Adding --approval-mode auto_edit${NC}" >&2
|
|
||||||
args=("--approval-mode" "auto_edit" "${args[@]}")
|
|
||||||
|
|
||||||
# Automation/Batch tasks - use yolo (auto-approve all)
|
|
||||||
elif [[ "$prompt_text" =~ (automate|batch|mass|bulk|all|execute|run|deploy|install|setup) ]]; then
|
|
||||||
echo -e "${YELLOW}⚡ Automation task detected: Adding --approval-mode yolo${NC}" >&2
|
|
||||||
args=("--approval-mode" "yolo" "${args[@]}")
|
|
||||||
|
|
||||||
# Default fallback - use default mode for safety
|
|
||||||
else
|
|
||||||
echo -e "${YELLOW}🔍 General task detected: Adding --approval-mode default${NC}" >&2
|
|
||||||
args=("--approval-mode" "default" "${args[@]}")
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Show approval mode explanation
|
|
||||||
case "${args[1]}" in
|
|
||||||
"default")
|
|
||||||
echo -e "${YELLOW} → Will prompt for approval on each tool call${NC}" >&2
|
|
||||||
;;
|
|
||||||
"auto_edit")
|
|
||||||
echo -e "${YELLOW} → Will auto-approve edit tools, prompt for others${NC}" >&2
|
|
||||||
;;
|
|
||||||
"yolo")
|
|
||||||
echo -e "${YELLOW} → Will auto-approve all tool calls${NC}" >&2
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Show final command (for transparency)
|
|
||||||
echo -e "${YELLOW}🚀 Executing: qwen ${args[*]}${NC}" >&2
|
|
||||||
|
|
||||||
# Execute qwen with adjusted arguments (we're already in the right directory)
|
|
||||||
qwen "${args[@]}"
|
|
||||||
@@ -1,14 +1,32 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Update CLAUDE.md for a specific module with unified template
|
# Update CLAUDE.md for modules with two strategies
|
||||||
# Usage: update_module_claude.sh <module_path> [update_type] [tool]
|
# Usage: update_module_claude.sh <strategy> <module_path> [tool] [model]
|
||||||
|
# strategy: single-layer|multi-layer
|
||||||
# module_path: Path to the module directory
|
# module_path: Path to the module directory
|
||||||
# update_type: full|related (default: full)
|
|
||||||
# tool: gemini|qwen|codex (default: gemini)
|
# tool: gemini|qwen|codex (default: gemini)
|
||||||
|
# model: Model name (optional, uses tool defaults)
|
||||||
|
#
|
||||||
|
# Default Models:
|
||||||
|
# gemini: gemini-2.5-flash
|
||||||
|
# qwen: coder-model
|
||||||
|
# codex: gpt5-codex
|
||||||
|
#
|
||||||
|
# Strategies:
|
||||||
|
# single-layer: Upward aggregation
|
||||||
|
# - Read: Current directory code + child CLAUDE.md files
|
||||||
|
# - Generate: Single ./CLAUDE.md in current directory
|
||||||
|
# - Use: Large projects, incremental bottom-up updates
|
||||||
|
#
|
||||||
|
# multi-layer: Downward distribution
|
||||||
|
# - Read: All files in current and subdirectories
|
||||||
|
# - Generate: CLAUDE.md for each directory containing files
|
||||||
|
# - Use: Small projects, full documentation generation
|
||||||
#
|
#
|
||||||
# Features:
|
# Features:
|
||||||
# - Respects .gitignore patterns (current directory or git root)
|
# - Minimal prompts based on unified template
|
||||||
# - Unified template for all modules (folders and files)
|
# - Respects .gitignore patterns
|
||||||
# - Template-based documentation generation
|
# - Path-focused processing (script only cares about paths)
|
||||||
|
# - Template-driven generation
|
||||||
|
|
||||||
# Build exclusion filters from .gitignore
|
# Build exclusion filters from .gitignore
|
||||||
build_exclusion_filters() {
|
build_exclusion_filters() {
|
||||||
@@ -59,15 +77,84 @@ build_exclusion_filters() {
|
|||||||
echo "$filters"
|
echo "$filters"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Scan directory structure and generate structured information
|
||||||
|
scan_directory_structure() {
|
||||||
|
local target_path="$1"
|
||||||
|
local strategy="$2"
|
||||||
|
|
||||||
|
if [ ! -d "$target_path" ]; then
|
||||||
|
echo "Directory not found: $target_path"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
local exclusion_filters=$(build_exclusion_filters)
|
||||||
|
local structure_info=""
|
||||||
|
|
||||||
|
# Get basic directory info
|
||||||
|
local dir_name=$(basename "$target_path")
|
||||||
|
local total_files=$(eval "find \"$target_path\" -type f $exclusion_filters 2>/dev/null" | wc -l)
|
||||||
|
local total_dirs=$(eval "find \"$target_path\" -type d $exclusion_filters 2>/dev/null" | wc -l)
|
||||||
|
|
||||||
|
structure_info+="Directory: $dir_name\n"
|
||||||
|
structure_info+="Total files: $total_files\n"
|
||||||
|
structure_info+="Total directories: $total_dirs\n\n"
|
||||||
|
|
||||||
|
if [ "$strategy" = "multi-layer" ]; then
|
||||||
|
# For multi-layer: show all subdirectories with file counts
|
||||||
|
structure_info+="Subdirectories with files:\n"
|
||||||
|
while IFS= read -r dir; do
|
||||||
|
if [ -n "$dir" ] && [ "$dir" != "$target_path" ]; then
|
||||||
|
local rel_path=${dir#$target_path/}
|
||||||
|
local file_count=$(eval "find \"$dir\" -maxdepth 1 -type f $exclusion_filters 2>/dev/null" | wc -l)
|
||||||
|
if [ $file_count -gt 0 ]; then
|
||||||
|
structure_info+=" - $rel_path/ ($file_count files)\n"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done < <(eval "find \"$target_path\" -type d $exclusion_filters 2>/dev/null")
|
||||||
|
else
|
||||||
|
# For single-layer: show direct children only
|
||||||
|
structure_info+="Direct subdirectories:\n"
|
||||||
|
while IFS= read -r dir; do
|
||||||
|
if [ -n "$dir" ]; then
|
||||||
|
local dir_name=$(basename "$dir")
|
||||||
|
local file_count=$(eval "find \"$dir\" -maxdepth 1 -type f $exclusion_filters 2>/dev/null" | wc -l)
|
||||||
|
local has_claude=$([ -f "$dir/CLAUDE.md" ] && echo " [has CLAUDE.md]" || echo "")
|
||||||
|
structure_info+=" - $dir_name/ ($file_count files)$has_claude\n"
|
||||||
|
fi
|
||||||
|
done < <(eval "find \"$target_path\" -maxdepth 1 -type d $exclusion_filters 2>/dev/null" | grep -v "^$target_path$")
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Show main file types in current directory
|
||||||
|
structure_info+="\nCurrent directory files:\n"
|
||||||
|
local code_files=$(eval "find \"$target_path\" -maxdepth 1 -type f \\( -name '*.ts' -o -name '*.tsx' -o -name '*.js' -o -name '*.jsx' -o -name '*.py' -o -name '*.sh' \\) $exclusion_filters 2>/dev/null" | wc -l)
|
||||||
|
local config_files=$(eval "find \"$target_path\" -maxdepth 1 -type f \\( -name '*.json' -o -name '*.yaml' -o -name '*.yml' -o -name '*.toml' \\) $exclusion_filters 2>/dev/null" | wc -l)
|
||||||
|
local doc_files=$(eval "find \"$target_path\" -maxdepth 1 -type f -name '*.md' $exclusion_filters 2>/dev/null" | wc -l)
|
||||||
|
|
||||||
|
structure_info+=" - Code files: $code_files\n"
|
||||||
|
structure_info+=" - Config files: $config_files\n"
|
||||||
|
structure_info+=" - Documentation: $doc_files\n"
|
||||||
|
|
||||||
|
printf "%b" "$structure_info"
|
||||||
|
}
|
||||||
|
|
||||||
update_module_claude() {
|
update_module_claude() {
|
||||||
local module_path="$1"
|
local strategy="$1"
|
||||||
local update_type="${2:-full}"
|
local module_path="$2"
|
||||||
local tool="${3:-gemini}"
|
local tool="${3:-gemini}"
|
||||||
|
local model="$4"
|
||||||
|
|
||||||
# Validate parameters
|
# Validate parameters
|
||||||
if [ -z "$module_path" ]; then
|
if [ -z "$strategy" ] || [ -z "$module_path" ]; then
|
||||||
echo "❌ Error: Module path is required"
|
echo "❌ Error: Strategy and module path are required"
|
||||||
echo "Usage: update_module_claude.sh <module_path> [update_type]"
|
echo "Usage: update_module_claude.sh <strategy> <module_path> [tool] [model]"
|
||||||
|
echo "Strategies: single-layer|multi-layer"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Validate strategy
|
||||||
|
if [ "$strategy" != "single-layer" ] && [ "$strategy" != "multi-layer" ]; then
|
||||||
|
echo "❌ Error: Invalid strategy '$strategy'"
|
||||||
|
echo "Valid strategies: single-layer, multi-layer"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -76,6 +163,24 @@ update_module_claude() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Set default models if not specified
|
||||||
|
if [ -z "$model" ]; then
|
||||||
|
case "$tool" in
|
||||||
|
gemini)
|
||||||
|
model="gemini-2.5-flash"
|
||||||
|
;;
|
||||||
|
qwen)
|
||||||
|
model="coder-model"
|
||||||
|
;;
|
||||||
|
codex)
|
||||||
|
model="gpt5-codex"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
model=""
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
# Build exclusion filters from .gitignore
|
# Build exclusion filters from .gitignore
|
||||||
local exclusion_filters=$(build_exclusion_filters)
|
local exclusion_filters=$(build_exclusion_filters)
|
||||||
|
|
||||||
@@ -85,79 +190,105 @@ update_module_claude() {
|
|||||||
echo "⚠️ Skipping '$module_path' - no files found (after .gitignore filtering)"
|
echo "⚠️ Skipping '$module_path' - no files found (after .gitignore filtering)"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Use unified template for all modules
|
# Use unified template for all modules
|
||||||
local template_path="$HOME/.claude/workflows/cli-templates/prompts/memory/claude-module-unified.txt"
|
local template_path="$HOME/.claude/workflows/cli-templates/prompts/memory/claude-module-unified.txt"
|
||||||
local analysis_strategy="--all-files"
|
|
||||||
|
# Read template content directly
|
||||||
|
local template_content=""
|
||||||
|
if [ -f "$template_path" ]; then
|
||||||
|
template_content=$(cat "$template_path")
|
||||||
|
echo " 📋 Loaded template: $(wc -l < "$template_path") lines"
|
||||||
|
else
|
||||||
|
echo " ⚠️ Template not found: $template_path"
|
||||||
|
echo " Using fallback template..."
|
||||||
|
template_content="Create comprehensive CLAUDE.md documentation following standard structure with Purpose, Structure, Components, Dependencies, Integration, and Implementation sections."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Scan directory structure first
|
||||||
|
echo " 🔍 Scanning directory structure..."
|
||||||
|
local structure_info=$(scan_directory_structure "$module_path" "$strategy")
|
||||||
|
|
||||||
# Prepare logging info
|
# Prepare logging info
|
||||||
local module_name=$(basename "$module_path")
|
local module_name=$(basename "$module_path")
|
||||||
|
|
||||||
echo "⚡ Updating: $module_path"
|
echo "⚡ Updating: $module_path"
|
||||||
echo " Type: $update_type | Tool: $tool | Files: $file_count"
|
echo " Strategy: $strategy | Tool: $tool | Model: $model | Files: $file_count"
|
||||||
echo " Template: $(basename "$template_path")"
|
echo " Template: $(basename "$template_path") ($(echo "$template_content" | wc -l) lines)"
|
||||||
|
echo " Structure: Scanned $(echo "$structure_info" | wc -l) lines of structure info"
|
||||||
# Generate prompt with template injection
|
|
||||||
local template_content=""
|
|
||||||
if [ -f "$template_path" ]; then
|
|
||||||
template_content=$(cat "$template_path")
|
|
||||||
else
|
|
||||||
echo " ⚠️ Template not found: $template_path, using fallback"
|
|
||||||
template_content="Update CLAUDE.md documentation for this module: document structure, key components, dependencies, and integration points."
|
|
||||||
fi
|
|
||||||
|
|
||||||
local update_context=""
|
|
||||||
if [ "$update_type" = "full" ]; then
|
|
||||||
update_context="
|
|
||||||
Update Mode: Complete refresh
|
|
||||||
- Perform comprehensive analysis of all content
|
|
||||||
- Document module structure, dependencies, and key components
|
|
||||||
- Follow template guidelines strictly"
|
|
||||||
else
|
|
||||||
update_context="
|
|
||||||
Update Mode: Context-aware update
|
|
||||||
- Focus on recent changes and affected areas
|
|
||||||
- Maintain consistency with existing documentation
|
|
||||||
- Update only relevant sections
|
|
||||||
- Follow template guidelines for updated content"
|
|
||||||
fi
|
|
||||||
|
|
||||||
local base_prompt="
|
|
||||||
⚠️ CRITICAL RULES - MUST FOLLOW:
|
|
||||||
1. ONLY modify CLAUDE.md files
|
|
||||||
2. NEVER modify source code files
|
|
||||||
3. Focus exclusively on updating documentation
|
|
||||||
4. Follow the template guidelines exactly
|
|
||||||
|
|
||||||
$template_content
|
# Build minimal strategy-specific prompt with explicit paths and structure info
|
||||||
|
local final_prompt=""
|
||||||
|
|
||||||
|
if [ "$strategy" = "multi-layer" ]; then
|
||||||
|
# multi-layer strategy: read all, generate for each directory
|
||||||
|
final_prompt="Directory Structure Analysis:
|
||||||
|
$structure_info
|
||||||
|
|
||||||
|
Read: @**/*
|
||||||
|
|
||||||
|
Generate CLAUDE.md files:
|
||||||
|
- Primary: ./CLAUDE.md (current directory)
|
||||||
|
- Additional: CLAUDE.md in each subdirectory containing files
|
||||||
|
|
||||||
|
Template Guidelines:
|
||||||
|
$template_content
|
||||||
|
|
||||||
|
Instructions:
|
||||||
|
- Work bottom-up: deepest directories first
|
||||||
|
- Parent directories reference children
|
||||||
|
- Each CLAUDE.md file must be in its respective directory
|
||||||
|
- Follow the template guidelines above for consistent structure
|
||||||
|
- Use the structure analysis to understand directory hierarchy"
|
||||||
|
else
|
||||||
|
# single-layer strategy: read current + child CLAUDE.md, generate current only
|
||||||
|
final_prompt="Directory Structure Analysis:
|
||||||
|
$structure_info
|
||||||
|
|
||||||
|
Read: @*/CLAUDE.md @*.ts @*.tsx @*.js @*.jsx @*.py @*.sh @*.md @*.json @*.yaml @*.yml
|
||||||
|
|
||||||
|
Generate single file: ./CLAUDE.md
|
||||||
|
|
||||||
|
Template Guidelines:
|
||||||
|
$template_content
|
||||||
|
|
||||||
|
Instructions:
|
||||||
|
- Create exactly one CLAUDE.md file in the current directory
|
||||||
|
- Reference child CLAUDE.md files, do not duplicate their content
|
||||||
|
- Follow the template guidelines above for consistent structure
|
||||||
|
- Use the structure analysis to understand the current directory context"
|
||||||
|
fi
|
||||||
|
|
||||||
$update_context"
|
|
||||||
|
|
||||||
# Execute update
|
# Execute update
|
||||||
local start_time=$(date +%s)
|
local start_time=$(date +%s)
|
||||||
echo " 🔄 Starting update..."
|
echo " 🔄 Starting update..."
|
||||||
|
|
||||||
if cd "$module_path" 2>/dev/null; then
|
if cd "$module_path" 2>/dev/null; then
|
||||||
local tool_result=0
|
local tool_result=0
|
||||||
local final_prompt="$base_prompt
|
|
||||||
|
|
||||||
Module Information:
|
# Execute with selected tool
|
||||||
- Name: $module_name
|
# NOTE: Model parameter (-m) is placed AFTER the prompt
|
||||||
- Path: $module_path
|
|
||||||
- Tool: $tool"
|
|
||||||
|
|
||||||
# Execute with selected tool (always use --all-files)
|
|
||||||
case "$tool" in
|
case "$tool" in
|
||||||
qwen)
|
qwen)
|
||||||
qwen --all-files --yolo -p "$final_prompt" 2>&1
|
if [ "$model" = "coder-model" ]; then
|
||||||
|
# coder-model is default, -m is optional
|
||||||
|
qwen -p "$final_prompt" --yolo 2>&1
|
||||||
|
else
|
||||||
|
qwen -p "$final_prompt" -m "$model" --yolo 2>&1
|
||||||
|
fi
|
||||||
tool_result=$?
|
tool_result=$?
|
||||||
;;
|
;;
|
||||||
codex)
|
codex)
|
||||||
codex --full-auto exec "$final_prompt" --skip-git-repo-check -s danger-full-access 2>&1
|
codex --full-auto exec "$final_prompt" -m "$model" --skip-git-repo-check -s danger-full-access 2>&1
|
||||||
tool_result=$?
|
tool_result=$?
|
||||||
;;
|
;;
|
||||||
gemini|*)
|
gemini)
|
||||||
gemini --all-files --yolo -p "$final_prompt" 2>&1
|
gemini -p "$final_prompt" -m "$model" --yolo 2>&1
|
||||||
|
tool_result=$?
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo " ⚠️ Unknown tool: $tool, defaulting to gemini"
|
||||||
|
gemini -p "$final_prompt" -m "$model" --yolo 2>&1
|
||||||
tool_result=$?
|
tool_result=$?
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@@ -181,5 +312,22 @@ update_module_claude() {
|
|||||||
|
|
||||||
# Execute function if script is run directly
|
# Execute function if script is run directly
|
||||||
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||||
|
# Show help if no arguments or help requested
|
||||||
|
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
|
||||||
|
echo "Usage: update_module_claude.sh <strategy> <module_path> [tool] [model]"
|
||||||
|
echo ""
|
||||||
|
echo "Strategies:"
|
||||||
|
echo " single-layer - Read current dir code + child CLAUDE.md, generate ./CLAUDE.md"
|
||||||
|
echo " multi-layer - Read all files, generate CLAUDE.md for each directory"
|
||||||
|
echo ""
|
||||||
|
echo "Tools: gemini (default), qwen, codex"
|
||||||
|
echo "Models: Use tool defaults if not specified"
|
||||||
|
echo ""
|
||||||
|
echo "Examples:"
|
||||||
|
echo " ./update_module_claude.sh single-layer ./src/auth"
|
||||||
|
echo " ./update_module_claude.sh multi-layer ./components gemini gemini-2.5-flash"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
update_module_claude "$@"
|
update_module_claude "$@"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -1,6 +1,12 @@
|
|||||||
Create or update CLAUDE.md documentation using unified module/file template.
|
Create or update CLAUDE.md documentation using unified module/file template.
|
||||||
|
|
||||||
|
## ⚠️ FILE NAMING RULE (CRITICAL)
|
||||||
|
- Target file: MUST be named exactly `CLAUDE.md` in the current directory
|
||||||
|
- NEVER create files like `ToolSidebar.CLAUDE.md` or `[filename].CLAUDE.md`
|
||||||
|
- ALWAYS use the fixed name: `CLAUDE.md`
|
||||||
|
|
||||||
## CORE CHECKLIST ⚡
|
## CORE CHECKLIST ⚡
|
||||||
|
□ MUST create/update file named exactly 'CLAUDE.md' (not variants)
|
||||||
□ MUST include all 6 sections: Purpose, Structure, Components, Dependencies, Integration, Implementation
|
□ MUST include all 6 sections: Purpose, Structure, Components, Dependencies, Integration, Implementation
|
||||||
□ For code files: Document all public/exported APIs with complete parameter details
|
□ For code files: Document all public/exported APIs with complete parameter details
|
||||||
□ For folders: Reference subdirectory CLAUDE.md files instead of duplicating
|
□ For folders: Reference subdirectory CLAUDE.md files instead of duplicating
|
||||||
@@ -64,6 +70,11 @@ Create or update CLAUDE.md documentation using unified module/file template.
|
|||||||
|
|
||||||
## OUTPUT REQUIREMENTS
|
## OUTPUT REQUIREMENTS
|
||||||
|
|
||||||
|
### File Naming (CRITICAL)
|
||||||
|
- **Output file**: MUST be named exactly `CLAUDE.md` in the current directory
|
||||||
|
- **Examples of WRONG naming**: `ToolSidebar.CLAUDE.md`, `index.CLAUDE.md`, `utils.CLAUDE.md`
|
||||||
|
- **Correct naming**: `CLAUDE.md` (always, for all directories)
|
||||||
|
|
||||||
### Template Structure
|
### Template Structure
|
||||||
```markdown
|
```markdown
|
||||||
# [Module/File Name]
|
# [Module/File Name]
|
||||||
@@ -143,6 +154,7 @@ Create or update CLAUDE.md documentation using unified module/file template.
|
|||||||
- Update existing CLAUDE.md files rather than creating duplicate sections
|
- Update existing CLAUDE.md files rather than creating duplicate sections
|
||||||
|
|
||||||
## VERIFICATION CHECKLIST ✓
|
## VERIFICATION CHECKLIST ✓
|
||||||
|
□ Output file is named exactly 'CLAUDE.md' (not [filename].CLAUDE.md)
|
||||||
□ All 6 required sections included (Purpose, Structure, Components, Dependencies, Integration, Implementation)
|
□ All 6 required sections included (Purpose, Structure, Components, Dependencies, Integration, Implementation)
|
||||||
□ All public/exported APIs documented with complete signatures
|
□ All public/exported APIs documented with complete signatures
|
||||||
□ Parameters documented with types, descriptions, and defaults
|
□ Parameters documented with types, descriptions, and defaults
|
||||||
|
|||||||
@@ -148,10 +148,10 @@ bash(codex --full-auto exec "..." resume --last --skip-git-repo-check -s danger-
|
|||||||
|
|
||||||
### Gemini/Qwen Commands (Analysis/Documentation)
|
### Gemini/Qwen Commands (Analysis/Documentation)
|
||||||
```bash
|
```bash
|
||||||
bash(~/.claude/scripts/gemini-wrapper -p "PURPOSE: {purpose} TASK: {task} MODE: analysis CONTEXT: @{{synthesis_spec_path}} EXPECTED: {expected} RULES: {rules}")
|
bash(gemini "PURPOSE: {purpose} TASK: {task} MODE: analysis CONTEXT: @{synthesis_spec_path} EXPECTED: {expected} RULES: {rules}")
|
||||||
|
|
||||||
# With write permission
|
# With write permission
|
||||||
bash(~/.claude/scripts/gemini-wrapper --approval-mode yolo -p "PURPOSE: {purpose} TASK: {task} MODE: write CONTEXT: @{{context}} EXPECTED: {expected} RULES: {rules}")
|
bash(gemini --approval-mode yolo "PURPOSE: {purpose} TASK: {task} MODE: write CONTEXT: @{context} EXPECTED: {expected} RULES: {rules}")
|
||||||
```
|
```
|
||||||
|
|
||||||
## Field Descriptions
|
## Field Descriptions
|
||||||
@@ -175,4 +175,4 @@ bash(~/.claude/scripts/gemini-wrapper --approval-mode yolo -p "PURPOSE: {purpose
|
|||||||
5. **Step Dependencies**: Use `depends_on: [1, 2]` to specify execution order
|
5. **Step Dependencies**: Use `depends_on: [1, 2]` to specify execution order
|
||||||
6. **Parameter Position**:
|
6. **Parameter Position**:
|
||||||
- Codex: `--skip-git-repo-check -s danger-full-access` at END
|
- Codex: `--skip-git-repo-check -s danger-full-access` at END
|
||||||
- Gemini/Qwen: `--approval-mode yolo` AFTER wrapper command, BEFORE -p
|
- Gemini/Qwen: `--approval-mode yolo` BEFORE the prompt
|
||||||
|
|||||||
@@ -40,8 +40,8 @@ type: search-guideline
|
|||||||
### Quick Command Reference
|
### Quick Command Reference
|
||||||
```bash
|
```bash
|
||||||
# Semantic File Discovery (codebase-retrieval)
|
# Semantic File Discovery (codebase-retrieval)
|
||||||
~/.claude/scripts/gemini-wrapper --all-files -p "List all files relevant to: [task/feature description]"
|
gemini "CONTEXT: @**/* List all files relevant to: [task/feature description]"
|
||||||
bash(~/.claude/scripts/gemini-wrapper --all-files -p "List all files relevant to: [task/feature description]")
|
bash(gemini "CONTEXT: @**/* List all files relevant to: [task/feature description]")
|
||||||
|
|
||||||
# Program Architecture Analysis (MANDATORY FIRST)
|
# Program Architecture Analysis (MANDATORY FIRST)
|
||||||
~/.claude/scripts/get_modules_by_depth.sh # Discover program architecture
|
~/.claude/scripts/get_modules_by_depth.sh # Discover program architecture
|
||||||
@@ -65,7 +65,7 @@ grep -n -i "pattern" file.txt # Line numbers, case-insensitive
|
|||||||
### Workflow Integration Examples
|
### Workflow Integration Examples
|
||||||
```bash
|
```bash
|
||||||
# Semantic Discovery → Content Search → Analysis (Recommended Pattern)
|
# Semantic Discovery → Content Search → Analysis (Recommended Pattern)
|
||||||
~/.claude/scripts/gemini-wrapper --all-files -p "List all files relevant to: [task/feature]" # Get relevant files
|
gemini "CONTEXT: @**/* List all files relevant to: [task/feature]" # Get relevant files
|
||||||
rg "[pattern]" --type [filetype] # Then search within discovered files
|
rg "[pattern]" --type [filetype] # Then search within discovered files
|
||||||
|
|
||||||
# Program Architecture Analysis (MANDATORY BEFORE PLANNING)
|
# Program Architecture Analysis (MANDATORY BEFORE PLANNING)
|
||||||
|
|||||||
@@ -7,67 +7,93 @@ type: strategic-guideline
|
|||||||
# Intelligent Tools Selection Strategy
|
# Intelligent Tools Selection Strategy
|
||||||
|
|
||||||
## 📋 Table of Contents
|
## 📋 Table of Contents
|
||||||
1. [Core Framework](#-core-framework)
|
1. [Quick Start](#-quick-start)
|
||||||
2. [Tool Specifications](#-tool-specifications)
|
2. [Tool Specifications](#-tool-specifications)
|
||||||
3. [Command Templates](#-command-templates)
|
3. [Command Templates](#-command-templates)
|
||||||
4. [Tool Selection Guide](#-tool-selection-guide)
|
4. [Execution Configuration](#-execution-configuration)
|
||||||
5. [Usage Patterns](#-usage-patterns)
|
5. [Best Practices](#-best-practices)
|
||||||
6. [Best Practices](#-best-practices)
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## ⚡ Core Framework
|
## ⚡ Quick Start
|
||||||
|
|
||||||
### Tool Overview
|
### Tool Overview
|
||||||
- **Gemini**: Analysis, understanding, exploration & documentation (primary)
|
- **Gemini**: Analysis, understanding, exploration & documentation (primary)
|
||||||
- **Qwen**: Analysis, understanding, exploration & documentation (fallback, same capabilities as Gemini)
|
- **Qwen**: Analysis, understanding, exploration & documentation (fallback, same capabilities as Gemini)
|
||||||
- **Codex**: Development, implementation & automation
|
- **Codex**: Development, implementation & automation
|
||||||
|
|
||||||
### Decision Principles
|
### Model Selection (-m parameter)
|
||||||
|
|
||||||
|
**Gemini Models**:
|
||||||
|
- `gemini-2.5-pro` - Analysis tasks (default)
|
||||||
|
- `gemini-2.5-flash` - Documentation updates
|
||||||
|
|
||||||
|
**Qwen Models**:
|
||||||
|
- `coder-model` - Code analysis (default, -m optional)
|
||||||
|
- `vision-model` - Image analysis (rare usage)
|
||||||
|
|
||||||
|
**Codex Models**:
|
||||||
|
- `gpt-5` - Analysis & execution (default)
|
||||||
|
- `gpt5-codex` - Large context tasks
|
||||||
|
|
||||||
|
**Usage**: `tool -p "prompt" -m model-name` (NOTE: -m placed AFTER prompt)
|
||||||
|
|
||||||
|
### Quick Decision Matrix
|
||||||
|
|
||||||
|
| Scenario | Tool | Command Pattern |
|
||||||
|
|----------|------|-----------------|
|
||||||
|
| **Exploring/Understanding** | Gemini → Qwen | `cd [dir] && gemini -p "PURPOSE:... CONTEXT: @**/*"` |
|
||||||
|
| **Architecture/Analysis** | Gemini → Qwen | `cd [dir] && gemini -p "PURPOSE:... CONTEXT: @**/*"` |
|
||||||
|
| **Building/Fixing** | Codex | `codex -C [dir] --full-auto exec "PURPOSE:... MODE: auto"` |
|
||||||
|
| **Not sure?** | Multiple | Use tools in parallel |
|
||||||
|
| **Small task?** | Still use tools | Tools are faster than manual work |
|
||||||
|
|
||||||
|
### Core Principles
|
||||||
- **Use tools early and often** - Tools are faster, more thorough, and reliable than manual approaches
|
- **Use tools early and often** - Tools are faster, more thorough, and reliable than manual approaches
|
||||||
- **When in doubt, use both** - Parallel usage provides comprehensive coverage
|
- **When in doubt, use both** - Parallel usage provides comprehensive coverage
|
||||||
- **Default to tools** - Use specialized tools for most coding tasks, no matter how small
|
- **Default to tools** - Use specialized tools for most coding tasks, no matter how small
|
||||||
- **Lower barriers** - Engage tools immediately when encountering any complexity
|
- **Lower barriers** - Engage tools immediately when encountering any complexity
|
||||||
- **Context optimization** - Based on user intent, determine whether to use `-C [directory]` parameter for focused analysis to reduce irrelevant context import
|
|
||||||
- **⚠️ Write operation protection** - For local codebase write/modify operations, require EXPLICIT user confirmation unless user provides clear instructions containing MODE=write or MODE=auto
|
- **⚠️ Write operation protection** - For local codebase write/modify operations, require EXPLICIT user confirmation unless user provides clear instructions containing MODE=write or MODE=auto
|
||||||
|
|
||||||
### Quick Decision Rules
|
|
||||||
1. **Exploring/Understanding?** → Start with Gemini (fallback to Qwen if needed)
|
|
||||||
2. **Architecture/Analysis?** → Start with Gemini (fallback to Qwen if needed)
|
|
||||||
3. **Building/Fixing?** → Start with Codex
|
|
||||||
4. **Not sure?** → Use multiple tools in parallel
|
|
||||||
5. **Small task?** → Still use tools - they're faster than manual work
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 🎯 Tool Specifications
|
## 🎯 Tool Specifications
|
||||||
|
|
||||||
### Gemini
|
### Gemini & Qwen
|
||||||
- **Command**: `~/.claude/scripts/gemini-wrapper`
|
|
||||||
|
#### Overview
|
||||||
|
- **Commands**: `gemini` (primary) | `qwen` (fallback)
|
||||||
- **Strengths**: Large context window, pattern recognition
|
- **Strengths**: Large context window, pattern recognition
|
||||||
- **Best For**: Analysis, documentation generation, code exploration
|
- **Best For**: Analysis, documentation generation, code exploration, architecture review
|
||||||
- **Permissions**: Default read-only analysis, MODE=write requires explicit specification (auto-enables --approval-mode yolo)
|
- **Permissions**: Default read-only analysis, MODE=write requires explicit specification
|
||||||
- **Default MODE**: `analysis` (read-only)
|
- **Default MODE**: `analysis` (read-only)
|
||||||
- **⚠️ Write Trigger**: Only when user explicitly requests "generate documentation", "modify code", or specifies MODE=write
|
- **⚠️ Write Trigger**: Only when user explicitly requests "generate documentation", "modify code", or specifies MODE=write
|
||||||
|
- **Priority**: Prefer Gemini; use Qwen as fallback when Gemini unavailable
|
||||||
|
|
||||||
#### MODE Options
|
#### MODE Options
|
||||||
- `analysis` (default) - Read-only analysis and documentation generation
|
|
||||||
- `write` - ⚠️ Create/modify codebase files (requires explicit specification, auto-enables --approval-mode yolo)
|
|
||||||
|
|
||||||
### Qwen
|
**analysis** (default) - Read-only analysis and documentation generation
|
||||||
- **Command**: `~/.claude/scripts/qwen-wrapper`
|
- **⚠️ CRITICAL CONSTRAINT**: Absolutely NO file creation, modification, or deletion operations
|
||||||
- **Strengths**: Large context window, pattern recognition (same as Gemini)
|
- Analysis output should be returned as text response only
|
||||||
- **Best For**: Analysis, documentation generation, code exploration (fallback option when Gemini unavailable)
|
- Use for: code review, architecture analysis, pattern discovery, documentation reading
|
||||||
- **Permissions**: Default read-only analysis, MODE=write requires explicit specification (auto-enables --approval-mode yolo)
|
|
||||||
- **Default MODE**: `analysis` (read-only)
|
|
||||||
- **⚠️ Write Trigger**: Only when user explicitly requests "generate documentation", "modify code", or specifies MODE=write
|
|
||||||
- **Priority**: Secondary to Gemini - use as fallback for same tasks
|
|
||||||
|
|
||||||
#### MODE Options
|
**write** - ⚠️ Create/modify codebase files (requires explicit specification, auto-enables --approval-mode yolo)
|
||||||
- `analysis` (default) - Read-only analysis and documentation generation (same as Gemini)
|
- Use for: generating documentation files, creating code files, modifying existing files
|
||||||
- `write` - ⚠️ Create/modify codebase files (requires explicit specification, auto-enables --approval-mode yolo)
|
|
||||||
|
#### Tool Selection
|
||||||
|
```bash
|
||||||
|
# Default: Use Gemini
|
||||||
|
gemini -p "analysis prompt"
|
||||||
|
|
||||||
|
# Fallback: Use Qwen if Gemini unavailable
|
||||||
|
qwen -p "analysis prompt"
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
### Codex
|
### Codex
|
||||||
|
|
||||||
|
#### Overview
|
||||||
- **Command**: `codex --full-auto exec`
|
- **Command**: `codex --full-auto exec`
|
||||||
- **Strengths**: Autonomous development, mathematical reasoning
|
- **Strengths**: Autonomous development, mathematical reasoning
|
||||||
- **Best For**: Implementation, testing, automation
|
- **Best For**: Implementation, testing, automation
|
||||||
@@ -76,27 +102,39 @@ type: strategic-guideline
|
|||||||
- **⚠️ Write Trigger**: Only when user explicitly requests "implement", "modify", "generate code" AND specifies MODE
|
- **⚠️ Write Trigger**: Only when user explicitly requests "implement", "modify", "generate code" AND specifies MODE
|
||||||
|
|
||||||
#### MODE Options
|
#### MODE Options
|
||||||
- `auto` - ⚠️ Autonomous development with full file operations (requires explicit specification, enables -s danger-full-access)
|
|
||||||
- `write` - ⚠️ Test generation and file modification (requires explicit specification)
|
**auto** - ⚠️ Autonomous development with full file operations
|
||||||
- **Default**: No default mode, MODE must be explicitly specified
|
- Requires explicit specification
|
||||||
|
- Enables `-s danger-full-access`
|
||||||
|
- Use for: feature implementation, bug fixes, autonomous development
|
||||||
|
|
||||||
|
**write** - ⚠️ Test generation and file modification
|
||||||
|
- Requires explicit specification
|
||||||
|
- Use for: test generation, focused file modifications
|
||||||
|
|
||||||
#### Session Management
|
#### Session Management
|
||||||
- `codex resume` - Resume previous interactive session (picker by default)
|
|
||||||
- `codex exec "task" resume --last` - Continue most recent session with new task (maintains context)
|
|
||||||
- `codex -i <image_file>` - Attach image(s) to initial prompt (useful for UI/design references)
|
|
||||||
- **Multi-task Pattern**: First task uses `exec`, subsequent tasks use `exec "..." resume --last` for context continuity
|
|
||||||
- **Parameter Position**: `resume --last` must be placed AFTER the prompt string at command END
|
|
||||||
- **Example**:
|
|
||||||
```bash
|
|
||||||
# First task - establish session
|
|
||||||
codex -C project --full-auto exec "Implement auth module" --skip-git-repo-check -s danger-full-access
|
|
||||||
|
|
||||||
# Subsequent tasks - continue same session
|
**Basic Commands**:
|
||||||
codex --full-auto exec "Add JWT validation" resume --last --skip-git-repo-check -s danger-full-access
|
- `codex resume` - Resume previous interactive session (picker by default)
|
||||||
codex --full-auto exec "Write auth tests" resume --last --skip-git-repo-check -s danger-full-access
|
- `codex resume --last` - Resume most recent session directly
|
||||||
```
|
- `codex -i <image_file>` - Attach image(s) to initial prompt (useful for UI/design references)
|
||||||
|
|
||||||
|
**Multi-task Pattern**: First task uses `exec`, subsequent tasks use `exec "..." resume --last` for context continuity
|
||||||
|
|
||||||
|
**Parameter Position**: `resume --last` must be placed AFTER the prompt string at command END
|
||||||
|
|
||||||
|
**Example**:
|
||||||
|
```bash
|
||||||
|
# First task - establish session
|
||||||
|
codex -C project --full-auto exec "Implement auth module" --skip-git-repo-check -s danger-full-access
|
||||||
|
|
||||||
|
# Subsequent tasks - continue same session
|
||||||
|
codex --full-auto exec "Add JWT validation" resume --last --skip-git-repo-check -s danger-full-access
|
||||||
|
codex --full-auto exec "Write auth tests" resume --last --skip-git-repo-check -s danger-full-access
|
||||||
|
```
|
||||||
|
|
||||||
#### Auto-Resume Decision Rules
|
#### Auto-Resume Decision Rules
|
||||||
|
|
||||||
**When to use `resume --last`**:
|
**When to use `resume --last`**:
|
||||||
- Current task is related to/extends previous Codex task in conversation memory
|
- Current task is related to/extends previous Codex task in conversation memory
|
||||||
- Current task requires context from previous implementation
|
- Current task requires context from previous implementation
|
||||||
@@ -114,125 +152,170 @@ type: strategic-guideline
|
|||||||
## 🎯 Command Templates
|
## 🎯 Command Templates
|
||||||
|
|
||||||
### Universal Template Structure
|
### Universal Template Structure
|
||||||
|
|
||||||
Every command MUST follow this structure:
|
Every command MUST follow this structure:
|
||||||
- [ ] **PURPOSE** - Clear goal and intent
|
- [ ] **PURPOSE** - Clear goal and intent
|
||||||
- [ ] **TASK** - Specific execution task
|
- [ ] **TASK** - Specific execution task (use list format: • Task item 1 • Task item 2 • Task item 3)
|
||||||
- [ ] **MODE** - Execution mode and permission level
|
- [ ] **MODE** - Execution mode and permission level
|
||||||
- [ ] **CONTEXT** - File references and memory context from previous sessions
|
- [ ] **CONTEXT** - File references and memory context from previous sessions
|
||||||
- [ ] **EXPECTED** - Clear expected results
|
- [ ] **EXPECTED** - Clear expected results
|
||||||
- [ ] **RULES** - Template reference and constraints
|
- [ ] **RULES** - Template reference and constraints (include mode constraints: analysis=READ-ONLY | write=CREATE/MODIFY/DELETE | auto=FULL operations)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
### Standard Command Formats
|
### Standard Command Formats
|
||||||
|
|
||||||
#### Gemini Commands
|
#### Gemini & Qwen Commands
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Gemini Analysis (read-only, default)
|
# Analysis Mode (read-only, default)
|
||||||
cd [directory] && ~/.claude/scripts/gemini-wrapper -p "
|
# Use 'gemini' (primary) or 'qwen' (fallback)
|
||||||
|
cd [directory] && gemini -p "
|
||||||
PURPOSE: [clear analysis goal]
|
PURPOSE: [clear analysis goal]
|
||||||
TASK: [specific analysis task]
|
TASK: [specific analysis task]
|
||||||
MODE: analysis
|
MODE: analysis
|
||||||
CONTEXT: [file references and memory context]
|
CONTEXT: @**/* [default: all files, or specify file patterns]
|
||||||
EXPECTED: [expected output]
|
EXPECTED: [expected output]
|
||||||
RULES: [template reference and constraints]
|
RULES: [template reference and constraints]
|
||||||
"
|
"
|
||||||
|
|
||||||
# Gemini Write Mode (requires explicit MODE=write)
|
# Model Selection Examples (NOTE: -m placed AFTER prompt)
|
||||||
# NOTE: --approval-mode yolo must be placed AFTER wrapper command, BEFORE -p
|
cd [directory] && gemini -p "..." -m gemini-2.5-pro # Analysis (default)
|
||||||
cd [directory] && ~/.claude/scripts/gemini-wrapper --approval-mode yolo -p "
|
cd [directory] && gemini -p "..." -m gemini-2.5-flash # Documentation updates
|
||||||
|
cd [directory] && qwen -p "..." # coder-model (default, -m optional)
|
||||||
|
cd [directory] && qwen -p "..." -m vision-model # Image analysis (rare)
|
||||||
|
|
||||||
|
# Write Mode (requires explicit MODE=write)
|
||||||
|
# NOTE: --approval-mode yolo must be placed AFTER the prompt
|
||||||
|
cd [directory] && gemini -p "
|
||||||
PURPOSE: [clear goal]
|
PURPOSE: [clear goal]
|
||||||
TASK: [specific task]
|
TASK: [specific task]
|
||||||
MODE: write
|
MODE: write
|
||||||
CONTEXT: [file references and memory context]
|
CONTEXT: @**/* [default: all files, or specify file patterns]
|
||||||
EXPECTED: [expected output]
|
EXPECTED: [expected output]
|
||||||
RULES: [template reference and constraints]
|
RULES: [template reference and constraints]
|
||||||
"
|
" -m gemini-2.5-flash --approval-mode yolo
|
||||||
```
|
|
||||||
|
|
||||||
#### Qwen Commands
|
# Fallback: Replace 'gemini' with 'qwen' if Gemini unavailable
|
||||||
```bash
|
cd [directory] && qwen -p "..." # coder-model default (-m optional)
|
||||||
# Qwen Analysis (read-only, default) - Same as Gemini, use as fallback
|
|
||||||
cd [directory] && ~/.claude/scripts/qwen-wrapper -p "
|
|
||||||
PURPOSE: [clear analysis goal]
|
|
||||||
TASK: [specific analysis task]
|
|
||||||
MODE: analysis
|
|
||||||
CONTEXT: [file references and memory context]
|
|
||||||
EXPECTED: [expected output]
|
|
||||||
RULES: [template reference and constraints]
|
|
||||||
"
|
|
||||||
|
|
||||||
# Qwen Write Mode (requires explicit MODE=write)
|
|
||||||
# NOTE: --approval-mode yolo must be placed AFTER wrapper command, BEFORE -p
|
|
||||||
cd [directory] && ~/.claude/scripts/qwen-wrapper --approval-mode yolo -p "
|
|
||||||
PURPOSE: [clear goal]
|
|
||||||
TASK: [specific task]
|
|
||||||
MODE: write
|
|
||||||
CONTEXT: [file references and memory context]
|
|
||||||
EXPECTED: [expected output]
|
|
||||||
RULES: [template reference and constraints]
|
|
||||||
"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Codex Commands
|
#### Codex Commands
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Codex Development (requires explicit MODE=auto)
|
# Codex Development (requires explicit MODE=auto)
|
||||||
# NOTE: --skip-git-repo-check and -s danger-full-access must be placed at command END
|
# NOTE: -m, --skip-git-repo-check and -s danger-full-access must be placed at command END
|
||||||
codex -C [directory] --full-auto exec "
|
codex -C [directory] --full-auto exec "
|
||||||
PURPOSE: [clear development goal]
|
PURPOSE: [clear development goal]
|
||||||
TASK: [specific development task]
|
TASK: [specific development task]
|
||||||
MODE: auto
|
MODE: auto
|
||||||
CONTEXT: [file references and memory context]
|
CONTEXT: @**/* [default: all files, or specify file patterns and memory context]
|
||||||
EXPECTED: [expected deliverables]
|
EXPECTED: [expected deliverables]
|
||||||
RULES: [template reference and constraints]
|
RULES: [template reference and constraints]
|
||||||
" --skip-git-repo-check -s danger-full-access
|
" -m gpt-5 --skip-git-repo-check -s danger-full-access
|
||||||
|
|
||||||
|
# Model Selection Examples (NOTE: -m placed AFTER prompt, BEFORE flags)
|
||||||
|
codex -C [directory] --full-auto exec "..." -m gpt-5 --skip-git-repo-check -s danger-full-access # Analysis & execution (default)
|
||||||
|
codex -C [directory] --full-auto exec "..." -m gpt5-codex --skip-git-repo-check -s danger-full-access # Large context tasks
|
||||||
|
|
||||||
# Codex Test/Write Mode (requires explicit MODE=write)
|
# Codex Test/Write Mode (requires explicit MODE=write)
|
||||||
# NOTE: --skip-git-repo-check and -s danger-full-access must be placed at command END
|
# NOTE: -m, --skip-git-repo-check and -s danger-full-access must be placed at command END
|
||||||
codex -C [directory] --full-auto exec "
|
codex -C [directory] --full-auto exec "
|
||||||
PURPOSE: [clear goal]
|
PURPOSE: [clear goal]
|
||||||
TASK: [specific task]
|
TASK: [specific task]
|
||||||
MODE: write
|
MODE: write
|
||||||
CONTEXT: [file references and memory context]
|
CONTEXT: @**/* [default: all files, or specify file patterns and memory context]
|
||||||
EXPECTED: [expected deliverables]
|
EXPECTED: [expected deliverables]
|
||||||
RULES: [template reference and constraints]
|
RULES: [template reference and constraints]
|
||||||
" --skip-git-repo-check -s danger-full-access
|
" -m gpt-5 --skip-git-repo-check -s danger-full-access
|
||||||
```
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
### Directory Context Configuration
|
### Directory Context Configuration
|
||||||
Tools execute in current working directory:
|
|
||||||
- **Gemini**: `cd path/to/project && ~/.claude/scripts/gemini-wrapper -p "prompt"`
|
**Tool Directory Navigation**:
|
||||||
- **Qwen**: `cd path/to/project && ~/.claude/scripts/qwen-wrapper -p "prompt"`
|
- **Gemini & Qwen**: `cd path/to/project && gemini -p "prompt"` (or `qwen`)
|
||||||
- **Codex**: `codex -C path/to/project --full-auto exec "task"` (Codex still supports -C)
|
- **Codex**: `codex -C path/to/project --full-auto exec "task"` (Codex still supports -C)
|
||||||
- **Path types**: Supports both relative (`../project`) and absolute (`/full/path`) paths
|
- **Path types**: Supports both relative (`../project`) and absolute (`/full/path`) paths
|
||||||
- **Token analysis**: For gemini-wrapper and qwen-wrapper, token counting happens in current directory
|
- **Token analysis**: For Gemini/Qwen, token counting happens in current directory
|
||||||
|
|
||||||
### RULES Field Format
|
#### ⚠️ Critical Directory Scope Rules
|
||||||
|
|
||||||
|
**Once `cd` to a directory**:
|
||||||
|
- **@ references ONLY apply to current directory and its subdirectories**
|
||||||
|
- `@**/*` = All files within current directory tree
|
||||||
|
- `@*.ts` = TypeScript files in current directory tree
|
||||||
|
- `@src/**/*` = Files within src subdirectory (if exists under current directory)
|
||||||
|
- **CANNOT reference parent or sibling directories via @ alone**
|
||||||
|
|
||||||
|
**To reference files outside current directory (TWO-STEP REQUIREMENT)**:
|
||||||
|
- **Step 1**: Add `--include-directories` parameter to make external directories ACCESSIBLE
|
||||||
|
- **Step 2**: Explicitly reference external files in CONTEXT field with @ patterns
|
||||||
|
- **⚠️ BOTH steps are MANDATORY** - missing either step will fail
|
||||||
|
- Example: `cd src/auth && gemini -p "CONTEXT: @**/* @../shared/**/*" --include-directories ../shared`
|
||||||
|
- **Rule**: If CONTEXT contains `@../dir/**/*`, command MUST include `--include-directories ../dir`
|
||||||
|
- Without `--include-directories`, @ patterns CANNOT access parent/sibling directories at all
|
||||||
|
|
||||||
|
#### Multi-Directory Support (Gemini & Qwen)
|
||||||
|
|
||||||
|
**Purpose**: For large projects requiring fine-grained access across multiple directories
|
||||||
|
|
||||||
|
**Use Case**: When `cd` limits scope but you need to reference files from parent/sibling folders
|
||||||
|
|
||||||
|
**Parameter**: `--include-directories <dir1,dir2,...>`
|
||||||
|
- Includes additional directories in the workspace beyond current `cd` directory
|
||||||
|
- Can be specified multiple times or as comma-separated values
|
||||||
|
- Maximum 5 directories can be added
|
||||||
|
- **REQUIRED** when working in a subdirectory but needing context from parent or sibling directories
|
||||||
|
|
||||||
|
**Syntax Options**:
|
||||||
```bash
|
```bash
|
||||||
RULES: $(cat "~/.claude/workflows/cli-templates/prompts/[category]/[template].txt") | [constraints]
|
# Comma-separated format
|
||||||
|
gemini -p "prompt" --include-directories /path/to/project1,/path/to/project2
|
||||||
|
|
||||||
|
# Multiple flags format
|
||||||
|
gemini -p "prompt" --include-directories /path/to/project1 --include-directories /path/to/project2
|
||||||
|
|
||||||
|
# Combined with cd for focused analysis with extended context (RECOMMENDED)
|
||||||
|
cd src/auth && gemini -p "
|
||||||
|
PURPOSE: Analyze authentication with shared utilities context
|
||||||
|
TASK: Review auth implementation and its dependencies
|
||||||
|
MODE: analysis
|
||||||
|
CONTEXT: @**/* @../shared/**/* @../types/**/*
|
||||||
|
EXPECTED: Complete analysis with cross-directory dependencies
|
||||||
|
RULES: Focus on integration patterns
|
||||||
|
" --include-directories ../shared,../types
|
||||||
```
|
```
|
||||||
|
|
||||||
**⚠️ CRITICAL: Command Substitution Rules**
|
**Best Practices**:
|
||||||
When using `$(cat ...)` for template loading in actual CLI commands:
|
- **Recommended Pattern**: Use `cd` to navigate to primary focus directory, then use `--include-directories` for additional context
|
||||||
- **Template reference only, never read**: When user specifies template name, use `$(cat ...)` directly in RULES field, do NOT read template content first
|
- Example: `cd src/auth && gemini -p "CONTEXT: @**/* @../shared/**/*" --include-directories ../shared,../types`
|
||||||
- **NEVER use escape characters**: `\$`, `\"`, `\'` will break command substitution
|
- **⚠️ CRITICAL**: CONTEXT must explicitly list external files (e.g., `@../shared/**/*`), AND command must include `--include-directories ../shared`
|
||||||
- **In -p "..." context**: Path in `$(cat ...)` needs NO quotes (tilde expands correctly)
|
- Benefits: More precise file references (relative to current directory), clearer intent, better context control
|
||||||
- **Correct**: `RULES: $(cat ~/.claude/workflows/cli-templates/prompts/analysis/pattern.txt)`
|
- **Enforcement Rule**: When CONTEXT references external directories, ALWAYS add corresponding `--include-directories`
|
||||||
- **WRONG**: `RULES: \$(cat ...)` or `RULES: $(cat \"...\")` or `RULES: $(cat '...')`
|
- Use when `cd` alone limits necessary context visibility
|
||||||
- **Why**: Shell executes `$(...)` in subshell where path is safe without quotes
|
- Keep directory count ≤ 5 for optimal performance
|
||||||
|
- **Pattern matching rule**: `@../dir/**/*` in CONTEXT → `--include-directories ../dir` in command (MANDATORY)
|
||||||
|
- Prefer `cd + --include-directories` over multiple `cd` commands for cross-directory analysis
|
||||||
|
|
||||||
**Examples**:
|
---
|
||||||
- Single template: `$(cat "~/.claude/workflows/cli-templates/prompts/analysis/pattern.txt") | Focus on security`
|
|
||||||
- Multiple templates: `$(cat "template1.txt") $(cat "template2.txt") | Enterprise standards`
|
|
||||||
- No template: `Focus on security patterns, include dependency analysis`
|
|
||||||
- File patterns: `@{src/**/*.ts,CLAUDE.md} - Stay within scope`
|
|
||||||
|
|
||||||
### File Pattern Reference
|
### CONTEXT Field Configuration
|
||||||
- All files: `@{**/*}`
|
|
||||||
- Source files: `@{src/**/*}`
|
#### File Pattern Reference
|
||||||
- TypeScript: `@{*.ts,*.tsx}`
|
|
||||||
- With docs: `@{CLAUDE.md,**/*CLAUDE.md}`
|
**Default Pattern**:
|
||||||
- Tests: `@{src/**/*.test.*}`
|
- **All files (default)**: `@**/*` - Use this as default for comprehensive context
|
||||||
|
|
||||||
|
**Common Patterns**:
|
||||||
|
- Source files: `@src/**/*`
|
||||||
|
- TypeScript: `@*.ts @*.tsx` (multiple @ for multiple patterns)
|
||||||
|
- With docs: `@CLAUDE.md @**/*CLAUDE.md` (multiple @ for multiple patterns)
|
||||||
|
- Tests: `@src/**/*.test.*`
|
||||||
|
|
||||||
|
#### Complex Pattern Discovery
|
||||||
|
|
||||||
**Complex Pattern Discovery**:
|
|
||||||
For complex file pattern requirements, use semantic discovery tools BEFORE CLI execution:
|
For complex file pattern requirements, use semantic discovery tools BEFORE CLI execution:
|
||||||
- **rg (ripgrep)**: Content-based file discovery with regex patterns
|
- **rg (ripgrep)**: Content-based file discovery with regex patterns
|
||||||
- **Code Index MCP**: Semantic file search based on task requirements
|
- **Code Index MCP**: Semantic file search based on task requirements
|
||||||
@@ -245,14 +328,14 @@ rg "export.*Component" --files-with-matches --type ts # Find component files
|
|||||||
mcp__code-index__search_code_advanced(pattern="interface.*Props", file_pattern="*.tsx") # Find interface files
|
mcp__code-index__search_code_advanced(pattern="interface.*Props", file_pattern="*.tsx") # Find interface files
|
||||||
|
|
||||||
# Step 2: Build precise CONTEXT from discovery results
|
# Step 2: Build precise CONTEXT from discovery results
|
||||||
CONTEXT: @{src/components/Auth.tsx,src/types/auth.d.ts,src/hooks/useAuth.ts}
|
CONTEXT: @src/components/Auth.tsx @src/types/auth.d.ts @src/hooks/useAuth.ts
|
||||||
|
|
||||||
# Step 3: Execute CLI with precise file references
|
# Step 3: Execute CLI with precise file references
|
||||||
cd src && ~/.claude/scripts/gemini-wrapper -p "
|
cd src && gemini -p "
|
||||||
PURPOSE: Analyze authentication components
|
PURPOSE: Analyze authentication components
|
||||||
TASK: Review auth component patterns and props interfaces
|
TASK: Review auth component patterns and props interfaces
|
||||||
MODE: analysis
|
MODE: analysis
|
||||||
CONTEXT: @{components/Auth.tsx,types/auth.d.ts,hooks/useAuth.ts}
|
CONTEXT: @components/Auth.tsx @types/auth.d.ts @hooks/useAuth.ts
|
||||||
EXPECTED: Pattern analysis and improvement suggestions
|
EXPECTED: Pattern analysis and improvement suggestions
|
||||||
RULES: Focus on type safety and component composition
|
RULES: Focus on type safety and component composition
|
||||||
"
|
"
|
||||||
@@ -260,26 +343,38 @@ RULES: Focus on type safety and component composition
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 📊 Tool Selection Guide
|
### RULES Field Configuration
|
||||||
|
|
||||||
### Selection Matrix
|
#### Basic Format
|
||||||
|
```bash
|
||||||
|
RULES: $(cat ~/.claude/workflows/cli-templates/prompts/[category]/[template].txt) | [constraints]
|
||||||
|
```
|
||||||
|
|
||||||
| Task Type | Tool | Use Case | Template |
|
#### ⚠️ CRITICAL: Command Substitution Rules
|
||||||
|-----------|------|----------|-----------|
|
|
||||||
| **Analysis** | Gemini (Qwen fallback) | Code exploration, architecture review, patterns | `analysis/pattern.txt` |
|
When using `$(cat ...)` for template loading in actual CLI commands:
|
||||||
| **Architecture** | Gemini (Qwen fallback) | System design, architectural analysis | `analysis/architecture.txt` |
|
- **Template reference only, never read**: When user specifies template name, use `$(cat ...)` directly in RULES field, do NOT read template content first
|
||||||
| **Documentation** | Gemini (Qwen fallback) | Code docs, API specs, guides | `analysis/quality.txt` |
|
- **NEVER use escape characters**: `\$`, `\"`, `\'` will break command substitution
|
||||||
| **Development** | Codex | Feature implementation, bug fixes, testing | `development/feature.txt` |
|
- **In prompt context**: Path in `$(cat ...)` needs NO quotes (tilde expands correctly)
|
||||||
| **Planning** | Gemini/Qwen | Task breakdown, migration planning | `planning/task-breakdown.txt` |
|
- **Correct**: `RULES: $(cat ~/.claude/workflows/cli-templates/prompts/analysis/pattern.txt)`
|
||||||
| **Security** | Codex | Vulnerability assessment, fixes | `analysis/security.txt` |
|
- **WRONG**: `RULES: \$(cat ...)` or `RULES: $(cat \"...\")` or `RULES: $(cat '...')`
|
||||||
| **Refactoring** | Multiple | Gemini/Qwen for analysis, Codex for execution | `development/refactor.txt` |
|
- **Why**: Shell executes `$(...)` in subshell where path is safe without quotes
|
||||||
| **Module Documentation** | Gemini (Qwen fallback) | Universal module/file documentation for all levels | `memory/claude-module-unified.txt` |
|
|
||||||
|
#### Examples
|
||||||
|
- Single template: `$(cat ~/.claude/workflows/cli-templates/prompts/analysis/pattern.txt) | Focus on security`
|
||||||
|
- Multiple templates: `$(cat template1.txt) $(cat template2.txt) | Enterprise standards`
|
||||||
|
- No template: `Focus on security patterns, include dependency analysis`
|
||||||
|
- File patterns: `@src/**/*.ts @CLAUDE.md - Stay within scope`
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
### Template System
|
### Template System
|
||||||
|
|
||||||
**Base Structure**: `~/.claude/workflows/cli-templates/`
|
#### Base Structure
|
||||||
|
`~/.claude/workflows/cli-templates/`
|
||||||
|
|
||||||
#### Available Templates
|
#### Available Templates
|
||||||
|
|
||||||
```
|
```
|
||||||
prompts/
|
prompts/
|
||||||
├── analysis/
|
├── analysis/
|
||||||
@@ -307,11 +402,103 @@ tech-stacks/
|
|||||||
└── react-dev.md - React architecture
|
└── react-dev.md - React architecture
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Task-Template Selection Matrix
|
||||||
|
|
||||||
|
| Task Type | Tool | Use Case | Template |
|
||||||
|
|-----------|------|----------|-----------|
|
||||||
|
| **Analysis** | Gemini (Qwen fallback) | Code exploration, architecture review, patterns | `analysis/pattern.txt` |
|
||||||
|
| **Architecture** | Gemini (Qwen fallback) | System design, architectural analysis | `analysis/architecture.txt` |
|
||||||
|
| **Documentation** | Gemini (Qwen fallback) | Code docs, API specs, guides | `analysis/quality.txt` |
|
||||||
|
| **Development** | Codex | Feature implementation, bug fixes, testing | `development/feature.txt` |
|
||||||
|
| **Planning** | Gemini/Qwen | Task breakdown, migration planning | `planning/task-breakdown.txt` |
|
||||||
|
| **Security** | Codex | Vulnerability assessment, fixes | `analysis/security.txt` |
|
||||||
|
| **Refactoring** | Multiple | Gemini/Qwen for analysis, Codex for execution | `development/refactor.txt` |
|
||||||
|
| **Module Documentation** | Gemini (Qwen fallback) | Universal module/file documentation for all levels | `memory/claude-module-unified.txt` |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 🚀 Usage Patterns
|
## ⚙️ Execution Configuration
|
||||||
|
|
||||||
|
### Dynamic Timeout Allocation
|
||||||
|
|
||||||
|
**Timeout Ranges**:
|
||||||
|
- **Simple tasks** (analysis, search): 20-40min (1200000-2400000ms)
|
||||||
|
- **Medium tasks** (refactoring, documentation): 40-60min (2400000-3600000ms)
|
||||||
|
- **Complex tasks** (implementation, migration): 60-120min (3600000-7200000ms)
|
||||||
|
|
||||||
|
**Codex Multiplier**: Codex commands use 1.5x of allocated time
|
||||||
|
|
||||||
|
**Application**: All bash() wrapped commands including Gemini, Qwen and Codex executions
|
||||||
|
|
||||||
|
**Auto-detection**: Analyze PURPOSE and TASK fields to determine appropriate timeout
|
||||||
|
|
||||||
|
**Command Examples**:
|
||||||
|
```bash
|
||||||
|
bash(gemini -p "prompt") # Simple analysis: 20-40min
|
||||||
|
bash(codex -C directory --full-auto exec "task") # Complex implementation: 90-180min
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Permission Framework
|
||||||
|
|
||||||
|
#### Write Operation Protection
|
||||||
|
|
||||||
|
**⚠️ WRITE PROTECTION**: Local codebase write/modify requires EXPLICIT user confirmation
|
||||||
|
|
||||||
|
**Mode Hierarchy**:
|
||||||
|
- **Analysis Mode (default)**: Read-only, safe for auto-execution
|
||||||
|
- **Write Mode**: Requires user explicitly states MODE=write or MODE=auto in prompt
|
||||||
|
- **Exception**: User provides clear instructions like "modify", "create", "implement"
|
||||||
|
|
||||||
|
#### Tool-Specific Permissions
|
||||||
|
|
||||||
|
**Gemini/Qwen Write Access**:
|
||||||
|
- Use `--approval-mode yolo` ONLY when MODE=write explicitly specified
|
||||||
|
- **Parameter Position**: Place AFTER the prompt: `gemini -p "..." --approval-mode yolo`
|
||||||
|
|
||||||
|
**Codex Write Access**:
|
||||||
|
- Use `-s danger-full-access` and `--skip-git-repo-check` ONLY when MODE=auto explicitly specified
|
||||||
|
- **Parameter Position**: Place AFTER the prompt string at command END: `codex ... exec "..." --skip-git-repo-check -s danger-full-access`
|
||||||
|
|
||||||
|
**Default Behavior**: All tools default to analysis/read-only mode without explicit write permission
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🔧 Best Practices
|
||||||
|
|
||||||
|
### General Guidelines
|
||||||
|
|
||||||
|
**Workflow Principles**:
|
||||||
|
- **Start with templates** - Use predefined templates for consistency
|
||||||
|
- **Be specific** - Clear PURPOSE, TASK, and EXPECTED fields
|
||||||
|
- **Include constraints** - File patterns, scope, requirements in RULES
|
||||||
|
- **Discover patterns first** - Use rg/MCP for complex file discovery before CLI execution
|
||||||
|
- **Build precise CONTEXT** - Convert discovery results to explicit file references
|
||||||
|
- **Document context** - Always reference CLAUDE.md for context
|
||||||
|
- **Default to full context** - Use `@**/*` in CONTEXT for comprehensive analysis unless specific files needed
|
||||||
|
- **⚠️ No escape characters in CLI commands** - NEVER use `\$`, `\"`, `\'` in actual CLI execution (breaks command substitution and path expansion)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Context Optimization Strategy
|
||||||
|
|
||||||
|
**Directory Navigation**: Use `cd [directory] &&` pattern when analyzing specific areas to reduce irrelevant context
|
||||||
|
|
||||||
|
**When to change directory**:
|
||||||
|
- Specific directory mentioned → Use `cd directory &&` pattern
|
||||||
|
- Focused analysis needed → Target specific directory with cd
|
||||||
|
- Multi-directory scope → Use `cd` + `--include-directories` for precise control
|
||||||
|
|
||||||
|
**When to use `--include-directories`**:
|
||||||
|
- Working in subdirectory but need parent/sibling context
|
||||||
|
- Cross-directory dependency analysis required
|
||||||
|
- Multiple related modules need simultaneous access
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
### Workflow Integration (REQUIRED)
|
### Workflow Integration (REQUIRED)
|
||||||
|
|
||||||
When planning any coding task, **ALWAYS** integrate CLI tools:
|
When planning any coding task, **ALWAYS** integrate CLI tools:
|
||||||
|
|
||||||
1. **Understanding Phase**: Use Gemini for analysis (Qwen as fallback)
|
1. **Understanding Phase**: Use Gemini for analysis (Qwen as fallback)
|
||||||
@@ -319,185 +506,16 @@ When planning any coding task, **ALWAYS** integrate CLI tools:
|
|||||||
3. **Implementation Phase**: Use Codex for development
|
3. **Implementation Phase**: Use Codex for development
|
||||||
4. **Quality Phase**: Use Codex for testing and validation
|
4. **Quality Phase**: Use Codex for testing and validation
|
||||||
|
|
||||||
### Common Scenarios
|
|
||||||
|
|
||||||
#### Code Analysis
|
|
||||||
```bash
|
|
||||||
~/.claude/scripts/gemini-wrapper -p "
|
|
||||||
PURPOSE: Understand codebase architecture
|
|
||||||
TASK: Analyze project structure and identify patterns
|
|
||||||
MODE: analysis
|
|
||||||
CONTEXT: @{src/**/*.ts,CLAUDE.md} Previous analysis of auth system
|
|
||||||
EXPECTED: Architecture overview and integration points
|
|
||||||
RULES: $(cat ~/.claude/workflows/cli-templates/prompts/analysis/architecture.txt) | Focus on integration points
|
|
||||||
"
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Documentation Generation
|
|
||||||
```bash
|
|
||||||
~/.claude/scripts/gemini-wrapper -p "
|
|
||||||
PURPOSE: Generate API documentation
|
|
||||||
TASK: Create comprehensive API reference from code
|
|
||||||
MODE: write
|
|
||||||
CONTEXT: @{src/api/**/*}
|
|
||||||
EXPECTED: API.md with all endpoints documented
|
|
||||||
RULES: Follow project documentation standards
|
|
||||||
"
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Architecture Analysis (Qwen as Gemini fallback)
|
|
||||||
```bash
|
|
||||||
# Prefer Gemini for architecture analysis
|
|
||||||
cd src/auth && ~/.claude/scripts/gemini-wrapper -p "
|
|
||||||
PURPOSE: Analyze authentication system architecture
|
|
||||||
TASK: Review JWT-based auth system design
|
|
||||||
MODE: analysis
|
|
||||||
CONTEXT: @{src/auth/**/*} Existing patterns and requirements
|
|
||||||
EXPECTED: Architecture analysis report with recommendations
|
|
||||||
RULES: $(cat ~/.claude/workflows/cli-templates/prompts/analysis/architecture.txt) | Focus on security
|
|
||||||
"
|
|
||||||
|
|
||||||
# Use Qwen only if Gemini unavailable
|
|
||||||
cd src/auth && ~/.claude/scripts/qwen-wrapper -p "
|
|
||||||
PURPOSE: Analyze authentication system architecture
|
|
||||||
TASK: Review JWT-based auth system design
|
|
||||||
MODE: analysis
|
|
||||||
CONTEXT: @{src/auth/**/*} Existing patterns and requirements
|
|
||||||
EXPECTED: Architecture analysis report with recommendations
|
|
||||||
RULES: $(cat ~/.claude/workflows/cli-templates/prompts/analysis/architecture.txt) | Focus on security
|
|
||||||
"
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Feature Development (Multi-task with Resume)
|
|
||||||
```bash
|
|
||||||
# First task - establish session
|
|
||||||
codex -C path/to/project --full-auto exec "
|
|
||||||
PURPOSE: Implement user authentication
|
|
||||||
TASK: Create JWT-based authentication system
|
|
||||||
MODE: auto
|
|
||||||
CONTEXT: @{src/auth/**/*} Database schema from session memory
|
|
||||||
EXPECTED: Complete auth module with tests
|
|
||||||
RULES: $(cat ~/.claude/workflows/cli-templates/prompts/development/feature.txt) | Follow security best practices
|
|
||||||
" --skip-git-repo-check -s danger-full-access
|
|
||||||
|
|
||||||
# Continue in same session - Add JWT validation
|
|
||||||
codex --full-auto exec "
|
|
||||||
PURPOSE: Enhance authentication security
|
|
||||||
TASK: Add JWT token validation and refresh logic
|
|
||||||
MODE: auto
|
|
||||||
CONTEXT: Previous auth implementation from current session
|
|
||||||
EXPECTED: JWT validation middleware and token refresh endpoints
|
|
||||||
RULES: Follow JWT best practices, maintain session context
|
|
||||||
" resume --last --skip-git-repo-check -s danger-full-access
|
|
||||||
|
|
||||||
# Continue in same session - Add tests
|
|
||||||
codex --full-auto exec "
|
|
||||||
PURPOSE: Increase test coverage
|
|
||||||
TASK: Generate comprehensive tests for auth module
|
|
||||||
MODE: write
|
|
||||||
CONTEXT: Auth implementation from current session
|
|
||||||
EXPECTED: Complete test suite with 80%+ coverage
|
|
||||||
RULES: Use Jest, follow existing patterns
|
|
||||||
" resume --last --skip-git-repo-check -s danger-full-access
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Interactive Session Resume
|
|
||||||
```bash
|
|
||||||
# Resume previous session with picker
|
|
||||||
codex resume
|
|
||||||
|
|
||||||
# Or resume most recent session directly
|
|
||||||
codex resume --last
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 🔧 Best Practices
|
|
||||||
|
|
||||||
### General Guidelines
|
|
||||||
- **Start with templates** - Use predefined templates for consistency
|
|
||||||
- **Be specific** - Clear PURPOSE, TASK, and EXPECTED fields
|
|
||||||
- **Include constraints** - File patterns, scope, requirements in RULES
|
|
||||||
- **Discover patterns first** - Use rg/MCP for complex file discovery before CLI execution
|
|
||||||
- **Build precise CONTEXT** - Convert discovery results to explicit file references
|
|
||||||
- **Document context** - Always reference CLAUDE.md for context
|
|
||||||
- **⚠️ No escape characters in CLI commands** - NEVER use `\$`, `\"`, `\'` in actual CLI execution (breaks command substitution and path expansion)
|
|
||||||
|
|
||||||
### Context Optimization Strategy
|
|
||||||
**Directory Navigation**: Use `cd [directory] &&` pattern when analyzing specific areas to reduce irrelevant context
|
|
||||||
|
|
||||||
**When to change directory**:
|
|
||||||
- Specific directory mentioned → Use `cd directory &&` pattern
|
|
||||||
- Focused analysis needed → Target specific directory with cd
|
|
||||||
- Multi-directory scope → Stay in root, use explicit paths or multiple commands
|
|
||||||
|
|
||||||
**Example**:
|
|
||||||
```bash
|
|
||||||
# Gemini - Focused analysis
|
|
||||||
cd src/auth && ~/.claude/scripts/gemini-wrapper -p "
|
|
||||||
PURPOSE: Understand authentication patterns
|
|
||||||
TASK: Analyze auth implementation
|
|
||||||
MODE: analysis
|
|
||||||
CONTEXT: @{**/*.ts}
|
|
||||||
EXPECTED: Pattern documentation
|
|
||||||
RULES: Focus on security best practices
|
|
||||||
"
|
|
||||||
|
|
||||||
# Qwen - Analysis (fallback option, same as Gemini)
|
|
||||||
cd src/auth && ~/.claude/scripts/qwen-wrapper -p "
|
|
||||||
PURPOSE: Analyze auth architecture
|
|
||||||
TASK: Review auth system design and patterns
|
|
||||||
MODE: analysis
|
|
||||||
CONTEXT: @{**/*}
|
|
||||||
EXPECTED: Architecture analysis report
|
|
||||||
RULES: Focus on modularity and security
|
|
||||||
"
|
|
||||||
|
|
||||||
# Codex - Implementation
|
|
||||||
codex -C src/auth --full-auto exec "
|
|
||||||
PURPOSE: Improve auth implementation
|
|
||||||
TASK: Review and enhance auth code
|
|
||||||
MODE: auto
|
|
||||||
CONTEXT: @{**/*.ts}
|
|
||||||
EXPECTED: Code improvements and fixes
|
|
||||||
RULES: Maintain backward compatibility
|
|
||||||
" --skip-git-repo-check -s danger-full-access
|
|
||||||
```
|
|
||||||
|
|
||||||
### Planning Checklist
|
### Planning Checklist
|
||||||
|
|
||||||
For every development task:
|
For every development task:
|
||||||
- [ ] **Purpose defined** - Clear goal and intent
|
- [ ] **Purpose defined** - Clear goal and intent
|
||||||
- [ ] **Mode selected** - Execution mode and permission level determined
|
- [ ] **Mode selected** - Execution mode and permission level determined
|
||||||
- [ ] **Context gathered** - File references and session memory documented
|
- [ ] **Context gathered** - File references and session memory documented (default `@**/*`)
|
||||||
|
- [ ] **Directory navigation** - Determine if `cd` or `cd + --include-directories` needed
|
||||||
- [ ] **Gemini analysis** completed for understanding
|
- [ ] **Gemini analysis** completed for understanding
|
||||||
- [ ] **Template selected** - Appropriate template chosen
|
- [ ] **Template selected** - Appropriate template chosen
|
||||||
- [ ] **Constraints specified** - File patterns, scope, requirements
|
- [ ] **Constraints specified** - File patterns, scope, requirements
|
||||||
- [ ] **Implementation approach** - Tool selection and workflow
|
- [ ] **Implementation approach** - Tool selection and workflow
|
||||||
- [ ] **Quality measures** - Testing and validation plan
|
|
||||||
- [ ] **Tool configuration** - Review `.gemini/CLAUDE.md` or `.codex/Agent.md` if needed
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## ⚙️ Execution Configuration
|
|
||||||
|
|
||||||
### Core Execution Rules
|
|
||||||
- **Dynamic Timeout (20-120min)**: Allocate execution time based on task complexity
|
|
||||||
- Simple tasks (analysis, search): 20-40min (1200000-2400000ms)
|
|
||||||
- Medium tasks (refactoring, documentation): 40-60min (2400000-3600000ms)
|
|
||||||
- Complex tasks (implementation, migration): 60-120min (3600000-7200000ms)
|
|
||||||
- **Codex Multiplier**: Codex commands use 1.5x of allocated time
|
|
||||||
- **Apply to All Tools**: All bash() wrapped commands including Gemini, Qwen wrapper and Codex executions
|
|
||||||
- **Command Examples**: `bash(~/.claude/scripts/gemini-wrapper -p "prompt")`, `bash(codex -C directory --full-auto exec "task")`
|
|
||||||
- **Auto-detect**: Analyze PURPOSE and TASK fields to determine appropriate timeout
|
|
||||||
|
|
||||||
### Permission Framework
|
|
||||||
- **⚠️ WRITE PROTECTION**: Local codebase write/modify requires EXPLICIT user confirmation
|
|
||||||
- **Analysis Mode (default)**: Read-only, safe for auto-execution
|
|
||||||
- **Write Mode**: Requires user explicitly states MODE=write or MODE=auto in prompt
|
|
||||||
- **Exception**: User provides clear instructions like "modify", "create", "implement"
|
|
||||||
- **Gemini/Qwen Write Access**: Use `--approval-mode yolo` ONLY when MODE=write explicitly specified
|
|
||||||
- **Parameter Position**: Place AFTER the wrapper command: `gemini-wrapper --approval-mode yolo -p "..."`
|
|
||||||
- **Codex Write Access**: Use `-s danger-full-access` and `--skip-git-repo-check` ONLY when MODE=auto explicitly specified
|
|
||||||
- **Parameter Position**: Place AFTER the prompt string at command END: `codex ... exec "..." --skip-git-repo-check -s danger-full-access`
|
|
||||||
- **Default Behavior**: All tools default to analysis/read-only mode without explicit write permission
|
|
||||||
|
|||||||
@@ -86,9 +86,9 @@ mcp__code-index__search_code_advanced(pattern="async.*function", file_pattern="*
|
|||||||
mcp__exa__get_code_context_exa(query="TypeScript async patterns", tokensNum="dynamic")
|
mcp__exa__get_code_context_exa(query="TypeScript async patterns", tokensNum="dynamic")
|
||||||
|
|
||||||
# 3. Analyze with Gemini
|
# 3. Analyze with Gemini
|
||||||
cd "src/async" && ~/.claude/scripts/gemini-wrapper -p "
|
cd "src/async" && gemini "
|
||||||
PURPOSE: Understand async patterns
|
PURPOSE: Understand async patterns
|
||||||
CONTEXT: Code index results + Exa context + @{src/async/**/*}
|
CONTEXT: Code index results + Exa context + @src/async/**/*
|
||||||
EXPECTED: Pattern analysis
|
EXPECTED: Pattern analysis
|
||||||
RULES: Focus on TypeScript best practices
|
RULES: Focus on TypeScript best practices
|
||||||
"
|
"
|
||||||
@@ -134,7 +134,7 @@ codex -C src/async --full-auto exec "Apply modern async patterns" -s danger-full
|
|||||||
mcp__code-index__search_code_advanced(pattern="router|routing", file_pattern="*.ts")
|
mcp__code-index__search_code_advanced(pattern="router|routing", file_pattern="*.ts")
|
||||||
mcp__exa__get_code_context_exa(query="Next.js 14 app router", tokensNum="dynamic")
|
mcp__exa__get_code_context_exa(query="Next.js 14 app router", tokensNum="dynamic")
|
||||||
mcp__exa__web_search_exa(query="Next.js 14 best practices 2024", numResults=3)
|
mcp__exa__web_search_exa(query="Next.js 14 best practices 2024", numResults=3)
|
||||||
cd "src/app" && ~/.claude/scripts/gemini-wrapper -p "Learn Next.js patterns"
|
cd "src/app" && gemini "Learn Next.js patterns"
|
||||||
```
|
```
|
||||||
|
|
||||||
### Debugging
|
### Debugging
|
||||||
@@ -153,7 +153,7 @@ mcp__code-index__refresh_index() # 刷新索引
|
|||||||
mcp__code-index__find_files(pattern="*auth*") # Find auth-related files
|
mcp__code-index__find_files(pattern="*auth*") # Find auth-related files
|
||||||
mcp__code-index__search_code_advanced(pattern="function.*auth", file_pattern="*.ts") # Find auth functions
|
mcp__code-index__search_code_advanced(pattern="function.*auth", file_pattern="*.ts") # Find auth functions
|
||||||
mcp__code-index__get_file_summary(file_path="src/auth/index.ts") # Understand structure
|
mcp__code-index__get_file_summary(file_path="src/auth/index.ts") # Understand structure
|
||||||
cd "src/auth" && ~/.claude/scripts/gemini-wrapper -p "Analyze auth architecture"
|
cd "src/auth" && gemini "Analyze auth architecture"
|
||||||
```
|
```
|
||||||
|
|
||||||
### Project Setup Workflow
|
### Project Setup Workflow
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
# Tool Control Configuration
|
|
||||||
# Controls whether CLI tools (Gemini, Qwen, Codex) are enabled in the workspace
|
|
||||||
|
|
||||||
tools:
|
|
||||||
gemini:
|
|
||||||
enabled: true
|
|
||||||
qwen:
|
|
||||||
enabled: true
|
|
||||||
codex:
|
|
||||||
enabled: true
|
|
||||||
@@ -152,7 +152,7 @@ All task files use this unified 5-field schema with optional artifacts enhanceme
|
|||||||
{
|
{
|
||||||
"step": "analyze_architecture",
|
"step": "analyze_architecture",
|
||||||
"action": "Review system architecture",
|
"action": "Review system architecture",
|
||||||
"command": "~/.claude/scripts/gemini-wrapper -p \"analyze patterns: [patterns]\"",
|
"command": "gemini \"analyze patterns: [patterns]\"",
|
||||||
"output_to": "design"
|
"output_to": "design"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -416,7 +416,7 @@ The `[FLOW_CONTROL]` marker indicates that a task or prompt contains flow contro
|
|||||||
- **Bash commands**: `bash(command)` - Any shell command
|
- **Bash commands**: `bash(command)` - Any shell command
|
||||||
- **Tool calls**: `Read(file)`, `Glob(pattern)`, `Grep(pattern)`
|
- **Tool calls**: `Read(file)`, `Glob(pattern)`, `Grep(pattern)`
|
||||||
- **MCP tools**: `mcp__code-index__find_files()`, `mcp__exa__get_code_context_exa()`
|
- **MCP tools**: `mcp__code-index__find_files()`, `mcp__exa__get_code_context_exa()`
|
||||||
- **CLI wrappers**: `~/.claude/scripts/gemini-wrapper`, `codex --full-auto exec`
|
- **CLI commands**: `gemini`, `qwen`, `codex --full-auto exec`
|
||||||
|
|
||||||
**Example**:
|
**Example**:
|
||||||
```json
|
```json
|
||||||
@@ -477,10 +477,10 @@ The `[FLOW_CONTROL]` marker indicates that a task or prompt contains flow contro
|
|||||||
"command": "codex --full-auto exec \"task\" resume --last --skip-git-repo-check -s danger-full-access"
|
"command": "codex --full-auto exec \"task\" resume --last --skip-git-repo-check -s danger-full-access"
|
||||||
|
|
||||||
// Gemini (user requested)
|
// Gemini (user requested)
|
||||||
"command": "~/.claude/scripts/gemini-wrapper -p \"analyze [context]\""
|
"command": "gemini \"analyze [context]\""
|
||||||
|
|
||||||
// Qwen (fallback for Gemini)
|
// Qwen (fallback for Gemini)
|
||||||
"command": "~/.claude/scripts/qwen-wrapper -p \"analyze [context]\""
|
"command": "qwen \"analyze [context]\""
|
||||||
```
|
```
|
||||||
|
|
||||||
**Example Step**:
|
**Example Step**:
|
||||||
@@ -517,14 +517,14 @@ The `[FLOW_CONTROL]` marker indicates that a task or prompt contains flow contro
|
|||||||
|
|
||||||
**Gemini CLI**:
|
**Gemini CLI**:
|
||||||
```bash
|
```bash
|
||||||
~/.claude/scripts/gemini-wrapper -p "prompt"
|
gemini "prompt"
|
||||||
~/.claude/scripts/gemini-wrapper --approval-mode yolo -p "prompt" # For write mode
|
gemini --approval-mode yolo "prompt" # For write mode
|
||||||
```
|
```
|
||||||
|
|
||||||
**Qwen CLI** (Gemini fallback):
|
**Qwen CLI** (Gemini fallback):
|
||||||
```bash
|
```bash
|
||||||
~/.claude/scripts/qwen-wrapper -p "prompt"
|
qwen "prompt"
|
||||||
~/.claude/scripts/qwen-wrapper --approval-mode yolo -p "prompt" # For write mode
|
qwen --approval-mode yolo "prompt" # For write mode
|
||||||
```
|
```
|
||||||
|
|
||||||
**Codex CLI**:
|
**Codex CLI**:
|
||||||
@@ -892,13 +892,13 @@ fi
|
|||||||
- **Examples**: New features, API endpoints with integration, database schema changes
|
- **Examples**: New features, API endpoints with integration, database schema changes
|
||||||
- **Task Decomposition**: Two-level hierarchy when decomposition is needed
|
- **Task Decomposition**: Two-level hierarchy when decomposition is needed
|
||||||
- **Agent Coordination**: Context coordination between related tasks
|
- **Agent Coordination**: Context coordination between related tasks
|
||||||
- **Tool Strategy**: `gemini-wrapper` for pattern analysis, `codex --full-auto` for implementation
|
- **Tool Strategy**: `gemini` for pattern analysis, `codex --full-auto` for implementation
|
||||||
|
|
||||||
#### Complex Workflows
|
#### Complex Workflows
|
||||||
- **Examples**: Major features, architecture refactoring, security implementations, multi-service deployments
|
- **Examples**: Major features, architecture refactoring, security implementations, multi-service deployments
|
||||||
- **Task Decomposition**: Frequent use of two-level hierarchy with dynamic subtask creation
|
- **Task Decomposition**: Frequent use of two-level hierarchy with dynamic subtask creation
|
||||||
- **Agent Coordination**: Multi-agent orchestration with deep context analysis
|
- **Agent Coordination**: Multi-agent orchestration with deep context analysis
|
||||||
- **Tool Strategy**: `gemini-wrapper` for architecture analysis, `codex --full-auto` for complex problem solving, `bash()` commands for flexible analysis
|
- **Tool Strategy**: `gemini` for architecture analysis, `codex --full-auto` for complex problem solving, `bash()` commands for flexible analysis
|
||||||
|
|
||||||
### Assessment & Upgrades
|
### Assessment & Upgrades
|
||||||
- **During Creation**: System evaluates requirements and assigns complexity
|
- **During Creation**: System evaluates requirements and assigns complexity
|
||||||
|
|||||||
@@ -17,28 +17,43 @@ EXPECTED: [deliverables]
|
|||||||
RULES: [templates | additional constraints]
|
RULES: [templates | additional constraints]
|
||||||
```
|
```
|
||||||
|
|
||||||
## MODE Definitions
|
## MODE Definitions - STRICT OPERATION BOUNDARIES
|
||||||
|
|
||||||
### MODE: analysis (default)
|
### MODE: analysis (default) - READ-ONLY OPERATIONS
|
||||||
|
|
||||||
**Permissions**:
|
**ALLOWED OPERATIONS**:
|
||||||
- Read all CONTEXT files
|
- **READ**: All CONTEXT files and analyze content
|
||||||
- Create/modify documentation files
|
- **ANALYZE**: Code patterns, architecture, dependencies
|
||||||
|
- **GENERATE**: Text output, insights, recommendations
|
||||||
|
- **DOCUMENT**: Analysis results in output response only
|
||||||
|
|
||||||
|
**FORBIDDEN OPERATIONS**:
|
||||||
|
- **NO FILE CREATION**: Cannot create any files on disk
|
||||||
|
- **NO FILE MODIFICATION**: Cannot modify existing files
|
||||||
|
- **NO FILE DELETION**: Cannot delete any files
|
||||||
|
- **NO DIRECTORY OPERATIONS**: Cannot create/modify directories
|
||||||
|
|
||||||
**Execute**:
|
**Execute**:
|
||||||
1. Read and analyze CONTEXT files
|
1. Read and analyze CONTEXT files
|
||||||
2. Identify patterns and issues
|
2. Identify patterns and issues
|
||||||
3. Generate insights and recommendations
|
3. Generate insights and recommendations
|
||||||
4. Create documentation if needed
|
4. Output structured analysis (text response only)
|
||||||
5. Output structured analysis
|
|
||||||
|
|
||||||
**Constraint**: Do NOT modify source code files
|
**CRITICAL CONSTRAINT**: Absolutely NO file system operations - ANALYSIS OUTPUT ONLY
|
||||||
|
|
||||||
### MODE: write
|
### MODE: write - FILE CREATION/MODIFICATION OPERATIONS
|
||||||
|
|
||||||
**Permissions**:
|
**ALLOWED OPERATIONS**:
|
||||||
- Full file operations
|
- **READ**: All CONTEXT files and analyze content
|
||||||
- Create/modify any files
|
- **CREATE**: New files (documentation, code, configuration)
|
||||||
|
- **MODIFY**: Existing files (update content, refactor code)
|
||||||
|
- **DELETE**: Files when explicitly required
|
||||||
|
- **ORGANIZE**: Directory structure operations
|
||||||
|
|
||||||
|
**STILL RESTRICTED**:
|
||||||
|
- Must follow project conventions and patterns
|
||||||
|
- Cannot break existing functionality
|
||||||
|
- Must validate changes before completion
|
||||||
|
|
||||||
**Execute**:
|
**Execute**:
|
||||||
1. Read CONTEXT files
|
1. Read CONTEXT files
|
||||||
|
|||||||
@@ -17,28 +17,43 @@ EXPECTED: [deliverables]
|
|||||||
RULES: [templates | additional constraints]
|
RULES: [templates | additional constraints]
|
||||||
```
|
```
|
||||||
|
|
||||||
## MODE Definitions
|
## MODE Definitions - STRICT OPERATION BOUNDARIES
|
||||||
|
|
||||||
### MODE: analysis (default)
|
### MODE: analysis (default) - READ-ONLY OPERATIONS
|
||||||
|
|
||||||
**Permissions**:
|
**ALLOWED OPERATIONS**:
|
||||||
- Read all CONTEXT files
|
- **READ**: All CONTEXT files and analyze content
|
||||||
- Create/modify documentation files
|
- **ANALYZE**: Code patterns, architecture, dependencies
|
||||||
|
- **GENERATE**: Text output, insights, recommendations
|
||||||
|
- **DOCUMENT**: Analysis results in output response only
|
||||||
|
|
||||||
|
**FORBIDDEN OPERATIONS**:
|
||||||
|
- **NO FILE CREATION**: Cannot create any files on disk
|
||||||
|
- **NO FILE MODIFICATION**: Cannot modify existing files
|
||||||
|
- **NO FILE DELETION**: Cannot delete any files
|
||||||
|
- **NO DIRECTORY OPERATIONS**: Cannot create/modify directories
|
||||||
|
|
||||||
**Execute**:
|
**Execute**:
|
||||||
1. Read and analyze CONTEXT files
|
1. Read and analyze CONTEXT files
|
||||||
2. Identify patterns and issues
|
2. Identify patterns and issues
|
||||||
3. Generate insights and recommendations
|
3. Generate insights and recommendations
|
||||||
4. Create documentation if needed
|
4. Output structured analysis (text response only)
|
||||||
5. Output structured analysis
|
|
||||||
|
|
||||||
**Constraint**: Do NOT modify source code files
|
**CRITICAL CONSTRAINT**: Absolutely NO file system operations - ANALYSIS OUTPUT ONLY
|
||||||
|
|
||||||
### MODE: write
|
### MODE: write - FILE CREATION/MODIFICATION OPERATIONS
|
||||||
|
|
||||||
**Permissions**:
|
**ALLOWED OPERATIONS**:
|
||||||
- Full file operations
|
- **READ**: All CONTEXT files and analyze content
|
||||||
- Create/modify any files
|
- **CREATE**: New files (documentation, code, configuration)
|
||||||
|
- **MODIFY**: Existing files (update content, refactor code)
|
||||||
|
- **DELETE**: Files when explicitly required
|
||||||
|
- **ORGANIZE**: Directory structure operations
|
||||||
|
|
||||||
|
**STILL RESTRICTED**:
|
||||||
|
- Must follow project conventions and patterns
|
||||||
|
- Cannot break existing functionality
|
||||||
|
- Must validate changes before completion
|
||||||
|
|
||||||
**Execute**:
|
**Execute**:
|
||||||
1. Read CONTEXT files
|
1. Read CONTEXT files
|
||||||
|
|||||||
27
CHANGELOG.md
27
CHANGELOG.md
@@ -5,6 +5,33 @@ All notable changes to Claude Code Workflow (CCW) will be documented in this fil
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
n## [4.6.2] - 2025-10-20
|
||||||
|
|
||||||
|
### 📝 Documentation Optimization
|
||||||
|
|
||||||
|
#### Improved
|
||||||
|
|
||||||
|
**`/memory:load` Command Documentation**: Optimized command specification from 273 to 240 lines (12% reduction)
|
||||||
|
- Merged redundant sections for better information flow
|
||||||
|
- Removed unnecessary internal implementation details
|
||||||
|
- Simplified usage examples while preserving clarity
|
||||||
|
- Maintained all critical information (parameters, workflow, JSON structure)
|
||||||
|
- Improved user-centric documentation structure
|
||||||
|
|
||||||
|
#### Updated
|
||||||
|
|
||||||
|
**COMMAND_SPEC.md**: Updated `/memory:load` specification to match actual implementation
|
||||||
|
- Corrected syntax: `[--tool gemini|qwen]` instead of outdated `[--agent] [--json]` flags
|
||||||
|
- Added agent-driven execution details
|
||||||
|
- Clarified core philosophy and token-efficiency benefits
|
||||||
|
|
||||||
|
**GETTING_STARTED.md**: Added "Quick Context Loading for Specific Tasks" section
|
||||||
|
- Positioned between "Full Project Index Rebuild" and "Incremental Related Module Updates"
|
||||||
|
- Includes practical examples and use case guidance
|
||||||
|
- Explains how `/memory:load` works and when to use it
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## [4.6.0] - 2025-10-18
|
## [4.6.0] - 2025-10-18
|
||||||
|
|
||||||
### 🎯 Concept Clarification & Agent-Driven Analysis
|
### 🎯 Concept Clarification & Agent-Driven Analysis
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
This document defines project-specific coding standards and development principles.
|
This document defines project-specific coding standards and development principles.
|
||||||
### CLI Tool Context Protocols
|
### CLI Tool Context Protocols
|
||||||
For all CLI tool usage, command syntax, and integration guidelines:
|
For all CLI tool usage, command syntax, and integration guidelines:
|
||||||
- **Tool Control Configuration**: @~/.claude/workflows/tool-control.yaml - Controls CLI tool availability for all commands and agent executions (if disabled, use other enabled CLI tools or Claude's own capabilities)
|
|
||||||
- **MCP Tool Strategy**: @~/.claude/workflows/mcp-tool-strategy.md
|
- **MCP Tool Strategy**: @~/.claude/workflows/mcp-tool-strategy.md
|
||||||
- **Intelligent Context Strategy**: @~/.claude/workflows/intelligent-tools-strategy.md
|
- **Intelligent Context Strategy**: @~/.claude/workflows/intelligent-tools-strategy.md
|
||||||
- **Context Search Commands**: @~/.claude/workflows/context-search-strategy.md
|
- **Context Search Commands**: @~/.claude/workflows/context-search-strategy.md
|
||||||
|
|||||||
@@ -127,6 +127,7 @@ Commands for managing individual tasks within a workflow session.
|
|||||||
| Command | Description |
|
| Command | Description |
|
||||||
|---|---|
|
|---|---|
|
||||||
| `/memory:update-full` | Complete project-wide CLAUDE.md documentation update. |
|
| `/memory:update-full` | Complete project-wide CLAUDE.md documentation update. |
|
||||||
|
| `/memory:load` | Quickly load key project context into memory based on a task description. |
|
||||||
| `/memory:update-related` | Context-aware CLAUDE.md documentation updates based on recent changes. |
|
| `/memory:update-related` | Context-aware CLAUDE.md documentation updates based on recent changes. |
|
||||||
| `/version` | Display version information and check for updates. |
|
| `/version` | Display version information and check for updates. |
|
||||||
| `/enhance-prompt` | Context-aware prompt enhancement using session memory and codebase analysis. |
|
| `/enhance-prompt` | Context-aware prompt enhancement using session memory and codebase analysis. |
|
||||||
|
|||||||
@@ -299,6 +299,27 @@ Commands for managing individual tasks within a workflow session.
|
|||||||
/memory:update-full
|
/memory:update-full
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### **/memory:load**
|
||||||
|
- **Syntax**: `/memory:load [--tool gemini|qwen] "task context description"`
|
||||||
|
- **Parameters**:
|
||||||
|
- `"task context description"` (Required, String): Task description to guide context extraction.
|
||||||
|
- `--tool <gemini|qwen>` (Optional): Specify CLI tool for agent to use (default: gemini).
|
||||||
|
- **Responsibilities**: Delegates to `@general-purpose` agent to analyze the project and return a structured "Core Content Pack". This pack is loaded into the main thread's memory, providing essential context for subsequent operations.
|
||||||
|
- **Agent-Driven Execution**: Fully delegates to general-purpose agent which autonomously:
|
||||||
|
1. Analyzes project structure and documentation
|
||||||
|
2. Extracts keywords from task description
|
||||||
|
3. Discovers relevant files using MCP code-index or search tools
|
||||||
|
4. Executes Gemini/Qwen CLI for deep analysis
|
||||||
|
5. Generates structured JSON content package
|
||||||
|
- **Core Philosophy**: Read-only analysis, token-efficient (CLI analysis in agent), structured output
|
||||||
|
- **Agent Calls**: `@general-purpose` agent.
|
||||||
|
- **Integration**: Provides quick, task-relevant context for subsequent agent operations while minimizing token consumption.
|
||||||
|
- **Example**:
|
||||||
|
```bash
|
||||||
|
/memory:load "在当前前端基础上开发用户认证功能"
|
||||||
|
/memory:load --tool qwen "重构支付模块API"
|
||||||
|
```
|
||||||
|
|
||||||
### **/memory:update-related**
|
### **/memory:update-related**
|
||||||
- **Syntax**: `/memory:update-related [--tool gemini|qwen|codex]`
|
- **Syntax**: `/memory:update-related [--tool gemini|qwen|codex]`
|
||||||
- **Responsibilities**: Performs a context-aware update of `CLAUDE.md` files for modules affected by recent git changes.
|
- **Responsibilities**: Performs a context-aware update of `CLAUDE.md` files for modules affected by recent git changes.
|
||||||
|
|||||||
@@ -82,42 +82,77 @@ Understanding these concepts will help you use CCW more effectively:
|
|||||||
|
|
||||||
## 🛠️ Common Scenarios
|
## 🛠️ Common Scenarios
|
||||||
|
|
||||||
### Scenario 1: Developing a New Feature (as shown above)
|
### Scenario 1: Quick Feature Development
|
||||||
|
|
||||||
This is the most common use case, following the "start session → plan → execute" pattern.
|
For simple, well-defined features, use the direct "plan → execute" pattern:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# 1. Start a session
|
# Create plan (auto-creates session)
|
||||||
/workflow:session:start "User Login Feature"
|
|
||||||
|
|
||||||
# 2. Create a plan
|
|
||||||
/workflow:plan "Implement JWT-based user login and registration"
|
/workflow:plan "Implement JWT-based user login and registration"
|
||||||
|
|
||||||
# 3. Execute
|
# Execute
|
||||||
/workflow:execute
|
/workflow:execute
|
||||||
```
|
```
|
||||||
|
|
||||||
### Scenario 2: UI Design
|
> **💡 Note**: `/workflow:plan` automatically creates a session. You can also manually start a session first with `/workflow:session:start "Feature Name"`.
|
||||||
|
|
||||||
CCW has powerful UI design capabilities, capable of generating complex UI prototypes from simple text descriptions.
|
### Scenario 2: UI Design Exploration
|
||||||
|
|
||||||
|
For UI-focused projects, start with design exploration before implementation: **ui-design → update → plan → execute**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# 1. Start a UI design workflow
|
# Step 1: Generate UI design variations (auto-creates session)
|
||||||
/workflow:ui-design:explore-auto --prompt "A modern, clean admin dashboard login page with username, password fields and a login button"
|
/workflow:ui-design:explore-auto --prompt "A modern, clean admin dashboard login page"
|
||||||
|
|
||||||
# 2. View the generated prototype
|
# Step 2: Review designs in compare.html, then update brainstorming artifacts
|
||||||
# After the command finishes, it will provide a path to a compare.html file. Open it in your browser to preview.
|
/workflow:ui-design:update --session <session-id> --selected-prototypes "login-v1,login-v2"
|
||||||
|
|
||||||
|
# Step 3: Generate implementation plan with design references
|
||||||
|
/workflow:plan
|
||||||
|
|
||||||
|
# Step 4: Execute the implementation
|
||||||
|
/workflow:execute
|
||||||
```
|
```
|
||||||
|
|
||||||
### Scenario 3: Fixing a Bug
|
> **💡 Tip**: The `update` command integrates selected design prototypes into brainstorming artifacts, ensuring implementation follows the approved designs.
|
||||||
|
|
||||||
CCW can help you analyze and fix bugs.
|
### Scenario 3: Complex Feature with Multi-Agent Brainstorming
|
||||||
|
|
||||||
|
For complex features requiring thorough analysis, use the complete workflow: **brainstorm → plan → execute**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# 1. Use the bug-index command to analyze the problem
|
# Step 1: Multi-agent brainstorming (auto-creates session)
|
||||||
/cli:mode:bug-index "Incorrect success message even with wrong password on login"
|
/workflow:brainstorm:auto-parallel "Design a real-time collaborative document editing system with conflict resolution"
|
||||||
|
|
||||||
# 2. The AI will analyze the relevant code and generate a fix plan. You can then execute this plan.
|
# Optional: Specify number of expert roles (default: 3, max: 9)
|
||||||
|
/workflow:brainstorm:auto-parallel "Build scalable microservices platform" --count 5
|
||||||
|
|
||||||
|
# Step 2: Generate implementation plan from brainstorming results
|
||||||
|
/workflow:plan
|
||||||
|
|
||||||
|
# Step 3: Execute the plan
|
||||||
|
/workflow:execute
|
||||||
|
```
|
||||||
|
|
||||||
|
**Brainstorming Benefits**:
|
||||||
|
- **Auto role selection**: Analyzes your topic and selects 3-9 relevant expert roles (system-architect, ui-designer, product-manager, etc.)
|
||||||
|
- **Parallel execution**: Multiple AI agents analyze simultaneously from different perspectives
|
||||||
|
- **Comprehensive specification**: Generates integrated requirements and design document
|
||||||
|
|
||||||
|
**When to Use Brainstorming**:
|
||||||
|
- Complex features requiring multiple perspectives
|
||||||
|
- Architectural decisions with significant impact
|
||||||
|
- When you need thorough requirements before implementation
|
||||||
|
|
||||||
|
### Scenario 4: Bug Fixing
|
||||||
|
|
||||||
|
Quick bug analysis and fix workflow:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Analyze the bug
|
||||||
|
/cli:mode:bug-index "Incorrect success message with wrong password"
|
||||||
|
|
||||||
|
# Generate and execute fix plan
|
||||||
/workflow:execute
|
/workflow:execute
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -226,6 +261,31 @@ Suitable for large-scale refactoring, architectural changes, or first-time CCW u
|
|||||||
- Weekly routine maintenance
|
- Weekly routine maintenance
|
||||||
- When AI output drift is detected
|
- When AI output drift is detected
|
||||||
|
|
||||||
|
#### Quick Context Loading for Specific Tasks
|
||||||
|
|
||||||
|
When you need immediate, task-specific context without updating documentation:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Load context for a specific task into memory
|
||||||
|
/memory:load "在当前前端基础上开发用户认证功能"
|
||||||
|
|
||||||
|
# Use alternative CLI tool for analysis
|
||||||
|
/memory:load --tool qwen "重构支付模块API"
|
||||||
|
```
|
||||||
|
|
||||||
|
**How It Works**:
|
||||||
|
- Delegates to an AI agent for autonomous project analysis
|
||||||
|
- Discovers relevant files and extracts task-specific keywords
|
||||||
|
- Uses CLI tools (Gemini/Qwen) for deep analysis to save tokens
|
||||||
|
- Returns a structured "Core Content Pack" loaded into memory
|
||||||
|
- Provides context for subsequent agent operations
|
||||||
|
|
||||||
|
**When to Use**:
|
||||||
|
- Before starting a new feature or task
|
||||||
|
- When you need quick context without full documentation rebuild
|
||||||
|
- For task-specific architectural or pattern discovery
|
||||||
|
- As preparation for agent-based development workflows
|
||||||
|
|
||||||
#### Incremental Related Module Updates
|
#### Incremental Related Module Updates
|
||||||
|
|
||||||
Suitable for daily development, updating only modules affected by changes:
|
Suitable for daily development, updating only modules affected by changes:
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
# 🚀 Claude Code Workflow (CCW) - 快速上手指南
|
# 🚀 Claude Code Workflow (CCW) - 快速上手指南
|
||||||
|
|
||||||
欢迎来到 Claude Code Workflow (CCW) v4.5.0!本指南将帮助您在 5 分钟内快速入门,体验由 AI 驱动的自动化软件开发流程,以及我们最新的工作流系统优化。
|
欢迎来到 Claude Code Workflow (CCW) v4.6.2!本指南将帮助您在 5 分钟内快速入门,体验由 AI 驱动的自动化软件开发流程,以及我们最新的工作流系统优化。
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -13,30 +13,22 @@
|
|||||||
|
|
||||||
首先,请确保您已经根据 [安装指南](INSTALL_CN.md) 完成了 CCW 的安装。
|
首先,请确保您已经根据 [安装指南](INSTALL_CN.md) 完成了 CCW 的安装。
|
||||||
|
|
||||||
### 第 2 步:启动一个工作流会话
|
### 第 2 步:创建执行计划(会自动启动会话)
|
||||||
|
|
||||||
把“会话”想象成一个专门的项目文件夹。CCW 会在这里存放所有与您当前任务相关的文件。
|
直接告诉 CCW 您想做什么。CCW 会分析您的需求,并自动生成一个详细的、可执行的任务计划。
|
||||||
|
|
||||||
```bash
|
|
||||||
/workflow:session:start "我的第一个 Web 应用"
|
|
||||||
```
|
|
||||||
|
|
||||||
您会看到系统创建了一个新的会话,例如 `WFS-我的第一个-web-应用`。
|
|
||||||
|
|
||||||
### 第 3 步:创建执行计划
|
|
||||||
|
|
||||||
现在,告诉 CCW 您想做什么。CCW 会分析您的需求,并自动生成一个详细的、可执行的任务计划。
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
/workflow:plan "创建一个简单的 Express API,在根路径返回 Hello World"
|
/workflow:plan "创建一个简单的 Express API,在根路径返回 Hello World"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
> **💡 提示**:`/workflow:plan` 会自动创建和启动工作流会话,无需手动执行 `/workflow:session:start`。会话会根据任务描述自动命名,例如 `WFS-创建一个简单的-express-api`。
|
||||||
|
|
||||||
这个命令会启动一个完全自动化的规划流程,包括:
|
这个命令会启动一个完全自动化的规划流程,包括:
|
||||||
1. **上下文收集**:分析您的项目环境。
|
1. **上下文收集**:分析您的项目环境。
|
||||||
2. **智能体分析**:AI 智能体思考最佳实现路径。
|
2. **智能体分析**:AI 智能体思考最佳实现路径。
|
||||||
3. **任务生成**:创建具体的任务文件(`.json` 格式)。
|
3. **任务生成**:创建具体的任务文件(`.json` 格式)。
|
||||||
|
|
||||||
### 第 4 步:执行计划
|
### 第 3 步:执行计划
|
||||||
|
|
||||||
当计划创建完毕后,您就可以命令 AI 智能体开始工作了。
|
当计划创建完毕后,您就可以命令 AI 智能体开始工作了。
|
||||||
|
|
||||||
@@ -46,7 +38,7 @@
|
|||||||
|
|
||||||
您会看到 CCW 的智能体(如 `@code-developer`)开始逐一执行任务。它会自动创建文件、编写代码、安装依赖。
|
您会看到 CCW 的智能体(如 `@code-developer`)开始逐一执行任务。它会自动创建文件、编写代码、安装依赖。
|
||||||
|
|
||||||
### 第 5 步:查看状态
|
### 第 4 步:查看状态
|
||||||
|
|
||||||
想知道进展如何?随时可以查看当前工作流的状态。
|
想知道进展如何?随时可以查看当前工作流的状态。
|
||||||
|
|
||||||
@@ -82,42 +74,77 @@
|
|||||||
|
|
||||||
## 🛠️ 常见场景示例
|
## 🛠️ 常见场景示例
|
||||||
|
|
||||||
### 场景 1:开发一个新功能(如上所示)
|
### 场景 1:快速功能开发
|
||||||
|
|
||||||
这是最常见的用法,遵循“启动会话 → 规划 → 执行”的模式。
|
对于简单、明确的功能,使用直接的"规划 → 执行"模式:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# 1. 启动会话
|
# 创建计划(自动创建会话)
|
||||||
/workflow:session:start "用户登录功能"
|
|
||||||
|
|
||||||
# 2. 创建计划
|
|
||||||
/workflow:plan "实现基于 JWT 的用户登录和注册功能"
|
/workflow:plan "实现基于 JWT 的用户登录和注册功能"
|
||||||
|
|
||||||
# 3. 执行
|
# 执行
|
||||||
/workflow:execute
|
/workflow:execute
|
||||||
```
|
```
|
||||||
|
|
||||||
### 场景 2:进行 UI 设计
|
> **💡 提示**:`/workflow:plan` 会自动创建会话。您也可以先手动启动会话:`/workflow:session:start "功能名称"`。
|
||||||
|
|
||||||
CCW 拥有强大的 UI 设计能力,可以从简单的文本描述生成复杂的 UI 原型。
|
### 场景 2:UI 设计探索
|
||||||
|
|
||||||
|
对于以 UI 为重点的项目,在实现前先进行设计探索:**ui-design → update → 规划 → 执行**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# 1. 启动一个 UI 设计工作流
|
# 第 1 步:生成 UI 设计变体(自动创建会话)
|
||||||
/workflow:ui-design:explore-auto --prompt "一个现代、简洁的管理后台登录页面,包含用户名、密码输入框和登录按钮"
|
/workflow:ui-design:explore-auto --prompt "一个现代、简洁的管理后台登录页面"
|
||||||
|
|
||||||
# 2. 查看生成的原型
|
# 第 2 步:在 compare.html 中审查设计,然后更新头脑风暴工件
|
||||||
# 命令执行完毕后,会提供一个 compare.html 文件的路径,在浏览器中打开即可预览。
|
/workflow:ui-design:update --session <session-id> --selected-prototypes "login-v1,login-v2"
|
||||||
|
|
||||||
|
# 第 3 步:使用设计引用生成实现计划
|
||||||
|
/workflow:plan
|
||||||
|
|
||||||
|
# 第 4 步:执行实现
|
||||||
|
/workflow:execute
|
||||||
```
|
```
|
||||||
|
|
||||||
### 场景 3:修复一个 Bug
|
> **💡 提示**:`update` 命令将选定的设计原型集成到头脑风暴工件中,确保实现遵循批准的设计。
|
||||||
|
|
||||||
CCW 可以帮助您分析并修复 Bug。
|
### 场景 3:复杂功能的多智能体头脑风暴
|
||||||
|
|
||||||
|
对于需要深入分析的复杂功能,使用完整工作流:**头脑风暴 → 规划 → 执行**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# 1. 使用 bug-index 命令分析问题
|
# 第 1 步:多智能体头脑风暴(自动创建会话)
|
||||||
/cli:mode:bug-index "用户登录时,即使密码错误也提示成功"
|
/workflow:brainstorm:auto-parallel "设计一个支持冲突解决的实时协作文档编辑系统"
|
||||||
|
|
||||||
# 2. AI 会分析相关代码,并生成一个修复计划。然后您可以执行这个计划。
|
# 可选:指定专家角色数量(默认:3,最大:9)
|
||||||
|
/workflow:brainstorm:auto-parallel "构建可扩展的微服务平台" --count 5
|
||||||
|
|
||||||
|
# 第 2 步:从头脑风暴结果生成实现计划
|
||||||
|
/workflow:plan
|
||||||
|
|
||||||
|
# 第 3 步:执行计划
|
||||||
|
/workflow:execute
|
||||||
|
```
|
||||||
|
|
||||||
|
**头脑风暴优势**:
|
||||||
|
- **自动角色选择**:分析主题并选择 3-9 个相关专家角色(系统架构师、UI 设计师、产品经理等)
|
||||||
|
- **并行执行**:多个 AI 智能体从不同视角同时分析
|
||||||
|
- **综合规格说明**:生成整合的需求和设计文档
|
||||||
|
|
||||||
|
**何时使用头脑风暴**:
|
||||||
|
- 需要多视角分析的复杂功能
|
||||||
|
- 具有重大影响的架构决策
|
||||||
|
- 实现前需要详尽需求分析
|
||||||
|
|
||||||
|
### 场景 4:Bug 修复
|
||||||
|
|
||||||
|
快速 Bug 分析和修复工作流:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 分析 Bug
|
||||||
|
/cli:mode:bug-index "密码错误时仍显示成功消息"
|
||||||
|
|
||||||
|
# 生成并执行修复计划
|
||||||
/workflow:execute
|
/workflow:execute
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -226,6 +253,31 @@ CCW 使用分层的 CLAUDE.md 文档系统维护项目上下文。定期更新
|
|||||||
- 每周定期维护
|
- 每周定期维护
|
||||||
- 发现 AI 输出偏差时
|
- 发现 AI 输出偏差时
|
||||||
|
|
||||||
|
#### 快速加载特定任务上下文
|
||||||
|
|
||||||
|
当您需要立即获取特定任务的上下文,而无需更新文档时:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 为特定任务加载上下文到内存
|
||||||
|
/memory:load "在当前前端基础上开发用户认证功能"
|
||||||
|
|
||||||
|
# 使用其他 CLI 工具进行分析
|
||||||
|
/memory:load --tool qwen "重构支付模块API"
|
||||||
|
```
|
||||||
|
|
||||||
|
**工作原理**:
|
||||||
|
- 委托 AI 智能体进行自主项目分析
|
||||||
|
- 发现相关文件并提取任务特定关键词
|
||||||
|
- 使用 CLI 工具(Gemini/Qwen)进行深度分析以节省令牌
|
||||||
|
- 返回加载到内存中的结构化"核心内容包"
|
||||||
|
- 为后续智能体操作提供上下文
|
||||||
|
|
||||||
|
**使用时机**:
|
||||||
|
- 开始新功能或任务之前
|
||||||
|
- 需要快速获取上下文而无需完整文档重建时
|
||||||
|
- 针对特定任务的架构或模式发现
|
||||||
|
- 作为基于智能体开发工作流的准备工作
|
||||||
|
|
||||||
#### 增量更新相关模块
|
#### 增量更新相关模块
|
||||||
|
|
||||||
适用于日常开发,只更新变更影响的模块:
|
适用于日常开发,只更新变更影响的模块:
|
||||||
|
|||||||
@@ -26,6 +26,9 @@
|
|||||||
.PARAMETER NoBackup
|
.PARAMETER NoBackup
|
||||||
Disable automatic backup functionality
|
Disable automatic backup functionality
|
||||||
|
|
||||||
|
.PARAMETER Uninstall
|
||||||
|
Uninstall Claude Code Workflow System based on installation manifest
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
.\Install-Claude.ps1
|
.\Install-Claude.ps1
|
||||||
Interactive installation with mode selection
|
Interactive installation with mode selection
|
||||||
@@ -45,6 +48,14 @@
|
|||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
.\Install-Claude.ps1 -NoBackup
|
.\Install-Claude.ps1 -NoBackup
|
||||||
Installation without any backup (overwrite existing files)
|
Installation without any backup (overwrite existing files)
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
.\Install-Claude.ps1 -Uninstall
|
||||||
|
Uninstall Claude Code Workflow System
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
.\Install-Claude.ps1 -Uninstall -Force
|
||||||
|
Uninstall without confirmation prompts
|
||||||
#>
|
#>
|
||||||
|
|
||||||
param(
|
param(
|
||||||
@@ -61,6 +72,8 @@ param(
|
|||||||
|
|
||||||
[switch]$NoBackup,
|
[switch]$NoBackup,
|
||||||
|
|
||||||
|
[switch]$Uninstall,
|
||||||
|
|
||||||
[string]$SourceVersion = "",
|
[string]$SourceVersion = "",
|
||||||
|
|
||||||
[string]$SourceBranch = "",
|
[string]$SourceBranch = "",
|
||||||
@@ -98,6 +111,9 @@ $ColorWarning = "Yellow"
|
|||||||
$ColorError = "Red"
|
$ColorError = "Red"
|
||||||
$ColorPrompt = "Magenta"
|
$ColorPrompt = "Magenta"
|
||||||
|
|
||||||
|
# Global manifest directory location
|
||||||
|
$script:ManifestDir = Join-Path ([Environment]::GetFolderPath("UserProfile")) ".claude-manifests"
|
||||||
|
|
||||||
function Write-ColorOutput {
|
function Write-ColorOutput {
|
||||||
param(
|
param(
|
||||||
[string]$Message,
|
[string]$Message,
|
||||||
@@ -704,6 +720,427 @@ function Merge-DirectoryContents {
|
|||||||
return $true
|
return $true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ============================================================================
|
||||||
|
# INSTALLATION MANIFEST MANAGEMENT
|
||||||
|
# ============================================================================
|
||||||
|
|
||||||
|
function New-InstallManifest {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Create a new installation manifest to track installed files
|
||||||
|
#>
|
||||||
|
param(
|
||||||
|
[string]$InstallationMode,
|
||||||
|
[string]$InstallationPath
|
||||||
|
)
|
||||||
|
|
||||||
|
# Create manifest directory if it doesn't exist
|
||||||
|
if (-not (Test-Path $script:ManifestDir)) {
|
||||||
|
New-Item -ItemType Directory -Path $script:ManifestDir -Force | Out-Null
|
||||||
|
}
|
||||||
|
|
||||||
|
# Generate unique manifest ID based on timestamp and mode
|
||||||
|
$timestamp = Get-Date -Format "yyyyMMdd-HHmmss"
|
||||||
|
$manifestId = "install-$InstallationMode-$timestamp"
|
||||||
|
|
||||||
|
$manifest = @{
|
||||||
|
manifest_id = $manifestId
|
||||||
|
version = "1.0"
|
||||||
|
installation_mode = $InstallationMode
|
||||||
|
installation_path = $InstallationPath
|
||||||
|
installation_date = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")
|
||||||
|
installer_version = $ScriptVersion
|
||||||
|
files = @()
|
||||||
|
directories = @()
|
||||||
|
}
|
||||||
|
|
||||||
|
return $manifest
|
||||||
|
}
|
||||||
|
|
||||||
|
function Add-ManifestEntry {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Add a file or directory entry to the manifest
|
||||||
|
#>
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory=$true)]
|
||||||
|
[hashtable]$Manifest,
|
||||||
|
|
||||||
|
[Parameter(Mandatory=$true)]
|
||||||
|
[string]$Path,
|
||||||
|
|
||||||
|
[Parameter(Mandatory=$true)]
|
||||||
|
[ValidateSet("File", "Directory")]
|
||||||
|
[string]$Type
|
||||||
|
)
|
||||||
|
|
||||||
|
$entry = @{
|
||||||
|
path = $Path
|
||||||
|
type = $Type
|
||||||
|
timestamp = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($Type -eq "File") {
|
||||||
|
$Manifest.files += $entry
|
||||||
|
} else {
|
||||||
|
$Manifest.directories += $entry
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Save-InstallManifest {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Save the installation manifest to disk
|
||||||
|
#>
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory=$true)]
|
||||||
|
[hashtable]$Manifest
|
||||||
|
)
|
||||||
|
|
||||||
|
try {
|
||||||
|
# Use manifest ID to create unique file name
|
||||||
|
$manifestFileName = "$($Manifest.manifest_id).json"
|
||||||
|
$manifestPath = Join-Path $script:ManifestDir $manifestFileName
|
||||||
|
|
||||||
|
$Manifest | ConvertTo-Json -Depth 10 | Out-File -FilePath $manifestPath -Encoding utf8 -Force
|
||||||
|
Write-ColorOutput "Installation manifest saved: $manifestPath" $ColorSuccess
|
||||||
|
return $true
|
||||||
|
} catch {
|
||||||
|
Write-ColorOutput "WARNING: Failed to save installation manifest: $($_.Exception.Message)" $ColorWarning
|
||||||
|
return $false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Migrate-LegacyManifest {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Migrate old single manifest file to new multi-manifest system
|
||||||
|
#>
|
||||||
|
|
||||||
|
$legacyManifestPath = Join-Path ([Environment]::GetFolderPath("UserProfile")) ".claude-install-manifest.json"
|
||||||
|
|
||||||
|
if (-not (Test-Path $legacyManifestPath)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Write-ColorOutput "Found legacy manifest file, migrating to new system..." $ColorInfo
|
||||||
|
|
||||||
|
# Create manifest directory if it doesn't exist
|
||||||
|
if (-not (Test-Path $script:ManifestDir)) {
|
||||||
|
New-Item -ItemType Directory -Path $script:ManifestDir -Force | Out-Null
|
||||||
|
}
|
||||||
|
|
||||||
|
# Read legacy manifest
|
||||||
|
$legacyJson = Get-Content -Path $legacyManifestPath -Raw -Encoding utf8
|
||||||
|
$legacy = $legacyJson | ConvertFrom-Json
|
||||||
|
|
||||||
|
# Generate new manifest ID
|
||||||
|
$timestamp = Get-Date -Format "yyyyMMdd-HHmmss"
|
||||||
|
$mode = if ($legacy.installation_mode) { $legacy.installation_mode } else { "Global" }
|
||||||
|
$manifestId = "install-$mode-$timestamp-migrated"
|
||||||
|
|
||||||
|
# Create new manifest with all fields
|
||||||
|
$newManifest = @{
|
||||||
|
manifest_id = $manifestId
|
||||||
|
version = if ($legacy.version) { $legacy.version } else { "1.0" }
|
||||||
|
installation_mode = $mode
|
||||||
|
installation_path = if ($legacy.installation_path) { $legacy.installation_path } else { [Environment]::GetFolderPath("UserProfile") }
|
||||||
|
installation_date = if ($legacy.installation_date) { $legacy.installation_date } else { (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ") }
|
||||||
|
installer_version = if ($legacy.installer_version) { $legacy.installer_version } else { "unknown" }
|
||||||
|
files = if ($legacy.files) { @($legacy.files) } else { @() }
|
||||||
|
directories = if ($legacy.directories) { @($legacy.directories) } else { @() }
|
||||||
|
}
|
||||||
|
|
||||||
|
# Save to new location
|
||||||
|
$newManifestPath = Join-Path $script:ManifestDir "$manifestId.json"
|
||||||
|
$newManifest | ConvertTo-Json -Depth 10 | Out-File -FilePath $newManifestPath -Encoding utf8 -Force
|
||||||
|
|
||||||
|
# Rename old manifest (don't delete, keep as backup)
|
||||||
|
$backupPath = "$legacyManifestPath.migrated"
|
||||||
|
Move-Item -Path $legacyManifestPath -Destination $backupPath -Force
|
||||||
|
|
||||||
|
Write-ColorOutput "Legacy manifest migrated successfully" $ColorSuccess
|
||||||
|
Write-ColorOutput "Old manifest backed up to: $backupPath" $ColorInfo
|
||||||
|
} catch {
|
||||||
|
Write-ColorOutput "WARNING: Failed to migrate legacy manifest: $($_.Exception.Message)" $ColorWarning
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Get-AllInstallManifests {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Get all installation manifests
|
||||||
|
#>
|
||||||
|
|
||||||
|
# Migrate legacy manifest if exists
|
||||||
|
Migrate-LegacyManifest
|
||||||
|
|
||||||
|
if (-not (Test-Path $script:ManifestDir)) {
|
||||||
|
return @()
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$manifestFiles = Get-ChildItem -Path $script:ManifestDir -Filter "install-*.json" -File | Sort-Object LastWriteTime -Descending
|
||||||
|
$manifests = [System.Collections.ArrayList]::new()
|
||||||
|
|
||||||
|
foreach ($file in $manifestFiles) {
|
||||||
|
try {
|
||||||
|
$manifestJson = Get-Content -Path $file.FullName -Raw -Encoding utf8
|
||||||
|
$manifest = $manifestJson | ConvertFrom-Json
|
||||||
|
|
||||||
|
# Convert to hashtable for easier manipulation
|
||||||
|
# Handle both old and new manifest formats
|
||||||
|
|
||||||
|
# Safely get array counts
|
||||||
|
$filesCount = 0
|
||||||
|
$dirsCount = 0
|
||||||
|
|
||||||
|
if ($manifest.files) {
|
||||||
|
if ($manifest.files -is [System.Array]) {
|
||||||
|
$filesCount = $manifest.files.Count
|
||||||
|
} else {
|
||||||
|
$filesCount = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($manifest.directories) {
|
||||||
|
if ($manifest.directories -is [System.Array]) {
|
||||||
|
$dirsCount = $manifest.directories.Count
|
||||||
|
} else {
|
||||||
|
$dirsCount = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$manifestHash = @{
|
||||||
|
manifest_id = if ($manifest.manifest_id) { $manifest.manifest_id } else { $file.BaseName }
|
||||||
|
manifest_file = $file.FullName
|
||||||
|
version = if ($manifest.version) { $manifest.version } else { "1.0" }
|
||||||
|
installation_mode = if ($manifest.installation_mode) { $manifest.installation_mode } else { "Unknown" }
|
||||||
|
installation_path = if ($manifest.installation_path) { $manifest.installation_path } else { "" }
|
||||||
|
installation_date = if ($manifest.installation_date) { $manifest.installation_date } else { $file.LastWriteTime.ToString("yyyy-MM-ddTHH:mm:ssZ") }
|
||||||
|
installer_version = if ($manifest.installer_version) { $manifest.installer_version } else { "unknown" }
|
||||||
|
files = if ($manifest.files) { @($manifest.files) } else { @() }
|
||||||
|
directories = if ($manifest.directories) { @($manifest.directories) } else { @() }
|
||||||
|
files_count = $filesCount
|
||||||
|
directories_count = $dirsCount
|
||||||
|
}
|
||||||
|
|
||||||
|
$null = $manifests.Add($manifestHash)
|
||||||
|
} catch {
|
||||||
|
Write-ColorOutput "WARNING: Failed to load manifest $($file.Name): $($_.Exception.Message)" $ColorWarning
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ,$manifests.ToArray()
|
||||||
|
} catch {
|
||||||
|
Write-ColorOutput "ERROR: Failed to list installation manifests: $($_.Exception.Message)" $ColorError
|
||||||
|
return @()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# ============================================================================
|
||||||
|
# UNINSTALLATION FUNCTIONS
|
||||||
|
# ============================================================================
|
||||||
|
|
||||||
|
function Uninstall-ClaudeWorkflow {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Uninstall Claude Code Workflow based on installation manifest
|
||||||
|
#>
|
||||||
|
|
||||||
|
Write-ColorOutput "Claude Code Workflow System Uninstaller" $ColorInfo
|
||||||
|
Write-ColorOutput "========================================" $ColorInfo
|
||||||
|
Write-Host ""
|
||||||
|
|
||||||
|
# Load all manifests
|
||||||
|
$manifests = Get-AllInstallManifests
|
||||||
|
|
||||||
|
if (-not $manifests -or $manifests.Count -eq 0) {
|
||||||
|
Write-ColorOutput "ERROR: No installation manifests found in: $script:ManifestDir" $ColorError
|
||||||
|
Write-ColorOutput "Cannot proceed with uninstallation without manifest." $ColorError
|
||||||
|
Write-Host ""
|
||||||
|
Write-ColorOutput "Manual uninstallation instructions:" $ColorInfo
|
||||||
|
Write-Host "For Global installation, remove these directories:"
|
||||||
|
Write-Host " - ~/.claude/agents"
|
||||||
|
Write-Host " - ~/.claude/commands"
|
||||||
|
Write-Host " - ~/.claude/output-styles"
|
||||||
|
Write-Host " - ~/.claude/workflows"
|
||||||
|
Write-Host " - ~/.claude/scripts"
|
||||||
|
Write-Host " - ~/.claude/prompt-templates"
|
||||||
|
Write-Host " - ~/.claude/python_script"
|
||||||
|
Write-Host " - ~/.claude/skills"
|
||||||
|
Write-Host " - ~/.claude/version.json"
|
||||||
|
Write-Host " - ~/.claude/CLAUDE.md"
|
||||||
|
Write-Host " - ~/.codex"
|
||||||
|
Write-Host " - ~/.gemini"
|
||||||
|
Write-Host " - ~/.qwen"
|
||||||
|
return $false
|
||||||
|
}
|
||||||
|
|
||||||
|
# Display available installations
|
||||||
|
Write-ColorOutput "Found $($manifests.Count) installation(s):" $ColorInfo
|
||||||
|
Write-Host ""
|
||||||
|
|
||||||
|
# If only one manifest, use it directly
|
||||||
|
$selectedManifest = $null
|
||||||
|
if ($manifests.Count -eq 1) {
|
||||||
|
$selectedManifest = $manifests[0]
|
||||||
|
Write-ColorOutput "Only one installation found, will uninstall:" $ColorInfo
|
||||||
|
} else {
|
||||||
|
# Multiple manifests - let user choose
|
||||||
|
$options = @()
|
||||||
|
for ($i = 0; $i -lt $manifests.Count; $i++) {
|
||||||
|
$m = $manifests[$i]
|
||||||
|
|
||||||
|
# Safely extract date string
|
||||||
|
$dateStr = "unknown date"
|
||||||
|
if ($m.installation_date) {
|
||||||
|
try {
|
||||||
|
if ($m.installation_date.Length -ge 10) {
|
||||||
|
$dateStr = $m.installation_date.Substring(0, 10)
|
||||||
|
} else {
|
||||||
|
$dateStr = $m.installation_date
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
$dateStr = "unknown date"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Build option string with safe counts
|
||||||
|
$filesCount = if ($m.files_count) { $m.files_count } else { 0 }
|
||||||
|
$dirsCount = if ($m.directories_count) { $m.directories_count } else { 0 }
|
||||||
|
$pathInfo = if ($m.installation_path) { " ($($m.installation_path))" } else { "" }
|
||||||
|
$option = "$($i + 1). [$($m.installation_mode)] $dateStr - $filesCount files, $dirsCount dirs$pathInfo"
|
||||||
|
$options += $option
|
||||||
|
}
|
||||||
|
$options += "Cancel - Don't uninstall anything"
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
$selection = Get-UserChoiceWithArrows -Prompt "Select installation to uninstall:" -Options $options -DefaultIndex 0
|
||||||
|
|
||||||
|
if ($selection -like "Cancel*") {
|
||||||
|
Write-ColorOutput "Uninstallation cancelled." $ColorWarning
|
||||||
|
return $false
|
||||||
|
}
|
||||||
|
|
||||||
|
# Parse selection to get index
|
||||||
|
$selectedIndex = [int]($selection.Split('.')[0]) - 1
|
||||||
|
$selectedManifest = $manifests[$selectedIndex]
|
||||||
|
}
|
||||||
|
|
||||||
|
# Display selected installation info
|
||||||
|
Write-Host ""
|
||||||
|
Write-ColorOutput "Installation Information:" $ColorInfo
|
||||||
|
Write-Host " Manifest ID: $($selectedManifest.manifest_id)"
|
||||||
|
Write-Host " Mode: $($selectedManifest.installation_mode)"
|
||||||
|
Write-Host " Path: $($selectedManifest.installation_path)"
|
||||||
|
Write-Host " Date: $($selectedManifest.installation_date)"
|
||||||
|
Write-Host " Installer Version: $($selectedManifest.installer_version)"
|
||||||
|
|
||||||
|
# Use pre-calculated counts
|
||||||
|
$filesCount = if ($selectedManifest.files_count) { $selectedManifest.files_count } else { 0 }
|
||||||
|
$dirsCount = if ($selectedManifest.directories_count) { $selectedManifest.directories_count } else { 0 }
|
||||||
|
Write-Host " Files tracked: $filesCount"
|
||||||
|
Write-Host " Directories tracked: $dirsCount"
|
||||||
|
Write-Host ""
|
||||||
|
|
||||||
|
# Confirm uninstallation
|
||||||
|
if (-not (Confirm-Action "Do you want to uninstall this installation?" -DefaultYes:$false)) {
|
||||||
|
Write-ColorOutput "Uninstallation cancelled." $ColorWarning
|
||||||
|
return $false
|
||||||
|
}
|
||||||
|
|
||||||
|
# Use the selected manifest for uninstallation
|
||||||
|
$manifest = $selectedManifest
|
||||||
|
|
||||||
|
$removedFiles = 0
|
||||||
|
$removedDirs = 0
|
||||||
|
$failedItems = @()
|
||||||
|
|
||||||
|
# Remove files first
|
||||||
|
Write-ColorOutput "Removing installed files..." $ColorInfo
|
||||||
|
foreach ($fileEntry in $manifest.files) {
|
||||||
|
$filePath = $fileEntry.path
|
||||||
|
|
||||||
|
if (Test-Path $filePath) {
|
||||||
|
try {
|
||||||
|
Remove-Item -Path $filePath -Force -ErrorAction Stop
|
||||||
|
Write-ColorOutput " Removed file: $filePath" $ColorSuccess
|
||||||
|
$removedFiles++
|
||||||
|
} catch {
|
||||||
|
Write-ColorOutput " WARNING: Failed to remove file: $filePath" $ColorWarning
|
||||||
|
$failedItems += $filePath
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Write-ColorOutput " File not found (already removed): $filePath" $ColorInfo
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Remove directories (in reverse order to handle nested directories)
|
||||||
|
Write-ColorOutput "Removing installed directories..." $ColorInfo
|
||||||
|
$sortedDirs = $manifest.directories | Sort-Object { $_.path.Length } -Descending
|
||||||
|
|
||||||
|
foreach ($dirEntry in $sortedDirs) {
|
||||||
|
$dirPath = $dirEntry.path
|
||||||
|
|
||||||
|
if (Test-Path $dirPath) {
|
||||||
|
try {
|
||||||
|
# Check if directory is empty or only contains files we installed
|
||||||
|
$dirContents = Get-ChildItem -Path $dirPath -Recurse -Force -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
|
if (-not $dirContents -or ($dirContents | Measure-Object).Count -eq 0) {
|
||||||
|
Remove-Item -Path $dirPath -Recurse -Force -ErrorAction Stop
|
||||||
|
Write-ColorOutput " Removed directory: $dirPath" $ColorSuccess
|
||||||
|
$removedDirs++
|
||||||
|
} else {
|
||||||
|
Write-ColorOutput " Directory not empty (preserved): $dirPath" $ColorWarning
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
Write-ColorOutput " WARNING: Failed to remove directory: $dirPath" $ColorWarning
|
||||||
|
$failedItems += $dirPath
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Write-ColorOutput " Directory not found (already removed): $dirPath" $ColorInfo
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Remove manifest file
|
||||||
|
if (Test-Path $manifest.manifest_file) {
|
||||||
|
try {
|
||||||
|
Remove-Item -Path $manifest.manifest_file -Force
|
||||||
|
Write-ColorOutput "Removed installation manifest: $($manifest.manifest_id)" $ColorSuccess
|
||||||
|
} catch {
|
||||||
|
Write-ColorOutput "WARNING: Failed to remove manifest file" $ColorWarning
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Show summary
|
||||||
|
Write-Host ""
|
||||||
|
Write-ColorOutput "========================================" $ColorInfo
|
||||||
|
Write-ColorOutput "Uninstallation Summary:" $ColorInfo
|
||||||
|
Write-Host " Files removed: $removedFiles"
|
||||||
|
Write-Host " Directories removed: $removedDirs"
|
||||||
|
|
||||||
|
if ($failedItems.Count -gt 0) {
|
||||||
|
Write-Host ""
|
||||||
|
Write-ColorOutput "Failed to remove the following items:" $ColorWarning
|
||||||
|
foreach ($item in $failedItems) {
|
||||||
|
Write-Host " - $item"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
if ($failedItems.Count -eq 0) {
|
||||||
|
Write-ColorOutput "Claude Code Workflow has been successfully uninstalled!" $ColorSuccess
|
||||||
|
} else {
|
||||||
|
Write-ColorOutput "Uninstallation completed with warnings." $ColorWarning
|
||||||
|
Write-ColorOutput "Please manually remove the failed items listed above." $ColorInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
return $true
|
||||||
|
}
|
||||||
|
|
||||||
function Create-VersionJson {
|
function Create-VersionJson {
|
||||||
param(
|
param(
|
||||||
[string]$TargetClaudeDir,
|
[string]$TargetClaudeDir,
|
||||||
@@ -751,6 +1188,9 @@ function Install-Global {
|
|||||||
|
|
||||||
Write-ColorOutput "Global installation path: $userProfile" $ColorInfo
|
Write-ColorOutput "Global installation path: $userProfile" $ColorInfo
|
||||||
|
|
||||||
|
# Initialize manifest
|
||||||
|
$manifest = New-InstallManifest -InstallationMode "Global" -InstallationPath $userProfile
|
||||||
|
|
||||||
# Source paths
|
# Source paths
|
||||||
$sourceDir = $PSScriptRoot
|
$sourceDir = $PSScriptRoot
|
||||||
$sourceClaudeDir = Join-Path $sourceDir ".claude"
|
$sourceClaudeDir = Join-Path $sourceDir ".claude"
|
||||||
@@ -791,22 +1231,73 @@ function Install-Global {
|
|||||||
Write-ColorOutput "Installing .claude directory..." $ColorInfo
|
Write-ColorOutput "Installing .claude directory..." $ColorInfo
|
||||||
$claudeInstalled = Backup-AndReplaceDirectory -Source $sourceClaudeDir -Destination $globalClaudeDir -Description ".claude directory" -BackupFolder $backupFolder
|
$claudeInstalled = Backup-AndReplaceDirectory -Source $sourceClaudeDir -Destination $globalClaudeDir -Description ".claude directory" -BackupFolder $backupFolder
|
||||||
|
|
||||||
|
# Track .claude directory in manifest
|
||||||
|
if ($claudeInstalled) {
|
||||||
|
Add-ManifestEntry -Manifest $manifest -Path $globalClaudeDir -Type "Directory"
|
||||||
|
|
||||||
|
# Track files from SOURCE directory, not destination
|
||||||
|
Get-ChildItem -Path $sourceClaudeDir -Recurse -File | ForEach-Object {
|
||||||
|
# Calculate target path where this file will be installed
|
||||||
|
$relativePath = $_.FullName.Substring($sourceClaudeDir.Length)
|
||||||
|
$targetPath = $globalClaudeDir + $relativePath
|
||||||
|
Add-ManifestEntry -Manifest $manifest -Path $targetPath -Type "File"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Handle CLAUDE.md file in .claude directory
|
# Handle CLAUDE.md file in .claude directory
|
||||||
Write-ColorOutput "Installing CLAUDE.md to global .claude directory..." $ColorInfo
|
Write-ColorOutput "Installing CLAUDE.md to global .claude directory..." $ColorInfo
|
||||||
$claudeMdInstalled = Copy-FileToDestination -Source $sourceClaudeMd -Destination $globalClaudeMd -Description "CLAUDE.md" -BackupFolder $backupFolder
|
$claudeMdInstalled = Copy-FileToDestination -Source $sourceClaudeMd -Destination $globalClaudeMd -Description "CLAUDE.md" -BackupFolder $backupFolder
|
||||||
|
|
||||||
|
# Track CLAUDE.md in manifest
|
||||||
|
if ($claudeMdInstalled) {
|
||||||
|
Add-ManifestEntry -Manifest $manifest -Path $globalClaudeMd -Type "File"
|
||||||
|
}
|
||||||
|
|
||||||
# Replace .codex directory (backup → clear → copy entire folder)
|
# Replace .codex directory (backup → clear → copy entire folder)
|
||||||
Write-ColorOutput "Installing .codex directory..." $ColorInfo
|
Write-ColorOutput "Installing .codex directory..." $ColorInfo
|
||||||
$codexInstalled = Backup-AndReplaceDirectory -Source $sourceCodexDir -Destination $globalCodexDir -Description ".codex directory" -BackupFolder $backupFolder
|
$codexInstalled = Backup-AndReplaceDirectory -Source $sourceCodexDir -Destination $globalCodexDir -Description ".codex directory" -BackupFolder $backupFolder
|
||||||
|
|
||||||
|
# Track .codex directory in manifest
|
||||||
|
if ($codexInstalled) {
|
||||||
|
Add-ManifestEntry -Manifest $manifest -Path $globalCodexDir -Type "Directory"
|
||||||
|
# Track files from SOURCE directory
|
||||||
|
Get-ChildItem -Path $sourceCodexDir -Recurse -File | ForEach-Object {
|
||||||
|
$relativePath = $_.FullName.Substring($sourceCodexDir.Length)
|
||||||
|
$targetPath = $globalCodexDir + $relativePath
|
||||||
|
Add-ManifestEntry -Manifest $manifest -Path $targetPath -Type "File"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Replace .gemini directory (backup → clear → copy entire folder)
|
# Replace .gemini directory (backup → clear → copy entire folder)
|
||||||
Write-ColorOutput "Installing .gemini directory..." $ColorInfo
|
Write-ColorOutput "Installing .gemini directory..." $ColorInfo
|
||||||
$geminiInstalled = Backup-AndReplaceDirectory -Source $sourceGeminiDir -Destination $globalGeminiDir -Description ".gemini directory" -BackupFolder $backupFolder
|
$geminiInstalled = Backup-AndReplaceDirectory -Source $sourceGeminiDir -Destination $globalGeminiDir -Description ".gemini directory" -BackupFolder $backupFolder
|
||||||
|
|
||||||
|
# Track .gemini directory in manifest
|
||||||
|
if ($geminiInstalled) {
|
||||||
|
Add-ManifestEntry -Manifest $manifest -Path $globalGeminiDir -Type "Directory"
|
||||||
|
# Track files from SOURCE directory
|
||||||
|
Get-ChildItem -Path $sourceGeminiDir -Recurse -File | ForEach-Object {
|
||||||
|
$relativePath = $_.FullName.Substring($sourceGeminiDir.Length)
|
||||||
|
$targetPath = $globalGeminiDir + $relativePath
|
||||||
|
Add-ManifestEntry -Manifest $manifest -Path $targetPath -Type "File"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Replace .qwen directory (backup → clear → copy entire folder)
|
# Replace .qwen directory (backup → clear → copy entire folder)
|
||||||
Write-ColorOutput "Installing .qwen directory..." $ColorInfo
|
Write-ColorOutput "Installing .qwen directory..." $ColorInfo
|
||||||
$qwenInstalled = Backup-AndReplaceDirectory -Source $sourceQwenDir -Destination $globalQwenDir -Description ".qwen directory" -BackupFolder $backupFolder
|
$qwenInstalled = Backup-AndReplaceDirectory -Source $sourceQwenDir -Destination $globalQwenDir -Description ".qwen directory" -BackupFolder $backupFolder
|
||||||
|
|
||||||
|
# Track .qwen directory in manifest
|
||||||
|
if ($qwenInstalled) {
|
||||||
|
Add-ManifestEntry -Manifest $manifest -Path $globalQwenDir -Type "Directory"
|
||||||
|
# Track files from SOURCE directory
|
||||||
|
Get-ChildItem -Path $sourceQwenDir -Recurse -File | ForEach-Object {
|
||||||
|
$relativePath = $_.FullName.Substring($sourceQwenDir.Length)
|
||||||
|
$targetPath = $globalQwenDir + $relativePath
|
||||||
|
Add-ManifestEntry -Manifest $manifest -Path $targetPath -Type "File"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Create version.json in global .claude directory
|
# Create version.json in global .claude directory
|
||||||
Write-ColorOutput "Creating version.json..." $ColorInfo
|
Write-ColorOutput "Creating version.json..." $ColorInfo
|
||||||
Create-VersionJson -TargetClaudeDir $globalClaudeDir -InstallationMode "Global"
|
Create-VersionJson -TargetClaudeDir $globalClaudeDir -InstallationMode "Global"
|
||||||
@@ -820,6 +1311,9 @@ function Install-Global {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Save installation manifest
|
||||||
|
Save-InstallManifest -Manifest $manifest
|
||||||
|
|
||||||
return $true
|
return $true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -837,6 +1331,9 @@ function Install-Path {
|
|||||||
|
|
||||||
Write-ColorOutput "Global path: $userProfile" $ColorInfo
|
Write-ColorOutput "Global path: $userProfile" $ColorInfo
|
||||||
|
|
||||||
|
# Initialize manifest
|
||||||
|
$manifest = New-InstallManifest -InstallationMode "Path" -InstallationPath $TargetDirectory
|
||||||
|
|
||||||
# Source paths
|
# Source paths
|
||||||
$sourceDir = $PSScriptRoot
|
$sourceDir = $PSScriptRoot
|
||||||
$sourceClaudeDir = Join-Path $sourceDir ".claude"
|
$sourceClaudeDir = Join-Path $sourceDir ".claude"
|
||||||
@@ -877,8 +1374,19 @@ function Install-Path {
|
|||||||
if (Test-Path $sourceFolderPath) {
|
if (Test-Path $sourceFolderPath) {
|
||||||
# Use new backup and replace logic for local folders
|
# Use new backup and replace logic for local folders
|
||||||
Write-ColorOutput "Installing local folder: $folder..." $ColorInfo
|
Write-ColorOutput "Installing local folder: $folder..." $ColorInfo
|
||||||
Backup-AndReplaceDirectory -Source $sourceFolderPath -Destination $destFolderPath -Description "$folder folder" -BackupFolder $backupFolder
|
$folderInstalled = Backup-AndReplaceDirectory -Source $sourceFolderPath -Destination $destFolderPath -Description "$folder folder" -BackupFolder $backupFolder
|
||||||
Write-ColorOutput "Installed local folder: $folder" $ColorSuccess
|
Write-ColorOutput "Installed local folder: $folder" $ColorSuccess
|
||||||
|
|
||||||
|
# Track local folder in manifest
|
||||||
|
if ($folderInstalled) {
|
||||||
|
Add-ManifestEntry -Manifest $manifest -Path $destFolderPath -Type "Directory"
|
||||||
|
# Track files from SOURCE directory
|
||||||
|
Get-ChildItem -Path $sourceFolderPath -Recurse -File | ForEach-Object {
|
||||||
|
$relativePath = $_.FullName.Substring($sourceFolderPath.Length)
|
||||||
|
$targetPath = $destFolderPath + $relativePath
|
||||||
|
Add-ManifestEntry -Manifest $manifest -Path $targetPath -Type "File"
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Write-ColorOutput "WARNING: Source folder not found: $folder" $ColorWarning
|
Write-ColorOutput "WARNING: Source folder not found: $folder" $ColorWarning
|
||||||
}
|
}
|
||||||
@@ -933,23 +1441,71 @@ function Install-Path {
|
|||||||
|
|
||||||
Write-ColorOutput "Merged $mergedCount files to global location" $ColorSuccess
|
Write-ColorOutput "Merged $mergedCount files to global location" $ColorSuccess
|
||||||
|
|
||||||
|
# Track global files in manifest
|
||||||
|
$globalClaudeFiles = Get-ChildItem -Path $globalClaudeDir -Recurse -File | Where-Object {
|
||||||
|
$relativePath = $_.FullName.Substring($globalClaudeDir.Length + 1)
|
||||||
|
$topFolder = $relativePath.Split([System.IO.Path]::DirectorySeparatorChar)[0]
|
||||||
|
$topFolder -notin $localFolders
|
||||||
|
}
|
||||||
|
foreach ($file in $globalClaudeFiles) {
|
||||||
|
Add-ManifestEntry -Manifest $manifest -Path $file.FullName -Type "File"
|
||||||
|
}
|
||||||
|
|
||||||
# Handle CLAUDE.md file in global .claude directory
|
# Handle CLAUDE.md file in global .claude directory
|
||||||
$globalClaudeMd = Join-Path $globalClaudeDir "CLAUDE.md"
|
$globalClaudeMd = Join-Path $globalClaudeDir "CLAUDE.md"
|
||||||
Write-ColorOutput "Installing CLAUDE.md to global .claude directory..." $ColorInfo
|
Write-ColorOutput "Installing CLAUDE.md to global .claude directory..." $ColorInfo
|
||||||
Copy-FileToDestination -Source $sourceClaudeMd -Destination $globalClaudeMd -Description "CLAUDE.md" -BackupFolder $backupFolder
|
$claudeMdInstalled = Copy-FileToDestination -Source $sourceClaudeMd -Destination $globalClaudeMd -Description "CLAUDE.md" -BackupFolder $backupFolder
|
||||||
|
|
||||||
|
# Track CLAUDE.md in manifest
|
||||||
|
if ($claudeMdInstalled) {
|
||||||
|
Add-ManifestEntry -Manifest $manifest -Path $globalClaudeMd -Type "File"
|
||||||
|
}
|
||||||
|
|
||||||
# Replace .codex directory to local location (backup → clear → copy entire folder)
|
# Replace .codex directory to local location (backup → clear → copy entire folder)
|
||||||
Write-ColorOutput "Installing .codex directory to local location..." $ColorInfo
|
Write-ColorOutput "Installing .codex directory to local location..." $ColorInfo
|
||||||
$codexInstalled = Backup-AndReplaceDirectory -Source $sourceCodexDir -Destination $localCodexDir -Description ".codex directory" -BackupFolder $backupFolder
|
$codexInstalled = Backup-AndReplaceDirectory -Source $sourceCodexDir -Destination $localCodexDir -Description ".codex directory" -BackupFolder $backupFolder
|
||||||
|
|
||||||
|
# Track .codex directory in manifest
|
||||||
|
if ($codexInstalled) {
|
||||||
|
Add-ManifestEntry -Manifest $manifest -Path $localCodexDir -Type "Directory"
|
||||||
|
# Track files from SOURCE directory
|
||||||
|
Get-ChildItem -Path $sourceCodexDir -Recurse -File | ForEach-Object {
|
||||||
|
$relativePath = $_.FullName.Substring($sourceCodexDir.Length)
|
||||||
|
$targetPath = $localCodexDir + $relativePath
|
||||||
|
Add-ManifestEntry -Manifest $manifest -Path $targetPath -Type "File"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Replace .gemini directory to local location (backup → clear → copy entire folder)
|
# Replace .gemini directory to local location (backup → clear → copy entire folder)
|
||||||
Write-ColorOutput "Installing .gemini directory to local location..." $ColorInfo
|
Write-ColorOutput "Installing .gemini directory to local location..." $ColorInfo
|
||||||
$geminiInstalled = Backup-AndReplaceDirectory -Source $sourceGeminiDir -Destination $localGeminiDir -Description ".gemini directory" -BackupFolder $backupFolder
|
$geminiInstalled = Backup-AndReplaceDirectory -Source $sourceGeminiDir -Destination $localGeminiDir -Description ".gemini directory" -BackupFolder $backupFolder
|
||||||
|
|
||||||
|
# Track .gemini directory in manifest
|
||||||
|
if ($geminiInstalled) {
|
||||||
|
Add-ManifestEntry -Manifest $manifest -Path $localGeminiDir -Type "Directory"
|
||||||
|
# Track files from SOURCE directory
|
||||||
|
Get-ChildItem -Path $sourceGeminiDir -Recurse -File | ForEach-Object {
|
||||||
|
$relativePath = $_.FullName.Substring($sourceGeminiDir.Length)
|
||||||
|
$targetPath = $localGeminiDir + $relativePath
|
||||||
|
Add-ManifestEntry -Manifest $manifest -Path $targetPath -Type "File"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Replace .qwen directory to local location (backup → clear → copy entire folder)
|
# Replace .qwen directory to local location (backup → clear → copy entire folder)
|
||||||
Write-ColorOutput "Installing .qwen directory to local location..." $ColorInfo
|
Write-ColorOutput "Installing .qwen directory to local location..." $ColorInfo
|
||||||
$qwenInstalled = Backup-AndReplaceDirectory -Source $sourceQwenDir -Destination $localQwenDir -Description ".qwen directory" -BackupFolder $backupFolder
|
$qwenInstalled = Backup-AndReplaceDirectory -Source $sourceQwenDir -Destination $localQwenDir -Description ".qwen directory" -BackupFolder $backupFolder
|
||||||
|
|
||||||
|
# Track .qwen directory in manifest
|
||||||
|
if ($qwenInstalled) {
|
||||||
|
Add-ManifestEntry -Manifest $manifest -Path $localQwenDir -Type "Directory"
|
||||||
|
# Track files from SOURCE directory
|
||||||
|
Get-ChildItem -Path $sourceQwenDir -Recurse -File | ForEach-Object {
|
||||||
|
$relativePath = $_.FullName.Substring($sourceQwenDir.Length)
|
||||||
|
$targetPath = $localQwenDir + $relativePath
|
||||||
|
Add-ManifestEntry -Manifest $manifest -Path $targetPath -Type "File"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Create version.json in local .claude directory
|
# Create version.json in local .claude directory
|
||||||
Write-ColorOutput "Creating version.json in local directory..." $ColorInfo
|
Write-ColorOutput "Creating version.json in local directory..." $ColorInfo
|
||||||
Create-VersionJson -TargetClaudeDir $localClaudeDir -InstallationMode "Path"
|
Create-VersionJson -TargetClaudeDir $localClaudeDir -InstallationMode "Path"
|
||||||
@@ -966,6 +1522,9 @@ function Install-Path {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Save installation manifest
|
||||||
|
Save-InstallManifest -Manifest $manifest
|
||||||
|
|
||||||
return $true
|
return $true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1098,6 +1657,42 @@ function Main {
|
|||||||
# Use SourceVersion parameter if provided, otherwise use default
|
# Use SourceVersion parameter if provided, otherwise use default
|
||||||
$installVersion = if ($SourceVersion) { $SourceVersion } else { $DefaultVersion }
|
$installVersion = if ($SourceVersion) { $SourceVersion } else { $DefaultVersion }
|
||||||
|
|
||||||
|
# Show banner first
|
||||||
|
Show-Banner
|
||||||
|
|
||||||
|
# Check for uninstall mode from parameter or ask user interactively
|
||||||
|
$operationMode = "Install"
|
||||||
|
|
||||||
|
if ($Uninstall) {
|
||||||
|
$operationMode = "Uninstall"
|
||||||
|
} elseif (-not $NonInteractive -and -not $InstallMode) {
|
||||||
|
# Interactive mode selection
|
||||||
|
Write-Host ""
|
||||||
|
$operations = @(
|
||||||
|
"Install - Install Claude Code Workflow System",
|
||||||
|
"Uninstall - Remove Claude Code Workflow System"
|
||||||
|
)
|
||||||
|
$selection = Get-UserChoiceWithArrows -Prompt "Choose operation:" -Options $operations -DefaultIndex 0
|
||||||
|
|
||||||
|
if ($selection -like "Uninstall*") {
|
||||||
|
$operationMode = "Uninstall"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Handle uninstall mode
|
||||||
|
if ($operationMode -eq "Uninstall") {
|
||||||
|
$result = Uninstall-ClaudeWorkflow
|
||||||
|
|
||||||
|
if (-not $NonInteractive) {
|
||||||
|
Write-Host ""
|
||||||
|
Write-ColorOutput "Press any key to exit..." $ColorPrompt
|
||||||
|
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
|
||||||
|
}
|
||||||
|
|
||||||
|
return $(if ($result) { 0 } else { 1 })
|
||||||
|
}
|
||||||
|
|
||||||
|
# Continue with installation
|
||||||
Show-Header -InstallVersion $installVersion
|
Show-Header -InstallVersion $installVersion
|
||||||
|
|
||||||
# Test prerequisites
|
# Test prerequisites
|
||||||
|
|||||||
@@ -24,10 +24,14 @@ FORCE=false
|
|||||||
NON_INTERACTIVE=false
|
NON_INTERACTIVE=false
|
||||||
BACKUP_ALL=true # Enabled by default
|
BACKUP_ALL=true # Enabled by default
|
||||||
NO_BACKUP=false
|
NO_BACKUP=false
|
||||||
|
UNINSTALL=false # Uninstall mode
|
||||||
SOURCE_VERSION="" # Version from remote installer
|
SOURCE_VERSION="" # Version from remote installer
|
||||||
SOURCE_BRANCH="" # Branch from remote installer
|
SOURCE_BRANCH="" # Branch from remote installer
|
||||||
SOURCE_COMMIT="" # Commit SHA from remote installer
|
SOURCE_COMMIT="" # Commit SHA from remote installer
|
||||||
|
|
||||||
|
# Global manifest directory location
|
||||||
|
MANIFEST_DIR="${HOME}/.claude-manifests"
|
||||||
|
|
||||||
# Functions
|
# Functions
|
||||||
function write_color() {
|
function write_color() {
|
||||||
local message="$1"
|
local message="$1"
|
||||||
@@ -474,6 +478,9 @@ function install_global() {
|
|||||||
|
|
||||||
write_color "Global installation path: $user_home" "$COLOR_INFO"
|
write_color "Global installation path: $user_home" "$COLOR_INFO"
|
||||||
|
|
||||||
|
# Initialize manifest
|
||||||
|
local manifest_file=$(new_install_manifest "Global" "$user_home")
|
||||||
|
|
||||||
# Source paths
|
# Source paths
|
||||||
local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
local source_claude_dir="${script_dir}/.claude"
|
local source_claude_dir="${script_dir}/.claude"
|
||||||
@@ -507,23 +514,66 @@ function install_global() {
|
|||||||
|
|
||||||
# Replace .claude directory (backup → clear conflicting → copy)
|
# Replace .claude directory (backup → clear conflicting → copy)
|
||||||
write_color "Installing .claude directory..." "$COLOR_INFO"
|
write_color "Installing .claude directory..." "$COLOR_INFO"
|
||||||
backup_and_replace_directory "$source_claude_dir" "$global_claude_dir" ".claude directory" "$backup_folder"
|
if backup_and_replace_directory "$source_claude_dir" "$global_claude_dir" ".claude directory" "$backup_folder"; then
|
||||||
|
# Track .claude directory in manifest
|
||||||
|
add_manifest_entry "$manifest_file" "$global_claude_dir" "Directory"
|
||||||
|
|
||||||
|
# Track files from SOURCE directory, not destination
|
||||||
|
while IFS= read -r -d '' source_file; do
|
||||||
|
local relative_path="${source_file#$source_claude_dir}"
|
||||||
|
local target_path="${global_claude_dir}${relative_path}"
|
||||||
|
add_manifest_entry "$manifest_file" "$target_path" "File"
|
||||||
|
done < <(find "$source_claude_dir" -type f -print0)
|
||||||
|
fi
|
||||||
|
|
||||||
# Handle CLAUDE.md file
|
# Handle CLAUDE.md file
|
||||||
write_color "Installing CLAUDE.md to global .claude directory..." "$COLOR_INFO"
|
write_color "Installing CLAUDE.md to global .claude directory..." "$COLOR_INFO"
|
||||||
copy_file_to_destination "$source_claude_md" "$global_claude_md" "CLAUDE.md" "$backup_folder"
|
if copy_file_to_destination "$source_claude_md" "$global_claude_md" "CLAUDE.md" "$backup_folder"; then
|
||||||
|
# Track CLAUDE.md in manifest
|
||||||
|
add_manifest_entry "$manifest_file" "$global_claude_md" "File"
|
||||||
|
fi
|
||||||
|
|
||||||
# Replace .codex directory (backup → clear conflicting → copy)
|
# Replace .codex directory (backup → clear conflicting → copy)
|
||||||
write_color "Installing .codex directory..." "$COLOR_INFO"
|
write_color "Installing .codex directory..." "$COLOR_INFO"
|
||||||
backup_and_replace_directory "$source_codex_dir" "$global_codex_dir" ".codex directory" "$backup_folder"
|
if backup_and_replace_directory "$source_codex_dir" "$global_codex_dir" ".codex directory" "$backup_folder"; then
|
||||||
|
# Track .codex directory in manifest
|
||||||
|
add_manifest_entry "$manifest_file" "$global_codex_dir" "Directory"
|
||||||
|
|
||||||
|
# Track files from SOURCE directory
|
||||||
|
while IFS= read -r -d '' source_file; do
|
||||||
|
local relative_path="${source_file#$source_codex_dir}"
|
||||||
|
local target_path="${global_codex_dir}${relative_path}"
|
||||||
|
add_manifest_entry "$manifest_file" "$target_path" "File"
|
||||||
|
done < <(find "$source_codex_dir" -type f -print0)
|
||||||
|
fi
|
||||||
|
|
||||||
# Replace .gemini directory (backup → clear conflicting → copy)
|
# Replace .gemini directory (backup → clear conflicting → copy)
|
||||||
write_color "Installing .gemini directory..." "$COLOR_INFO"
|
write_color "Installing .gemini directory..." "$COLOR_INFO"
|
||||||
backup_and_replace_directory "$source_gemini_dir" "$global_gemini_dir" ".gemini directory" "$backup_folder"
|
if backup_and_replace_directory "$source_gemini_dir" "$global_gemini_dir" ".gemini directory" "$backup_folder"; then
|
||||||
|
# Track .gemini directory in manifest
|
||||||
|
add_manifest_entry "$manifest_file" "$global_gemini_dir" "Directory"
|
||||||
|
|
||||||
|
# Track files from SOURCE directory
|
||||||
|
while IFS= read -r -d '' source_file; do
|
||||||
|
local relative_path="${source_file#$source_gemini_dir}"
|
||||||
|
local target_path="${global_gemini_dir}${relative_path}"
|
||||||
|
add_manifest_entry "$manifest_file" "$target_path" "File"
|
||||||
|
done < <(find "$source_gemini_dir" -type f -print0)
|
||||||
|
fi
|
||||||
|
|
||||||
# Replace .qwen directory (backup → clear conflicting → copy)
|
# Replace .qwen directory (backup → clear conflicting → copy)
|
||||||
write_color "Installing .qwen directory..." "$COLOR_INFO"
|
write_color "Installing .qwen directory..." "$COLOR_INFO"
|
||||||
backup_and_replace_directory "$source_qwen_dir" "$global_qwen_dir" ".qwen directory" "$backup_folder"
|
if backup_and_replace_directory "$source_qwen_dir" "$global_qwen_dir" ".qwen directory" "$backup_folder"; then
|
||||||
|
# Track .qwen directory in manifest
|
||||||
|
add_manifest_entry "$manifest_file" "$global_qwen_dir" "Directory"
|
||||||
|
|
||||||
|
# Track files from SOURCE directory
|
||||||
|
while IFS= read -r -d '' source_file; do
|
||||||
|
local relative_path="${source_file#$source_qwen_dir}"
|
||||||
|
local target_path="${global_qwen_dir}${relative_path}"
|
||||||
|
add_manifest_entry "$manifest_file" "$target_path" "File"
|
||||||
|
done < <(find "$source_qwen_dir" -type f -print0)
|
||||||
|
fi
|
||||||
|
|
||||||
# Remove empty backup folder
|
# Remove empty backup folder
|
||||||
if [ -n "$backup_folder" ] && [ -d "$backup_folder" ]; then
|
if [ -n "$backup_folder" ] && [ -d "$backup_folder" ]; then
|
||||||
@@ -537,6 +587,9 @@ function install_global() {
|
|||||||
write_color "Creating version.json..." "$COLOR_INFO"
|
write_color "Creating version.json..." "$COLOR_INFO"
|
||||||
create_version_json "$global_claude_dir" "Global"
|
create_version_json "$global_claude_dir" "Global"
|
||||||
|
|
||||||
|
# Save installation manifest
|
||||||
|
save_install_manifest "$manifest_file"
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -550,6 +603,9 @@ function install_path() {
|
|||||||
local global_claude_dir="${user_home}/.claude"
|
local global_claude_dir="${user_home}/.claude"
|
||||||
write_color "Global path: $user_home" "$COLOR_INFO"
|
write_color "Global path: $user_home" "$COLOR_INFO"
|
||||||
|
|
||||||
|
# Initialize manifest
|
||||||
|
local manifest_file=$(new_install_manifest "Path" "$target_dir")
|
||||||
|
|
||||||
# Source paths
|
# Source paths
|
||||||
local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
local source_claude_dir="${script_dir}/.claude"
|
local source_claude_dir="${script_dir}/.claude"
|
||||||
@@ -588,7 +644,17 @@ function install_path() {
|
|||||||
if [ -d "$source_folder" ]; then
|
if [ -d "$source_folder" ]; then
|
||||||
# Use new backup and replace logic for local folders
|
# Use new backup and replace logic for local folders
|
||||||
write_color "Installing local folder: $folder..." "$COLOR_INFO"
|
write_color "Installing local folder: $folder..." "$COLOR_INFO"
|
||||||
backup_and_replace_directory "$source_folder" "$dest_folder" "$folder folder" "$backup_folder"
|
if backup_and_replace_directory "$source_folder" "$dest_folder" "$folder folder" "$backup_folder"; then
|
||||||
|
# Track local folder in manifest
|
||||||
|
add_manifest_entry "$manifest_file" "$dest_folder" "Directory"
|
||||||
|
|
||||||
|
# Track files from SOURCE directory
|
||||||
|
while IFS= read -r -d '' source_file; do
|
||||||
|
local relative_path="${source_file#$source_folder}"
|
||||||
|
local target_path="${dest_folder}${relative_path}"
|
||||||
|
add_manifest_entry "$manifest_file" "$target_path" "File"
|
||||||
|
done < <(find "$source_folder" -type f -print0)
|
||||||
|
fi
|
||||||
write_color "✓ Installed local folder: $folder" "$COLOR_SUCCESS"
|
write_color "✓ Installed local folder: $folder" "$COLOR_SUCCESS"
|
||||||
else
|
else
|
||||||
write_color "WARNING: Source folder not found: $folder" "$COLOR_WARNING"
|
write_color "WARNING: Source folder not found: $folder" "$COLOR_WARNING"
|
||||||
@@ -644,19 +710,52 @@ function install_path() {
|
|||||||
# Handle CLAUDE.md file in global .claude directory
|
# Handle CLAUDE.md file in global .claude directory
|
||||||
local global_claude_md="${global_claude_dir}/CLAUDE.md"
|
local global_claude_md="${global_claude_dir}/CLAUDE.md"
|
||||||
write_color "Installing CLAUDE.md to global .claude directory..." "$COLOR_INFO"
|
write_color "Installing CLAUDE.md to global .claude directory..." "$COLOR_INFO"
|
||||||
copy_file_to_destination "$source_claude_md" "$global_claude_md" "CLAUDE.md" "$backup_folder"
|
if copy_file_to_destination "$source_claude_md" "$global_claude_md" "CLAUDE.md" "$backup_folder"; then
|
||||||
|
# Track CLAUDE.md in manifest
|
||||||
|
add_manifest_entry "$manifest_file" "$global_claude_md" "File"
|
||||||
|
fi
|
||||||
|
|
||||||
# Replace .codex directory to local location (backup → clear conflicting → copy)
|
# Replace .codex directory to local location (backup → clear conflicting → copy)
|
||||||
write_color "Installing .codex directory to local location..." "$COLOR_INFO"
|
write_color "Installing .codex directory to local location..." "$COLOR_INFO"
|
||||||
backup_and_replace_directory "$source_codex_dir" "$local_codex_dir" ".codex directory" "$backup_folder"
|
if backup_and_replace_directory "$source_codex_dir" "$local_codex_dir" ".codex directory" "$backup_folder"; then
|
||||||
|
# Track .codex directory in manifest
|
||||||
|
add_manifest_entry "$manifest_file" "$local_codex_dir" "Directory"
|
||||||
|
|
||||||
|
# Track files from SOURCE directory
|
||||||
|
while IFS= read -r -d '' source_file; do
|
||||||
|
local relative_path="${source_file#$source_codex_dir}"
|
||||||
|
local target_path="${local_codex_dir}${relative_path}"
|
||||||
|
add_manifest_entry "$manifest_file" "$target_path" "File"
|
||||||
|
done < <(find "$source_codex_dir" -type f -print0)
|
||||||
|
fi
|
||||||
|
|
||||||
# Replace .gemini directory to local location (backup → clear conflicting → copy)
|
# Replace .gemini directory to local location (backup → clear conflicting → copy)
|
||||||
write_color "Installing .gemini directory to local location..." "$COLOR_INFO"
|
write_color "Installing .gemini directory to local location..." "$COLOR_INFO"
|
||||||
backup_and_replace_directory "$source_gemini_dir" "$local_gemini_dir" ".gemini directory" "$backup_folder"
|
if backup_and_replace_directory "$source_gemini_dir" "$local_gemini_dir" ".gemini directory" "$backup_folder"; then
|
||||||
|
# Track .gemini directory in manifest
|
||||||
|
add_manifest_entry "$manifest_file" "$local_gemini_dir" "Directory"
|
||||||
|
|
||||||
|
# Track files from SOURCE directory
|
||||||
|
while IFS= read -r -d '' source_file; do
|
||||||
|
local relative_path="${source_file#$source_gemini_dir}"
|
||||||
|
local target_path="${local_gemini_dir}${relative_path}"
|
||||||
|
add_manifest_entry "$manifest_file" "$target_path" "File"
|
||||||
|
done < <(find "$source_gemini_dir" -type f -print0)
|
||||||
|
fi
|
||||||
|
|
||||||
# Replace .qwen directory to local location (backup → clear conflicting → copy)
|
# Replace .qwen directory to local location (backup → clear conflicting → copy)
|
||||||
write_color "Installing .qwen directory to local location..." "$COLOR_INFO"
|
write_color "Installing .qwen directory to local location..." "$COLOR_INFO"
|
||||||
backup_and_replace_directory "$source_qwen_dir" "$local_qwen_dir" ".qwen directory" "$backup_folder"
|
if backup_and_replace_directory "$source_qwen_dir" "$local_qwen_dir" ".qwen directory" "$backup_folder"; then
|
||||||
|
# Track .qwen directory in manifest
|
||||||
|
add_manifest_entry "$manifest_file" "$local_qwen_dir" "Directory"
|
||||||
|
|
||||||
|
# Track files from SOURCE directory
|
||||||
|
while IFS= read -r -d '' source_file; do
|
||||||
|
local relative_path="${source_file#$source_qwen_dir}"
|
||||||
|
local target_path="${local_qwen_dir}${relative_path}"
|
||||||
|
add_manifest_entry "$manifest_file" "$target_path" "File"
|
||||||
|
done < <(find "$source_qwen_dir" -type f -print0)
|
||||||
|
fi
|
||||||
|
|
||||||
# Remove empty backup folder
|
# Remove empty backup folder
|
||||||
if [ -n "$backup_folder" ] && [ -d "$backup_folder" ]; then
|
if [ -n "$backup_folder" ] && [ -d "$backup_folder" ]; then
|
||||||
@@ -674,6 +773,9 @@ function install_path() {
|
|||||||
write_color "Creating version.json in global directory..." "$COLOR_INFO"
|
write_color "Creating version.json in global directory..." "$COLOR_INFO"
|
||||||
create_version_json "$global_claude_dir" "Global"
|
create_version_json "$global_claude_dir" "Global"
|
||||||
|
|
||||||
|
# Save installation manifest
|
||||||
|
save_install_manifest "$manifest_file"
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -749,6 +851,357 @@ function get_installation_path() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ============================================================================
|
||||||
|
# INSTALLATION MANIFEST MANAGEMENT
|
||||||
|
# ============================================================================
|
||||||
|
|
||||||
|
function new_install_manifest() {
|
||||||
|
local installation_mode="$1"
|
||||||
|
local installation_path="$2"
|
||||||
|
|
||||||
|
# Create manifest directory if it doesn't exist
|
||||||
|
mkdir -p "$MANIFEST_DIR"
|
||||||
|
|
||||||
|
# Generate unique manifest ID based on timestamp and mode
|
||||||
|
local timestamp=$(date +"%Y%m%d-%H%M%S")
|
||||||
|
local manifest_id="install-${installation_mode}-${timestamp}"
|
||||||
|
|
||||||
|
# Create manifest file path
|
||||||
|
local manifest_file="${MANIFEST_DIR}/${manifest_id}.json"
|
||||||
|
|
||||||
|
# Get current UTC timestamp
|
||||||
|
local installation_date_utc=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
||||||
|
|
||||||
|
# Create manifest JSON
|
||||||
|
cat > "$manifest_file" << EOF
|
||||||
|
{
|
||||||
|
"manifest_id": "$manifest_id",
|
||||||
|
"version": "1.0",
|
||||||
|
"installation_mode": "$installation_mode",
|
||||||
|
"installation_path": "$installation_path",
|
||||||
|
"installation_date": "$installation_date_utc",
|
||||||
|
"installer_version": "$VERSION",
|
||||||
|
"files": [],
|
||||||
|
"directories": []
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
echo "$manifest_file"
|
||||||
|
}
|
||||||
|
|
||||||
|
function add_manifest_entry() {
|
||||||
|
local manifest_file="$1"
|
||||||
|
local entry_path="$2"
|
||||||
|
local entry_type="$3"
|
||||||
|
|
||||||
|
if [ ! -f "$manifest_file" ]; then
|
||||||
|
write_color "WARNING: Manifest file not found: $manifest_file" "$COLOR_WARNING"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
local timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
||||||
|
|
||||||
|
# Escape path for JSON
|
||||||
|
local escaped_path=$(echo "$entry_path" | sed 's/\\/\\\\/g' | sed 's/"/\\"/g')
|
||||||
|
|
||||||
|
# Create entry JSON
|
||||||
|
local entry_json=$(cat << EOF
|
||||||
|
{
|
||||||
|
"path": "$escaped_path",
|
||||||
|
"type": "$entry_type",
|
||||||
|
"timestamp": "$timestamp"
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
|
||||||
|
# Read manifest, add entry, write back
|
||||||
|
local temp_file="${manifest_file}.tmp"
|
||||||
|
|
||||||
|
if [ "$entry_type" = "File" ]; then
|
||||||
|
jq --argjson entry "$entry_json" '.files += [$entry]' "$manifest_file" > "$temp_file"
|
||||||
|
else
|
||||||
|
jq --argjson entry "$entry_json" '.directories += [$entry]' "$manifest_file" > "$temp_file"
|
||||||
|
fi
|
||||||
|
|
||||||
|
mv "$temp_file" "$manifest_file"
|
||||||
|
}
|
||||||
|
|
||||||
|
function save_install_manifest() {
|
||||||
|
local manifest_file="$1"
|
||||||
|
|
||||||
|
if [ -f "$manifest_file" ]; then
|
||||||
|
write_color "Installation manifest saved: $manifest_file" "$COLOR_SUCCESS"
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
write_color "WARNING: Failed to save installation manifest" "$COLOR_WARNING"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function migrate_legacy_manifest() {
|
||||||
|
local legacy_manifest="${HOME}/.claude-install-manifest.json"
|
||||||
|
|
||||||
|
if [ ! -f "$legacy_manifest" ]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
write_color "Found legacy manifest file, migrating to new system..." "$COLOR_INFO"
|
||||||
|
|
||||||
|
# Create manifest directory if it doesn't exist
|
||||||
|
mkdir -p "$MANIFEST_DIR"
|
||||||
|
|
||||||
|
# Read legacy manifest
|
||||||
|
local mode=$(jq -r '.installation_mode // "Global"' "$legacy_manifest")
|
||||||
|
local timestamp=$(date +"%Y%m%d-%H%M%S")
|
||||||
|
local manifest_id="install-${mode}-${timestamp}-migrated"
|
||||||
|
|
||||||
|
# Create new manifest file
|
||||||
|
local new_manifest="${MANIFEST_DIR}/${manifest_id}.json"
|
||||||
|
|
||||||
|
# Copy with new manifest_id field
|
||||||
|
jq --arg id "$manifest_id" '. + {manifest_id: $id}' "$legacy_manifest" > "$new_manifest"
|
||||||
|
|
||||||
|
# Rename old manifest (don't delete, keep as backup)
|
||||||
|
mv "$legacy_manifest" "${legacy_manifest}.migrated"
|
||||||
|
|
||||||
|
write_color "Legacy manifest migrated successfully" "$COLOR_SUCCESS"
|
||||||
|
write_color "Old manifest backed up to: ${legacy_manifest}.migrated" "$COLOR_INFO"
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_all_install_manifests() {
|
||||||
|
# Migrate legacy manifest if exists
|
||||||
|
migrate_legacy_manifest
|
||||||
|
|
||||||
|
if [ ! -d "$MANIFEST_DIR" ]; then
|
||||||
|
echo "[]"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if any manifest files exist
|
||||||
|
local manifest_count=$(find "$MANIFEST_DIR" -name "install-*.json" -type f 2>/dev/null | wc -l)
|
||||||
|
|
||||||
|
if [ "$manifest_count" -eq 0 ]; then
|
||||||
|
echo "[]"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Collect all manifests into JSON array
|
||||||
|
local manifests="["
|
||||||
|
local first=true
|
||||||
|
|
||||||
|
while IFS= read -r -d '' file; do
|
||||||
|
if [ "$first" = true ]; then
|
||||||
|
first=false
|
||||||
|
else
|
||||||
|
manifests+=","
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Add manifest_file field
|
||||||
|
local manifest_content=$(jq --arg file "$file" '. + {manifest_file: $file}' "$file")
|
||||||
|
|
||||||
|
# Count files and directories safely
|
||||||
|
local files_count=$(echo "$manifest_content" | jq '.files | length')
|
||||||
|
local dirs_count=$(echo "$manifest_content" | jq '.directories | length')
|
||||||
|
|
||||||
|
# Add counts to manifest
|
||||||
|
manifest_content=$(echo "$manifest_content" | jq --argjson fc "$files_count" --argjson dc "$dirs_count" '. + {files_count: $fc, directories_count: $dc}')
|
||||||
|
|
||||||
|
manifests+="$manifest_content"
|
||||||
|
done < <(find "$MANIFEST_DIR" -name "install-*.json" -type f -print0 | sort -z)
|
||||||
|
|
||||||
|
manifests+="]"
|
||||||
|
|
||||||
|
echo "$manifests"
|
||||||
|
}
|
||||||
|
|
||||||
|
# ============================================================================
|
||||||
|
# UNINSTALLATION FUNCTIONS
|
||||||
|
# ============================================================================
|
||||||
|
|
||||||
|
function uninstall_claude_workflow() {
|
||||||
|
write_color "Claude Code Workflow System Uninstaller" "$COLOR_INFO"
|
||||||
|
write_color "========================================" "$COLOR_INFO"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Load all manifests
|
||||||
|
local manifests_json=$(get_all_install_manifests)
|
||||||
|
local manifests_count=$(echo "$manifests_json" | jq 'length')
|
||||||
|
|
||||||
|
if [ "$manifests_count" -eq 0 ]; then
|
||||||
|
write_color "ERROR: No installation manifests found in: $MANIFEST_DIR" "$COLOR_ERROR"
|
||||||
|
write_color "Cannot proceed with uninstallation without manifest." "$COLOR_ERROR"
|
||||||
|
echo ""
|
||||||
|
write_color "Manual uninstallation instructions:" "$COLOR_INFO"
|
||||||
|
echo "For Global installation, remove these directories:"
|
||||||
|
echo " - ~/.claude/agents"
|
||||||
|
echo " - ~/.claude/commands"
|
||||||
|
echo " - ~/.claude/output-styles"
|
||||||
|
echo " - ~/.claude/workflows"
|
||||||
|
echo " - ~/.claude/scripts"
|
||||||
|
echo " - ~/.claude/prompt-templates"
|
||||||
|
echo " - ~/.claude/python_script"
|
||||||
|
echo " - ~/.claude/skills"
|
||||||
|
echo " - ~/.claude/version.json"
|
||||||
|
echo " - ~/.claude/CLAUDE.md"
|
||||||
|
echo " - ~/.codex"
|
||||||
|
echo " - ~/.gemini"
|
||||||
|
echo " - ~/.qwen"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Display available installations
|
||||||
|
write_color "Found $manifests_count installation(s):" "$COLOR_INFO"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# If only one manifest, use it directly
|
||||||
|
local selected_index=0
|
||||||
|
local selected_manifest=""
|
||||||
|
|
||||||
|
if [ "$manifests_count" -eq 1 ]; then
|
||||||
|
selected_manifest=$(echo "$manifests_json" | jq '.[0]')
|
||||||
|
write_color "Only one installation found, will uninstall:" "$COLOR_INFO"
|
||||||
|
else
|
||||||
|
# Multiple manifests - let user choose
|
||||||
|
local options=()
|
||||||
|
|
||||||
|
for i in $(seq 0 $((manifests_count - 1))); do
|
||||||
|
local m=$(echo "$manifests_json" | jq ".[$i]")
|
||||||
|
|
||||||
|
# Safely extract date string
|
||||||
|
local date_str=$(echo "$m" | jq -r '.installation_date // "unknown date"' | cut -c1-10)
|
||||||
|
local mode=$(echo "$m" | jq -r '.installation_mode // "Unknown"')
|
||||||
|
local files_count=$(echo "$m" | jq -r '.files_count // 0')
|
||||||
|
local dirs_count=$(echo "$m" | jq -r '.directories_count // 0')
|
||||||
|
local path_info=$(echo "$m" | jq -r '.installation_path // ""')
|
||||||
|
|
||||||
|
if [ -n "$path_info" ]; then
|
||||||
|
path_info=" ($path_info)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
options+=("$((i + 1)). [$mode] $date_str - $files_count files, $dirs_count dirs$path_info")
|
||||||
|
done
|
||||||
|
|
||||||
|
options+=("Cancel - Don't uninstall anything")
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
local selection=$(get_user_choice "Select installation to uninstall:" "${options[@]}")
|
||||||
|
|
||||||
|
if [[ "$selection" == Cancel* ]]; then
|
||||||
|
write_color "Uninstallation cancelled." "$COLOR_WARNING"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Parse selection to get index
|
||||||
|
selected_index=$((${selection%%.*} - 1))
|
||||||
|
selected_manifest=$(echo "$manifests_json" | jq ".[$selected_index]")
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Display selected installation info
|
||||||
|
echo ""
|
||||||
|
write_color "Installation Information:" "$COLOR_INFO"
|
||||||
|
echo " Manifest ID: $(echo "$selected_manifest" | jq -r '.manifest_id')"
|
||||||
|
echo " Mode: $(echo "$selected_manifest" | jq -r '.installation_mode')"
|
||||||
|
echo " Path: $(echo "$selected_manifest" | jq -r '.installation_path')"
|
||||||
|
echo " Date: $(echo "$selected_manifest" | jq -r '.installation_date')"
|
||||||
|
echo " Installer Version: $(echo "$selected_manifest" | jq -r '.installer_version')"
|
||||||
|
echo " Files tracked: $(echo "$selected_manifest" | jq -r '.files_count')"
|
||||||
|
echo " Directories tracked: $(echo "$selected_manifest" | jq -r '.directories_count')"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Confirm uninstallation
|
||||||
|
if ! confirm_action "Do you want to uninstall this installation?" false; then
|
||||||
|
write_color "Uninstallation cancelled." "$COLOR_WARNING"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
local removed_files=0
|
||||||
|
local removed_dirs=0
|
||||||
|
local failed_items=()
|
||||||
|
|
||||||
|
# Remove files first
|
||||||
|
write_color "Removing installed files..." "$COLOR_INFO"
|
||||||
|
|
||||||
|
local files_array=$(echo "$selected_manifest" | jq -c '.files[]')
|
||||||
|
|
||||||
|
while IFS= read -r file_entry; do
|
||||||
|
local file_path=$(echo "$file_entry" | jq -r '.path')
|
||||||
|
|
||||||
|
if [ -f "$file_path" ]; then
|
||||||
|
if rm -f "$file_path" 2>/dev/null; then
|
||||||
|
write_color " Removed file: $file_path" "$COLOR_SUCCESS"
|
||||||
|
((removed_files++))
|
||||||
|
else
|
||||||
|
write_color " WARNING: Failed to remove file: $file_path" "$COLOR_WARNING"
|
||||||
|
failed_items+=("$file_path")
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
write_color " File not found (already removed): $file_path" "$COLOR_INFO"
|
||||||
|
fi
|
||||||
|
done <<< "$files_array"
|
||||||
|
|
||||||
|
# Remove directories (in reverse order by path length)
|
||||||
|
write_color "Removing installed directories..." "$COLOR_INFO"
|
||||||
|
|
||||||
|
local dirs_array=$(echo "$selected_manifest" | jq -c '.directories[] | {path: .path, length: (.path | length)}' | sort -t: -k2 -rn | jq -c '.path')
|
||||||
|
|
||||||
|
while IFS= read -r dir_path_json; do
|
||||||
|
local dir_path=$(echo "$dir_path_json" | jq -r '.')
|
||||||
|
|
||||||
|
if [ -d "$dir_path" ]; then
|
||||||
|
# Check if directory is empty
|
||||||
|
if [ -z "$(ls -A "$dir_path" 2>/dev/null)" ]; then
|
||||||
|
if rmdir "$dir_path" 2>/dev/null; then
|
||||||
|
write_color " Removed directory: $dir_path" "$COLOR_SUCCESS"
|
||||||
|
((removed_dirs++))
|
||||||
|
else
|
||||||
|
write_color " WARNING: Failed to remove directory: $dir_path" "$COLOR_WARNING"
|
||||||
|
failed_items+=("$dir_path")
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
write_color " Directory not empty (preserved): $dir_path" "$COLOR_WARNING"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
write_color " Directory not found (already removed): $dir_path" "$COLOR_INFO"
|
||||||
|
fi
|
||||||
|
done <<< "$dirs_array"
|
||||||
|
|
||||||
|
# Remove manifest file
|
||||||
|
local manifest_file=$(echo "$selected_manifest" | jq -r '.manifest_file')
|
||||||
|
|
||||||
|
if [ -f "$manifest_file" ]; then
|
||||||
|
if rm -f "$manifest_file" 2>/dev/null; then
|
||||||
|
write_color "Removed installation manifest: $(basename "$manifest_file")" "$COLOR_SUCCESS"
|
||||||
|
else
|
||||||
|
write_color "WARNING: Failed to remove manifest file" "$COLOR_WARNING"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Show summary
|
||||||
|
echo ""
|
||||||
|
write_color "========================================" "$COLOR_INFO"
|
||||||
|
write_color "Uninstallation Summary:" "$COLOR_INFO"
|
||||||
|
echo " Files removed: $removed_files"
|
||||||
|
echo " Directories removed: $removed_dirs"
|
||||||
|
|
||||||
|
if [ ${#failed_items[@]} -gt 0 ]; then
|
||||||
|
echo ""
|
||||||
|
write_color "Failed to remove the following items:" "$COLOR_WARNING"
|
||||||
|
for item in "${failed_items[@]}"; do
|
||||||
|
echo " - $item"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
if [ ${#failed_items[@]} -eq 0 ]; then
|
||||||
|
write_color "✓ Claude Code Workflow has been successfully uninstalled!" "$COLOR_SUCCESS"
|
||||||
|
else
|
||||||
|
write_color "Uninstallation completed with warnings." "$COLOR_WARNING"
|
||||||
|
write_color "Please manually remove the failed items listed above." "$COLOR_INFO"
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
function create_version_json() {
|
function create_version_json() {
|
||||||
local target_claude_dir="$1"
|
local target_claude_dir="$1"
|
||||||
local installation_mode="$2"
|
local installation_mode="$2"
|
||||||
@@ -863,6 +1316,10 @@ function parse_arguments() {
|
|||||||
BACKUP_ALL=false
|
BACKUP_ALL=false
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
-Uninstall)
|
||||||
|
UNINSTALL=true
|
||||||
|
shift
|
||||||
|
;;
|
||||||
-SourceVersion)
|
-SourceVersion)
|
||||||
SOURCE_VERSION="$2"
|
SOURCE_VERSION="$2"
|
||||||
shift 2
|
shift 2
|
||||||
@@ -901,6 +1358,7 @@ Options:
|
|||||||
-NonInteractive Run in non-interactive mode with default options
|
-NonInteractive Run in non-interactive mode with default options
|
||||||
-BackupAll Automatically backup all existing files (default)
|
-BackupAll Automatically backup all existing files (default)
|
||||||
-NoBackup Disable automatic backup functionality
|
-NoBackup Disable automatic backup functionality
|
||||||
|
-Uninstall Uninstall Claude Code Workflow System based on installation manifest
|
||||||
-SourceVersion <ver> Source version (passed from install-remote.sh)
|
-SourceVersion <ver> Source version (passed from install-remote.sh)
|
||||||
-SourceBranch <name> Source branch (passed from install-remote.sh)
|
-SourceBranch <name> Source branch (passed from install-remote.sh)
|
||||||
-SourceCommit <sha> Source commit SHA (passed from install-remote.sh)
|
-SourceCommit <sha> Source commit SHA (passed from install-remote.sh)
|
||||||
@@ -919,6 +1377,12 @@ Examples:
|
|||||||
# Installation without backup
|
# Installation without backup
|
||||||
$0 -NoBackup
|
$0 -NoBackup
|
||||||
|
|
||||||
|
# Uninstall Claude Code Workflow System
|
||||||
|
$0 -Uninstall
|
||||||
|
|
||||||
|
# Uninstall without confirmation prompts
|
||||||
|
$0 -Uninstall -Force
|
||||||
|
|
||||||
# With version info (typically called by install-remote.sh)
|
# With version info (typically called by install-remote.sh)
|
||||||
$0 -InstallMode Global -Force -SourceVersion "3.4.2" -SourceBranch "main" -SourceCommit "abc1234"
|
$0 -InstallMode Global -Force -SourceVersion "3.4.2" -SourceBranch "main" -SourceCommit "abc1234"
|
||||||
|
|
||||||
@@ -926,6 +1390,46 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
function main() {
|
function main() {
|
||||||
|
# Show banner first
|
||||||
|
show_banner
|
||||||
|
|
||||||
|
# Check for uninstall mode from parameter or ask user interactively
|
||||||
|
local operation_mode="Install"
|
||||||
|
|
||||||
|
if [ "$UNINSTALL" = true ]; then
|
||||||
|
operation_mode="Uninstall"
|
||||||
|
elif [ "$NON_INTERACTIVE" != true ] && [ -z "$INSTALL_MODE" ]; then
|
||||||
|
# Interactive mode selection
|
||||||
|
echo ""
|
||||||
|
local operations=(
|
||||||
|
"Install - Install Claude Code Workflow System"
|
||||||
|
"Uninstall - Remove Claude Code Workflow System"
|
||||||
|
)
|
||||||
|
local selection=$(get_user_choice "Choose operation:" "${operations[@]}")
|
||||||
|
|
||||||
|
if [[ "$selection" == Uninstall* ]]; then
|
||||||
|
operation_mode="Uninstall"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Handle uninstall mode
|
||||||
|
if [ "$operation_mode" = "Uninstall" ]; then
|
||||||
|
if uninstall_claude_workflow; then
|
||||||
|
local result=0
|
||||||
|
else
|
||||||
|
local result=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$NON_INTERACTIVE" != true ]; then
|
||||||
|
echo ""
|
||||||
|
write_color "Press Enter to exit..." "$COLOR_PROMPT"
|
||||||
|
read -r
|
||||||
|
fi
|
||||||
|
|
||||||
|
return $result
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Continue with installation
|
||||||
show_header
|
show_header
|
||||||
|
|
||||||
# Test prerequisites
|
# Test prerequisites
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<div align="center">
|
<div align="center">
|
||||||
|
|
||||||
[](https://github.com/catlog22/Claude-Code-Workflow/releases)
|
[](https://github.com/catlog22/Claude-Code-Workflow/releases)
|
||||||
[](LICENSE)
|
[](LICENSE)
|
||||||
[]()
|
[]()
|
||||||
[](https://github.com/modelcontextprotocol)
|
[](https://github.com/modelcontextprotocol)
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
**Claude Code Workflow (CCW)** transforms AI development from simple prompt chaining into a robust, context-first orchestration system. It solves execution uncertainty and error accumulation through structured planning, deterministic execution, and intelligent multi-model orchestration.
|
**Claude Code Workflow (CCW)** transforms AI development from simple prompt chaining into a robust, context-first orchestration system. It solves execution uncertainty and error accumulation through structured planning, deterministic execution, and intelligent multi-model orchestration.
|
||||||
|
|
||||||
> **🎉 Latest: v4.6.0** - Concept Clarification & Agent-Driven Analysis. See [CHANGELOG.md](CHANGELOG.md) for details.
|
> **🎉 Latest: v4.6.2** - Documentation Optimization & `/memory:load` Command Refinement. See [CHANGELOG.md](CHANGELOG.md) for details.
|
||||||
|
|
||||||
> 📚 **New to CCW?** Check out the [**Getting Started Guide**](GETTING_STARTED.md) for a beginner-friendly 5-minute tutorial!
|
> 📚 **New to CCW?** Check out the [**Getting Started Guide**](GETTING_STARTED.md) for a beginner-friendly 5-minute tutorial!
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user