Memory
Persistent memory layers for project and agent context.
On this page
Memory is where Knowns stores durable context that should be recalled later.
The three layers
- working memory: short-lived, session-scoped context
- project memory: patterns, conventions, failures, and short implementation context specific to one repository
- global memory: user-level preferences or reusable rules across projects
When to use memory instead of docs
Use memory when the information is:
- short enough to recall quickly
- useful for recall but not a durable system-level choice
- useful across many future interactions
Use docs when the information needs longer narrative explanation or structured sections.
Typical examples
- “We use repository pattern for data access”
- “Always validate before marking a task done”
- “This team prefers semantic search before manual grep for exploratory work”
Commands
knowns memory add "We use repository pattern" --category pattern
knowns memory list --plain
knowns memory <id> --plain
Memory category decision is legacy and new writes are rejected. Existing entries remain readable until a reviewed migration has a verified, accepted, current replacement and Decision consumption is active. Record durable architecture or workflow choices with a first-class System Decision instead:
knowns decision create "Use Postgres for metadata"
knowns decision link <id> --source @doc/architecture/storage --task <done-task-id>
knowns decision accept <id>
Use knowns decision migrate preview --plain for a read-only inventory. Apply only one explicitly reviewed resolution at a time; use knowns decision migrate rollback <memory-id> to reverse a safe migration.
Related
Memory là nơi Knowns lưu context cần nhớ lại sau này.
Ba layer
- working memory — context ngắn hạn, chỉ sống trong một session
- project memory — pattern, convention, failure và implementation context ngắn 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
- hữu ích để recall nhưng không phải lựa chọn hệ thống bền vững
- 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
knowns memory add "We use repository pattern" --category pattern
knowns memory list --plain
knowns memory <id> --plain
Memory category decision là legacy và write mới sẽ bị từ chối. Record cũ vẫn đọc được cho tới khi migration đã review có replacement được verify, accepted, current và luồng consumption của Decision đã active. Lựa chọn architecture hoặc workflow bền vững phải dùng first-class System Decision:
knowns decision create "Use Postgres for metadata"
knowns decision link <id> --source @doc/architecture/storage --task <done-task-id>
knowns decision accept <id>
Dùng knowns decision migrate preview --plain để lấy inventory read-only. Mỗi lần chỉ apply một resolution đã review rõ ràng; dùng knowns decision migrate rollback <memory-id> để hoàn tác migration an toàn.