mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-06 01:54:11 +08:00
175 lines
5.1 KiB
Plaintext
175 lines
5.1 KiB
Plaintext
---
|
|
title: /memory:docs-related-cli
|
|
sidebar_label: /memory:docs-related-cli
|
|
sidebar_position: 5
|
|
description: Generate CLI documentation for git-changed modules
|
|
---
|
|
|
|
# /memory:docs-related-cli
|
|
|
|
Generate CLI documentation for modules affected by git changes using batched agent execution with automatic tool fallback.
|
|
|
|
## Overview
|
|
|
|
The `/memory:docs-related-cli` command generates documentation only for modules affected by recent git changes, providing faster documentation updates for daily development.
|
|
|
|
**Parameters**:
|
|
- `--tool <gemini|qwen|codex>`: Primary tool (default: gemini)
|
|
|
|
**Execution Flow**:
|
|
1. Change Detection → 2. Plan Presentation → 3. Batched Generation → 4. Verification
|
|
|
|
## Features
|
|
|
|
- **Changed Module Detection** - Uses git diff to identify affected modules
|
|
- **Intelligent Batching** - Groups modules by depth (4 modules/agent)
|
|
- **Automatic Fallback** - gemini→qwen→codex on failure
|
|
- **Depth Sequential** - Process depths N→0, parallel batches within depth
|
|
- **Smart Filtering** - Auto-detects and skips tests/build/config/docs
|
|
- **Single Strategy** - Uses single-layer documentation for speed
|
|
|
|
## Usage
|
|
|
|
```bash
|
|
# Generate docs for changed modules
|
|
/memory:docs-related-cli
|
|
|
|
# Use specific tool
|
|
/memory:docs-related-cli --tool qwen
|
|
```
|
|
|
|
## Tool Fallback Hierarchy
|
|
|
|
```javascript
|
|
--tool gemini → [gemini, qwen, codex] // default
|
|
--tool qwen → [qwen, gemini, codex]
|
|
--tool codex → [codex, gemini, qwen]
|
|
```
|
|
|
|
## Execution Flow
|
|
|
|
### Phase 1: Change Detection & Analysis
|
|
|
|
```javascript
|
|
// Detect changed modules
|
|
Bash({command: "ccw tool exec detect_changed_modules '{\"format\":\"list\"}'", run_in_background: false});
|
|
|
|
// Cache git changes
|
|
Bash({command: "git add -A 2>/dev/null || true", run_in_background: false});
|
|
```
|
|
|
|
**Parse output** `depth:N|path:<PATH>|change:<TYPE>` to extract affected modules.
|
|
|
|
**Smart filter**: Auto-detect and skip tests/build/config/docs based on project tech stack.
|
|
|
|
**Fallback**: If no changes detected, use recent modules (first 10 by depth).
|
|
|
|
### Phase 2: Plan Presentation
|
|
|
|
- Parse `--tool` (default: gemini)
|
|
- Refresh code index for accurate change detection
|
|
- Detect changed modules
|
|
- **Smart filter modules** (auto-detect tech stack, skip tests/build/config)
|
|
- Cache git changes
|
|
- Apply fallback if no changes
|
|
- Construct tool fallback order
|
|
- **Present filtered plan** with change types
|
|
- **Wait for y/n confirmation**
|
|
|
|
### Phase 3: Batched Documentation Generation
|
|
|
|
```javascript
|
|
let modules_by_depth = group_by_depth(changed_modules);
|
|
let tool_order = construct_tool_order(primary_tool);
|
|
|
|
for (let depth of sorted_depths.reverse()) { // N → 0
|
|
let batches = batch_modules(modules_by_depth[depth], 4);
|
|
|
|
for (let batch of batches) {
|
|
let parallel_tasks = batch.map(module => {
|
|
return async () => {
|
|
for (let tool of tool_order) {
|
|
Bash({
|
|
command: `cd ${module.path} && ccw tool exec generate_module_docs '{"strategy":"single","sourcePath":".","projectName":"${project_name}","tool":"${tool}"}'`,
|
|
run_in_background: false
|
|
});
|
|
if (bash_result.exit_code === 0) {
|
|
report(`✅ ${module.path} docs generated with ${tool}`);
|
|
return true;
|
|
}
|
|
}
|
|
report(`❌ FAILED: ${module.path} failed all tools`);
|
|
return false;
|
|
};
|
|
});
|
|
await Promise.all(parallel_tasks.map(task => task()));
|
|
}
|
|
}
|
|
```
|
|
|
|
### Phase 4: Verification
|
|
|
|
- Verify documentation files were created
|
|
- Display statistics
|
|
- Show summary of generated docs
|
|
|
|
## Strategy Selection
|
|
|
|
**Related Mode** uses `single` strategy:
|
|
- Generates single document per module
|
|
- Faster than full mode's multi-layer approach
|
|
- Suitable for iterative development
|
|
|
|
## Comparison with Full CLI Documentation
|
|
|
|
| Aspect | Related Docs | Full Docs |
|
|
|--------|--------------|-----------|
|
|
| **Scope** | Changed modules only | All project modules |
|
|
| **Speed** | Fast (minutes) | Slower (10-30 min) |
|
|
| **Use case** | Daily development | Major refactoring |
|
|
| **Strategy** | single only | full for depth>=3 |
|
|
| **Trigger** | After commits | After major changes |
|
|
| **Batching** | 4 modules/agent | 4 modules/agent |
|
|
| **Fallback** | gemini→qwen→codex | gemini→qwen→codex |
|
|
|
|
## Examples
|
|
|
|
### Basic Usage
|
|
|
|
```bash
|
|
# Document changed modules after commits
|
|
/memory:docs-related-cli
|
|
|
|
# Output:
|
|
# Detecting git changes...
|
|
# Found 8 changed modules
|
|
# Filtered: 3 test modules skipped
|
|
# Plan: Generate docs for 5 modules
|
|
# Confirm? (y/n): y
|
|
#
|
|
# Depth 3: [4/4] ✅
|
|
# Depth 2: [1/1] ✅
|
|
# Summary: 5/5 modules documented
|
|
```
|
|
|
|
### Tool Selection
|
|
|
|
```bash
|
|
# Use Qwen for generation
|
|
/memory:docs-related-cli --tool qwen
|
|
```
|
|
|
|
## Related Commands
|
|
|
|
- **/memory:docs-full-cli** - Generate docs for all modules
|
|
- **/memory:update-related** - Update CLAUDE.md for changed modules
|
|
- **/memory:compact** - Compact session memory
|
|
|
|
## Notes
|
|
|
|
- **Smart filtering** automatically skips test/build/config directories
|
|
- **Change detection** uses git diff to find affected modules
|
|
- **Single strategy** optimizes for speed in iterative development
|
|
- **Tool fallback** ensures completion even if primary tool fails
|
|
- **Verification** confirms all documentation files created successfully
|