Memory System
Persistent project memory for AI agents with project and global layers
Memory System
Knowns includes a 2-layer memory system so agents can retain patterns, decisions, and conventions across sessions instead of relearning them every time.
The 2 Layers
| Layer | Scope | Best for |
|---|---|---|
| Project | Current repository | Team conventions, architecture decisions, reusable patterns |
| Global | Across projects | Personal defaults and broadly reusable practices |
Why It Matters
- Agents can load project memory at session start
- Reusable learnings stop disappearing between sessions
- Important patterns can be promoted instead of copied into every prompt
- Search and graph views can connect memories to tasks and docs
CLI Commands
Persistent memory is managed with the knowns memory command group:
bash
# List memory entries
knowns memory list --plain
# Filter by layer or category
knowns memory list --layer project --category pattern --plain
# View a memory entry
knowns memory view <id> --plain
# Add a new memory entry
knowns memory add \
--title "Auth token rotation pattern" \
--category pattern \
--tags auth,security \
--content "Rotate access tokens every 15 minutes"
# Promote reusable knowledge
knowns memory promote <id>
knowns memory demote <id>
MCP Tools
MCP has full memory coverage for both persistent and session-scoped memory (v0.20 consolidated format):
Persistent memory:
TypeScript
memory({ action: "add", title: "Auth pattern", category: "pattern", layer: "project", content: "..." })
memory({ action: "list", layer: "project" })
memory({ action: "get", id: "abc123" })
memory({ action: "update", id: "abc123", content: "..." })
memory({ action: "promote", id: "abc123" }) // project → global
memory({ action: "demote", id: "abc123" }) // global → project
Search memory:
TypeScript
search({ action: "search", query: "auth pattern", type: "memory" })
See MCP Integration for the full tool list.
Typical Workflow
text
Research something once
→ save the distilled lesson to project memory
→ load it automatically in later sessions
→ promote it to global if it applies everywhere
Good Memory Candidates
- Architecture decisions that should not be re-debated every session
- Team conventions that are easy for agents to miss
- Reusable debugging lessons
- Patterns extracted from completed tasks
Related
- Skills System -
kn-init,kn-research, andkn-extractnow use memory-aware workflows - Web UI - Browse memory entries and graph relationships visually
- CLI Reference - Full command syntax
Memory
Memory là nơi Knowns lưu context cần nhớ lại sau này.
Hai layer
- project memory — decision, pattern, convention riêng của một repo
- global memory — preference hoặc rule dùng được across projects
Memory hay doc?
Dùng memory khi:
- ngắn gọn, cần recall nhanh
- thiên về decision hơn là giải thích dài
- hữu ích cho nhiều lần làm việc sau
Dùng doc khi cần giải thích dài hoặc chia thành nhiều section.
Ví dụ
"We use repository pattern for data access"
"Always validate before marking a task done"
"Prefer semantic search over manual grep for exploration"
Nội dung memory thường viết bằng tiếng Anh vì AI đọc trực tiếp.
Lệnh
bash
knowns memory add "We use repository pattern" --category decision
knowns memory list --plain
knowns memory <id> --plain