memory-manage

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

memory-manage

内存管理

Unified management of the ai-context/ memory layer. Three modes: init, update, maintain.
Triggers:
/memory-init
,
/memory-update
,
/memory-maintain
, initialize memory, update memory, maintain memory, memory housekeeping, clean ai-context

统一管理ai-context/内存层。包含三种模式:初始化(init)、更新(update)、维护(maintain)。
触发指令
/memory-init
,
/memory-update
,
/memory-maintain
, initialize memory, update memory, maintain memory, memory housekeeping, clean ai-context

Mode Detection

模式检测

Determine the mode from the invocation:
  • /memory-init
    or "initialize memory" or "generate ai-context" → init mode
  • /memory-update
    or "update memory" or "sync memory" or "record session" → update mode
  • /memory-maintain
    or "maintain memory" or "memory housekeeping" or "clean ai-context" → maintain mode

根据调用指令判断模式:
  • /memory-init
    或 "initialize memory" 或 "generate ai-context" → 初始化模式(init mode)
  • /memory-update
    或 "update memory" 或 "sync memory" 或 "record session" → 更新模式(update mode)
  • /memory-maintain
    或 "maintain memory" 或 "memory housekeeping" 或 "clean ai-context" → 维护模式(maintain mode)

Mode: init

模式:初始化(init)

Creates the 5 core ai-context/ files from scratch by reading the project.
Use when: Project has no
ai-context/
yet, or you want to regenerate from scratch.
通过读取项目内容,从头创建5个核心ai-context/文件。
适用场景:项目尚未创建
ai-context/
目录,或需要从头重新生成该目录下的文件。

Process

执行流程

  1. Project inventory: Read configuration files, folder structure, README, representative source files, tests, CI/CD configs.
  2. Generate files:
    • ai-context/stack.md
      — tech stack, versions, key tools
    • ai-context/architecture.md
      — architectural decisions and rationale
    • ai-context/conventions.md
      — naming patterns, code conventions
    • ai-context/known-issues.md
      — known bugs, tech debt, gotchas
    • ai-context/changelog-ai.md
      — empty, ready for session entries
  3. Feature stubs: Scan for bounded contexts (directories with domain logic). Create
    ai-context/features/_template.md
    and stub files for discovered domains.
  4. Report: List files created and coverage summary.

  1. 项目盘点:读取配置文件、文件夹结构、README、代表性源码文件、测试文件、CI/CD配置文件。
  2. 生成文件
    • ai-context/stack.md
      — 技术栈、版本信息、核心工具
    • ai-context/architecture.md
      — 架构决策及理由
    • ai-context/conventions.md
      — 命名规范、代码约定
    • ai-context/known-issues.md
      — 已知Bug、技术债务、注意事项
    • ai-context/changelog-ai.md
      — 空文件,用于记录会话内容
  3. 功能存根生成:扫描有界上下文(包含领域逻辑的目录)。创建
    ai-context/features/_template.md
    模板文件,并为发现的领域生成存根文件。
  4. 生成报告:列出已创建的文件及覆盖范围总结。

Mode: update

模式:更新(update)

Incrementally updates ai-context/ with work done in the current session.
Use when: After completing significant work (SDD cycles, architecture changes, bug fixes).
根据当前会话完成的工作,增量更新ai-context/目录下的文件。
适用场景:完成重要工作后(如SDD周期迭代、架构变更、Bug修复)。

Process

执行流程

  1. Analyze session: Review what changed — files created/modified, decisions made, bugs fixed, conventions established.
  2. Update relevant files:
    • ai-context/stack.md
      — new dependencies, version changes
    • ai-context/architecture.md
      — new decisions, pattern changes
    • ai-context/conventions.md
      — new naming patterns, style changes
    • ai-context/known-issues.md
      — new issues found, resolved issues marked
    • ai-context/changelog-ai.md
      — append entry with date, summary, files affected
    • ai-context/features/<domain>.md
      — update if relevant domain was touched
  3. Preserve: Never overwrite
    [manual]
    sections. Only update
    [auto-updated]
    markers.

  1. 会话分析:回顾会话中的变更内容——创建/修改的文件、做出的决策、修复的Bug、确立的规范。
  2. 更新相关文件
    • ai-context/stack.md
      — 添加新依赖、更新版本信息
    • ai-context/architecture.md
      — 记录新决策、架构模式变更
    • ai-context/conventions.md
      — 更新命名规范、代码风格变更
    • ai-context/known-issues.md
      — 添加新发现的问题、标记已解决的问题
    • ai-context/changelog-ai.md
      — 追加条目,包含日期、内容摘要、受影响的文件
    • ai-context/features/<domain>.md
      — 若相关领域有变更则进行更新
  3. 保留规则:绝不覆盖
    [manual]
    标记的手动维护部分。仅更新
    [auto-updated]
    标记的自动更新区域。

Mode: maintain

模式:维护(maintain)

Periodic housekeeping: archive old entries, separate resolved issues, detect gaps.
Use when: changelog-ai.md is long (30+ entries), known-issues has resolved items, or at the start of a new project phase.
定期整理工作:归档旧条目、分离已解决的问题、检测文件缺失。
适用场景
changelog-ai.md
条目过多(超过30条)、
known-issues.md
中有已解决的问题,或进入项目新阶段时。

Process

执行流程

  1. Changelog archival: If
    changelog-ai.md
    has more than 30 entries, move older entries to
    changelog-ai-archive.md
    .
  2. Known-issues cleanup: Move resolved items from
    known-issues.md
    to
    known-issues-archive.md
    .
  3. Index generation: Create/update
    ai-context/index.md
    listing all ai-context/ files with one-line descriptions.
  4. Gap detection: Check if CLAUDE.md references ai-context/ files that don't exist. Report gaps.
  5. Dry-run first: Present all proposed changes, require user confirmation before applying.

  1. 变更日志归档:若
    changelog-ai.md
    条目超过30条,将旧条目迁移至
    changelog-ai-archive.md
  2. 已知问题清理:将
    known-issues.md
    中已解决的问题迁移至
    known-issues-archive.md
  3. 生成索引:创建/更新
    ai-context/index.md
    ,列出所有ai-context/文件并添加一行描述。
  4. 缺失检测:检查CLAUDE.md中引用的ai-context/文件是否存在,报告缺失情况。
  5. 先执行预演:展示所有拟执行的变更,需用户确认后再应用。

Rules

规则

  • Init mode MUST NOT run if ai-context/ already exists — warn and suggest update mode instead
  • Update mode MUST NOT create new core files — only modify existing ones
  • Maintain mode MUST present dry-run before any destructive action (archival, moves)
  • All modes are read-heavy, write-light — the goal is accurate, concise documentation
  • Never overwrite
    [manual]
    sections in any file
  • Feature file updates follow the format defined in
    skills/feature-domain-expert/SKILL.md
  • ai-context/
    目录已存在,禁止运行初始化模式(init mode)——需发出警告并建议使用更新模式
  • 更新模式(update mode)禁止创建新的核心文件——仅可修改现有文件
  • 维护模式(maintain mode)在执行任何破坏性操作(归档、迁移)前必须先进行预演
  • 所有模式均为“多读少写”——目标是生成准确、简洁的文档
  • 绝不覆盖任何文件中
    [manual]
    标记的手动维护部分
  • 功能文件的更新需遵循
    skills/feature-domain-expert/SKILL.md
    中定义的格式