Agent Rules File
This is the exact file that context-vault setup installs on your system. You can review it here before running setup, or install it manually.
Transparency first
This is the only file context-vault installs outside of the MCP config. It is additive (never overwrites your existing rules), versioned, and you can edit or delete it at any time. Run context-vault uninstall to remove everything setup created.
Rules file content
<!-- context-vault-rules v1.0 --> # Context Vault — Agent Rules You have access to a persistent knowledge vault via MCP tools (`get_context`, `save_context`, `list_context`, `delete_context`). Use it to build lasting memory across sessions. ## When to Retrieve Check the vault when you're about to invest effort that past knowledge could shortcut. Apply this test: "Might I or a previous session have encountered this before?" If yes, search first. Retrieval triggers: - **Starting a session**: call `session_start()` or `get_context(query: "<project or task context>")` to load relevant prior knowledge - **Hitting an error**: search for the error message or root cause before debugging from scratch - **Making a decision**: check if this architectural or design choice was already made and why - **Integrating with an API, library, or service**: search for known quirks, gotchas, or working patterns - **Entering an unfamiliar area of the codebase**: check for prior insights about that module or domain - **Before saving**: search to avoid duplicates and to update existing entries instead A vault search takes milliseconds. Debugging from scratch takes minutes. Always check first. ## When to Save Save when you encounter something a future session would benefit from knowing. Apply this test: "Would I tell a colleague about this to save them time?" If yes, save it. Save triggers: - Solved a non-obvious bug (root cause was not apparent from the error) - Discovered undocumented API/library/tool behavior - Found a working integration pattern requiring non-obvious configuration - Hit a framework limitation and found a workaround - Made an architectural decision with tradeoffs worth preserving ## When NOT to Save - Facts derivable from reading the current code or git history - The fix itself (that belongs in the commit, not the vault) - Generic programming knowledge you already know - Session-specific state (files edited, commands run) ## How to Save Every entry must have: - `title`: clear, specific (not "auth fix" but "Express 5 raw body parser breaks Stripe webhook verification") - `tags`: at minimum a `bucket:<project>` tag for scoping - `kind`: insight, pattern, reference, decision, or event - `tier`: `working` for active context, `durable` for long-term reference Capture what was learned (the insight), why it matters (what problem it prevents), and when it applies (what context makes it relevant). ## Session Review At the end of significant work sessions, review what you learned. If the session produced novel knowledge (not every session does), save 1-3 consolidated entries. Prefer one solid entry over multiple fragments.
What each section does
The rules file has five sections. Each one addresses a different failure mode in how AI agents use memory.
When to Retrieve
Triggers that tell the agent to search the vault before doing work. Covers session start, error debugging, architectural decisions, API integrations, and unfamiliar code. The key heuristic: "Might I or a previous session have encountered this before?"
When to Save
Triggers that tell the agent to preserve new knowledge. Covers non-obvious bugs, undocumented behavior, integration patterns, workarounds, and architectural decisions. The key heuristic: "Would I tell a colleague about this to save them time?"
When NOT to Save
Guardrails to prevent noise. Excludes facts derivable from code or git history, generic knowledge, the fix itself (belongs in the commit), and session-specific state. Keeps the vault signal-dense.
How to Save
Required fields for every entry: title (specific), tags (bucket scoped), kind (insight/pattern/reference/decision/event), and tier (working vs durable). Enforces findability by making entries structured from the start.
Session Review
End-of-session habit to consolidate learnings into 1-3 solid entries. Prevents fragmentation. Not every session produces novel knowledge, and that is fine.
Automatic install
The fastest way: run setup and it detects your AI client automatically.
npx context-vault setupPrints every file path it creates or modifies. Use --dry-run to preview without writing anything, or --no-rules to install only the MCP config.
Manual install by client
Claude Code
Installed as a rules file at ~/.claude/rules/context-vault.md
~/.claude/rules/context-vault.md- 1.Create the directory if it does not exist: mkdir -p ~/.claude/rules
- 2.Save the rules file: copy the content above to ~/.claude/rules/context-vault.md
- 3.Claude Code automatically loads all .md files from ~/.claude/rules/ on startup.
Or run npx context-vault setup to install automatically.
Cursor
Installed as a rules file at ~/.cursor/rules/context-vault.mdc
~/.cursor/rules/context-vault.mdc- 1.Create the directory if it does not exist: mkdir -p ~/.cursor/rules
- 2.Save the rules file: copy the content above to ~/.cursor/rules/context-vault.mdc
- 3.Cursor automatically loads .mdc files from ~/.cursor/rules/ globally.
Or run npx context-vault setup to install automatically.
Windsurf
Appended to ~/.windsurfrules with delimiters
~/.windsurfrules- 1.Open ~/.windsurfrules in a text editor (create the file if it does not exist).
- 2.Append the rules content wrapped in delimiter comments: <!-- context-vault agent rules --> ... <!-- /context-vault agent rules -->
- 3.Windsurf loads ~/.windsurfrules on every session. The delimiters allow future upgrades without touching your other rules.
Or run npx context-vault setup to install automatically.
Other MCP clients
Paste directly into system prompt or agent instructions
System prompt / agent instructions- 1.Copy the rules content above.
- 2.Paste it into your client's system prompt, agent instructions, or rules configuration.
- 3.The rules work with any MCP-compatible client.
Managing rules
context-vault rules show
context-vault rules diff
context-vault setup --upgrade
context-vault rules path
The rules file is plain markdown. You can edit it directly at the path shown by context-vault rules path. Running context-vault rules install will overwrite customizations. Back up first, or use --no-rules during setup to skip.
Version history
v1.02025-01
Initial release. Five sections: When to Retrieve, When to Save, When NOT to Save, How to Save, Session Review.
Version is stored in the first line of the rules file as <!-- context-vault-rules v1.0 -->. The upgrade command uses this to detect outdated installations.
Customization
The rules file is plain markdown. You can edit it after installation to match your workflow:
- Add project-specific save triggers (e.g., "always save when working with the payments module")
- Adjust retrieval triggers to match your domain
- Add custom "When NOT to Save" entries to reduce noise
For Claude Code and Cursor, edit the file directly at the path shown by context-vault rules path. For Windsurf, edit the section between the <!-- context-vault agent rules --> delimiters in ~/.windsurfrules.
Note
Running context-vault rules install or context-vault setup --upgrade will overwrite your customizations. If you have changes you want to keep, back up the file before upgrading, or skip the rules step during setup with --no-rules.
Uninstalling
Rules are removed when you uninstall context-vault:
context-vault uninstall
This removes the Claude Code and Cursor rules files entirely, and strips the delimited section from .windsurfrules (preserving any other content in that file).
Agent-assisted setup
After installing the rules file, paste this prompt into your AI session for conflict detection, project-aware bucket setup, and rule merging:
/vault setup
This runs the agent-assisted setup flow: verifies the MCP connection, detects active projects, proposes vault bucket configuration, and resolves conflicts with existing rules.
Standalone prompt (no CLI required)
If you cannot run context-vault setup or prefer not to install files, copy this self-contained prompt into your AI tool's system prompt or chat session. It includes the full agent rules and works with any MCP-compatible client.
You have access to a persistent knowledge vault via MCP tools (`get_context`, `save_context`, `list_context`, `delete_context`). Use it to build lasting memory across sessions. Follow these guidelines to use the vault effectively. ## When to Retrieve Check the vault when you're about to invest effort that past knowledge could shortcut. Apply this test: "Might I or a previous session have encountered this before?" If yes, search first. Retrieval triggers: - Starting a session: call session_start() or get_context(query: "<project or task context>") to load relevant prior knowledge - Hitting an error: search for the error message or root cause before debugging from scratch - Making a decision: check if this architectural or design choice was already made and why - Integrating with an API, library, or service: search for known quirks, gotchas, or working patterns - Entering an unfamiliar area of the codebase: check for prior insights about that module or domain - Before saving: search to avoid duplicates and to update existing entries instead A vault search takes milliseconds. Debugging from scratch takes minutes. Always check first. ## When to Save Save when you encounter something a future session would benefit from knowing. Apply this test: "Would I tell a colleague about this to save them time?" If yes, save it. Save triggers: - Solved a non-obvious bug (root cause was not apparent from the error) - Discovered undocumented API/library/tool behavior - Found a working integration pattern requiring non-obvious configuration - Hit a framework limitation and found a workaround - Made an architectural decision with tradeoffs worth preserving ## When NOT to Save - Facts derivable from reading the current code or git history - The fix itself (that belongs in the commit, not the vault) - Generic programming knowledge the model already knows - Session-specific state (files edited, commands run) ## How to Save Every entry must have: - title: clear, specific (not "auth fix" but "Express 5 raw body parser breaks Stripe webhook verification") - tags: at minimum a bucket:<project> tag for scoping - kind: insight, pattern, reference, decision, or event - tier: working for active context, durable for long-term reference Capture what was learned (the insight), why it matters (what problem it prevents), and when it applies (what context makes it relevant). ## Session Review At the end of significant work sessions, review what you learned. If the session produced novel knowledge (not every session does), save 1-3 consolidated entries. Prefer one solid entry over multiple fragments.