Description
Create a layered memory management system in the target project root directory, including:
- Memory management rules
.agents/rules/memory/RULE.md(project-shared, committable) - Project-private skill
.agents/skills/yy-memory/SKILL.md(project-shared, committable) - Memory repository structure
.memory/(personal and private, not committed) - Capacity trimming script
.agents/skills/yy-memory/scripts/src/main.ts - In
AGENTS.mdinject a reference to the memory management rules
Use cases
- The user mentions "add memory functionality", "enable memory management", "give this project memory capability"
- The user mentions "create a yy-memory skill", "add long-term memory to the project"
Should not trigger:
- The user requests to query or read existing memory content
- The user requests to update or modify existing memory
- The user is only asking what a memory system is
- The user requests adding memory for a non-project directory (such as Desktop or Downloads folder)
Instructions
Step 1. Confirm the target project
Decision branch:
- The user specified a target project path: use the path specified by the user, skip to Step 2
- The user did not specify a target project path: use the current working directory (cwd) as the target project
Step 2. Detect the target project environment
Check whether the following exist under the target project root directory:
AGENTS.mdfile (must exist; otherwise prompt the user to create it first).agents/rules/directory (create it if it does not exist).agents/skills/directory (create it if it does not exist).agents/rules/memory/directory.agents/skills/yy-memory/directory
Decision branch:
- AGENTS.md does not exist: prompt the user "The target project is missing the AGENTS.md file; please create it first", and abort the operation
- The memory rules or yy-memory skill already exist: ask the user "The target project already has a memory system; overwrite or update?", and continue after the user confirms
Step 3. Detect the target project structure
Read the target project's AGENTS.md, and determine its structural characteristics:
- Whether it already has a "rules to follow" section
- Whether it already has memory-related rule references
- Whether it already has
.gitignorefile
Step 4. Create memory management rules
Generate the rules file from the templates/rule-template.md template:
- Target path:
.agents/rules/memory/RULE.md - If it already exists, read it first and then decide whether to overwrite or append
- The rules content includes: trigger scenarios, read flow, write flow, memory system architecture, capacity management rules
Step 5. Create the project-private yy-memory skill
Generate the skill file from the templates/yy-memory-skill.md template:
- Target path:
.agents/skills/yy-memory/SKILL.md - If it already exists, read it first and then decide whether to overwrite or append
- The skill content includes: description, use cases, instruction steps (execute memory update after commit)
Step 6. Initialize the memory repository structure
Create the memory repository files in the following order:
- Create
.memory/Table of Contents - From
templates/memory-md.mdgenerateMEMORY.md - From
templates/catalog-md.mdgenerateCATALOG.md - From
templates/archive-md.mdgenerateARCHIVE.md - Create
work-log.mdwork log file - Create
.memory/hubs/directory, fromtemplates/hub-template.mdgenerate 5 topic hubs - Create
.memory/leaf/directory, fromtemplates/leaf-template.mdgenerate an example leaf
Hub topic naming(5):
hub-1-project-knowledge.md- Project knowledgehub-2-architecture-decisions.md- Architecture decisionshub-3-user-preferences.md- User preferenceshub-4-business-rules.md- Business ruleshub-5-tool-usage.md- Tool usage
Step 7. Create the pruning script
Copy the scripts/ directory to the target project:
- Target path:
.agents/skills/yy-memory/scripts/ - How to run:
node .agents/skills/yy-memory/scripts/src/main.ts
Step 8. Add .memory/ to .gitignore
Check the target project's .gitignore file:
- does not exist: create
.gitignore, add the.memory/entry - exists and does not contain
.memory/: append the.memory/entry at the end - exists and already contains
.memory/: skip this step
Step 9. Inject the AGENTS.md rule reference
Read the snippet in resources/agentes-rule-snippet.md and insert it into the appropriate location in AGENTS.md :
- If there is already a "Rules to follow" section, add it at the end of that section
- If there is no such section, add it at the end of the file
- Keep the existing content unchanged and only append new content
Step 10. Output the results
The following content must be output:
- Creation result: operation type (create/update)
- Generated directory structure: display it using a tree structure
- Memory store path:
.memory/(personal and private, already added to .gitignore) - Trigger method: automatically load MEMORY.md when the conversation starts, and update memory after manually executing the yy-memory skill
- Usage reminder: suggest how the user can verify that the installation succeeded
Security boundaries
- The memory system can only be created under a valid project directory (containing AGENTS.md)
- Do not overwrite the user's existing AGENTS.md content; only append the rule reference
- Do not modify any other files in the target project
- When initializing the memory store, only generate template files, not specific memory content related to the user's business
.memory/The directory is automatically added to.gitignoreto ensure personal memories are not committed to the repository
Related resources
templates/rule-template.md: memory management rules templatetemplates/yy-memory-skill.md: yy-memory project private skill templatetemplates/memory-md.md: MEMORY.md core routing templatetemplates/catalog-md.md: CATALOG.md complete catalog templatetemplates/archive-md.md: ARCHIVE.md archive templatetemplates/hub-template.md: hub topic hub templatetemplates/leaf-template.md: leaf leaf memory templateresources/agentes-rule-snippet.md: AGENTS.md injection snippetscripts/: capacity pruning script project (including TypeScript source code, package.json, tsconfig.json, and other configuration)