memory-kernel
Skill18 starsChanged 7 months agoMITView on GitHub
Manage and query persistent cross-session memory via MCP Knowledge Graph. Step 0 executor: query before ANY task for project/pattern/user context. Use when the task involves remembering, retrieving, or storing project knowledge, or when you need historical context, including Chinese requests such as \"你还记得吗\"\"之前讨论过\"\"校准记忆\"\"同步记忆\". Does NOT replace Trae Core Memory — complements it.
In this repository37 other files it gives its agents.
- a11y-debuggingSkill
- agent-blueprint-architectSkill
- brainstormingSkill
- chart-visualizationSkill
- chinese-copywritingSkill
- chinese-git-workflowSkill
- chrome-devtoolsSkill
- creating-trae-rulesSkill
- debug-optimize-lcpSkill
- discovering-subagent-capabilitiesSkill
- dispatching-parallel-agentsSkill
- everything-searchSkill
- executing-plansSkill
- find-docsSkill
- finishing-a-development-branchSkill
- frontend-designSkill
- gh-cliSkill
- git-commitSkill
- image-manipulation-python-magickSkill
- memory-leak-debuggingSkill
- mineru-to-mdSkill
- model-config-lookupSkill
- receiving-code-reviewSkill
- requesting-code-reviewSkill
- self-improvementSkill
- skill-creatorSkill
- skill-language-policySkill
- skill-stability-reviewSkill
- subagent-driven-developmentSkill
- systematic-debuggingSkill
- test-driven-developmentSkill
- troubleshootingSkill
- using-git-worktreesSkill
- verification-before-completionSkill
- visual-brainstormingSkill
- workflow-runnerSkill
- writing-plansSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
27 rules. About 0 are common, 13 are distinctive, and 14 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈13
Distinctive · estimate
This author's own choices. Worth a look.
14
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 17
Check MCP Memory before scanning the project from scratch.
- Distinctive: line 57
Every observation written to MCP Memory must pass these gates.
- Distinctive: line 81
Prefer growing existing entities over creating new ones.
- Distinctive: line 90
Only modify entities whose name matches the current project context (derived from git remote or directory name).
- Distinctive: line 93
When in doubt (no git remote, ambiguous project identity), ask the user before writing, updating, or deleting any entity.
- Very specific: line 97
Check if the entity already exists via mcp_memory_search_nodes
- Very specific: line 98
If entity exists: use mcp_memory_add_observations to append new facts
- Very specific: line 99
If entity does not exist: use mcp_memory_create_entities with name, type, and initial observations
- Very specific: line 101
Every observation must include a [YYYY-MM-DD] prefix.
- Very specific: line 104
Project entities: no prefix — named as the project name (e.g., trae_agent_enhancements)
- Very specific: line 115
Pre-flight check: Verify whether mcp_memory_search_nodes is in the available tool list.
- Very specific: line 116
Level 0 (MCP available): Start with mcp_memory_search_nodes — use broad queries relevant to the task/project context.
- Very specific: line 117
If results are returned, open specific nodes with mcp_memory_open_nodes to get full observations
- Distinctive: line 127
If MCP call fails (timeout/error), fall back to Level 1.
- Very specific: line 128
Level 1 (MCP unavailable, Core Memory available): Check if manage_core_memory tool is available.
- Distinctive: line 139
No memory write-back expected at Level 2.
- Distinctive: line 143
When information in MCP Memory is found to be outdated:
- Very specific: line 144
Use mcp_memory_delete_observations to remove stale facts (identified by their timestamp prefix [YYYY-MM-DD])
- Very specific: line 145
Use mcp_memory_add_observations to add corrected facts with the current date [YYYY-MM-DD]
- Distinctive: line 146
Do NOT delete and recreate the entity unless the entire entity is invalid
- Distinctive: line 150
When the user says "校准记忆" or "同步记忆", perform a targeted refresh:
- Very specific: line 152
Read key project files: package.json, rules/ directory listing, skills/ directory listing, docs/ directory listing
- Very specific: line 153
Read the current project entity via mcp_memory_open_nodes
- Distinctive: line 154
If entity does not exist (search returned empty):
- Very specific: line 157
If confirmed: use mcp_memory_create_entities to create the project entity with initial observations from step 1
- Distinctive: line 164
Only write changes after user confirmation
- Distinctive: line 177
When using MCP Memory (including Step 0 pre-check), include in your response:
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Memory Kernel
Overview
This skill governs the dual memory system:
| Layer | Backend | Scope | Lifetime |
| Trae Core Memory | Trae native | Current session | Ephemeral |
| MCP Memory | Knowledge Graph (JSONL) | Cross-session | Persistent |
Check MCP Memory before scanning the project from scratch.
Use This Skill
- "你还记得吗" / "之前我们讨论过" / 跨会话记忆召回
- "校准记忆" / "同步记忆"(触发 Calibration Mode)
- 新会话,需要项目上下文再开始
- 已知项目,需要查架构/约定/用户偏好
- 任务中需要持久化新知识到跨会话记忆
Do Not Use
- 当前文件树可见的琐碎事实
- 用户刚在当前消息中提供的信息
- 会话级别的临时状态
- MCP 工具确认不可用且 Core Memory 可用时(直接用 Core Memory,不浪费调用)
- 一次性调试步骤
- 临时变量名或文件路径
- 用户明确说不要记住的信息
Input Contract
Required Inputs:
- 用户的自然语言查询或任务指令(Step 0 自动触发)
- 或用户显式说出"校准记忆" / "同步记忆"
- 或用户显式说出"你还记得吗" / "之前我们讨论过"
Optional Inputs:
- 实体命名约定(默认
snake_case,项目实体无前缀,公共实体加public_前缀) - 实体类型约定:
project/pattern/preference/profile
Missing input handling:
- 查询太泛:先缩小搜索范围再重试
- 未指定项目上下文:从当前 git remote 或目录名推断
- MCP 工具不可用:按三级降级链处理,不阻塞
Execution Protocol
Writing Standard
Every observation written to MCP Memory must pass these gates.
Observation format: [YYYY-MM-DD] <content>
- Timestamp is the date the observation was written or last verified.
- Content is a single, self-contained fact. One sentence per observation.
Write-worthy (pass the gate):
- Project architecture, tech stack, key design decisions
- Conventions (naming, patterns, workflows) that affect multiple files
- User preferences that persist across sessions
- Reusable solutions, recurring error patterns, root causes
- Entity relationships that structure the knowledge graph
Not write-worthy (skip):
- Current file tree structure (always re-scanable)
- Information the user just provided in the current message
- Session-only state (variable names, temp file paths)
- Trivial or self-evident facts ("this project uses Git")
- Secrets, tokens, passwords, API keys — NEVER
Entity granularity:
- One project entity per project. Add observations to it, do not create multiple project entities.
- One pattern entity per distinct solution. Merge related patterns — do not split a single concept across entities.
- One preference entity per user profile.
- Prefer growing existing entities over creating new ones.
Update discipline:
- Stale observation:
delete_observationsthe old one,add_observationsthe corrected one (both with current timestamp). - Entity relationship stale:
delete_relationsthencreate_relations. - Entire entity invalid: only then
delete_entities.
Safety boundary — cross-project isolation: MCP Memory is a shared store. All projects share one knowledge graph.
- Only modify entities whose name matches the current project context (derived from
git remoteor directory name). public_-prefixed entities are shared across projects. Append observations to them but do NOT delete or rename them without explicit user confirmation.delete_entitiesanddelete_observationsare prohibited on entities that do not match the current project name or thepublic_prefix — if you encountered one via search, skip it and proceed.- When in doubt (no git remote, ambiguous project identity), ask the user before writing, updating, or deleting any entity.
Write Protocol
- Check if the entity already exists via
mcp_memory_search_nodes - If entity exists: use
mcp_memory_add_observationsto append new facts - If entity does not exist: use
mcp_memory_create_entitieswith name, type, and initial observations - For relationships between entities, use
mcp_memory_create_relations - Every observation must include a
[YYYY-MM-DD]prefix. Same date for bulk updates.
Entity naming convention: use snake_case. Timestamps are in observations, not in entity names.
- Project entities: no prefix — named as the project name (e.g.,
trae_agent_enhancements) - Public entities: prefix
public_— reusable across projects (e.g.,public_chenxing,public_architecture_patterns)
Entity type convention:
projectfor project-level entities (tech stack, architecture, conventions) — project memorypatternfor reusable solutions and decisions — public memorypreferencefor user preferences — public memoryprofilefor user identity — public memory
Read Protocol (Step 0 Execution)
- Pre-flight check: Verify whether
mcp_memory_search_nodesis in the available tool list. If the tool is not registered, skip to Fallback Level 2 immediately — do not attempt the call. - Level 0 (MCP available): Start with
mcp_memory_search_nodes— use broad queries relevant to the task/project context. Search for project name, domain keywords, entity types (project,pattern,profile,preference).- If results are returned, open specific nodes with
mcp_memory_open_nodesto get full observations Assess whether the context is sufficient by checking both criteria:
Check Question Sufficient if... Answer check Can the user's question be answered from MCP observations alone? Yes Task check Does MCP data provide enough project structure/convention/pattern context to proceed without project-wide discovery? Yes - Both checks negative or empty: Insufficient — proceed with normal task execution. Write new findings back afterward.
- At least one check positive: Sufficient — skip project-wide file scanning. Only read 1-2 key files (e.g.,
package.json) to verify version/state changes.
- If MCP call fails (timeout/error), fall back to Level 1.
- If results are returned, open specific nodes with
- Level 1 (MCP unavailable, Core Memory available): Check if
manage_core_memorytool is available. If yes, use Core Memory as a degraded context source. Level 2 (both unavailable): Skip all memory lookups. Choose fallback behavior based on task type:
Task type Fallback Single-file question, code explanation Read current file(s) only Project overview, "what is this project" Ask user briefly or read docs//README.mdFeature implementation, refactoring, bug fix Full file scan + T-Shirt sizing Ambiguous request, "help me with..." Ask user for context Conversational, greeting, meta Respond directly No memory write-back expected at Level 2.
Update Protocol
When information in MCP Memory is found to be outdated:
- Use
mcp_memory_delete_observationsto remove stale facts (identified by their timestamp prefix[YYYY-MM-DD]) - Use
mcp_memory_add_observationsto add corrected facts with the current date[YYYY-MM-DD] - Do NOT delete and recreate the entity unless the entire entity is invalid
Calibration Mode (Manual Trigger)
When the user says "校准记忆" or "同步记忆", perform a targeted refresh:
- Read key project files:
package.json,rules/directory listing,skills/directory listing,docs/directory listing - Read the current project entity via
mcp_memory_open_nodes - If entity does not exist (search returned empty):
- Summarize what was found: project name from
package.json, skill count, rule count, docs count - Ask user: "项目记忆为空,是否基于当前文件状态初始化?"
- If confirmed: use
mcp_memory_create_entitiesto create the project entity with initial observations from step 1 - Then proceed to step 4 to confirm the diff
- Summarize what was found: project name from
- Compare observations (check timestamp prefix
[YYYY-MM-DD]for staleness) against actual file state (or against the just-created entity):- Missing skills or rules → append via
mcp_memory_add_observations - Outdated version numbers or descriptions →
mcp_memory_delete_observations+mcp_memory_add_observations - Renamed or removed items →
mcp_memory_delete_observations
- Missing skills or rules → append via
- Report the diff to the user before writing: "发现 X 处差异,是否更新?(列出差异明细)"
- Only write changes after user confirmation
Failure Handling
- MCP tools unavailable (tool not registered): Pre-flight check catches this. Skip MCP entirely, attempt Level 1 or Level 2 (task-type-based fallback). Do not waste a call.
- MCP tools unavailable (runtime failure): Fall back to Level 1 (Core Memory). If Core Memory also unavailable, Level 2 (task-type-based fallback). Do not block task execution.
- Search returns no results: Proceed with Level 0 insufficient path (normal execution). Write new findings back afterward.
- Write fails: Log the failed write and continue. The information can be re-captured later.
- Duplicate entity: The tools handle duplicates silently — no action needed.
- Both Core Memory and MCP unavailable: Level 2 — choose fallback based on task type (see Read Protocol table).
Output Contract
When using MCP Memory (including Step 0 pre-check), include in your response:
- Whether Step 0 MCP Memory query was performed
- Whether context was sufficient (skipping file scan) or insufficient (triggering fallback)
- What relevant information was found (if any)
- What new information was persisted (if any)
Integration
discovering-subagent-capabilities: Adjacent — MCP Memory tools are platform-level, not subagent-levelself-improvement: Downstream — persistent learnings from self-improvement should also be written to MCP Memory
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

