cortex
Skill1 starsChanged 7 months agoMITView on GitHub
Long-term memory system for Claude Code and Open Claw, designed for developers who run Open Claw on a VPS 24/7 and work locally on their own machine. Cortex keeps a shared knowledge base in sync across both using GitHub (free) for file sync and Neon Postgres (free) for fast querying. Works with Obsidian on the local side. Use this skill whenever you need to store, retrieve, query, or sync knowledge across sessions or machines. Trigger on: "remember this", "find my notes about", "what do I have on", "save this for later", "sync my vault", "reindex", "create a note", working with .md knowledge bases, setting up long-term memory, or any situation where Claude needs persistent context across sessions. Also use when the user is working with Obsidian vaults, markdown note systems, or asks about giving Claude memory. If the user mentions Neon, vault, frontmatter, cortex, or knowledge base — use this skill.
- Installs packages
- Commits and pushes
5 other projects use a version of this.
Adopted by
Most recently taken up by
- Pixxle/skillstheir own version, first seen Nov 1, 2026
- valsecchi75/project-scaffoldertheir own version, first seen Aug 3, 2026
- synpulse8-opensource/pulse8-ai-cortex-knowledge-vaulttheir own version, first seen Jun 25, 2026
- sahilsaini432/claude_skillstheir own version, first seen May 22, 2026
- ttaosci/cortextheir own version, first seen Apr 30, 2026
Other versions5 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 5
- synpulse8-opensource/pulse8-ai-cortex-knowledge-vault★ 15same name
- valsecchi75/project-scaffolder★ 9same name
- ttaosci/cortex★ 2same name
- Pixxle/skills★ 1same name
- sahilsaini432/claude_skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repositoryOne other file it gives its agents.
- cortexSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
18 rules. 0 are common, 7 are distinctive, and 11 are very specific to this project.
0
Common
Most of the 5 edited versions we read keep these.
7
Distinctive
This author's own choices. Worth a look.
11
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 30
Always check the current level: before suggesting setup steps:
- Distinctive: line 47
Run the init script — it handles everything interactively and detects what's available:
- Very specific: line 99
Every .md file managed by Cortex has a YAML frontmatter block:
- Very specific: line 127
Infer aggressively: When Claude creates a note, fill in every field from context.
- Very specific: line 131
Normalize proactively: If Claude notices inconsistencies during a query (e.g., auth vs authentication vs authn), flag it and offer to …
- Distinctive: line 137
When the user wants to save something:
- Very specific: line 140
Write the .md file to the vault
- Distinctive: line 149
When the user asks Claude to find or recall something, pick the right query type:
- Very specific: line 188
Always read only the files returned: Never load the whole vault.
- Distinctive: line 196
Before committing significant vault edits, run lint to catch convention violations:
- Distinctive: line 221
Run a full sync:
- Distinctive: line 233
If the index gets out of sync (files edited without the sync script, bulk import, etc.):
- Very specific: line 253
When auto_commit is true, every operation triggers a commit like cortex: create log — stripe rate limiting fix.
- Very specific: line 257
Add to schema.extensions in config:
- Very specific: line 305
Add the following to ~/.claude/settings.json under a hooks key:
- Very specific: line 325
If ~/.claude/settings.json already has other content, merge the hooks key into the existing object.
- Very specific: line 354
Remove the Stop entry from ~/.claude/settings.json hooks, or delete the hooks key entirely.
- Very specific: line 358
All scripts live in scripts/ and read the config file for connection details.
“Common” is measured: kept by at least 6 in 10 of the 5 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Cortex
A long-term memory system that gives Claude persistent knowledge across sessions and machines. It works progressively — start with just a folder of .md files, add GitHub and Neon as you need them.
Progressive Setup Levels
Cortex doesn't require everything upfront. Each layer is optional and additive:
- Level 0: Just files — Create
.mdfiles with YAML frontmatter in any folder. Query by scanning files locally. No accounts needed. - Level 1: + Obsidian — Point Obsidian at the vault folder. Notes are now browsable and locally searchable.
- Level 2: + GitHub — Push the vault to a repo. Files sync between your local machine and VPS via git.
- Level 3: + Neon — Add a Postgres connection string. Fast SQL queries across the entire vault from any machine.
Always check the current level before suggesting setup steps:
python <skill-path>/scripts/cortex_query.py --config <config-path> --levelIf the user doesn't have GitHub or Neon yet, that's fine — Cortex works at Level 0. Create notes with proper frontmatter immediately. The structured data is captured from day one, and when the user adds GitHub or Neon later, everything migrates automatically via cortex_init.py or cortex_reindex.py.
Why This Architecture (for the full setup)
The full stack solves a specific problem: running Open Claw on a VPS 24/7 while doing dev work on a local machine, with both needing the same knowledge base.
GitHub handles file sync (free, both machines push/pull). Neon handles fast queries (free 0.5GB tier, both machines query directly — no database file to sync). Obsidian reads the vault natively on the local side.
SQLite doesn't work cross-machine — you'd have to sync a binary file through git, which causes merge conflicts. This two-layer approach is the simplest thing that works.
First-Time Setup
Run the init script — it handles everything interactively and detects what's available:
python <skill-path>/scripts/cortex_init.pyOr with args for non-interactive use:
python <skill-path>/scripts/cortex_init.py --vault ~/notes --neon "postgresql://..."The init script:
- Asks for vault path (or uses current directory)
- Optionally asks for Neon connection string (skips if not ready)
- Creates
.cortex/config.yaml - Adds config to
.gitignore(protects credentials) - Creates the Postgres table if Neon is configured
- Indexes all existing
.mdfiles - Verifies with a test query
- Optionally sets up a VPS via SSH
For manual setup or the minimal config (Level 0), just create .cortex/config.yaml with:
vault_path: ~/notes
neon_connection_string: postgresql://...
git:
auto_commit: true
auto_push: true
commit_prefix: "cortex:"
remote: origin
branch: main
schema:
extensions: []- Ensure
.cortex/config.yamlis in.gitignore— it contains database credentials. Enforce this programmatically, don't just mention it:grep -qxF '.cortex/config.yaml' .gitignore 2>/dev/null || echo '.cortex/config.yaml' >> .gitignore - Run the setup script to create the Postgres table and do the initial index:
python <skill-path>/scripts/cortex_setup.py --config <vault-path>/.cortex/config.yaml - Verify with a test query to confirm the connection works.
- Set up the VPS — SSH in, clone the same repo, create the same config (with the same Neon connection string but the VPS vault path), and run setup there too. Both machines now share the same GitHub repo and the same Neon index.
Default Frontmatter Schema
Every .md file managed by Cortex has a YAML frontmatter block:
---
title: "Human-readable title"
type: spec # open-ended — use whatever fits: spec, analysis, contact, outreach,
# checklist, log, review, decision, roadmap, reference, project, etc.
status: active # active | done | ready | planned | draft | waiting | archived
tags: [] # freeform list, 3-5 tags max
priority: P1 # P0 (must ship now) | P1 (current sprint) | P2 (next) | P3 (future)
# omit priority if not relevant (contacts, logs, references, etc.)
created: 2026-04-08
updated: 2026-04-08
---These fields cover the most common filtering needs. Users can add custom fields (like client, sprint, due_date) through schema.extensions in the config — the migrate script adds corresponding Postgres columns.
type is fully open-ended — any string is accepted and stored as-is. Use whatever is meaningful for your vault's taxonomy. Cortex will never overwrite or normalise it.
status has a soft-validated set. Values outside active | done | ready | planned | draft | waiting | archived are stored as-is with a warning so you can decide how to handle them.
priority uses P0 | P1 | P2 | P3. Omit it entirely for notes where priority is not meaningful (contacts, references, logs). Unrecognised values are stored with a warning, never overwritten.
Frontmatter Discipline
The system is only useful if the metadata is consistent. Three principles:
Infer aggressively. When Claude creates a note, fill in every field from context. "Save this conversation about fixing the auth bug" → type: log, tags: [auth, bugfix], priority: normal, status: active. Never ask the user to fill in fields manually.
Validate on sync. The sync script checks for missing required fields, invalid enum values, and common issues. It auto-repairs what it can (adds missing created dates, normalizes tag casing) and warns about the rest. This prevents the index from decaying over time.
Normalize proactively. If Claude notices inconsistencies during a query (e.g., auth vs authentication vs authn), flag it and offer to normalize. The tag cleanup script can handle this across the entire vault.
Core Operations
Creating a Note
When the user wants to save something:
- Generate frontmatter with inferred values (type, tags, priority from context)
- Write the
.mdfile to the vault - Sync to Neon and git:
This upserts the frontmatter to Neon, validates the metadata, and (ifpython <skill-path>/scripts/cortex_sync.py --config <config-path> --file <new-file-path>auto_commitis on) commits and pushes to GitHub.
Querying the Vault
When the user asks Claude to find or recall something, pick the right query type:
Metadata filter — when the user knows what kind of note they want:
python <skill-path>/scripts/cortex_query.py --config <config-path> \
--type project --status active --search "authentication" --jsonFull-text search — when looking for content, not metadata (Level 3+):
python <skill-path>/scripts/cortex_query.py --config <config-path> \
--search-fts "rate limiting stripe"Returns ranked results with HTML-bolded snippets via Postgres tsvector.
Backlinks / forward links — when exploring the graph (Level 3+):
python <skill-path>/scripts/cortex_query.py --config <config-path> \
--backlinks projects/strata/README.md
python <skill-path>/scripts/cortex_query.py --config <config-path> \
--forward-links infrastructure/openclaw.mdSection extraction — when only one part of a long note is needed (Level 3+):
python <skill-path>/scripts/cortex_query.py --config <config-path> \
--section infrastructure/openclaw.md "Identity"Returns just that H2 (and any subsections under it) without the rest of the file. Saves tokens dramatically on large hub notes.
Dangling links — when validating the vault (Level 3+):
python <skill-path>/scripts/cortex_query.py --config <config-path> --danglingLists all [[wikilinks]] whose targets don't resolve. Same data as cortex_lint.py produces but cheaper to query.
Always read only the files returned. Never load the whole vault. For long notes, prefer --section over reading the full file.
For natural language queries, translate to the best combination of flags. If the query mentions a topic without a tag, prefer --search-fts. If it asks "what links to X", use --backlinks. If it asks "what's in section Y of Z", use --section.
Never use the --filter flag with user-provided input. The --filter flag accepts raw SQL and exists only for advanced scripting. For interactive use, always use the structured flags which are parameterized and safe.
Linting
Before committing significant vault edits, run lint to catch convention violations:
python <skill-path>/scripts/cortex_lint.py --config <config-path> --note <path>Or scan the whole vault:
python <skill-path>/scripts/cortex_lint.py --config <config-path>Output includes missing summaries, atomic-ceiling violations, dangling wikilinks, pronoun openers at H2 sections, frontmatter validation issues, and heading slug collisions. Warnings only — never blocks indexing.
Syncing Between Machines
Local → GitHub → VPS:
- User edits or creates a note locally
- Sync script upserts frontmatter to Neon + git commit + push
- On the VPS, Open Claw pulls and has the latest files. Neon already has the metadata (the local machine wrote it directly).
VPS → GitHub → Local:
- Open Claw creates or edits a note on the VPS
- Sync script upserts frontmatter to Neon + git commit + push
- On the local machine, user pulls (or auto-pull via cron/hook). Obsidian sees the new files immediately. Neon already has the metadata.
Run a full sync:
python <skill-path>/scripts/cortex_sync.py --config <config-path> --allSync a single file:
python <skill-path>/scripts/cortex_sync.py --config <config-path> --file <path-to-file>Reindexing
If the index gets out of sync (files edited without the sync script, bulk import, etc.):
python <skill-path>/scripts/cortex_reindex.py --config <config-path>This reads every .md file, parses frontmatter, validates it, rebuilds the Neon table, and removes orphaned entries for deleted files. Idempotent and safe to run anytime.
Git Configuration
# in .cortex/config.yaml
git:
auto_commit: true # commit after every file create/edit
auto_push: true # push after every commit
commit_prefix: "cortex:" # prefix for auto-generated commit messages
remote: origin
branch: mainWhen auto_commit is true, every operation triggers a commit like cortex: create log — stripe rate limiting fix. When auto_push is true, it pushes immediately so the other machine can pull.
Adding Custom Fields
- Add to
schema.extensionsin config:schema: extensions: - name: client type: text default: null - name: due_date type: date default: null - Run migration:
python <skill-path>/scripts/cortex_migrate.py --config <config-path> - Reindex to pick up existing values:
python <skill-path>/scripts/cortex_reindex.py --config <config-path>
Advanced: Semantic Search with pgvector
For querying by meaning rather than just metadata, Cortex supports pgvector. When enabled, the sync script generates an embedding of each note's content and stores it in Neon alongside the frontmatter.
Queries like "find anything related to how we handle rate limiting" work even if no note is tagged with rate-limiting — vector search finds semantically similar content.
Setup requires an OpenAI API key (for embeddings) and pgvector enabled on the Neon database (free tier supports it). See references/vector-setup.md for instructions.
Auto-Capture (Stop Hook)
Cortex can automatically save a session summary note every time a Claude Code session ends, with no manual action required. Enable it once and it runs silently in the background.
How it works
Claude Code fires a Stop hook when a session ends. Cortex registers a hook that calls scripts/cortex_autosave.py. That script:
- Reads the session transcript (passed via stdin as JSON by Claude Code)
- Skips sessions with fewer than 3 turns or no meaningful content (no file paths, commands, or technical terms)
- Extracts: topics discussed, files referenced, commands run, the original request, and the final assistant response
- Creates
logs/YYYY-MM-DD-session-<session_id[:8]>.mdin the vault withtype: logfrontmatter - Calls
cortex_sync.pyto upsert the note to Neon and git push
The script always exits 0 and swallows all errors — it will never block or break a Claude Code session.
Enabling the hook
Add the following to ~/.claude/settings.json under a hooks key:
{
"hooks": {
"Stop": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "python3 ~/.claude/plugins/cache/wynexlabs/cortex/1.4.0/scripts/cortex_autosave.py"
}
]
}
]
}
}If ~/.claude/settings.json already has other content, merge the hooks key into the existing object.
The script reads config from the hardcoded path ~/Documents/Obsidian Vault/.cortex/config.yaml — consistent with the rest of Cortex. If the config is missing or the vault doesn't exist, the script exits silently without writing anything.
Notes produced
Each auto-captured session creates a note like:
logs/2026-04-09-session-a1b2c3d4.mdWith frontmatter:
---
title: "Session — 2026-04-09 — implement the auth refresh logic"
type: log
status: active
tags: [session, auto-capture]
created: 2026-04-09
updated: 2026-04-09
---The body contains: session overview (ID, turn count), topics discussed, files referenced, commands run, the original user request, and the final assistant response. All extracted locally without calling any LLM — fast and private.
Disabling
Remove the Stop entry from ~/.claude/settings.json hooks, or delete the hooks key entirely.
Script Reference
All scripts live in scripts/ and read the config file for connection details. Every script supports --help and --dry-run.
| Script | Purpose |
cortex_setup.py | First-time setup: create table, initial index, verify connection |
cortex_sync.py | Sync frontmatter to Neon + git commit/push (single file or all) |
cortex_query.py | Query the Neon index with structured filters, return file paths + metadata |
cortex_reindex.py | Full reindex: rebuild Neon table from all vault files, remove orphans |
cortex_migrate.py | Add new schema fields to the Postgres table |
cortex_autosave.py | Stop hook: auto-capture session summary notes at session end |
Dependencies
pip install psycopg2-binary pyyamlBoth are well-maintained, widely used packages. psycopg2-binary is the standard Python Postgres driver. pyyaml handles frontmatter parsing.
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.

