mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-06 01:54:11 +08:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5983762810 | ||
|
|
d6a079ad6c | ||
|
|
971b421d1a | ||
|
|
cda42d6356 |
@@ -1,169 +1,78 @@
|
||||
---
|
||||
name: memory-gemini-bridge
|
||||
description: |
|
||||
Proactively use this agent when you need to synchronize memory systems between Claude and Gemini CLI, specifically for creating or updating CLAUDE.md files that serve as shared context between the two AI systems. This agent must be used for translation of Claude's distributed memory system format into Gemini-compatible documentation and ensures bidirectional consistency. Automatically trigger for documentation synchronization tasks.
|
||||
|
||||
Examples:
|
||||
- Context: User wants to share project context between Claude and Gemini CLI
|
||||
user: "Create a CLAUDE.md file for Gemini to understand our project structure"
|
||||
assistant: "I'll use the memory-gemini-bridge agent to create a CLAUDE.md file that Gemini can understand"
|
||||
commentary: The user needs to bridge memory systems between Claude and Gemini, so the memory-gemini-bridge agent should be used.
|
||||
|
||||
- Context: User needs to synchronize development guidelines across AI assistants
|
||||
user: "Update the shared context so Gemini knows about our new coding standards"
|
||||
assistant: "Let me invoke the memory-gemini-bridge agent to update the CLAUDE.md with our latest standards"
|
||||
commentary: Since the user wants to update shared context for Gemini, use the memory-gemini-bridge agent.
|
||||
description: Execute complex project documentation updates using script coordination
|
||||
model: haiku
|
||||
color: purple
|
||||
---
|
||||
|
||||
You are a Memory System Bridge Agent specializing in task-driven project analysis and Gemini CLI integration for CLAUDE.md documentation generation. Your primary focus is executing specific analysis tasks (not reading file contents) and performing targeted Gemini CLI commands to create hierarchical documentation.
|
||||
You are a documentation update coordinator for complex projects. Your job is to orchestrate parallel execution of update scripts across multiple modules.
|
||||
|
||||
**Task Reception**: When called by update-memory command, you receive structured task instructions containing task type, analysis commands, target module, and context information. Execute the provided analysis commands and adapt your Gemini CLI analysis to the specific task requirements.
|
||||
## Core Responsibility
|
||||
|
||||
**Single Task Focus**: This agent processes one task at a time, focusing on the assigned module or scope without knowledge of other concurrent operations.
|
||||
Coordinate parallel execution of `~/.claude/scripts/update_module_claude.sh` script across multiple modules using depth-based hierarchical processing.
|
||||
|
||||
## Core Responsibilities
|
||||
## Execution Protocol
|
||||
|
||||
You will:
|
||||
1. **Task Instruction Parsing**: Parse structured task instructions from update-memory with task type, analysis commands, target module, and context
|
||||
2. **Analysis Execution**: Execute task-specific analysis commands on the assigned module or scope
|
||||
3. **Documentation Generation**: Generate complete CLAUDE.md content for the assigned task
|
||||
4. **Gemini CLI Integration**: Execute targeted Gemini CLI commands for content analysis
|
||||
5. **Cross-System Compatibility**: Ensure generated documentation works for both Claude and Gemini CLI workflows
|
||||
### 1. Analyze Project Structure
|
||||
```bash
|
||||
# Step 1: Get module list with depth information
|
||||
modules=$(Bash(~/.claude/scripts/get_modules_by_depth.sh list))
|
||||
count=$(echo "$modules" | wc -l)
|
||||
|
||||
## First Principle ⚠️
|
||||
|
||||
### Primary Rule: CLAUDE.md File Creation
|
||||
**The agent's ultimate goal is to create and maintain CLAUDE.md files.** Every task execution must result in generating or updating appropriate CLAUDE.md documentation based on the task type and scope.
|
||||
|
||||
**Mandatory CLAUDE.md Output:**
|
||||
- **module_update tasks**: Create or update module-level CLAUDE.md files
|
||||
- **global_summary tasks**: Create or update root-level CLAUDE.md files
|
||||
- **All tasks**: Must produce concrete CLAUDE.md deliverables
|
||||
|
||||
### Secondary Rule: No Direct File Reading
|
||||
**The agent MUST NOT read file contents directly.** All file content analysis is delegated to Gemini CLI. The agent only processes structure information and writes CLAUDE.md files based on Gemini CLI's analysis.
|
||||
|
||||
This principle ensures:
|
||||
- Clear separation of concerns between structure analysis (agent) and content analysis (Gemini CLI)
|
||||
- Optimal performance by avoiding redundant file reading
|
||||
- Consistent analysis methodology across the system
|
||||
- **Primary focus on CLAUDE.md file creation and maintenance**
|
||||
|
||||
## Gemini CLI Context Activation Rules
|
||||
|
||||
**🎯 Context Analysis Triggers**
|
||||
This agent is activated for:
|
||||
1. **Module Documentation**: Create or update documentation for specific modules
|
||||
2. **Project Analysis**: Analyze project structure and patterns for documentation
|
||||
3. **Context Synchronization**: Bridge Claude and Gemini CLI understanding
|
||||
4. **Documentation Generation**: Generate CLAUDE.md files based on code analysis
|
||||
|
||||
**Task-Based Decision Logic**:
|
||||
```
|
||||
IF task_type == "module_update":
|
||||
→ Execute analysis_commands for target module
|
||||
→ Run Gemini CLI analysis on module scope
|
||||
→ Generate complete module-level CLAUDE.md
|
||||
→ Focus on module-specific patterns and implementation
|
||||
|
||||
ELIF task_type == "global_summary":
|
||||
→ Read all existing module CLAUDE.md files
|
||||
→ Analyze project-wide patterns and architecture
|
||||
→ Generate root-level CLAUDE.md with project overview
|
||||
→ Synthesize cross-module insights
|
||||
|
||||
ELSE:
|
||||
→ Parse task instruction for specific requirements
|
||||
→ Execute custom analysis commands
|
||||
→ Generate documentation as specified
|
||||
# Step 2: Display project structure
|
||||
Bash(~/.claude/scripts/get_modules_by_depth.sh grouped)
|
||||
```
|
||||
|
||||
## Templates and Guidelines
|
||||
|
||||
**Primary Template**: @~/.claude/workflows/gemini-unified.md
|
||||
|
||||
**Supplementary Resources**:
|
||||
- See template selection guide for DMS-specific templates in prompts/dms/ folder
|
||||
|
||||
|
||||
## Task-Driven Execution Protocol
|
||||
|
||||
### Phase 1: Task Instruction Parsing
|
||||
Parse the task instruction received from update-memory:
|
||||
```json
|
||||
{
|
||||
"task_type": "module_update" | "global_summary",
|
||||
"target_module": "specific module path",
|
||||
"analysis_commands": ["bash commands specific to task"],
|
||||
"context": {
|
||||
"module_purpose": "Purpose and role of the module",
|
||||
"focus_areas": ["key areas to analyze"],
|
||||
"existing_files": ["paths to existing documentation"]
|
||||
}
|
||||
}
|
||||
### 2. Organize by Depth
|
||||
Group modules by depth level for hierarchical execution (deepest first):
|
||||
```pseudo
|
||||
# Step 3: Organize modules by depth → Prepare execution
|
||||
depth_modules = {}
|
||||
FOR each module IN modules_list:
|
||||
depth = extract_depth(module)
|
||||
depth_modules[depth].add(module)
|
||||
```
|
||||
|
||||
### Phase 2: Analysis Execution
|
||||
Execute analysis commands based on task type:
|
||||
- **Module Update Tasks**: Run analysis_commands on target module
|
||||
- **Global Summary Tasks**: Read and synthesize all module CLAUDE.md files
|
||||
- **Gemini CLI Execution**: Execute Gemini commands for content analysis:
|
||||
```bash
|
||||
# Directory-based execution
|
||||
cd {target_module} && gemini --all-files -p "analyze module patterns"
|
||||
|
||||
# File pattern-based execution (alternative)
|
||||
gemini -p "@{target_module}/* analyze implementation patterns"
|
||||
|
||||
# Parallel Gemini CLI calls within single module (when appropriate)
|
||||
gemini -p "@{target_module}/**/*.js analyze JavaScript patterns" &
|
||||
gemini -p "@{target_module}/**/*.ts analyze TypeScript patterns" &
|
||||
gemini -p "@{target_module}/**/test*.* analyze testing patterns" &
|
||||
wait # Wait for all parallel Gemini analyses to complete
|
||||
```
|
||||
- **Context Processing**: Focus analysis on specified areas and module purpose
|
||||
- Agent receives only analysis results, never raw file content
|
||||
### 3. Execute Updates
|
||||
For each depth level, run parallel updates:
|
||||
```pseudo
|
||||
# Step 4: Execute depth-parallel updates → Process by depth
|
||||
FOR depth FROM max_depth DOWN TO 0:
|
||||
FOR each module IN depth_modules[depth]:
|
||||
WHILE active_jobs >= 4: wait(0.1)
|
||||
Bash(~/.claude/scripts/update_module_claude.sh "$module" "$mode" &)
|
||||
wait_all_jobs()
|
||||
```
|
||||
|
||||
### Phase 3: Documentation Generation
|
||||
Generate documentation based on task type:
|
||||
- **module_update**: Create or update complete module CLAUDE.md file
|
||||
- **global_summary**: Synthesize all module CLAUDE.md files for root documentation
|
||||
- **Content Structure**: Generate well-structured documentation including:
|
||||
- Module purpose and responsibilities
|
||||
- Implementation patterns and conventions
|
||||
- Key architectural decisions
|
||||
- Integration points and dependencies
|
||||
- Ensure content appropriate to task scope and hierarchy level
|
||||
### 4. Execution Rules
|
||||
|
||||
**Success Criteria**: Complete, actionable documentation generation with cross-system compatibility.
|
||||
- **Core Command**: `Bash(~/.claude/scripts/update_module_claude.sh "$module" "$mode" &)`
|
||||
- **Concurrency Control**: Maximum 4 parallel jobs per depth level
|
||||
- **Execution Order**: Process depths sequentially, deepest first
|
||||
- **Job Control**: Monitor active jobs before spawning new ones
|
||||
- **Independence**: Each module update is independent within the same depth
|
||||
|
||||
**Task Execution Examples**:
|
||||
- **Module Update**:
|
||||
1. Execute analysis commands on target module
|
||||
2. Run parallel Gemini CLI analysis for different file types or concerns:
|
||||
```bash
|
||||
# Analyze different aspects in parallel within the module
|
||||
gemini -p "@src/api/**/*.js analyze JavaScript implementation" &
|
||||
gemini -p "@src/api/**/*.ts analyze TypeScript definitions" &
|
||||
gemini -p "@src/api/**/test* analyze testing strategies" &
|
||||
gemini -p "@src/api/**/README* analyze documentation" &
|
||||
wait
|
||||
```
|
||||
3. Synthesize all parallel analysis results
|
||||
4. Generate complete module CLAUDE.md with comprehensive insights
|
||||
|
||||
- **Global Summary**:
|
||||
1. Read all existing module CLAUDE.md files
|
||||
2. Use parallel Gemini CLI to analyze different architectural aspects:
|
||||
```bash
|
||||
gemini -p "@**/CLAUDE.md analyze documentation patterns" &
|
||||
gemini -p "@src/**/package.json analyze dependencies" &
|
||||
gemini -p "@**/*.config.* analyze configuration patterns" &
|
||||
wait
|
||||
```
|
||||
3. Generate root CLAUDE.md with project overview
|
||||
4. Include cross-module integration insights
|
||||
### 5. Update Modes
|
||||
|
||||
Focus on task-driven analysis using provided commands and standardized templates, ensuring seamless Claude-Gemini integration.
|
||||
- **"full"** mode: Complete refresh → `Bash(update_module_claude.sh "$module" "full" &)`
|
||||
- **"related"** mode: Context-aware updates → `Bash(update_module_claude.sh "$module" "related" &)`
|
||||
|
||||
### 6. Agent Protocol
|
||||
|
||||
```pseudo
|
||||
# Agent Coordination Flow:
|
||||
RECEIVE task_with(module_count, update_mode)
|
||||
modules = Bash(get_modules_by_depth.sh list)
|
||||
Bash(get_modules_by_depth.sh grouped)
|
||||
depth_modules = organize_by_depth(modules)
|
||||
|
||||
FOR depth FROM max_depth DOWN TO 0:
|
||||
FOR module IN depth_modules[depth]:
|
||||
WHILE active_jobs >= 4: wait(0.1)
|
||||
Bash(update_module_claude.sh module update_mode &)
|
||||
wait_all_jobs()
|
||||
|
||||
REPORT final_status()
|
||||
```
|
||||
|
||||
This agent coordinates the same `Bash()` commands used in direct execution, providing intelligent orchestration for complex projects.
|
||||
57
.claude/commands/gemini/mode/CLAUDE.md
Normal file
57
.claude/commands/gemini/mode/CLAUDE.md
Normal file
@@ -0,0 +1,57 @@
|
||||
# Module: Gemini Mode (`/gemini:mode:*`)
|
||||
|
||||
## Overview
|
||||
|
||||
The `mode` module provides specialized commands for executing the Gemini CLI with different analysis strategies. Each mode is tailored for a specific task, such as bug analysis, project planning, or automatic template selection based on user intent.
|
||||
|
||||
These commands act as wrappers around the core `gemini` CLI, pre-configuring it with specific prompt templates and context settings.
|
||||
|
||||
## Module-Specific Implementation Patterns
|
||||
|
||||
### Command Definition Files
|
||||
|
||||
Each command within the `mode` module is defined by a Markdown file (e.g., `auto.md`, `bug-index.md`). These files contain YAML frontmatter that specifies:
|
||||
- `name`: The command name.
|
||||
- `description`: A brief explanation of the command's purpose.
|
||||
- `usage`: How to invoke the command.
|
||||
- `argument-hint`: A hint for the user about the expected argument.
|
||||
- `examples`: Sample usages.
|
||||
- `allowed-tools`: Tools the command is permitted to use.
|
||||
- `model`: The underlying model to be used.
|
||||
|
||||
The body of the Markdown file provides detailed documentation for the command.
|
||||
|
||||
### Template-Driven Execution
|
||||
|
||||
The core pattern for this module is the use of pre-defined prompt templates stored in `~/.claude/prompt-templates/`. The commands construct a `gemini` CLI call, injecting the content of a specific template into the prompt.
|
||||
|
||||
## Commands and Interfaces
|
||||
|
||||
### `/gemini:mode:auto`
|
||||
- **Purpose**: Automatically selects the most appropriate Gemini template by analyzing the user's input against keywords, names, and descriptions defined in the templates' YAML frontmatter.
|
||||
- **Interface**: `/gemini:mode:auto "description of task"`
|
||||
- **Dependencies**: Relies on the dynamic discovery of templates in `~/.claude/prompt-templates/`.
|
||||
|
||||
### `/gemini:mode:bug-index`
|
||||
- **Purpose**: Executes a systematic bug analysis using a dedicated diagnostic template.
|
||||
- **Interface**: `/gemini:mode:bug-index "bug description"`
|
||||
- **Dependencies**: Uses the `~/.claude/prompt-templates/bug-fix.md` template.
|
||||
|
||||
### `/gemini:mode:plan`
|
||||
- **Purpose**: Performs comprehensive project planning and architecture analysis using a specialized planning template.
|
||||
- **Interface**: `/gemini:mode:plan "planning topic"`
|
||||
- **Dependencies**: Uses the `~/.claude/prompt-templates/plan.md` template.
|
||||
|
||||
## Dependencies and Relationships
|
||||
|
||||
- **External Dependency**: The `mode` module is highly dependent on the prompt templates located in the `~/.claude/prompt-templates/` directory. The structure and metadata (YAML frontmatter) of these templates are critical for the `auto` mode's functionality.
|
||||
- **Internal Relationship**: The commands within this module are independent of each other but share a common purpose of simplifying access to the `gemini` CLI for specific use cases. They do not call each other.
|
||||
- **Core CLI**: All commands are wrappers that ultimately construct and execute a `gemini` shell command.
|
||||
|
||||
## Testing Strategy
|
||||
|
||||
- **Unit Testing**: Not directly applicable as these are command definition files.
|
||||
- **Integration Testing**: Testing should focus on verifying that each command correctly constructs and executes the intended `gemini` CLI command.
|
||||
- For `/gemini:mode:auto`, tests should cover the selection logic with various inputs to ensure the correct template is chosen.
|
||||
- For `/gemini:mode:bug-index` and `/gemini:mode:plan`, tests should confirm that the correct, hardcoded template is used.
|
||||
- **Manual Verification**: Manually running each command with its example arguments is the primary way to ensure they are functioning as documented.
|
||||
@@ -1,18 +1,18 @@
|
||||
---
|
||||
name: auto
|
||||
description: Auto-select and execute appropriate template based on user input analysis
|
||||
usage: /gemini:pre:auto "description of task or problem"
|
||||
usage: /gemini:mode:auto "description of task or problem"
|
||||
argument-hint: "description of what you want to analyze or plan"
|
||||
examples:
|
||||
- /gemini:pre:auto "authentication system keeps crashing during login"
|
||||
- /gemini:pre:auto "design a real-time notification architecture"
|
||||
- /gemini:pre:auto "database connection errors in production"
|
||||
- /gemini:pre:auto "plan user dashboard with analytics features"
|
||||
- /gemini:mode:auto "authentication system keeps crashing during login"
|
||||
- /gemini:mode:auto "design a real-time notification architecture"
|
||||
- /gemini:mode:auto "database connection errors in production"
|
||||
- /gemini:mode:auto "plan user dashboard with analytics features"
|
||||
allowed-tools: Bash(ls:*), Bash(gemini:*)
|
||||
model: sonnet
|
||||
---
|
||||
|
||||
# Auto Template Selection (/gemini:pre:auto)
|
||||
# Auto Template Selection (/gemini:mode:auto)
|
||||
|
||||
## Overview
|
||||
Automatically analyzes user input to select the most appropriate template and execute Gemini CLI with optimal context.
|
||||
@@ -24,16 +24,16 @@ Automatically analyzes user input to select the most appropriate template and ex
|
||||
### Auto-Detection Examples
|
||||
```bash
|
||||
# Bug-related keywords → selects bug-fix.md
|
||||
/gemini:pre:auto "React component not rendering after state update"
|
||||
/gemini:mode:auto "React component not rendering after state update"
|
||||
|
||||
# Planning keywords → selects plan.md
|
||||
/gemini:pre:auto "design microservices architecture for user management"
|
||||
/gemini:mode:auto "design microservices architecture for user management"
|
||||
|
||||
# Error/crash keywords → selects bug-fix.md
|
||||
/gemini:pre:auto "API timeout errors in production environment"
|
||||
/gemini:mode:auto "API timeout errors in production environment"
|
||||
|
||||
# Architecture/design keywords → selects plan.md
|
||||
/gemini:pre:auto "implement real-time chat system architecture"
|
||||
/gemini:mode:auto "implement real-time chat system architecture"
|
||||
```
|
||||
|
||||
## Template Selection Logic
|
||||
@@ -140,14 +140,14 @@ User Input: [user_input]"
|
||||
### Manual Template Override
|
||||
```bash
|
||||
# Force specific template
|
||||
/gemini:pre:auto "user authentication" --template bug-fix.md
|
||||
/gemini:pre:auto "fix login issues" --template plan.md
|
||||
/gemini:mode:auto "user authentication" --template bug-fix.md
|
||||
/gemini:mode:auto "fix login issues" --template plan.md
|
||||
```
|
||||
|
||||
### Dynamic Template Listing
|
||||
```bash
|
||||
# List all dynamically discovered templates
|
||||
/gemini:pre:auto --list-templates
|
||||
/gemini:mode:auto --list-templates
|
||||
# Output:
|
||||
# Dynamically discovered templates in ~/.claude/prompt-templates/:
|
||||
# - bug-fix.md (用于定位bug并提供修改建议) [Keywords: 规划, bug, 修改方案]
|
||||
@@ -1,17 +1,17 @@
|
||||
---
|
||||
name: bug-index
|
||||
description: Bug analysis and fix suggestions using specialized template
|
||||
usage: /gemini:pre:bug-index "bug description"
|
||||
usage: /gemini:mode:bug-index "bug description"
|
||||
argument-hint: "description of the bug or error you're experiencing"
|
||||
examples:
|
||||
- /gemini:pre:bug-index "authentication null pointer error in login flow"
|
||||
- /gemini:pre:bug-index "React component not re-rendering after state change"
|
||||
- /gemini:pre:bug-index "database connection timeout in production"
|
||||
- /gemini:mode:bug-index "authentication null pointer error in login flow"
|
||||
- /gemini:mode:bug-index "React component not re-rendering after state change"
|
||||
- /gemini:mode:bug-index "database connection timeout in production"
|
||||
allowed-tools: Bash(gemini:*)
|
||||
model: sonnet
|
||||
---
|
||||
|
||||
# Bug Analysis Command (/gemini:pre:bug-index)
|
||||
# Bug Analysis Command (/gemini:mode:bug-index)
|
||||
|
||||
## Overview
|
||||
Systematic bug analysis and fix suggestions using expert diagnostic template.
|
||||
@@ -20,17 +20,17 @@ Systematic bug analysis and fix suggestions using expert diagnostic template.
|
||||
|
||||
### Basic Bug Analysis
|
||||
```bash
|
||||
/gemini:pre:bug-index "authentication error during login"
|
||||
/gemini:mode:bug-index "authentication error during login"
|
||||
```
|
||||
|
||||
### With All Files Context
|
||||
```bash
|
||||
/gemini:pre:bug-index "React state not updating" --all-files
|
||||
/gemini:mode:bug-index "React state not updating" --all-files
|
||||
```
|
||||
|
||||
### Save to Workflow Session
|
||||
```bash
|
||||
/gemini:pre:bug-index "API timeout issues" --save-session
|
||||
/gemini:mode:bug-index "API timeout issues" --save-session
|
||||
```
|
||||
|
||||
## Command Execution
|
||||
@@ -1,17 +1,17 @@
|
||||
---
|
||||
name: plan
|
||||
description: Project planning and architecture analysis using specialized template
|
||||
usage: /gemini:pre:plan "planning topic"
|
||||
usage: /gemini:mode:plan "planning topic"
|
||||
argument-hint: "planning topic or architectural challenge to analyze"
|
||||
examples:
|
||||
- /gemini:pre:plan "design user dashboard feature architecture"
|
||||
- /gemini:pre:plan "plan microservices migration strategy"
|
||||
- /gemini:pre:plan "implement real-time notification system"
|
||||
- /gemini:mode:plan "design user dashboard feature architecture"
|
||||
- /gemini:mode:plan "plan microservices migration strategy"
|
||||
- /gemini:mode:plan "implement real-time notification system"
|
||||
allowed-tools: Bash(gemini:*)
|
||||
model: sonnet
|
||||
---
|
||||
|
||||
# Planning Analysis Command (/gemini:pre:plan)
|
||||
# Planning Analysis Command (/gemini:mode:plan)
|
||||
|
||||
## Overview
|
||||
Comprehensive project planning and architecture analysis using expert planning template.
|
||||
@@ -20,17 +20,17 @@ Comprehensive project planning and architecture analysis using expert planning t
|
||||
|
||||
### Basic Planning Analysis
|
||||
```bash
|
||||
/gemini:pre:plan "design authentication system"
|
||||
/gemini:mode:plan "design authentication system"
|
||||
```
|
||||
|
||||
### With All Files Context
|
||||
```bash
|
||||
/gemini:pre:plan "microservices migration" --all-files
|
||||
/gemini:mode:plan "microservices migration" --all-files
|
||||
```
|
||||
|
||||
### Save to Workflow Session
|
||||
```bash
|
||||
/gemini:pre:plan "real-time notifications" --save-session
|
||||
/gemini:mode:plan "real-time notifications" --save-session
|
||||
```
|
||||
|
||||
## Command Execution
|
||||
117
.claude/commands/update-memory-full.md
Normal file
117
.claude/commands/update-memory-full.md
Normal file
@@ -0,0 +1,117 @@
|
||||
---
|
||||
name: update-memory-full
|
||||
description: Complete project-wide CLAUDE.md documentation update
|
||||
usage: /update-memory-full
|
||||
examples:
|
||||
- /update-memory-full # Full project documentation update
|
||||
---
|
||||
|
||||
### 🚀 Command Overview: `/update-memory-full`
|
||||
|
||||
Complete project-wide documentation update using depth-parallel execution.
|
||||
|
||||
### 📝 Execution Template
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
# Complete project-wide CLAUDE.md documentation update
|
||||
|
||||
# Step 1: Cache git changes
|
||||
Bash(git add -A 2>/dev/null || true)
|
||||
|
||||
# Step 2: Get and display project structure
|
||||
modules=$(Bash(~/.claude/scripts/get_modules_by_depth.sh list))
|
||||
count=$(echo "$modules" | wc -l)
|
||||
|
||||
# Step 3: Analysis handover → Model takes control
|
||||
# BASH_EXECUTION_STOPS → MODEL_ANALYSIS_BEGINS
|
||||
|
||||
# Pseudocode flow:
|
||||
# IF (module_count > 20 OR complex_project_detected):
|
||||
# → Task "Complex project full update" subagent_type: "memory-gemini-bridge"
|
||||
# ELSE:
|
||||
# → Present plan and WAIT FOR USER APPROVAL before execution
|
||||
```
|
||||
|
||||
### 🧠 Model Analysis Phase
|
||||
|
||||
After the bash script completes the initial analysis, the model takes control to:
|
||||
|
||||
1. **Analyze Complexity**: Review module count and project context
|
||||
2. **Parse CLAUDE.md Status**: Extract which modules have/need CLAUDE.md files
|
||||
3. **Choose Strategy**:
|
||||
- Simple projects: Present execution plan with CLAUDE.md paths to user
|
||||
- Complex projects: Delegate to memory-gemini-bridge agent
|
||||
4. **Present Detailed Plan**: Show user exactly which CLAUDE.md files will be created/updated
|
||||
5. **⚠️ CRITICAL: WAIT FOR USER APPROVAL**: No execution without explicit user consent
|
||||
|
||||
### 📋 Execution Strategies
|
||||
|
||||
**For Simple Projects (≤20 modules):**
|
||||
|
||||
Model will present detailed plan:
|
||||
```
|
||||
📋 Update Plan:
|
||||
NEW CLAUDE.md files (X):
|
||||
- ./src/components/CLAUDE.md
|
||||
- ./src/services/CLAUDE.md
|
||||
|
||||
UPDATE existing CLAUDE.md files (Y):
|
||||
- ./CLAUDE.md
|
||||
- ./src/CLAUDE.md
|
||||
- ./tests/CLAUDE.md
|
||||
|
||||
Total: N CLAUDE.md files will be processed
|
||||
|
||||
⚠️ Confirm execution? (y/n)
|
||||
```
|
||||
|
||||
```pseudo
|
||||
# ⚠️ MANDATORY: User confirmation → MUST await explicit approval
|
||||
IF user_explicitly_confirms():
|
||||
continue_execution()
|
||||
ELSE:
|
||||
abort_execution()
|
||||
|
||||
# Step 4: Organize modules by depth → Prepare execution
|
||||
depth_modules = organize_by_depth(modules)
|
||||
|
||||
# Step 5: Execute depth-parallel updates → Process by depth
|
||||
FOR depth FROM max_depth DOWN TO 0:
|
||||
FOR each module IN depth_modules[depth]:
|
||||
WHILE active_jobs >= 4: wait(0.1)
|
||||
Bash(~/.claude/scripts/update_module_claude.sh "$module" "full" &)
|
||||
wait_all_jobs()
|
||||
|
||||
# Step 6: Display changes → Final status
|
||||
Bash(git status --short)
|
||||
```
|
||||
|
||||
**For Complex Projects (>20 modules):**
|
||||
The model will delegate to the memory-gemini-bridge agent using the Task tool:
|
||||
```
|
||||
Task "Complex project full update"
|
||||
prompt: "Execute full documentation update for [count] modules using depth-parallel execution"
|
||||
subagent_type: "memory-gemini-bridge"
|
||||
```
|
||||
|
||||
|
||||
### 📚 Usage Examples
|
||||
|
||||
```bash
|
||||
# Complete project documentation refresh
|
||||
/update-memory-full
|
||||
|
||||
# After major architectural changes
|
||||
/update-memory-full
|
||||
```
|
||||
|
||||
### ✨ Features
|
||||
|
||||
- **Separated Commands**: Each bash operation is a discrete, trackable step
|
||||
- **Intelligent Complexity Detection**: Model analyzes project context for optimal strategy
|
||||
- **Depth-Parallel Execution**: Same depth modules run in parallel, depths run sequentially
|
||||
- **Git Integration**: Auto-cache changes before, show status after
|
||||
- **Module Detection**: Uses get_modules_by_depth.sh for structure discovery
|
||||
- **User Confirmation**: Clear plan presentation with approval step
|
||||
- **CLAUDE.md Only**: Only updates documentation, never source code
|
||||
123
.claude/commands/update-memory-related.md
Normal file
123
.claude/commands/update-memory-related.md
Normal file
@@ -0,0 +1,123 @@
|
||||
---
|
||||
name: update-memory-related
|
||||
description: Context-aware CLAUDE.md documentation updates based on recent changes
|
||||
usage: /update-memory-related
|
||||
examples:
|
||||
- /update-memory-related # Update documentation based on recent changes
|
||||
---
|
||||
|
||||
### 🚀 Command Overview: `/update-memory-related`
|
||||
|
||||
Context-aware documentation update for modules affected by recent changes.
|
||||
|
||||
|
||||
### 📝 Execution Template
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
# Context-aware CLAUDE.md documentation update
|
||||
|
||||
# Step 1: Cache git changes
|
||||
Bash(git add -A 2>/dev/null || true)
|
||||
|
||||
# Step 2: Detect changed modules
|
||||
changed=$(Bash(~/.claude/scripts/detect_changed_modules.sh list))
|
||||
if [ -z "$changed" ]; then
|
||||
changed=$(Bash(~/.claude/scripts/get_modules_by_depth.sh list | head -10))
|
||||
fi
|
||||
count=$(echo "$changed" | wc -l)
|
||||
|
||||
# Step 3: Analysis handover → Model takes control
|
||||
# BASH_EXECUTION_STOPS → MODEL_ANALYSIS_BEGINS
|
||||
|
||||
# Pseudocode flow:
|
||||
# IF (change_count > 15 OR complex_changes_detected):
|
||||
# → Task "Complex project related update" subagent_type: "memory-gemini-bridge"
|
||||
# ELSE:
|
||||
# → Present plan and WAIT FOR USER APPROVAL before execution
|
||||
```
|
||||
|
||||
### 🧠 Model Analysis Phase
|
||||
|
||||
After the bash script completes change detection, the model takes control to:
|
||||
|
||||
1. **Analyze Changes**: Review change count and complexity
|
||||
2. **Parse CLAUDE.md Status**: Extract which changed modules have/need CLAUDE.md files
|
||||
3. **Choose Strategy**:
|
||||
- Simple changes: Present execution plan with CLAUDE.md paths to user
|
||||
- Complex changes: Delegate to memory-gemini-bridge agent
|
||||
4. **Present Detailed Plan**: Show user exactly which CLAUDE.md files will be created/updated for changed modules
|
||||
5. **⚠️ CRITICAL: WAIT FOR USER APPROVAL**: No execution without explicit user consent
|
||||
|
||||
### 📋 Execution Strategies
|
||||
|
||||
**For Simple Changes (≤15 modules):**
|
||||
|
||||
Model will present detailed plan for affected modules:
|
||||
```
|
||||
📋 Related Update Plan:
|
||||
CHANGED modules affecting CLAUDE.md:
|
||||
|
||||
NEW CLAUDE.md files (X):
|
||||
- ./src/api/auth/CLAUDE.md [new module]
|
||||
- ./src/utils/helpers/CLAUDE.md [new module]
|
||||
|
||||
UPDATE existing CLAUDE.md files (Y):
|
||||
- ./src/api/CLAUDE.md [parent of changed auth/]
|
||||
- ./src/CLAUDE.md [root level]
|
||||
|
||||
Total: N CLAUDE.md files will be processed for recent changes
|
||||
|
||||
⚠️ Confirm execution? (y/n)
|
||||
```
|
||||
|
||||
```pseudo
|
||||
# ⚠️ MANDATORY: User confirmation → MUST await explicit approval
|
||||
IF user_explicitly_confirms():
|
||||
continue_execution()
|
||||
ELSE:
|
||||
abort_execution()
|
||||
|
||||
# Step 4: Organize modules by depth → Prepare execution
|
||||
depth_modules = organize_by_depth(changed_modules)
|
||||
|
||||
# Step 5: Execute depth-parallel updates → Process by depth
|
||||
FOR depth FROM max_depth DOWN TO 0:
|
||||
FOR each module IN depth_modules[depth]:
|
||||
WHILE active_jobs >= 4: wait(0.1)
|
||||
Bash(~/.claude/scripts/update_module_claude.sh "$module" "related" &)
|
||||
wait_all_jobs()
|
||||
|
||||
# Step 6: Display changes → Final status
|
||||
Bash(git diff --stat)
|
||||
```
|
||||
|
||||
**For Complex Changes (>15 modules):**
|
||||
The model will delegate to the memory-gemini-bridge agent using the Task tool:
|
||||
```
|
||||
Task "Complex project related update"
|
||||
prompt: "Execute context-aware update for [count] changed modules using depth-parallel execution"
|
||||
subagent_type: "memory-gemini-bridge"
|
||||
```
|
||||
|
||||
|
||||
### 📚 Usage Examples
|
||||
|
||||
```bash
|
||||
# Daily development update
|
||||
/update-memory-related
|
||||
|
||||
# After feature work
|
||||
/update-memory-related
|
||||
```
|
||||
|
||||
### ✨ Features
|
||||
|
||||
- **Separated Commands**: Each bash operation is a discrete, trackable step
|
||||
- **Intelligent Change Analysis**: Model analyzes change complexity for optimal strategy
|
||||
- **Change Detection**: Automatically finds affected modules using git diff
|
||||
- **Depth-Parallel Execution**: Same depth modules run in parallel, depths run sequentially
|
||||
- **Git Integration**: Auto-cache changes, show diff statistics after
|
||||
- **Fallback Mode**: Updates recent files when no git changes found
|
||||
- **User Confirmation**: Clear plan presentation with approval step
|
||||
- **CLAUDE.md Only**: Only updates documentation, never source code
|
||||
@@ -1,354 +0,0 @@
|
||||
---
|
||||
name: update-memory
|
||||
description: Intelligent CLAUDE.md documentation system with context-aware updates
|
||||
usage: /update-memory [mode]
|
||||
argument-hint: [related|full]
|
||||
examples:
|
||||
- /update-memory # Default: related mode (context-based)
|
||||
- /update-memory related # Update only context-related modules
|
||||
- /update-memory full # Full project documentation update
|
||||
---
|
||||
|
||||
### 🚀 Command Overview: `/update-memory`
|
||||
|
||||
- **Type**: Hierarchical Documentation Management System
|
||||
- **Purpose**: To maintain `CLAUDE.md` documentation using intelligent context detection and automatic task partitioning.
|
||||
- **Key Features**: Context-aware updates, strict hierarchy preservation, automatic scaling of execution strategy, and direct file modification via `Gemini --yolo`.
|
||||
|
||||
### ⚙️ Processing Modes
|
||||
|
||||
- **related (Default)**
|
||||
- **Scope**: Updates only context-related modules based on recent changes (git diff, recent edits).
|
||||
- **Action**: Updates affected module `CLAUDE.md` files, their parent hierarchy, and the root `CLAUDE.md`.
|
||||
- **Use Case**: Ideal for daily development, feature updates, and bug fixes.
|
||||
- **full**
|
||||
- **Scope**: Executes a complete, project-wide documentation update.
|
||||
- **Action**: Analyzes the entire project and updates all `CLAUDE.md` files at every hierarchy level.
|
||||
- **Use Case**: Best for major refactoring, project initialization, or periodic maintenance.
|
||||
|
||||
### 🧠 Core Execution Logic: Automatic Strategy Selection
|
||||
|
||||
The command automatically selects an execution strategy based on project complexity. This logic applies to both `related` and `full` modes.
|
||||
|
||||
```pseudo
|
||||
FUNCTION select_execution_strategy(mode):
|
||||
// Step 1: Analyze project scale
|
||||
file_count = count_source_code_files()
|
||||
|
||||
// Step 2: Determine execution strategy based on file count
|
||||
IF file_count < 50:
|
||||
// This action corresponds to the "Small Project" templates.
|
||||
EXECUTE_STRATEGY("Single Gemini Execution")
|
||||
ELSE IF file_count < 200:
|
||||
// This action corresponds to the "Medium Project" templates.
|
||||
EXECUTE_STRATEGY("Parallel Shell Execution")
|
||||
ELSE:
|
||||
// This action corresponds to the "Large Project" template.
|
||||
EXECUTE_STRATEGY("Multi-Agent Coordination")
|
||||
END FUNCTION
|
||||
```
|
||||
|
||||
### 🔍 Context Detection Logic (`related` Mode)
|
||||
|
||||
This describes how the command identifies which files need updating in `related` mode.
|
||||
|
||||
```pseudo
|
||||
FUNCTION detect_affected_modules():
|
||||
// Priority 1: Check for staged or recent git changes.
|
||||
changed_files = get_git_diff_or_status()
|
||||
|
||||
// Priority 2: If no git changes, find recently edited files as a fallback.
|
||||
IF changed_files is empty:
|
||||
changed_files = find_recently_modified_source_files(limit=10)
|
||||
|
||||
// Convert file paths into a unique list of parent directories.
|
||||
affected_modules = extract_unique_directories_from(changed_files)
|
||||
|
||||
RETURN affected_modules
|
||||
END FUNCTION
|
||||
```
|
||||
|
||||
### 📝 Template: Small Project (`related` Mode Update)
|
||||
|
||||
This template is executed when the project is small and the mode is `related`.
|
||||
|
||||
```bash
|
||||
# Single comprehensive analysis
|
||||
gemini --all-files --yolo -p "@{changed_files} @{affected_module/CLAUDE.md} @{CLAUDE.md}
|
||||
Analyze recent changes and update only affected CLAUDE.md files:
|
||||
|
||||
1. Module-level update:
|
||||
- Focus on changed patterns and implementations
|
||||
- Follow Layer 3/4 hierarchy rules
|
||||
- Avoid duplicating parent content
|
||||
|
||||
2. Root-level update:
|
||||
- Reflect only significant architectural changes
|
||||
- Maintain high-level project perspective
|
||||
- Reference but don't duplicate module details
|
||||
|
||||
Only update files that are actually affected by the changes."
|
||||
```
|
||||
|
||||
### 📝 Template: Medium/Large Project (`related` Mode Update)
|
||||
|
||||
This template is executed for medium or large projects in `related` mode.
|
||||
|
||||
```bash
|
||||
# Step-by-step layered update
|
||||
|
||||
# Update affected modules first
|
||||
for module in $affected_modules; do
|
||||
echo "Updating module: $module"
|
||||
gemini --all-files --yolo -p "@{$module/**/*} @{$module/CLAUDE.md}
|
||||
Update $module/CLAUDE.md based on recent changes:
|
||||
- Analyze what specifically changed in this module
|
||||
- Update implementation patterns that were modified
|
||||
- Follow Layer 3 hierarchy rules (module-specific focus)
|
||||
- Do not include project overview or domain-wide patterns
|
||||
- Only document what changed or was impacted"
|
||||
done
|
||||
|
||||
# Update parent domain if structure changed
|
||||
parent_domains=$(echo "$affected_modules" | xargs dirname | sort -u)
|
||||
for domain in $parent_domains; do
|
||||
if [ -f "$domain/CLAUDE.md" ]; then
|
||||
echo "Checking domain impact: $domain"
|
||||
gemini --all-files --yolo -p "@{$domain/*/CLAUDE.md} @{$domain/CLAUDE.md}
|
||||
Review if domain-level documentation needs updates:
|
||||
- Check if module organization changed
|
||||
- Update integration patterns if affected
|
||||
- Follow Layer 2 hierarchy rules (domain focus)
|
||||
- Only update if there are actual structural changes
|
||||
- Do not duplicate module details"
|
||||
fi
|
||||
done
|
||||
|
||||
# Finally, update root if significant changes
|
||||
echo "Updating root documentation"
|
||||
gemini --all-files --yolo -p "@{changed_files} @{*/CLAUDE.md} @{CLAUDE.md}
|
||||
Review and update root CLAUDE.md only if changes affect:
|
||||
- Project architecture or technology stack
|
||||
- Major feature additions
|
||||
- Development workflow changes
|
||||
|
||||
Follow Layer 1 hierarchy rules:
|
||||
- Maintain high-level project perspective
|
||||
- Only reference architectural impacts
|
||||
- Do not duplicate domain or module content"
|
||||
```
|
||||
|
||||
### 📝 Template: Small Project (`full` Mode Update)
|
||||
|
||||
This template is executed when the project is small and the mode is `full`.
|
||||
|
||||
```bash
|
||||
# Single comprehensive analysis with hierarchy awareness
|
||||
gemini --all-files --yolo -p "@{**/*} @{**/*CLAUDE.md}
|
||||
Perform complete project analysis and update all CLAUDE.md files with strict hierarchy:
|
||||
|
||||
1. Root CLAUDE.md (Layer 1):
|
||||
- Project overview, architecture, technology stack
|
||||
- Development guidelines and workflow
|
||||
- Do NOT include implementation details
|
||||
|
||||
2. Domain CLAUDE.md (Layer 2):
|
||||
- Domain architecture and module organization
|
||||
- Inter-module communication patterns
|
||||
- Do NOT duplicate project overview or module internals
|
||||
|
||||
3. Module CLAUDE.md (Layer 3):
|
||||
- Module-specific patterns and internal architecture
|
||||
- API contracts and dependencies
|
||||
- Do NOT duplicate domain patterns or project overview
|
||||
|
||||
4. Sub-module CLAUDE.md (Layer 4):
|
||||
- Implementation specifics and configuration
|
||||
- Usage examples and performance notes
|
||||
- Do NOT duplicate higher-level architecture
|
||||
|
||||
Ensure each layer maintains its proper abstraction level without content duplication."
|
||||
```
|
||||
|
||||
### 📝 Template: Medium Project (`full` Mode Update)
|
||||
|
||||
This template is executed when the project is medium-sized and the mode is `full`.
|
||||
|
||||
```bash
|
||||
# Dependency-aware parallel execution
|
||||
|
||||
echo "🏗️ Layer 1: Foundation modules (parallel)"
|
||||
(
|
||||
gemini --all-files --yolo -p "@{src/utils/**/*} @{src/utils/CLAUDE.md}
|
||||
Update utilities documentation (Layer 3 focus):
|
||||
- Utility patterns and helper functions
|
||||
- Module internal organization
|
||||
- Avoid project/domain overview" &
|
||||
|
||||
gemini --all-files --yolo -p "@{src/types/**/*} @{src/types/CLAUDE.md}
|
||||
Update types documentation (Layer 3 focus):
|
||||
- Type definitions and interface patterns
|
||||
- Type architecture within module
|
||||
- Avoid project/domain overview" &
|
||||
|
||||
gemini --all-files --yolo -p "@{src/core/**/*} @{src/core/CLAUDE.md}
|
||||
Update core documentation (Layer 3 focus):
|
||||
- Core module patterns and initialization
|
||||
- Internal system architecture
|
||||
- Avoid project/domain overview" &
|
||||
wait
|
||||
)
|
||||
|
||||
echo "🏭 Layer 2: Business modules (parallel, with foundation context)"
|
||||
(
|
||||
gemini --all-files --yolo -p "@{src/api/**/*} @{src/core/CLAUDE.md,src/types/CLAUDE.md} @{src/api/CLAUDE.md}
|
||||
Update API documentation with foundation context (Layer 3 focus):
|
||||
- API architecture and endpoint patterns
|
||||
- Integration with core and types modules
|
||||
- Module-specific implementation details
|
||||
- Avoid duplicating foundation or project content" &
|
||||
|
||||
gemini --all-files --yolo -p "@{src/services/**/*} @{src/utils/CLAUDE.md} @{src/services/CLAUDE.md}
|
||||
Update services documentation with utils context (Layer 3 focus):
|
||||
- Service layer patterns and business logic
|
||||
- Integration with utility modules
|
||||
- Module internal architecture
|
||||
- Avoid duplicating utils or project content" &
|
||||
wait
|
||||
)
|
||||
|
||||
echo "🎨 Layer 3: Application modules (parallel, with business context)"
|
||||
(
|
||||
gemini --all-files --yolo -p "@{src/components/**/*} @{src/api/CLAUDE.md} @{src/components/CLAUDE.md}
|
||||
Update components documentation with API context (Layer 3 focus):
|
||||
- Component architecture and patterns
|
||||
- API integration approaches
|
||||
- Module-specific UI patterns
|
||||
- Avoid duplicating API or project content" &
|
||||
|
||||
gemini --all-files --yolo -p "@{src/pages/**/*} @{src/services/CLAUDE.md} @{src/pages/CLAUDE.md}
|
||||
Update pages documentation with services context (Layer 3 focus):
|
||||
- Page structure and routing patterns
|
||||
- Service utilization approaches
|
||||
- Module-specific page architecture
|
||||
- Avoid duplicating services or project content" &
|
||||
wait
|
||||
)
|
||||
|
||||
echo "📋 Layer 4: Domain integration"
|
||||
gemini --all-files --yolo -p "@{src/*/CLAUDE.md} @{src/CLAUDE.md}
|
||||
Update src domain documentation (Layer 2 focus):
|
||||
- Synthesize module organization and relationships
|
||||
- Domain-wide architecture patterns
|
||||
- Inter-module communication strategies
|
||||
- Do NOT duplicate module implementation details
|
||||
- Do NOT duplicate project overview content"
|
||||
|
||||
echo "🎯 Layer 5: Root integration"
|
||||
gemini --all-files --yolo -p "@{*/CLAUDE.md} @{CLAUDE.md}
|
||||
Update root documentation (Layer 1 focus):
|
||||
- High-level project architecture and overview
|
||||
- Technology stack summary and decisions
|
||||
- Development workflow and guidelines
|
||||
- Do NOT duplicate domain-specific content
|
||||
- Do NOT include implementation details"
|
||||
```
|
||||
|
||||
### 📝 Template: Large Project (`full` Mode Update)
|
||||
|
||||
This YAML-based plan is used for large projects in `full` mode, coordinating multiple agents.
|
||||
|
||||
```yaml
|
||||
# Multi-agent coordination for complex projects
|
||||
Main Coordinator Agent:
|
||||
description: "Coordinate full documentation update"
|
||||
subagent_type: "memory-gemini-bridge"
|
||||
prompt: |
|
||||
Execute large project full documentation update:
|
||||
|
||||
1. Analyze project structure:
|
||||
gemini --all-files -p "@{**/*} Identify major domains, complexity, and module relationships"
|
||||
|
||||
2. Launch parallel domain agents:
|
||||
- Each agent handles one domain (frontend, backend, infrastructure)
|
||||
- Each agent follows hierarchy rules strictly
|
||||
- Each agent avoids content duplication
|
||||
|
||||
3. Final integration:
|
||||
gemini --all-files --yolo -p "@{*/CLAUDE.md} @{CLAUDE.md}
|
||||
Update root with Layer 1 focus only:
|
||||
- Project overview and architecture
|
||||
- Technology stack decisions
|
||||
- Development workflow
|
||||
- Do NOT duplicate domain details"
|
||||
|
||||
Frontend Domain Agent:
|
||||
prompt: |
|
||||
Update frontend domain with hierarchy awareness:
|
||||
|
||||
1. Module updates (Layer 3):
|
||||
gemini --all-files --yolo -p "@{src/components/**/*} @{src/components/CLAUDE.md}
|
||||
Component-specific patterns and architecture"
|
||||
|
||||
gemini --all-files --yolo -p "@{src/pages/**/*} @{src/pages/CLAUDE.md}
|
||||
Page-specific patterns and routing"
|
||||
|
||||
2. Domain integration (Layer 2):
|
||||
gemini --all-files --yolo -p "@{src/frontend/*/CLAUDE.md} @{src/frontend/CLAUDE.md}
|
||||
Frontend domain architecture, module relationships
|
||||
Do NOT duplicate component details or project overview"
|
||||
|
||||
Backend Domain Agent:
|
||||
prompt: |
|
||||
Update backend domain with hierarchy awareness:
|
||||
|
||||
1. Module updates (Layer 3):
|
||||
gemini --all-files --yolo -p "@{src/api/**/*} @{src/api/CLAUDE.md}
|
||||
API-specific patterns and endpoints"
|
||||
|
||||
gemini --all-files --yolo -p "@{src/services/**/*} @{src/services/CLAUDE.md}
|
||||
Service-specific business logic and patterns"
|
||||
|
||||
2. Domain integration (Layer 2):
|
||||
gemini --all-files --yolo -p "@{src/backend/*/CLAUDE.md} @{src/backend/CLAUDE.md}
|
||||
Backend domain architecture, service relationships
|
||||
Do NOT duplicate service details or project overview"
|
||||
```
|
||||
|
||||
### 📈 Performance Characteristics
|
||||
|
||||
| Mode | Small Project (<50 files) | Medium Project (50-200 files) | Large Project (>200 files) |
|
||||
| :-------- | :------------------------ | :---------------------------- | :------------------------- |
|
||||
| **related** | <1 minute | 1-3 minutes | 3-5 minutes |
|
||||
| **full** | 1-2 minutes | 3-5 minutes | 10-15 minutes |
|
||||
|
||||
### 📚 Usage Examples
|
||||
|
||||
```bash
|
||||
# Daily development (automatically detects what you've been working on)
|
||||
/update-memory
|
||||
|
||||
# After working in a specific module, explicitly run related mode
|
||||
cd src/api && /update-memory related
|
||||
|
||||
# Weekly full refresh for project-wide consistency
|
||||
/update-memory full
|
||||
|
||||
# Intelligently update based on a large refactoring commit
|
||||
git add -A && git commit -m "Major refactoring"
|
||||
/update-memory related
|
||||
```
|
||||
|
||||
### ✨ Key Features
|
||||
|
||||
- **Context Intelligence**: Automatically detects which modules need updating based on recent changes.
|
||||
- **Hierarchy Preservation**: Enforces strict content boundaries between documentation layers to prevent duplication.
|
||||
- **Smart Partitioning**: Dynamically scales its execution strategy (single, parallel, multi-agent) based on project size.
|
||||
- **Zero Configuration**: Works out-of-the-box with intelligent defaults for context detection and execution.
|
||||
|
||||
### 📝 Best Practices
|
||||
|
||||
- Use `related` mode for daily development; it's fast and focused.
|
||||
- Run `full` mode weekly or after major architectural changes to ensure consistency.
|
||||
- Trust the hierarchy; let each `CLAUDE.md` file serve its specific layer of abstraction.
|
||||
- Allow the automatic context detection to guide updates rather than manually specifying files.
|
||||
75
.claude/commands/workflow/brainstorm/CLAUDE.md
Normal file
75
.claude/commands/workflow/brainstorm/CLAUDE.md
Normal file
@@ -0,0 +1,75 @@
|
||||
# Module Analysis: `workflow:brainstorm`
|
||||
|
||||
## 1. Module-specific Implementation Patterns
|
||||
|
||||
### Role-Based Command Structure
|
||||
The `brainstorm` workflow is composed of multiple, distinct "role" commands. Each role is defined in its own Markdown file (e.g., `product-manager.md`, `system-architect.md`). This modular design allows for easy extension by adding new role files.
|
||||
|
||||
- **Command Naming Convention**: Each role is invoked via a consistent command structure: `/workflow:brainstorm:<role-name> <topic>`.
|
||||
- **File Naming Convention**: The command's `<role-name>` corresponds directly to the filename (e.g., `product-manager.md` implements `/workflow:brainstorm:product-manager`).
|
||||
|
||||
### Standardized Role Definition Structure
|
||||
Each role's `.md` file follows a strict, standardized structure:
|
||||
1. **Frontmatter**: Defines the command `name`, `description`, `usage`, `argument-hint`, `examples`, and `allowed-tools`. All roles consistently use `Task(conceptual-planning-agent)` and `TodoWrite(*)`.
|
||||
2. **Role Overview**: Defines the role's purpose, responsibilities, and success metrics.
|
||||
3. **Analysis Framework**: References shared principles (`brainstorming-principles.md`, `brainstorming-framework.md`) and lists key questions specific to the role's perspective.
|
||||
4. **Execution Protocol**: A multi-phase process detailing session detection, directory creation, task initialization (`TodoWrite`), and delegation to the `conceptual-planning-agent`.
|
||||
5. **Output Specification**: Defines the directory structure and file templates for the analysis artifacts generated by the role.
|
||||
6. **Session Integration**: Specifies how the role's output integrates with the parent session state (`workflow-session.json`).
|
||||
7. **Quality Assurance**: Provides checklists and standards for validating the quality of the role's output.
|
||||
|
||||
## 2. Internal Architecture and Design Decisions
|
||||
|
||||
### Session-Based Workflow
|
||||
The entire workflow is stateful and session-based, managed within the `.workflow/` directory.
|
||||
- **State Management**: An active session is marked by a `.workflow/.active-*` file.
|
||||
- **Output Scaffolding**: Each role command creates a dedicated output directory: `.workflow/WFS-{topic-slug}/.brainstorming/<role-name>/`. This isolates each perspective's artifacts.
|
||||
|
||||
### "Map-Reduce" Architectural Pattern
|
||||
The workflow follows a pattern analogous to Map-Reduce:
|
||||
- **Map Phase**: Each individual role command (`product-manager`, `ui-designer`, etc.) acts as a "mapper". It takes the input `{topic}` and produces a detailed analysis from its unique perspective.
|
||||
- **Reduce Phase**: The `synthesis` command acts as the "reducer". It collects the outputs from all completed roles, integrates them, identifies consensus and conflicts, and produces a single, comprehensive strategic report.
|
||||
|
||||
### Delegation to `conceptual-planning-agent`
|
||||
The core analytical work is not performed by the commands themselves. Instead, they act as templating engines that construct a detailed prompt for the `conceptual-planning-agent`. This design decision centralizes the complex reasoning and generation logic into a single, powerful tool, while the Markdown files serve as declarative "configurations" for that tool.
|
||||
|
||||
## 3. API Contracts and Interfaces
|
||||
|
||||
### Command-Line Interface (CLI)
|
||||
The primary user-facing interface is the set of CLI commands:
|
||||
- **Role Commands**: `/workflow:brainstorm:<role-name> <topic>`
|
||||
- **Synthesis Command**: `/workflow:brainstorm:synthesis` (no arguments)
|
||||
|
||||
### `conceptual-planning-agent` Contract
|
||||
The interface with the planning agent is a structured prompt passed to the `Task()` tool. This prompt consistently contains:
|
||||
- `ASSIGNED_ROLE` / `ROLE CONTEXT`: Defines the persona for the agent.
|
||||
- `USER_CONTEXT`: Injects user requirements from the session.
|
||||
- `ANALYSIS_REQUIREMENTS`: A detailed, numbered list of tasks for the agent to perform.
|
||||
- `OUTPUT REQUIREMENTS`: Specifies the exact file paths and high-level content structure for the generated artifacts.
|
||||
|
||||
### Filesystem Contract
|
||||
The workflow relies on a strict filesystem structure for state and outputs:
|
||||
- **Session State**: `.workflow/WFS-{topic-slug}/workflow-session.json` is updated by each role to track progress.
|
||||
- **Role Outputs**: Each role must produce a set of `.md` files in its designated directory (e.g., `analysis.md`, `roadmap.md`).
|
||||
- **Synthesis Input**: The `synthesis` command expects to find these specific output files to perform its function.
|
||||
|
||||
## 4. Module Dependencies and Relationships
|
||||
|
||||
- **Internal Dependencies**:
|
||||
- The `synthesis` command is dependent on the outputs of all other role commands. It cannot function until one or more roles have completed their analysis.
|
||||
- Individual role commands are largely independent of one another.
|
||||
|
||||
- **External Dependencies**:
|
||||
- **`conceptual-planning-agent`**: All roles have a critical dependency on this tool for their core logic.
|
||||
- **Shared Frameworks**: All roles include and depend on `@~/.claude/workflows/brainstorming-principles.md` and `@~/.claude/workflows/brainstorming-framework.md`, ensuring a consistent analytical foundation.
|
||||
|
||||
## 5. Testing Strategies
|
||||
|
||||
This module does not contain automated tests. Validation relies on a set of quality assurance standards defined within each role's Markdown file.
|
||||
|
||||
- **Checklist-Based Validation**: Each file contains a "Quality Assurance" or "Quality Standards" section with checklists for:
|
||||
- **Required Analysis Elements**: Ensures all necessary components are present in the output.
|
||||
- **Core Principles**: Validates that the analysis adheres to the role's guiding principles (e.g., "User-Centric", "Data-Driven").
|
||||
- **Quality Metrics**: Provides criteria for assessing the quality of the output (e.g., "Requirements completeness", "Feasibility of implementation plan").
|
||||
|
||||
This approach serves as a form of manual, requirement-based testing for the output generated by the `conceptual-planning-agent`.
|
||||
@@ -2,7 +2,6 @@
|
||||
name: list
|
||||
description: List all workflow sessions with status
|
||||
usage: /workflow:session:list
|
||||
|
||||
---
|
||||
|
||||
# List Workflow Sessions (/workflow/session/list)
|
||||
|
||||
97
.claude/scripts/detect_changed_modules.sh
Normal file
97
.claude/scripts/detect_changed_modules.sh
Normal file
@@ -0,0 +1,97 @@
|
||||
#!/bin/bash
|
||||
# Detect modules affected by git changes or recent modifications
|
||||
# Usage: detect_changed_modules.sh [format]
|
||||
# format: list|grouped|paths (default: paths)
|
||||
|
||||
detect_changed_modules() {
|
||||
local format="${1:-paths}"
|
||||
local changed_files=""
|
||||
local affected_dirs=""
|
||||
|
||||
# Step 1: Try to get git changes (staged + unstaged)
|
||||
if git rev-parse --git-dir > /dev/null 2>&1; then
|
||||
changed_files=$(git diff --name-only HEAD 2>/dev/null; git diff --name-only --cached 2>/dev/null)
|
||||
|
||||
# If no changes in working directory, check last commit
|
||||
if [ -z "$changed_files" ]; then
|
||||
changed_files=$(git diff --name-only HEAD~1 HEAD 2>/dev/null)
|
||||
fi
|
||||
fi
|
||||
|
||||
# Step 2: If no git changes, find recently modified source files (last 24 hours)
|
||||
if [ -z "$changed_files" ]; then
|
||||
changed_files=$(find . -type f \( \
|
||||
-name "*.md" -o \
|
||||
-name "*.js" -o -name "*.ts" -o -name "*.jsx" -o -name "*.tsx" -o \
|
||||
-name "*.py" -o -name "*.go" -o -name "*.rs" -o \
|
||||
-name "*.java" -o -name "*.cpp" -o -name "*.c" -o -name "*.h" -o \
|
||||
-name "*.sh" -o -name "*.ps1" -o \
|
||||
-name "*.json" -o -name "*.yaml" -o -name "*.yml" \
|
||||
\) -not -path '*/.*' -mtime -1 2>/dev/null)
|
||||
fi
|
||||
|
||||
# Step 3: Extract unique parent directories
|
||||
if [ -n "$changed_files" ]; then
|
||||
affected_dirs=$(echo "$changed_files" | \
|
||||
sed 's|/[^/]*$||' | \
|
||||
grep -v '^\.$' | \
|
||||
sort -u)
|
||||
|
||||
# Add current directory if files are in root
|
||||
if echo "$changed_files" | grep -q '^[^/]*$'; then
|
||||
affected_dirs=$(echo -e ".\n$affected_dirs" | sort -u)
|
||||
fi
|
||||
fi
|
||||
|
||||
# Step 4: Output in requested format
|
||||
case "$format" in
|
||||
"list")
|
||||
if [ -n "$affected_dirs" ]; then
|
||||
echo "$affected_dirs" | while read dir; do
|
||||
if [ -d "$dir" ]; then
|
||||
local file_count=$(find "$dir" -maxdepth 1 -type f 2>/dev/null | wc -l)
|
||||
local depth=$(echo "$dir" | tr -cd '/' | wc -c)
|
||||
if [ "$dir" = "." ]; then depth=0; fi
|
||||
|
||||
local types=$(find "$dir" -maxdepth 1 -type f -name "*.*" 2>/dev/null | \
|
||||
grep -E '\.[^/]*$' | sed 's/.*\.//' | sort -u | tr '\n' ',' | sed 's/,$//')
|
||||
echo "depth:$depth|path:$dir|files:$file_count|types:[$types]|status:changed"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
;;
|
||||
|
||||
"grouped")
|
||||
if [ -n "$affected_dirs" ]; then
|
||||
echo "📊 Affected modules by changes:"
|
||||
# Group by depth
|
||||
echo "$affected_dirs" | while read dir; do
|
||||
if [ -d "$dir" ]; then
|
||||
local depth=$(echo "$dir" | tr -cd '/' | wc -c)
|
||||
if [ "$dir" = "." ]; then depth=0; fi
|
||||
echo "$depth:$dir"
|
||||
fi
|
||||
done | sort -n | awk -F: '
|
||||
{
|
||||
if ($1 != prev_depth) {
|
||||
if (prev_depth != "") print ""
|
||||
print " 📁 Depth " $1 ":"
|
||||
prev_depth = $1
|
||||
}
|
||||
print " - " $2 " (changed)"
|
||||
}'
|
||||
else
|
||||
echo "📊 No recent changes detected"
|
||||
fi
|
||||
;;
|
||||
|
||||
"paths"|*)
|
||||
echo "$affected_dirs"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Execute function if script is run directly
|
||||
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||
detect_changed_modules "$@"
|
||||
fi
|
||||
106
.claude/scripts/get_modules_by_depth.sh
Normal file
106
.claude/scripts/get_modules_by_depth.sh
Normal file
@@ -0,0 +1,106 @@
|
||||
#!/bin/bash
|
||||
# Get modules organized by directory depth (deepest first)
|
||||
# Usage: get_modules_by_depth.sh [format]
|
||||
# format: list|grouped|json (default: list)
|
||||
|
||||
# Parse .gitignore patterns and build exclusion filters
|
||||
build_exclusion_filters() {
|
||||
local filters=""
|
||||
|
||||
# Always exclude these system/cache directories
|
||||
local system_excludes=(
|
||||
".git" ".history" ".vscode" "__pycache__" ".pytest_cache"
|
||||
"node_modules" "dist" "build" ".egg-info" ".env"
|
||||
)
|
||||
|
||||
for exclude in "${system_excludes[@]}"; do
|
||||
filters+=" -not -path '*/$exclude' -not -path '*/$exclude/*'"
|
||||
done
|
||||
|
||||
# Parse .gitignore if it exists
|
||||
if [ -f ".gitignore" ]; then
|
||||
while IFS= read -r line; do
|
||||
# Skip empty lines and comments
|
||||
[[ -z "$line" || "$line" =~ ^[[:space:]]*# ]] && continue
|
||||
|
||||
# Remove trailing slash and whitespace
|
||||
line=$(echo "$line" | sed 's|/$||' | xargs)
|
||||
|
||||
# Add to filters
|
||||
filters+=" -not -path '*/$line' -not -path '*/$line/*'"
|
||||
done < .gitignore
|
||||
fi
|
||||
|
||||
echo "$filters"
|
||||
}
|
||||
|
||||
get_modules_by_depth() {
|
||||
local format="${1:-list}"
|
||||
local exclusion_filters=$(build_exclusion_filters)
|
||||
local max_depth=$(eval "find . -type d $exclusion_filters 2>/dev/null" | awk -F/ '{print NF-1}' | sort -n | tail -1)
|
||||
|
||||
case "$format" in
|
||||
"grouped")
|
||||
echo "📊 Modules by depth (deepest first):"
|
||||
for depth in $(seq $max_depth -1 0); do
|
||||
local dirs=$(eval "find . -mindepth $depth -maxdepth $depth -type d $exclusion_filters 2>/dev/null" | \
|
||||
while read dir; do
|
||||
if [ $(find "$dir" -maxdepth 1 -type f 2>/dev/null | wc -l) -gt 0 ]; then
|
||||
local claude_indicator=""
|
||||
[ -f "$dir/CLAUDE.md" ] && claude_indicator=" [✓]"
|
||||
echo "$dir$claude_indicator"
|
||||
fi
|
||||
done)
|
||||
if [ -n "$dirs" ]; then
|
||||
echo " 📁 Depth $depth:"
|
||||
echo "$dirs" | sed 's/^/ - /'
|
||||
fi
|
||||
done
|
||||
;;
|
||||
|
||||
"json")
|
||||
echo "{"
|
||||
echo " \"max_depth\": $max_depth,"
|
||||
echo " \"modules\": {"
|
||||
for depth in $(seq $max_depth -1 0); do
|
||||
local dirs=$(eval "find . -mindepth $depth -maxdepth $depth -type d $exclusion_filters 2>/dev/null" | \
|
||||
while read dir; do
|
||||
if [ $(find "$dir" -maxdepth 1 -type f 2>/dev/null | wc -l) -gt 0 ]; then
|
||||
local has_claude="false"
|
||||
[ -f "$dir/CLAUDE.md" ] && has_claude="true"
|
||||
echo "{\"path\":\"$dir\",\"has_claude\":$has_claude}"
|
||||
fi
|
||||
done | tr '\n' ',')
|
||||
if [ -n "$dirs" ]; then
|
||||
dirs=${dirs%,} # Remove trailing comma
|
||||
echo " \"$depth\": [$dirs]"
|
||||
[ $depth -gt 0 ] && echo ","
|
||||
fi
|
||||
done
|
||||
echo " }"
|
||||
echo "}"
|
||||
;;
|
||||
|
||||
"list"|*)
|
||||
# Simple list format (deepest first)
|
||||
for depth in $(seq $max_depth -1 0); do
|
||||
eval "find . -mindepth $depth -maxdepth $depth -type d $exclusion_filters 2>/dev/null" | \
|
||||
while read dir; do
|
||||
if [ $(find "$dir" -maxdepth 1 -type f 2>/dev/null | wc -l) -gt 0 ]; then
|
||||
local file_count=$(find "$dir" -maxdepth 1 -type f 2>/dev/null | wc -l)
|
||||
local types=$(find "$dir" -maxdepth 1 -type f -name "*.*" 2>/dev/null | \
|
||||
grep -E '\.[^/]*$' | sed 's/.*\.//' | sort -u | tr '\n' ',' | sed 's/,$//')
|
||||
local has_claude="no"
|
||||
[ -f "$dir/CLAUDE.md" ] && has_claude="yes"
|
||||
echo "depth:$depth|path:$dir|files:$file_count|types:[$types]|has_claude:$has_claude"
|
||||
fi
|
||||
done
|
||||
done
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Execute function if script is run directly
|
||||
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||
get_modules_by_depth "$@"
|
||||
fi
|
||||
153
.claude/scripts/update_module_claude.sh
Normal file
153
.claude/scripts/update_module_claude.sh
Normal file
@@ -0,0 +1,153 @@
|
||||
#!/bin/bash
|
||||
# Update CLAUDE.md for a specific module with automatic layer detection
|
||||
# Usage: update_module_claude.sh <module_path> [update_type]
|
||||
# module_path: Path to the module directory
|
||||
# update_type: full|related (default: full)
|
||||
# Script automatically detects layer depth and selects appropriate template
|
||||
|
||||
update_module_claude() {
|
||||
local module_path="$1"
|
||||
local update_type="${2:-full}"
|
||||
|
||||
# Validate parameters
|
||||
if [ -z "$module_path" ]; then
|
||||
echo "❌ Error: Module path is required"
|
||||
echo "Usage: update_module_claude.sh <module_path> [update_type]"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ ! -d "$module_path" ]; then
|
||||
echo "❌ Error: Directory '$module_path' does not exist"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Check if directory has files
|
||||
local file_count=$(find "$module_path" -maxdepth 1 -type f 2>/dev/null | wc -l)
|
||||
if [ $file_count -eq 0 ]; then
|
||||
echo "⚠️ Skipping '$module_path' - no files found"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Determine documentation layer based on path patterns
|
||||
local layer=""
|
||||
local template_path=""
|
||||
local analysis_strategy=""
|
||||
|
||||
# Clean path for pattern matching
|
||||
local clean_path=$(echo "$module_path" | sed 's|^\./||')
|
||||
|
||||
# Pattern-based layer detection
|
||||
if [ "$module_path" = "." ]; then
|
||||
# Root directory
|
||||
layer="Layer 1 (Root)"
|
||||
template_path="~/.claude/workflows/gemini-templates/prompts/dms/claude-layer1-root.txt"
|
||||
analysis_strategy="--all-files"
|
||||
elif [[ "$clean_path" =~ ^[^/]+$ ]]; then
|
||||
# Top-level directories (e.g., .claude, src, tests)
|
||||
layer="Layer 2 (Domain)"
|
||||
template_path="~/.claude/workflows/gemini-templates/prompts/dms/claude-layer2-domain.txt"
|
||||
analysis_strategy="@{*/CLAUDE.md}"
|
||||
elif [[ "$clean_path" =~ ^[^/]+/[^/]+$ ]]; then
|
||||
# Second-level directories (e.g., .claude/scripts, src/components)
|
||||
layer="Layer 3 (Module)"
|
||||
template_path="~/.claude/workflows/gemini-templates/prompts/dms/claude-layer3-module.txt"
|
||||
analysis_strategy="@{*/CLAUDE.md}"
|
||||
else
|
||||
# Deeper directories (e.g., .claude/workflows/gemini-templates/prompts)
|
||||
layer="Layer 4 (Sub-Module)"
|
||||
template_path="~/.claude/workflows/gemini-templates/prompts/dms/claude-layer4-submodule.txt"
|
||||
analysis_strategy="--all-files"
|
||||
fi
|
||||
|
||||
# Prepare logging info
|
||||
local module_name=$(basename "$module_path")
|
||||
|
||||
echo "⚡ Updating: $module_path"
|
||||
echo " Layer: $layer | Type: $update_type | Files: $file_count"
|
||||
echo " Template: $(basename "$template_path") | Strategy: $analysis_strategy"
|
||||
|
||||
# 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 following hierarchy standards."
|
||||
fi
|
||||
|
||||
local update_context=""
|
||||
if [ "$update_type" = "full" ]; then
|
||||
update_context="
|
||||
Update Mode: Complete refresh
|
||||
- Perform comprehensive analysis of all content
|
||||
- Document patterns, architecture, and purpose
|
||||
- Consider existing documentation hierarchy
|
||||
- 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 at any hierarchy level
|
||||
2. NEVER modify source code files
|
||||
3. Focus exclusively on updating documentation
|
||||
4. Follow the template guidelines exactly
|
||||
|
||||
$template_content
|
||||
|
||||
$update_context"
|
||||
|
||||
# Execute update
|
||||
local start_time=$(date +%s)
|
||||
echo " 🔄 Starting update..."
|
||||
|
||||
if cd "$module_path" 2>/dev/null; then
|
||||
# Execute gemini command with layer-specific analysis strategy
|
||||
local gemini_result=0
|
||||
if [ "$analysis_strategy" = "--all-files" ]; then
|
||||
gemini --all-files --yolo -p "$base_prompt
|
||||
|
||||
Module Information:
|
||||
- Name: $module_name
|
||||
- Path: $module_path
|
||||
- Layer: $layer
|
||||
- Analysis Strategy: $analysis_strategy" 2>&1
|
||||
gemini_result=$?
|
||||
else
|
||||
gemini --yolo -p "$analysis_strategy $base_prompt
|
||||
|
||||
Module Information:
|
||||
- Name: $module_name
|
||||
- Path: $module_path
|
||||
- Layer: $layer
|
||||
- Analysis Strategy: $analysis_strategy" 2>&1
|
||||
gemini_result=$?
|
||||
fi
|
||||
|
||||
if [ $gemini_result -eq 0 ]; then
|
||||
local end_time=$(date +%s)
|
||||
local duration=$((end_time - start_time))
|
||||
echo " ✅ Completed in ${duration}s"
|
||||
cd - > /dev/null
|
||||
return 0
|
||||
else
|
||||
echo " ❌ Update failed for $module_path"
|
||||
cd - > /dev/null
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
echo " ❌ Cannot access directory: $module_path"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Execute function if script is run directly
|
||||
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||
update_module_claude "$@"
|
||||
fi
|
||||
@@ -0,0 +1,34 @@
|
||||
# Module: Analysis Prompts
|
||||
|
||||
## Overview
|
||||
|
||||
This module provides a collection of standardized prompt templates for conducting detailed analysis of software projects. Each template is designed to guide the language model in focusing on a specific area of concern, ensuring comprehensive and structured feedback.
|
||||
|
||||
## Component Documentation
|
||||
|
||||
The `analysis` module contains the following prompt templates:
|
||||
|
||||
- **`architecture.txt`**: Guides the analysis of high-level system architecture, design patterns, module dependencies, and scalability.
|
||||
- **`pattern.txt`**: Focuses on identifying and evaluating implementation patterns, code structure, and adherence to conventions.
|
||||
- **`performance.txt`**: Directs the analysis towards performance bottlenecks, algorithm efficiency, and optimization opportunities.
|
||||
- **`quality.txt`**: Used for assessing code quality, maintainability, error handling, and test coverage.
|
||||
- **`security.txt`**: Concentrates on identifying security vulnerabilities, including issues with authentication, authorization, input validation, and data encryption.
|
||||
|
||||
## Usage Patterns
|
||||
|
||||
To use a template, its content should be prepended to a user's request for analysis. This primes the model with specific instructions and output requirements for the desired analysis type.
|
||||
|
||||
### Example: Requesting a Security Analysis
|
||||
|
||||
```
|
||||
[Content of security.txt]
|
||||
|
||||
---
|
||||
|
||||
Analyze the following codebase for security vulnerabilities:
|
||||
[Code or project context]
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
The prompt templates are plain text files and can be customized to adjust the focus or output requirements of the analysis. No special configuration is required to use them.
|
||||
@@ -0,0 +1,63 @@
|
||||
Create or update root-level CLAUDE.md documentation:
|
||||
|
||||
## Layer 1: Root Level Documentation Requirements
|
||||
|
||||
### Content Focus (MUST INCLUDE):
|
||||
1. **Project Overview and Purpose**
|
||||
- High-level project description and mission
|
||||
- Target audience and use cases
|
||||
- Key value propositions
|
||||
|
||||
2. **Technology Stack Summary**
|
||||
- Primary programming languages and frameworks
|
||||
- Key dependencies and tools
|
||||
- Platform and runtime requirements
|
||||
|
||||
3. **Architecture Decisions and Principles**
|
||||
- Core architectural patterns used
|
||||
- Design principles governing the codebase
|
||||
- Major technical decisions and rationale
|
||||
|
||||
4. **Development Workflow Overview**
|
||||
- Build and deployment processes
|
||||
- Testing approach and quality standards
|
||||
- Contributing guidelines and processes
|
||||
|
||||
5. **Quick Start Guide**
|
||||
- Installation prerequisites
|
||||
- Setup instructions
|
||||
- Basic usage examples
|
||||
|
||||
### Content Restrictions (STRICTLY AVOID):
|
||||
- Implementation details (belongs in module-level docs)
|
||||
- Module-specific patterns (belongs in module-level docs)
|
||||
- Code examples from specific modules (belongs in module-level docs)
|
||||
- Domain internal architecture (belongs in domain-level docs)
|
||||
|
||||
### Documentation Style:
|
||||
- Use high-level, strategic perspective
|
||||
- Focus on "what" and "why" rather than "how"
|
||||
- Reference other documentation layers rather than duplicating content
|
||||
- Maintain concise, executive-summary style
|
||||
|
||||
### Template Structure:
|
||||
```markdown
|
||||
# [Project Name] - Development Guidelines
|
||||
|
||||
## 1. Project Overview and Purpose
|
||||
[Brief project description, mission, and target audience]
|
||||
|
||||
## 2. Technology Stack Summary
|
||||
[Primary technologies, frameworks, and tools]
|
||||
|
||||
## 3. Architecture Decisions and Principles
|
||||
[Core architectural patterns and design principles]
|
||||
|
||||
## 4. Development Workflow Overview
|
||||
[Build, test, and deployment processes]
|
||||
|
||||
## 5. Quick Start Guide
|
||||
[Installation and basic usage]
|
||||
```
|
||||
|
||||
Remember: This is Layer 1 - stay at the strategic level and avoid diving into implementation details.
|
||||
@@ -0,0 +1,63 @@
|
||||
Create or update domain-level CLAUDE.md documentation:
|
||||
|
||||
## Layer 2: Domain Level Documentation Requirements
|
||||
|
||||
### Content Focus (MUST INCLUDE):
|
||||
1. **Domain Architecture and Responsibilities**
|
||||
- Domain's role within the larger system
|
||||
- Core responsibilities and boundaries
|
||||
- Key abstractions and concepts
|
||||
|
||||
2. **Module Organization Within Domain**
|
||||
- How modules are structured within this domain
|
||||
- Module relationships and hierarchies
|
||||
- Organizational patterns used
|
||||
|
||||
3. **Inter-Module Communication Patterns**
|
||||
- How modules within this domain communicate
|
||||
- Data flow patterns and interfaces
|
||||
- Shared resources and dependencies
|
||||
|
||||
4. **Domain-Specific Conventions**
|
||||
- Coding standards specific to this domain
|
||||
- Naming conventions and patterns
|
||||
- Testing approaches for this domain
|
||||
|
||||
5. **Integration Points with Other Domains**
|
||||
- External dependencies and interfaces
|
||||
- Cross-domain communication protocols
|
||||
- Shared contracts and data formats
|
||||
|
||||
### Content Restrictions (STRICTLY AVOID):
|
||||
- Duplicating root project overview (belongs in root-level docs)
|
||||
- Component/function-level details (belongs in module-level docs)
|
||||
- Specific implementation code (belongs in module-level docs)
|
||||
- Module internal patterns (belongs in module-level docs)
|
||||
|
||||
### Documentation Style:
|
||||
- Focus on domain-wide patterns and organization
|
||||
- Explain relationships between modules within the domain
|
||||
- Describe domain boundaries and responsibilities
|
||||
- Reference module-level docs for implementation details
|
||||
|
||||
### Template Structure:
|
||||
```markdown
|
||||
# [Domain Name] - Domain Architecture
|
||||
|
||||
## 1. Domain Overview
|
||||
[Domain's role and core responsibilities]
|
||||
|
||||
## 2. Module Organization
|
||||
[How modules are structured within this domain]
|
||||
|
||||
## 3. Inter-Module Communication
|
||||
[Communication patterns and data flow]
|
||||
|
||||
## 4. Domain Conventions
|
||||
[Domain-specific standards and patterns]
|
||||
|
||||
## 5. External Integration
|
||||
[Integration with other domains and systems]
|
||||
```
|
||||
|
||||
Remember: This is Layer 2 - focus on domain-wide organization and avoid both high-level project details and low-level implementation specifics.
|
||||
@@ -0,0 +1,66 @@
|
||||
Create or update module-level CLAUDE.md documentation:
|
||||
|
||||
## Layer 3: Module Level Documentation Requirements
|
||||
|
||||
### Content Focus (MUST INCLUDE):
|
||||
1. **Module-Specific Implementation Patterns**
|
||||
- Implementation patterns used within this module
|
||||
- Common coding approaches and idioms
|
||||
- Module-specific design patterns
|
||||
|
||||
2. **Internal Architecture and Design Decisions**
|
||||
- How the module is internally organized
|
||||
- Key design decisions and their rationale
|
||||
- Component relationships within the module
|
||||
|
||||
3. **API Contracts and Interfaces**
|
||||
- Public interfaces exposed by this module
|
||||
- Input/output contracts and data formats
|
||||
- Integration points with other modules
|
||||
|
||||
4. **Module Dependencies and Relationships**
|
||||
- Direct dependencies of this module
|
||||
- How this module fits into the larger system
|
||||
- Data flow in and out of the module
|
||||
|
||||
5. **Testing Strategies for This Module**
|
||||
- Testing approaches specific to this module
|
||||
- Test coverage strategies and targets
|
||||
- Module-specific testing tools and frameworks
|
||||
|
||||
### Content Restrictions (STRICTLY AVOID):
|
||||
- Project overview content (belongs in root-level docs)
|
||||
- Domain-wide architectural patterns (belongs in domain-level docs)
|
||||
- Detailed function documentation (belongs in sub-module-level docs)
|
||||
- Configuration specifics (belongs in sub-module-level docs)
|
||||
|
||||
### Documentation Style:
|
||||
- Focus on module-level architecture and patterns
|
||||
- Explain how components within the module work together
|
||||
- Document public interfaces and contracts
|
||||
- Reference sub-module docs for detailed implementation
|
||||
|
||||
### Template Structure:
|
||||
```markdown
|
||||
# [Module Name] - Module Architecture
|
||||
|
||||
## 1. Module Overview
|
||||
[Module's purpose and responsibilities]
|
||||
|
||||
## 2. Implementation Patterns
|
||||
[Common patterns and approaches used]
|
||||
|
||||
## 3. Internal Architecture
|
||||
[How the module is organized internally]
|
||||
|
||||
## 4. Public Interfaces
|
||||
[APIs and contracts exposed by this module]
|
||||
|
||||
## 5. Dependencies and Integration
|
||||
[Module dependencies and system integration]
|
||||
|
||||
## 6. Testing Strategy
|
||||
[Testing approaches for this module]
|
||||
```
|
||||
|
||||
Remember: This is Layer 3 - focus on module-level architecture and patterns, avoiding both domain-wide and detailed implementation concerns.
|
||||
@@ -0,0 +1,69 @@
|
||||
Create or update sub-module-level CLAUDE.md documentation:
|
||||
|
||||
## Layer 4: Sub-Module Level Documentation Requirements
|
||||
|
||||
### Content Focus (MUST INCLUDE):
|
||||
1. **Detailed Implementation Specifics**
|
||||
- Specific implementation details and algorithms
|
||||
- Code-level patterns and idioms
|
||||
- Implementation trade-offs and decisions
|
||||
|
||||
2. **Component/Function Documentation**
|
||||
- Individual component descriptions
|
||||
- Function signatures and behaviors
|
||||
- Class/struct/interface documentation
|
||||
|
||||
3. **Configuration Details and Examples**
|
||||
- Configuration options and parameters
|
||||
- Environment-specific settings
|
||||
- Configuration examples and templates
|
||||
|
||||
4. **Usage Examples and Patterns**
|
||||
- Code examples and usage patterns
|
||||
- Common use cases and scenarios
|
||||
- Integration examples with other components
|
||||
|
||||
5. **Performance Considerations**
|
||||
- Performance characteristics and constraints
|
||||
- Optimization strategies and techniques
|
||||
- Resource usage and scalability notes
|
||||
|
||||
### Content Restrictions (STRICTLY AVOID):
|
||||
- Architecture decisions (belong in higher levels)
|
||||
- Module-level organizational patterns (belong in module-level docs)
|
||||
- Domain or project overview content (belong in higher levels)
|
||||
- Cross-module architectural concerns (belong in higher levels)
|
||||
|
||||
### Documentation Style:
|
||||
- Focus on detailed, actionable implementation information
|
||||
- Provide concrete examples and code snippets
|
||||
- Document specific behaviors and edge cases
|
||||
- Include troubleshooting and debugging guidance
|
||||
|
||||
### Template Structure:
|
||||
```markdown
|
||||
# [Sub-Module/Component Name] - Implementation Guide
|
||||
|
||||
## 1. Component Overview
|
||||
[Specific purpose and functionality]
|
||||
|
||||
## 2. Implementation Details
|
||||
[Detailed implementation specifics]
|
||||
|
||||
## 3. API Reference
|
||||
[Function/method documentation]
|
||||
|
||||
## 4. Configuration
|
||||
[Configuration options and examples]
|
||||
|
||||
## 5. Usage Examples
|
||||
[Code examples and patterns]
|
||||
|
||||
## 6. Performance and Optimization
|
||||
[Performance considerations and tips]
|
||||
|
||||
## 7. Troubleshooting
|
||||
[Common issues and solutions]
|
||||
```
|
||||
|
||||
Remember: This is Layer 4 - focus on concrete, actionable implementation details and avoid architectural or organizational concerns.
|
||||
@@ -1,4 +1,3 @@
|
||||
```markdown
|
||||
---
|
||||
name: gemini-unified
|
||||
description: Consolidated Gemini CLI guidelines - core rules, syntax, patterns, templates, and best practices
|
||||
@@ -47,28 +46,6 @@ type: technical-guideline
|
||||
)"
|
||||
```
|
||||
|
||||
### 🔄 Execution Modes
|
||||
|
||||
- **1. Directory-Scoped**: Navigate to a directory first, then run `gemini`.
|
||||
```bash
|
||||
cd src/components && gemini --all-files -p "@{CLAUDE.md} Analyze component patterns"
|
||||
```
|
||||
- **2. Pattern-Based**: Target files directly from any location using patterns.
|
||||
```bash
|
||||
gemini -p "@{src/components/**/*} @{CLAUDE.md} Analyze component patterns"
|
||||
```
|
||||
- **3. Template-Injected**: Use `$(cat)` to inject a predefined prompt template.
|
||||
```bash
|
||||
gemini -p "@{src/**/*} $(cat ~/.claude/workflows/gemini-templates/prompts/analysis/pattern.txt)"
|
||||
```
|
||||
- **4. Parallel Execution**: Run multiple analyses concurrently for efficiency.
|
||||
```bash
|
||||
(
|
||||
gemini -p "@{**/*auth*} @{CLAUDE.md} Auth patterns" &
|
||||
gemini -p "@{**/api/**/*} @{CLAUDE.md} API patterns" &
|
||||
wait
|
||||
)
|
||||
```
|
||||
|
||||
### 📂 File Pattern Rules
|
||||
|
||||
@@ -88,109 +65,12 @@ type: technical-guideline
|
||||
- Enclose paths with spaces in quotes: `@{"My Project/src/**/*"}`.
|
||||
- Escape special characters like brackets: `@{src/**/*\[bracket\]*}`.
|
||||
|
||||
### 🧠 Smart Pattern Discovery - Logic Flow
|
||||
|
||||
This feature automates the process of finding relevant files for analysis.
|
||||
|
||||
`Step 1: Analyze File Extensions` -> `Step 2: Generate Patterns` -> `Step 3: Execute Gemini`
|
||||
|
||||
```pseudo
|
||||
FUNCTION analyze_and_run_gemini(analysis_type):
|
||||
// Step 1: Analyze the project's file types.
|
||||
// Corresponds to the `discover_extensions` shell function.
|
||||
discovered_extensions = analyze_project_extensions()
|
||||
log("Discovered extensions:", discovered_extensions)
|
||||
|
||||
// Also identify the likely primary programming language.
|
||||
// Corresponds to the `detect_primary_language` shell function.
|
||||
primary_language = detect_main_language(discovered_extensions)
|
||||
log("Primary language:", primary_language)
|
||||
|
||||
// Step 2: Generate file patterns based on the analysis type (e.g., "code", "config").
|
||||
// Corresponds to the `generate_patterns_by_extension` shell function.
|
||||
patterns = generate_patterns(analysis_type, discovered_extensions)
|
||||
log("Generated patterns:", patterns)
|
||||
|
||||
// Step 3: Construct and execute the gemini command.
|
||||
// Always include project standards from CLAUDE.md.
|
||||
// Uses a pre-defined analysis template for consistency.
|
||||
command = "gemini -p \"" + patterns + " @{CLAUDE.md} $(cat ~/.claude/workflows/gemini-templates/prompts/analysis/pattern.txt)\""
|
||||
execute_shell(command)
|
||||
|
||||
END FUNCTION
|
||||
```
|
||||
|
||||
### 📜 Smart Discovery - Shell Implementation
|
||||
|
||||
These functions provide the concrete implementation for the smart discovery logic.
|
||||
|
||||
- **Step 1: Analyze File Extensions & Language**
|
||||
```bash
|
||||
# Discover actual file types in project
|
||||
discover_extensions() {
|
||||
echo "=== File Extension Analysis ==="
|
||||
find . -type f -name "*.*" 2>/dev/null | \
|
||||
sed 's/.*\.//' | \
|
||||
sort | uniq -c | sort -rn | \
|
||||
head -10
|
||||
}
|
||||
|
||||
# Identify primary language
|
||||
detect_primary_language() {
|
||||
local extensions=$(find . -type f -name "*.*" 2>/dev/null | sed 's/.*\.//' | sort | uniq -c | sort -rn)
|
||||
if echo "$extensions" | grep -q "js\|jsx\|ts\|tsx"; then
|
||||
echo "JavaScript/TypeScript"
|
||||
elif echo "$extensions" | grep -q "py\|pyw"; then
|
||||
echo "Python"
|
||||
# ... other language checks ...
|
||||
else
|
||||
echo "Unknown/Mixed"
|
||||
fi
|
||||
}
|
||||
```
|
||||
- **Step 2: Generate Patterns**
|
||||
```bash
|
||||
# Generate patterns from discovered extensions
|
||||
generate_patterns_by_extension() {
|
||||
local analysis_type="$1"
|
||||
local top_exts=$(find . -type f -name "*.*" 2>/dev/null | sed 's/.*\.//' | sort | uniq -c | sort -rn | head -5 | awk '{print $2}')
|
||||
local pattern=""
|
||||
case "$analysis_type" in
|
||||
"code")
|
||||
for ext in $top_exts; do
|
||||
case $ext in
|
||||
js|ts|jsx|tsx|py|java|go|rs|cpp|c|h)
|
||||
pattern="${pattern}**/*.${ext},"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
echo "@{${pattern%,}}"
|
||||
;;
|
||||
"config") echo "@{*.json,*.yml,*.yaml,*.toml,*.ini,*.env}" ;;
|
||||
"docs") echo "@{**/*.md,**/*.txt,**/README*}" ;;
|
||||
"all")
|
||||
for ext in $top_exts; do pattern="${pattern}**/*.${ext},"; done
|
||||
echo "@{${pattern%,}}"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
```
|
||||
|
||||
### ⚡ Smart Discovery - Quick Commands
|
||||
|
||||
| Need | Command | Description |
|
||||
|------|---------|-------------|
|
||||
| Analyze Extensions | `discover_extensions` | View project file type distribution. |
|
||||
| Code Files | `generate_patterns_by_extension "code"` | Generate patterns for source code files only. |
|
||||
| Config Files | `generate_patterns_by_extension "config"` | Generate patterns for configuration files. |
|
||||
| Docs | `generate_patterns_by_extension "docs"` | Generate patterns for documentation. |
|
||||
| All Top Types | `generate_patterns_by_extension "all"` | Generate patterns for all discovered file types. |
|
||||
|
||||
### TPL (Templates)
|
||||
|
||||
#### 🗂️ Template Directory Structure
|
||||
This structure must be located at `~/.claude/workflows/gemini-templates/`.
|
||||
```
|
||||
|
||||
~/.claude/workflows/gemini-templates/
|
||||
├── prompts/
|
||||
│ ├── analysis/ # Code analysis templates
|
||||
@@ -209,7 +89,7 @@ This structure must be located at `~/.claude/workflows/gemini-templates/`.
|
||||
│ └── dms/ # DMS-specific
|
||||
│ └── hierarchy-analysis.txt # 📚 Documentation structure optimization
|
||||
└── commands/ # Command examples
|
||||
```
|
||||
|
||||
|
||||
#### 🧭 Template Selection Guide
|
||||
| Task Type | Primary Template | Purpose |
|
||||
@@ -279,16 +159,22 @@ These are recommended command templates for common scenarios.
|
||||
|
||||
### ⭐ Best Practices & Rules
|
||||
|
||||
- **Mandatory Context**: Always include `@{CLAUDE.md,**/*CLAUDE.md}` to ground the analysis in project-specific standards.
|
||||
- **Specificity**: Use precise file patterns to reduce scope, improve performance, and increase accuracy.
|
||||
- **Performance**: Avoid overly broad patterns (`@{**/*}`) on large projects. Prefer directory-scoped execution or parallel chunks.
|
||||
- **Agent Integration**: All agent workflows **must** begin with a context analysis step using `gemini`.
|
||||
```bash
|
||||
# Mandatory first step for any agent task
|
||||
gemini --all-files -p "@{relevant_patterns} @{CLAUDE.md} Context for: [task_description]"
|
||||
```
|
||||
- **Error Handling**:
|
||||
- Validate patterns match existing files before executing a long analysis.
|
||||
- Quote paths that contain spaces or special characters.
|
||||
- Test complex patterns on a small subset of files first.
|
||||
|
||||
**When to Use @ Patterns:**
|
||||
1. **User explicitly provides @ patterns** - ALWAYS preserve them exactly
|
||||
2. **Cross-directory analysis** - When analyzing relationships between modules
|
||||
3. **Configuration files** - When analyzing scattered config files
|
||||
4. **Selective inclusion** - When you only need specific file types
|
||||
|
||||
**CLAUDE.md Loading Rules:**
|
||||
- **With --all-files**: CLAUDE.md files automatically included (no @ needed)
|
||||
- **Without --all-files**: Must use `@{CLAUDE.md}` or `@{**/CLAUDE.md}`
|
||||
|
||||
|
||||
#### ⚠️ Error Prevention
|
||||
|
||||
- **Quote paths with spaces**: Use proper shell quoting
|
||||
- **Test patterns first**: Validate @ patterns match existing files
|
||||
- **Prefer directory navigation**: Reduces complexity and improves performance
|
||||
- **Preserve user patterns**: When user provides @, always keep them
|
||||
|
||||
|
||||
112
README.md
112
README.md
@@ -8,7 +8,7 @@
|
||||
|
||||
A sophisticated multi-agent automation workflow framework that transforms complex software development tasks from conceptualization to implementation review into manageable, trackable, AI-orchestrated processes.
|
||||
|
||||
> **🎉 Major Architecture Upgrade (v2.0)**: Recently underwent comprehensive refactoring with **JSON-only data model**, **marker file session management**, and **unified complexity standards**. See [WORKFLOW_SYSTEM_UPGRADE.md](WORKFLOW_SYSTEM_UPGRADE.md) for details.
|
||||
> **🎉 v1.0 Release**: Complete Gemini CLI integration with template system, dynamic template discovery, streamlined documentation, and intelligent auto-selection capabilities. See [CHANGELOG.md](CHANGELOG.md) for details.
|
||||
|
||||
## 🏗️ Architecture Overview
|
||||
|
||||
@@ -39,7 +39,13 @@ CCW intelligently adapts its file structure and workflow processes based on unif
|
||||
- **Action Planning Agent**: Converts high-level concepts into executable implementation plans
|
||||
- **Code Developer**: Implements code based on plans
|
||||
- **Code Review Agent**: Reviews code quality and compliance
|
||||
- **Memory Gemini Bridge**: Intelligent CLAUDE.md documentation system with 4-layer hierarchy, context-aware updates, and automatic scaling based on project complexity
|
||||
- **Memory Gemini Bridge**: Intelligent CLAUDE.md documentation system with context-aware updates
|
||||
|
||||
### Gemini CLI Integration (v1.0)
|
||||
- **Dynamic Template Discovery**: Automatically detects and loads templates from `~/.claude/prompt-templates/`
|
||||
- **Intelligent Auto-Selection**: Matches user input against template keywords and descriptions
|
||||
- **Template System**: Bug-fix, planning, and custom analysis templates
|
||||
- **Streamlined Commands**: Consolidated documentation with 500+ lines reduced
|
||||
|
||||
### Workflow Session Management
|
||||
- Create, pause, resume, list, and switch workflow sessions
|
||||
@@ -119,23 +125,27 @@ For Gemini CLI integration, configure your `settings.json` file:
|
||||
| Command | Syntax | Description |
|
||||
|---------|--------|-------------|
|
||||
| `/enhance-prompt` | `/enhance-prompt <input>` | Enhance and structure user inputs with technical context |
|
||||
| `/gemini:analyze` | `/gemini:analyze <inquiry> [--all-files] [--save-session]` | Direct codebase analysis and investigation |
|
||||
| `/gemini:chat` | `/gemini:chat <inquiry> [--all-files] [--save-session]` | Simple direct interaction with Gemini CLI without templates |
|
||||
| `/gemini:chat:bug-fix` | `/gemini:chat:bug-fix <bug-description> [--all-files] [--save-session]` | Bug analysis using specialized diagnostic template |
|
||||
| `/gemini:chat:plan` | `/gemini:chat:plan <planning-topic> [--all-files] [--save-session]` | Project planning using specialized architecture template |
|
||||
| `/gemini-execute` | `/gemini-execute <task-id\|description> [--yolo] [--debug]` | Intelligent executor with automatic file context inference |
|
||||
| `/gemini-mode` | `/gemini-mode <analysis-type> <target> [options]` | Template-driven codebase analysis (pattern, architecture, security) |
|
||||
| `/update-memory` | `/update-memory [related\|full]` | Intelligent CLAUDE.md documentation system with context-aware updates and strict hierarchy preservation |
|
||||
| `/gemini:execute` | `/gemini:execute <task-id\|description> [--yolo] [--debug]` | Intelligent executor with automatic file context inference |
|
||||
| `/gemini:mode:auto` | `/gemini:mode:auto "<description>"` | 🆕 Auto-select and execute appropriate template based on user input analysis |
|
||||
| `/gemini:mode:bug-index` | `/gemini:mode:bug-index <bug-description>` | Bug analysis using specialized diagnostic template |
|
||||
| `/gemini:mode:plan` | `/gemini:mode:plan <planning-topic>` | Project planning using specialized architecture template |
|
||||
| `/update-memory` | `/update-memory [related\|full]` | Intelligent CLAUDE.md documentation system with context-aware updates |
|
||||
| `/update-memory-full` | `/update-memory-full` | 🆕 Complete project-wide CLAUDE.md documentation update with depth-parallel execution |
|
||||
| `/update-memory-related` | `/update-memory-related` | 🆕 Context-aware documentation updates for modules affected by recent changes |
|
||||
|
||||
### Workflow Management
|
||||
|
||||
| Command | Syntax | Description |
|
||||
|---------|--------|-------------|
|
||||
| `/workflow:session` | `start\|pause\|resume\|list\|switch\|status [complexity] ["task"]` | Session lifecycle management with complexity adaptation |
|
||||
| `/workflow:brainstorm` | `/brainstorm <topic> [--perspectives=role1,role2]` | Multi-agent conceptual planning from different expert perspectives |
|
||||
| `/workflow:action-plan` | `[--from-brainstorming] [--skip-brainstorming] [--replan]` | Convert concepts to executable implementation plans |
|
||||
| `/workflow:implement` | `[--type=simple\|medium\|complex] [--auto-create-tasks]` | Enter implementation phase with complexity-based organization |
|
||||
| `/workflow:session:*` | `/workflow:session:start\|pause\|resume\|list\|switch\|status "task"` | Session lifecycle management with complexity adaptation |
|
||||
| `/workflow:brainstorm` | `/workflow:brainstorm <topic> [--perspectives=role1,role2]` | Multi-agent conceptual planning from different expert perspectives |
|
||||
| `/workflow:plan` | `[--from-brainstorming] [--skip-brainstorming]` | Convert concepts to executable implementation plans |
|
||||
| `/workflow:plan-deep` | `<topic> [--complexity=high] [--depth=3]` | Deep architectural planning with comprehensive analysis |
|
||||
| `/workflow:execute` | `[--type=simple\|medium\|complex] [--auto-create-tasks]` | Enter implementation phase with complexity-based organization |
|
||||
| `/workflow:review` | `[--auto-fix]` | Final quality assurance with automated testing and validation |
|
||||
| `/workflow:issue` | `create\|list\|update\|integrate\|close [options]` | Dynamic issue and change request management |
|
||||
| `/workflow:issue:*` | `create\|list\|update\|close [options]` | 🆕 Dynamic issue and change request management |
|
||||
| `/context` | `[task-id\|--filter] [--analyze] [--format=tree\|list\|json]` | Unified task and workflow context with automatic data consistency |
|
||||
|
||||
### Task Execution
|
||||
@@ -152,38 +162,39 @@ For Gemini CLI integration, configure your `settings.json` file:
|
||||
### Complex Feature Development
|
||||
```bash
|
||||
# 1. Start sophisticated workflow with full documentation
|
||||
/workflow:session start complex "Implement OAuth2 authentication system"
|
||||
/workflow:session:start "Implement OAuth2 authentication system"
|
||||
|
||||
# 2. Multi-perspective brainstorming
|
||||
/brainstorm "OAuth2 architecture design" --perspectives=system-architect,security-expert,data-architect
|
||||
/workflow:brainstorm "OAuth2 architecture design" --perspectives=system-architect,security-expert,data-architect
|
||||
|
||||
# 3. Create detailed implementation plan
|
||||
/workflow:action-plan --from-brainstorming
|
||||
/workflow:plan --from-brainstorming
|
||||
|
||||
# 4. Break down into manageable tasks
|
||||
/task:create "Backend API development"
|
||||
/task:breakdown IMPL-1 --strategy=auto
|
||||
|
||||
# 5. Execute with intelligent automation
|
||||
/gemini-execute IMPL-1.1 --yolo
|
||||
/gemini-execute IMPL-1.2 --yolo
|
||||
/gemini:execute IMPL-1.1 --yolo
|
||||
/gemini:execute IMPL-1.2 --yolo
|
||||
|
||||
# 6. Handle dynamic changes
|
||||
/workflow:issue create --type=enhancement "Add social login support"
|
||||
/workflow:issue integrate ISS-001 --position=next
|
||||
# 6. Handle dynamic changes and issues
|
||||
/workflow:issue:create "Add social login support"
|
||||
/workflow:issue:list
|
||||
/workflow:issue:update 1 --status=in-progress
|
||||
|
||||
# 7. Monitor and review
|
||||
/workflow:context --detailed
|
||||
/context --format=hierarchy
|
||||
/workflow:review --auto-fix
|
||||
```
|
||||
|
||||
### Quick Bug Fix
|
||||
```bash
|
||||
# 1. Lightweight session for simple tasks
|
||||
/workflow:session start simple "Fix login button alignment"
|
||||
/workflow:session:start "Fix login button alignment"
|
||||
|
||||
# 2. Direct analysis and implementation
|
||||
/gemini-chat "Analyze login button CSS issues in @{src/components/Login.js}"
|
||||
/gemini:analyze "Analyze login button CSS issues in @{src/components/Login.js}"
|
||||
|
||||
# 3. Create and execute single task
|
||||
/task:create "Apply CSS fix to login button"
|
||||
@@ -193,37 +204,52 @@ For Gemini CLI integration, configure your `settings.json` file:
|
||||
/workflow:review
|
||||
```
|
||||
|
||||
### Advanced Code Analysis
|
||||
### Smart Template Auto-Selection (v1.0)
|
||||
```bash
|
||||
# 1. Security audit
|
||||
/gemini-mode security "Scan authentication modules for vulnerabilities"
|
||||
# 1. Automatic template selection based on keywords
|
||||
/gemini:mode:auto "React component not rendering after state update"
|
||||
# → Auto-selects bug-fix template
|
||||
|
||||
# 2. Architecture analysis
|
||||
/gemini-mode architecture "Analyze component dependencies and data flow"
|
||||
# 2. Planning template for architecture work
|
||||
/gemini:mode:auto "design microservices architecture for user management"
|
||||
# → Auto-selects planning template
|
||||
|
||||
# 3. Performance optimization
|
||||
/gemini-mode performance "Identify bottlenecks in React rendering"
|
||||
# 3. Manual template override when needed
|
||||
/gemini:mode:auto "authentication issues" --template plan.md
|
||||
|
||||
# 4. Pattern recognition
|
||||
/gemini-mode pattern "Extract reusable component patterns"
|
||||
# 4. List available templates
|
||||
/gemini:mode:auto --list-templates
|
||||
```
|
||||
|
||||
### Intelligent Documentation Management
|
||||
```bash
|
||||
# 1. Daily development - context-aware updates
|
||||
/update-memory # Automatically detects and updates only affected modules
|
||||
/update-memory # Default: related mode - detects and updates affected modules
|
||||
/update-memory-related # Explicit: context-aware updates based on recent changes
|
||||
|
||||
# 2. After working in specific module
|
||||
cd src/api && /update-memory related # Updates API module and parent hierarchy
|
||||
/update-memory-related # Same as above, with intelligent change detection
|
||||
|
||||
# 3. Periodic full refresh
|
||||
/update-memory full # Complete project-wide documentation update
|
||||
/update-memory-full # Explicit: full project scan with depth-parallel execution
|
||||
|
||||
# 4. Post-refactoring documentation sync
|
||||
git commit -m "Major refactoring"
|
||||
/update-memory related # Intelligently updates all affected areas
|
||||
/update-memory-related # Intelligently updates all affected areas with git-aware detection
|
||||
|
||||
# 5. Project initialization or major architectural changes
|
||||
/update-memory-full # Complete baseline documentation creation
|
||||
```
|
||||
|
||||
#### Update Mode Comparison
|
||||
|
||||
| Mode | Trigger | Complexity Threshold | Best Use Case |
|
||||
|------|---------|---------------------|---------------|
|
||||
| `related` (default) | Git changes + recent files | >15 modules | Daily development, feature work |
|
||||
| `full` | Complete project scan | >20 modules | Initial setup, major refactoring |
|
||||
|
||||
## 📊 Complexity-Based Strategies
|
||||
|
||||
| Complexity | Task Count | Hierarchy Depth | File Structure | Command Strategy |
|
||||
@@ -232,19 +258,23 @@ git commit -m "Major refactoring"
|
||||
| **Medium** | 5-15 tasks | 2 levels (impl-N.M) | Enhanced + auto-generated TODO_LIST.md | Optional brainstorming → Action plan → Progress tracking |
|
||||
| **Complex** | >15 tasks | 3 levels (impl-N.M.P) | Complete document suite | Required brainstorming → Multi-agent orchestration → Deep context analysis |
|
||||
|
||||
### 🚀 Architecture v2.0 Benefits
|
||||
- **Performance**: 95% faster session operations with marker file system
|
||||
- **Consistency**: 100% data consistency with JSON-only model
|
||||
- **Efficiency**: 40-50% reduction in maintenance overhead
|
||||
- **Scalability**: Support for hundreds of concurrent sessions
|
||||
- **Onboarding**: 50% faster learning curve with progressive complexity
|
||||
### 🚀 v1.0 Release Benefits
|
||||
- **Smart Automation**: Intelligent template selection reduces manual template discovery
|
||||
- **Documentation**: 500+ lines streamlined while maintaining functionality
|
||||
- **Template System**: Dynamic discovery and YAML-based metadata parsing
|
||||
- **Cross-Platform**: Unified path handling for Windows/Linux compatibility
|
||||
- **Developer Experience**: Simplified commands with powerful auto-selection
|
||||
|
||||
## 🔧 Technical Highlights
|
||||
|
||||
- **Intelligent Context Processing**: Dynamic context construction with technology stack detection
|
||||
- **Template-Driven Architecture**: Highly customizable and extensible through templates
|
||||
- **Quality Assurance Integration**: Built-in code review and testing strategy phases
|
||||
- **Intelligent Documentation System**: 4-layer hierarchical CLAUDE.md system with strict content boundaries, context-aware updates (related/full modes), and automatic complexity-based execution scaling
|
||||
- **Intelligent Documentation System**: 4-layer hierarchical CLAUDE.md system with:
|
||||
- **Dual-mode Operations**: `related` (git-aware change detection) and `full` (complete project scan)
|
||||
- **Complexity-adaptive Execution**: Auto-delegation to memory-gemini-bridge for complex projects (>15/20 modules)
|
||||
- **Depth-parallel Processing**: Bottom-up execution ensuring child context availability for parent updates
|
||||
- **Git Integration**: Smart change detection with fallback strategies and comprehensive status reporting
|
||||
- **CLI-First Design**: Powerful, orthogonal command-line interface for automation
|
||||
|
||||
## 🎨 Design Philosophy
|
||||
|
||||
91
README_CN.md
91
README_CN.md
@@ -8,7 +8,7 @@
|
||||
|
||||
一个精密的多智能体自动化工作流框架,将复杂的软件开发任务从概念构思到实现审查转化为可管理、可追踪、AI协调的流程。
|
||||
|
||||
> **🎉 重大架构升级 (v2.0)**:最近进行了全面重构,采用 **JSON纯数据模型**、**标记文件会话管理** 和 **统一复杂度标准**。详见 [WORKFLOW_SYSTEM_UPGRADE.md](WORKFLOW_SYSTEM_UPGRADE.md)。
|
||||
> **🎉 v1.0 版本发布**:完整的 Gemini CLI 集成,包含模板系统、动态模板发现、精简文档和智能自动选择功能。详见 [CHANGELOG.md](CHANGELOG.md)。
|
||||
|
||||
## 🏗️ 架构概览
|
||||
|
||||
@@ -39,7 +39,14 @@ CCW 根据统一的任务数量阈值智能调整其文件结构和工作流程
|
||||
- **行动规划智能体**:将高层概念转化为可执行的实施计划
|
||||
- **代码开发智能体**:基于计划实现代码
|
||||
- **代码审查智能体**:审查代码质量和合规性
|
||||
- **记忆桥接智能体**:同步 Claude 和 Gemini 记忆,维护 CLAUDE.md 文件
|
||||
- **记忆桥接智能体**:智能 CLAUDE.md 文档系统,提供上下文感知更新
|
||||
|
||||
### Gemini CLI 集成 (v1.0)
|
||||
- **动态模板发现**:自动检测和加载来自 `~/.claude/prompt-templates/` 的模板
|
||||
- **智能自动选择**:根据模板关键词和描述匹配用户输入
|
||||
- **模板系统**:Bug修复、规划和自定义分析模板
|
||||
- **精简命令**:整合文档,减少500+行代码
|
||||
- **准确命令结构**:统一的 `/gemini:mode:*` 和 `/workflow:*` 命令模式
|
||||
|
||||
### 工作流会话管理
|
||||
- 创建、暂停、恢复、列出和切换工作流会话
|
||||
@@ -120,20 +127,24 @@ Invoke-Expression (Invoke-WebRequest -Uri "https://raw.githubusercontent.com/cat
|
||||
|---------|--------|-------------|
|
||||
| `/enhance-prompt` | `/enhance-prompt <输入>` | 增强和构造用户输入,添加技术上下文 |
|
||||
| `/gemini:chat` | `/gemini:chat <查询> [--all-files] [--save-session]` | 与 Gemini CLI 的简单直接交互,不使用模板 |
|
||||
| `/gemini:chat:bug-fix` | `/gemini:chat:bug-fix <错误描述> [--all-files] [--save-session]` | 使用专门的诊断模板进行错误分析 |
|
||||
| `/gemini:chat:plan` | `/gemini:chat:plan <规划主题> [--all-files] [--save-session]` | 使用专门的架构模板进行项目规划 |
|
||||
| `/gemini-execute` | `/gemini-execute <任务ID\|描述> [--yolo] [--debug]` | 智能执行器,自动推断文件上下文 |
|
||||
| `/gemini-mode` | `/gemini-mode <分析类型> <目标> [选项]` | 模板驱动的代码库分析(模式、架构、安全) |
|
||||
| `/update-memory` | `/update-memory [full\|fast\|deep] [路径]` | 分布式记忆系统管理,维护层级化 CLAUDE.md |
|
||||
| `/gemini:analyze` | `/gemini:analyze <查询> [--all-files] [--save-session]` | 直接代码库分析和调查 |
|
||||
| `/gemini:execute` | `/gemini:execute <任务ID\|描述> [--yolo] [--debug]` | 智能执行器,自动推断文件上下文 |
|
||||
| `/gemini:mode:auto` | `/gemini:mode:auto "<描述>"` | 🆕 基于用户输入分析自动选择和执行合适的模板 |
|
||||
| `/gemini:mode:bug-index` | `/gemini:mode:bug-index <错误描述>` | 使用专门的诊断模板进行错误分析 |
|
||||
| `/gemini:mode:plan` | `/gemini:mode:plan <规划主题>` | 使用专门的架构模板进行项目规划 |
|
||||
| `/update-memory` | `/update-memory [related\|full]` | 智能 CLAUDE.md 文档系统,提供上下文感知更新 |
|
||||
| `/update-memory-full` | `/update-memory-full` | 🆕 完整的项目级 CLAUDE.md 文档更新,采用深度并行执行 |
|
||||
| `/update-memory-related` | `/update-memory-related` | 🆕 基于近期变更的上下文感知文档更新 |
|
||||
|
||||
### 工作流管理
|
||||
|
||||
| 命令 | 语法 | 描述 |
|
||||
|---------|--------|-------------|
|
||||
| `/workflow:session` | `start\|pause\|resume\|list\|switch\|status [复杂度] ["任务"]` | 会话生命周期管理,支持复杂度自适应 |
|
||||
| `/workflow:brainstorm` | `/brainstorm <主题> [--perspectives=角色1,角色2]` | 多智能体概念规划,提供不同专家视角 |
|
||||
| `/workflow:action-plan` | `[--from-brainstorming] [--skip-brainstorming] [--replan]` | 将概念转化为可执行的实施计划 |
|
||||
| `/workflow:implement` | `[--type=simple\|medium\|complex] [--auto-create-tasks]` | 进入实施阶段,基于复杂度组织流程 |
|
||||
| `/workflow:session:*` | `/workflow:session:start\|pause\|resume\|list\|switch\|status "任务"` | 会话生命周期管理,支持复杂度自适应 |
|
||||
| `/workflow:brainstorm` | `/workflow:brainstorm <主题> [--perspectives=角色1,角色2]` | 多智能体概念规划,提供不同专家视角 |
|
||||
| `/workflow:plan` | `[--from-brainstorming] [--skip-brainstorming]` | 将概念转化为可执行的实施计划 |
|
||||
| `/workflow:plan-deep` | `<主题> [--complexity=high] [--depth=3]` | 深度架构规划与全面分析 |
|
||||
| `/workflow:execute` | `[--type=simple\|medium\|complex] [--auto-create-tasks]` | 进入实施阶段,基于复杂度组织流程 |
|
||||
| `/workflow:review` | `[--auto-fix]` | 最终质量保证,自动化测试和验证 |
|
||||
| `/workflow:issue` | `create\|list\|update\|integrate\|close [选项]` | 动态问题和变更请求管理 |
|
||||
| `/context` | `[任务ID\|--filter] [--analyze] [--format=tree\|list\|json]` | 统一的任务和工作流上下文,自动数据一致性 |
|
||||
@@ -152,38 +163,39 @@ Invoke-Expression (Invoke-WebRequest -Uri "https://raw.githubusercontent.com/cat
|
||||
### 复杂功能开发
|
||||
```bash
|
||||
# 1. 启动完整文档的复杂工作流
|
||||
/workflow:session start complex "实现 OAuth2 认证系统"
|
||||
/workflow:session:start "实现 OAuth2 认证系统"
|
||||
|
||||
# 2. 多视角头脑风暴
|
||||
/brainstorm "OAuth2 架构设计" --perspectives=system-architect,security-expert,data-architect
|
||||
/workflow:brainstorm "OAuth2 架构设计" --perspectives=system-architect,security-expert,data-architect
|
||||
|
||||
# 3. 创建详细实施计划
|
||||
/workflow:action-plan --from-brainstorming
|
||||
/workflow:plan --from-brainstorming
|
||||
|
||||
# 4. 分解为可管理的任务
|
||||
/task:create "后端 API 开发"
|
||||
/task:breakdown IMPL-1 --strategy=auto
|
||||
|
||||
# 5. 智能自动化执行
|
||||
/gemini-execute IMPL-1.1 --yolo
|
||||
/gemini-execute IMPL-1.2 --yolo
|
||||
/gemini:execute IMPL-1.1 --yolo
|
||||
/gemini:execute IMPL-1.2 --yolo
|
||||
|
||||
# 6. 处理动态变更
|
||||
/workflow:issue create --type=enhancement "添加社交登录支持"
|
||||
/workflow:issue integrate ISS-001 --position=next
|
||||
# 6. 处理动态变更和问题
|
||||
/workflow:issue:create "添加社交登录支持"
|
||||
/workflow:issue:list
|
||||
/workflow:issue:update 1 --status=in-progress
|
||||
|
||||
# 7. 监控和审查
|
||||
/workflow:context --detailed
|
||||
/context --format=hierarchy
|
||||
/workflow:review --auto-fix
|
||||
```
|
||||
|
||||
### 快速Bug修复
|
||||
```bash
|
||||
# 1. 简单任务的轻量级会话
|
||||
/workflow:session start simple "修复登录按钮对齐问题"
|
||||
/workflow:session:start "修复登录按钮对齐问题"
|
||||
|
||||
# 2. 直接分析和实施
|
||||
/gemini-chat "分析 @{src/components/Login.js} 中登录按钮的 CSS 问题"
|
||||
/gemini:analyze "分析 @{src/components/Login.js} 中登录按钮的 CSS 问题"
|
||||
|
||||
# 3. 创建并执行单一任务
|
||||
/task:create "应用登录按钮的 CSS 修复"
|
||||
@@ -208,6 +220,35 @@ Invoke-Expression (Invoke-WebRequest -Uri "https://raw.githubusercontent.com/cat
|
||||
/gemini-mode pattern "提取可重用的组件模式"
|
||||
```
|
||||
|
||||
### 智能文档管理
|
||||
```bash
|
||||
# 1. 日常开发 - 上下文感知更新
|
||||
/update-memory # 默认:related 模式 - 检测并更新受影响的模块
|
||||
/update-memory-related # 显式:基于近期变更的上下文感知更新
|
||||
|
||||
# 2. 在特定模块中工作后
|
||||
cd src/api && /update-memory related # 更新 API 模块和父级层次结构
|
||||
/update-memory-related # 同上,具有智能变更检测
|
||||
|
||||
# 3. 定期完整刷新
|
||||
/update-memory full # 完整的项目级文档更新
|
||||
/update-memory-full # 显式:使用深度并行执行的完整项目扫描
|
||||
|
||||
# 4. 重构后的文档同步
|
||||
git commit -m "重大重构"
|
||||
/update-memory-related # 通过 git 感知检测智能更新所有受影响区域
|
||||
|
||||
# 5. 项目初始化或重大架构变更
|
||||
/update-memory-full # 完整的基准文档创建
|
||||
```
|
||||
|
||||
#### 更新模式比较
|
||||
|
||||
| 模式 | 触发器 | 复杂度阈值 | 最佳使用场景 |
|
||||
|------|---------|-----------|--------------|
|
||||
| `related` (默认) | Git 变更 + 近期文件 | >15个模块 | 日常开发、功能开发 |
|
||||
| `full` | 完整项目扫描 | >20个模块 | 初始设置、重大重构 |
|
||||
|
||||
## 📊 基于复杂度的策略
|
||||
|
||||
| 复杂度 | 任务数量 | 层次深度 | 文件结构 | 命令策略 |
|
||||
@@ -228,7 +269,11 @@ Invoke-Expression (Invoke-WebRequest -Uri "https://raw.githubusercontent.com/cat
|
||||
- **智能上下文处理**:基于技术栈检测的动态上下文构建
|
||||
- **模板驱动架构**:通过模板实现高度可定制和可扩展性
|
||||
- **质量保证集成**:内置代码审查和测试策略阶段
|
||||
- **分布式记忆系统 (DMS)**:通过 CLAUDE.md 文件维护项目级共享记忆
|
||||
- **智能文档系统**:4层分层 CLAUDE.md 系统,具有:
|
||||
- **双模式操作**:`related`(git感知变更检测)和 `full`(完整项目扫描)
|
||||
- **复杂度自适应执行**:复杂项目(>15/20个模块)自动委托给 memory-gemini-bridge
|
||||
- **深度并行处理**:自下而上执行,确保子上下文可用于父级更新
|
||||
- **Git集成**:智能变更检测,带回退策略和综合状态报告
|
||||
- **CLI 优先设计**:强大、正交的命令行界面,便于自动化
|
||||
|
||||
## 🎨 设计理念
|
||||
|
||||
Reference in New Issue
Block a user