memory-manage
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseMemory Management Skill
内存管理技能
Unified entry point for project memory (CLAUDE.md) updates and documentation (API.md/README.md) generation. Routes to specialized sub-commands via arguments or interactive needs assessment.
这是项目记忆文件(CLAUDE.md)更新与项目文档(API.md/README.md)生成的统一入口,可通过参数或交互式需求评估路由到专用子命令执行。
Architecture Overview
架构概述
┌──────────────────────────────────────────────────────┐
│ Memory Manage (Router) │
│ → Parse input → Detect mode → Route to phase │
└───────────────┬──────────────────────────────────────┘
│
┌───────┴───────┐
↓ ↓
┌───────────┐ ┌───────────┐
│ CLAUDE.md │ │ Docs │
│ 管理 │ │ 生成 │
└─────┬─────┘ └─────┬─────┘
│ │
┌────┼────┐ ┌────┴────┐
↓ ↓ ↓ ↓ ↓
Full Related Single Full Related
全量 增量 单模块 全量 增量┌──────────────────────────────────────────────────────┐
│ Memory Manage (Router) │
│ → Parse input → Detect mode → Route to phase │
└───────────────┬──────────────────────────────────────┘
│
┌───────┴───────┐
↓ ↓
┌───────────┐ ┌───────────┐
│ CLAUDE.md │ │ Docs │
│ 管理 │ │ 生成 │
└─────┬─────┘ └─────┬─────┘
│ │
┌────┼────┐ ┌────┴────┐
↓ ↓ ↓ ↓ ↓
Full Related Single Full Related
全量 增量 单模块 全量 增量Execution Flow
执行流程
Step 1: Parse Input & Route
步骤1:解析输入与路由
Detect execution mode from user input:
Auto-Route Rules (priority order):
| Signal | Route | Examples |
|---|---|---|
| Explicit sub-command token | → Direct dispatch | |
| Keyword: full, 全量, all, entire + update/claude | → update-full | "全量更新claude" |
| Keyword: related, changed, 增量, diff + update/claude | → update-related | "更新变更模块" |
| Keyword: single, module, 单模块 + path-like token | → update-single | "更新 src/auth 模块" |
| Keyword: docs, documentation, 文档 + full/all/全量 | → docs-full | "全量生成文档" |
| Keyword: docs, documentation, 文档 + related/changed/增量 | → docs-related | "增量生成文档" |
| Ambiguous or no arguments | → AskUserQuestion | |
Valid sub-command tokens: , , , ,
update-fullupdate-relatedupdate-singledocs-fulldocs-relatedDirect dispatch examples:
input = "update-full --tool qwen"
→ subcommand = "update-full", remainingArgs = "--tool qwen"
→ Read phases/01-update-full.md, execute
input = "update-single src/auth --tool gemini"
→ subcommand = "update-single", remainingArgs = "src/auth --tool gemini"
→ Read phases/03-update-single.md, executeWhen ambiguous or no arguments, proceed to Step 2.
从用户输入中检测执行模式:
自动路由规则(按优先级排序):
| 触发信号 | 路由目标 | 示例 |
|---|---|---|
| 显式子命令标记 | → 直接分发 | |
| 关键词:full, 全量, all, entire + update/claude | → update-full | "全量更新claude" |
| 关键词:related, changed, 增量, diff + update/claude | → update-related | "更新变更模块" |
| 关键词:single, module, 单模块 + 类路径标记 | → update-single | "更新 src/auth 模块" |
| 关键词:docs, documentation, 文档 + full/all/全量 | → docs-full | "全量生成文档" |
| 关键词:docs, documentation, 文档 + related/changed/增量 | → docs-related | "增量生成文档" |
| 输入含义模糊或无参数 | → AskUserQuestion | |
有效子命令标记:、、、、
update-fullupdate-relatedupdate-singledocs-fulldocs-related直接分发示例:
input = "update-full --tool qwen"
→ subcommand = "update-full", remainingArgs = "--tool qwen"
→ Read phases/01-update-full.md, execute
input = "update-single src/auth --tool gemini"
→ subcommand = "update-single", remainingArgs = "src/auth --tool gemini"
→ Read phases/03-update-single.md, execute当输入含义模糊或未携带参数时,进入步骤2。
Step 2: Interactive Needs Assessment
步骤2:交互式需求评估
Q1 — 确定内容类别:
AskUserQuestion({
questions: [{
question: "你要管理哪类内容?",
header: "类别",
multiSelect: false,
options: [
{
label: "CLAUDE.md (项目记忆)",
description: "更新模块指令文件,帮助Claude理解代码库结构和约定"
},
{
label: "项目文档 (API+README)",
description: "生成API.md和README.md到.workflow/docs/目录"
}
]
}]
})Q2a — CLAUDE.md 管理范围 (用户选了 CLAUDE.md):
AskUserQuestion({
questions: [{
question: "CLAUDE.md 更新范围?",
header: "范围",
multiSelect: false,
options: [
{
label: "增量更新 (Recommended)",
description: "仅更新git变更模块及其父级,日常开发首选"
},
{
label: "全量更新",
description: "更新所有模块,3层架构bottom-up,适合重大重构后"
},
{
label: "单模块更新",
description: "指定一个模块,Explore深度分析后生成说明书式文档"
}
]
}]
})Route mapping:
- "增量更新" → → Ref: phases/02-update-related.md
update-related - "全量更新" → → Ref: phases/01-update-full.md
update-full - "单模块更新" → → continue to Q3
update-single
Q2b — 文档生成范围 (用户选了项目文档):
AskUserQuestion({
questions: [{
question: "文档生成范围?",
header: "范围",
multiSelect: false,
options: [
{
label: "增量生成 (Recommended)",
description: "仅为git变更模块生成/更新文档,日常开发首选"
},
{
label: "全量生成",
description: "所有模块+项目级文档(ARCHITECTURE.md等),适合初始化"
}
]
}]
})Route mapping:
- "增量生成" → → Ref: phases/05-docs-related.md
docs-related - "全量生成" → → Ref: phases/04-docs-full.md
docs-full
Q3 — 补充路径 (仅 update-single 需要,且无路径参数时):
AskUserQuestion({
questions: [{
question: "请指定要更新的模块路径:",
header: "路径",
multiSelect: false,
options: [
{
label: "src",
description: "src 目录"
},
{
label: ".",
description: "项目根目录"
}
]
}]
})用户可选 "Other" 输入自定义路径。
Q1 — 确定内容类别:
AskUserQuestion({
questions: [{
question: "你要管理哪类内容?",
header: "类别",
multiSelect: false,
options: [
{
label: "CLAUDE.md (项目记忆)",
description: "更新模块指令文件,帮助Claude理解代码库结构和约定"
},
{
label: "项目文档 (API+README)",
description: "生成API.md和README.md到.workflow/docs/目录"
}
]
}]
})Q2a — CLAUDE.md 管理范围 (用户选了 CLAUDE.md):
AskUserQuestion({
questions: [{
question: "CLAUDE.md 更新范围?",
header: "范围",
multiSelect: false,
options: [
{
label: "增量更新 (Recommended)",
description: "仅更新git变更模块及其父级,日常开发首选"
},
{
label: "全量更新",
description: "更新所有模块,3层架构bottom-up,适合重大重构后"
},
{
label: "单模块更新",
description: "指定一个模块,Explore深度分析后生成说明书式文档"
}
]
}]
})路由映射:
- "增量更新" → → 参考:phases/02-update-related.md
update-related - "全量更新" → → 参考:phases/01-update-full.md
update-full - "单模块更新" → → 继续进入Q3
update-single
Q2b — 文档生成范围 (用户选了项目文档):
AskUserQuestion({
questions: [{
question: "文档生成范围?",
header: "范围",
multiSelect: false,
options: [
{
label: "增量生成 (Recommended)",
description: "仅为git变更模块生成/更新文档,日常开发首选"
},
{
label: "全量生成",
description: "所有模块+项目级文档(ARCHITECTURE.md等),适合初始化"
}
]
}]
})路由映射:
- "增量生成" → → 参考:phases/05-docs-related.md
docs-related - "全量生成" → → 参考:phases/04-docs-full.md
docs-full
Q3 — 补充路径 (仅 update-single 需要,且无路径参数时):
AskUserQuestion({
questions: [{
question: "请指定要更新的模块路径:",
header: "路径",
multiSelect: false,
options: [
{
label: "src",
description: "src 目录"
},
{
label: ".",
description: "项目根目录"
}
]
}]
})用户可选 "Other" 输入自定义路径。
Step 3: Execute Selected Phase
步骤3:执行选定阶段
Based on routing result, read and execute the corresponding phase:
Phase Reference Documents (read on-demand when phase executes):
| Mode | Document | Purpose |
|---|---|---|
| update-full | phases/01-update-full.md | Full CLAUDE.md update, 3-layer architecture, batched agents |
| update-related | phases/02-update-related.md | Git-changed CLAUDE.md update, depth-first |
| update-single | phases/03-update-single.md | Single module CLAUDE.md, Explore + handbook style |
| docs-full | phases/04-docs-full.md | Full API.md + README.md generation |
| docs-related | phases/05-docs-related.md | Git-changed docs generation, incremental |
根据路由结果,读取并执行对应阶段的逻辑:
阶段参考文档(阶段执行时按需读取):
| 模式 | 文档 | 用途 |
|---|---|---|
| update-full | phases/01-update-full.md | CLAUDE.md全量更新,3层架构,批量化Agent处理 |
| update-related | phases/02-update-related.md | 仅更新Git变更的CLAUDE.md内容,深度优先处理 |
| update-single | phases/03-update-single.md | 单模块CLAUDE.md更新,Explore分析+手册式文档风格 |
| docs-full | phases/04-docs-full.md | 全量生成API.md + README.md |
| docs-related | phases/05-docs-related.md | 仅为Git变更模块生成文档,增量更新 |
Shared Configuration
通用配置
Tool Fallback Hierarchy
工具降级优先级
All sub-commands share the same fallback:
--tool gemini → [gemini, qwen, codex] // default
--tool qwen → [qwen, gemini, codex]
--tool codex → [codex, gemini, qwen]所有子命令共用同一套降级规则:
--tool gemini → [gemini, qwen, codex] // default
--tool qwen → [qwen, gemini, codex]
--tool codex → [codex, gemini, qwen]Common Parameters
通用参数
| Parameter | Description | Default | Used By |
|---|---|---|---|
| Primary CLI tool | gemini | All |
| Target directory | . | update-full, docs-full |
| Module path | (required) | update-single |
| 参数 | 描述 | 默认值 | 适用命令 |
|---|---|---|---|
| 首选CLI工具 | gemini | 所有命令 |
| 目标目录 | . | update-full, docs-full |
| 模块路径 | (必填) | update-single |
Batching Thresholds
批处理阈值
| Sub-Command | Direct Execution | Agent Batch | Batch Size |
|---|---|---|---|
| update-full | <20 modules | ≥20 modules | 4/agent |
| update-related | <15 modules | ≥15 modules | 4/agent |
| update-single | always single | N/A | 1 |
| docs-full | <20 modules | ≥20 modules | 4/agent |
| docs-related | <15 modules | ≥15 modules | 4/agent |
| 子命令 | 直接执行阈值 | Agent批处理阈值 | 每批大小 |
|---|---|---|---|
| update-full | <20个模块 | ≥20个模块 | 4个/Agent |
| update-related | <15个模块 | ≥15个模块 | 4个/Agent |
| update-single | 始终单线程执行 | N/A | 1 |
| docs-full | <20个模块 | ≥20个模块 | 4个/Agent |
| docs-related | <15个模块 | ≥15个模块 | 4个/Agent |
Core Rules
核心规则
- Route before execute: Determine sub-command before any execution
- Phase doc is truth: All execution logic lives in phase docs, router only dispatches
- Read on-demand: Only read the selected phase doc, never load all
- Pass arguments through: Forward remaining args unchanged to sub-command
- User confirmation: Each sub-command handles its own plan presentation and y/n confirmation
- 先路由后执行:在执行任何操作前先确定对应的子命令
- 阶段文档为唯一标准:所有执行逻辑都存放在阶段文档中,路由仅负责分发
- 按需读取:仅读取选定的阶段文档,绝不加载全部文档
- 参数透传:将剩余参数原封不动转发给子命令
- 用户确认:每个子命令自行处理执行方案展示与是否执行的确认逻辑
Error Handling
错误处理
| Error | Resolution |
|---|---|
| Unknown sub-command | Fall through to interactive flow |
| Phase doc not found | Abort with file path error |
| Missing path for update-single | Prompt via Q3 |
| Sub-command execution fails | Follow phase doc's own error handling |
| 错误类型 | 解决方案 |
|---|---|
| 未知子命令 | 降级进入交互式流程 |
| 阶段文档不存在 | 抛出文件路径错误并终止执行 |
| update-single命令缺失路径参数 | 通过Q3提示用户输入 |
| 子命令执行失败 | 遵循对应阶段文档自带的错误处理逻辑 |