Maintain persistent memory across sessions using a .context/ directory. Only activates when .context/ already exists OR the user explicitly asks to initialize it. When active, use it to recall prior context at session start, record learnings after significant tasks, or when the user asks you to remember something. Also handles memory consolidation and defragmentation.
You maintain a .context/ directory at the project root as your persistent memory. Inside
it, structured markdown files with YAML frontmatter organize what you know. You control
what stays loaded in context and what you retrieve on demand.
Important: If no .context/ directory exists, this skill is a complete no-op. Do not
initialize, record, recall, or do anything else described here unless the user explicitly
asks you to set up context tracking (e.g. "initialize .context", "start tracking context",
"remember this").
.context/ directory exists → Do nothing (no-op) unless the user explicitly asks
to initialize.context/ → Recall.context/ exists) → RecordRun this once per project, when no .context/ directory exists.
Create the directory structure:
.context/
├── system/
├── domain/
└── learnings/
Add .context/ to the project's .gitignore (if not already present).
Bootstrap initial memory by spawning concurrent subagents to explore the codebase. Assign each a distinct focus:
Merge subagent findings into initial memory files:
system/overview.md — project summary, tech stack, top-level structuresystem/preferences.md — user preferences discovered so far (can be empty initially)domain/architecture.md — system architecture and data flowdomain/patterns.md — recurring patterns and abstractionsFollow the format in references/FILE-FORMAT.md for every file you create.
After completing a task or when the user asks you to remember something, persist the
insight to .context/.
.context/ first — append to an
existing file if the topic matches. Create a new file only if no existing file covers
the topic.references/FILE-FORMAT.md.At the start of a task or session, load relevant memories.
.context/ directory tree to see what memory files exist.description field) of each file to understand its
contents without loading the full body.system/.domain/ and learnings/ based on the current task.
Use the description and importance fields to decide.Periodically review and refine your memory. This converts raw, incremental notes into clean, organized knowledge. Do this:
Follow the full checklist in references/CONSOLIDATION.md. The short version:
.context/ and the current conversationlearnings/ into domain/Consider spawning a subagent for consolidation so it does not block the main interaction.
When memory files become unwieldy, reorganize them.