AgentSkillsCN

Configure Memory Bank

配置内存银行

SKILL.md

Configure Memory Bank

Supplementary reference for memory bank configuration. Consult skill.json first for goal and acceptance criteria.


Initialization Protocol

Trigger

  • New project with no memory-bank/ directory
  • User requests memory bank setup
  • Agent starts work and no memory bank exists

Steps

  1. Create memory-bank/ at repo root (or at package level for monorepos)
  2. Create all 6 core files using seed content from project context
  3. Create memory-bank/details/ directory (empty initially)
  4. Populate each file following Core File Specifications

Seed Content Rules

  • Never create empty files — each must have at least a heading and 2–3 bullets
  • Derive content from: project README, package.json, existing docs, conversation context
  • If no context available, use structured placeholders with [TODO] markers
  • Mark the initialization in progress.md

Core File Specifications

Each file has a defined purpose, required sections, and size limit (~300 words). Use bullets and tables over prose.

projectbrief.md

Purpose: Foundation document — shapes all other files.

SectionContent
Project NameOne-line identifier
GoalWhat the project achieves (1–2 sentences)
RequirementsBulleted list of core requirements
ConstraintsTechnical/business constraints
Success CriteriaHow to know it's done

productContext.md

Purpose: Why the project exists and how it should work.

SectionContent
Problem StatementWhat problem this solves (1–2 sentences)
Target UsersWho uses this
User Experience GoalsWhat the experience should feel like
Key WorkflowsOne-line summaries of main flows

systemPatterns.md

Purpose: Architecture, technical decisions, and design patterns.

SectionContent
ArchitectureHigh-level structure (diagram or bullet list)
Key PatternsDesign patterns in use (name + one-line description each)
Technical DecisionsDecision + rationale (table format preferred)
Component RelationshipsHow major parts connect

techContext.md

Purpose: Technologies, setup, and development environment.

SectionContent
Tech StackLanguage, framework, runtime versions
Dev SetupSteps to get running (commands, env vars)
DependenciesKey dependencies with purpose
ConventionsNaming, file structure, coding style rules

activeContext.md

Purpose: Current work snapshot — what's happening now.

SectionContent
Current Focus1–3 items actively being worked on
Recent ChangesLast 3–5 changes (one-line each, newest first)
Next StepsPrioritized list of upcoming work
Active DecisionsOpen questions or choices pending resolution
BlockersAnything preventing progress

progress.md

Purpose: Status tracking and decision history.

SectionContent
StatusOverall project phase (e.g., "Phase 1: Foundation")
What WorksFeatures/components confirmed working
What's LeftRemaining work items
Known IssuesBugs or limitations
Decision LogKey decisions as table: Date

Detail Offloading

When to Offload

  • Core file exceeds ~300 words
  • A section contains deep technical detail beyond its one-line summary
  • Historical content no longer needs prominence but should be preserved

Naming Convention

code
details/{prefix}_{category}_{name}.md

Prefixes (one per core file):

Core FilePrefix
projectbrief.mdpb_
productContext.mdpc_
systemPatterns.mdsp_
techContext.mdtc_
activeContext.mdac_
progress.mdpr_

Categories (per file):

SourceCategories
projectbriefconstraint, problem, requirement
productContextproblem, workflow, goalchange
systemPatternsarchitecture, pattern, decision
techContextsetup, env, dependency
activeContextfocus, change, decision
progresschangelog, tasks, issues

How to Offload

  1. Extract detailed content from core file
  2. Create detail file with full content and a # Title heading
  3. Replace extracted content in core file with one-line summary + relative link:
    markdown
    - Auth pattern: JWT with role claims. See [details/sp_pattern_auth.md](details/sp_pattern_auth.md)
    

Chained Memory Banks

For monorepos where packages share context but have local specifics.

Structure

code
my-monorepo/
├── memory-bank/                    # Root: shared patterns
├── packages/
│   ├── api/memory-bank/            # Child: _chain.md → ../../memory-bank
│   └── web/memory-bank/            # Child: _chain.md → ../../memory-bank

_chain.md

markdown
parent: ../../memory-bank

Resolution Order

  1. Scan parent directories for memory-bank/
  2. If found, create _chain.md with relative path
  3. Read top-down: root → child
  4. Child overrides parent on conflicts

Scope Rules for Chained Banks

ScopeStore At
Shared patterns, standards, cross-packageRoot/ancestor
Package-specific details, local progressCurrent

When unclear, ask the user: "Store globally or locally?"


Update Protocol

When to Update

  • After discovering new project patterns
  • After implementing significant changes
  • User requests "update memory bank"
  • When context becomes stale or misleading

What to Update

Always update:

  • activeContext.md — current focus and recent changes
  • progress.md — status and remaining work

Review and update if relevant:

  • systemPatterns.md — new patterns or architecture changes
  • techContext.md — new dependencies or setup changes
  • productContext.md — goal or scope shifts
  • projectbrief.md — rarely; only if fundamental requirements change

How to Update

  1. Read all 6 core files to get full picture
  2. Update activeContext.md with current focus and recent changes
  3. Update progress.md with current status
  4. Review other files for accuracy — remove stale content
  5. Check word counts — offload to details/ if any file exceeds ~300 words
  6. Ensure cross-file consistency (no contradictions)