Cortex / core
AGENTS.md1 starsChanged 2 months agoMITView on GitHub
Four modules that both index/ and mcp/ depend on. Everything security-critical in Cortex lives here, which is why the directory is small and stays small. - core/ imports nothing else in this repo. Not index/, not mcp/. Enforced by test/architecture.test.js; if you need something from a leaf, the dependency is backwards. - Every caller-supplied path goes through resolveInRoot. It realpaths the nearest existing ancestor, so a symlink escape is caught even for a file that does not exist yet. projects.js…
In this repository50 other files it gives its agents.
- AGENTS.mdAGENTS.md
- index/AGENTS.mdAGENTS.md
- mcp/AGENTS.mdAGENTS.md
- tools/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- analyze-specSkill
- auditSkill
- captureSkill
- catch-me-upSkill
- connect-brainSkill
- cortex-auditSkill
- cortex-briefSkill
- cortex-enrichSkill
- cortex-impactSkill
- cortex-installSkill
- cortex-nextSkill
- cortex-profileSkill
- cortex-reviewSkill
- cortex-scaffoldSkill
- cortexSkill
- cortex-skillsSkill
- cortex-viewSkill
- dailySkill
- diagnosing-bugsSkill
- domain-modelingSkill
- dreamSkill
- grillingSkill
- handoffSkill
- improve-codebase-architectureSkill
- install-projectSkill
- level-upSkill
- migrate-engineSkill
- onboardSkill
- optimize-contextSkill
- optimize-promptSkill
- plugin-syncSkill
- reindexSkill
- resolving-merge-conflictsSkill
- resumeSkill
- scan-projectsSkill
- setup-pluginsSkill
- shipSkill
- site-syncSkill
- skill-auditSkill
- skill-creatorSkill
- team-addSkill
- team-initSkill
- weekly-reviewSkill
- wizardSkill
- writing-for-agentsSkill
The file
Files
core/ — the shared kernel
Four modules that both index/ and mcp/ depend on. Everything security-critical in Cortex lives
here, which is why the directory is small and stays small.
Invariants
core/imports nothing else in this repo. Notindex/, notmcp/. Enforced bytest/architecture.test.js; if you need something from a leaf, the dependency is backwards.- Every caller-supplied path goes through
resolveInRoot. It realpaths the nearest existing ancestor, so a symlink escape is caught even for a file that does not exist yet.projects.jsonce skipped this andgetProjectContext(root, "../../secret")read any file on disk. scrub.jsrefuses; it never sanitises.assertWritablethrowsRefusedWriteErrorand the write does not happen. Silently rewriting a developer's note to remove a secret is a worse failure than declining it with a reason.- No error message may echo a secret.
redact()exists for this;RefusedWriteErrornames the kind of secret and its line, never the value. - Memory is append-only.
append()never rewrites an existing entry. Two developers writing on the same day append to one file and git merges it as text; there is no lost-update case, and introducing one would break the whole shared-memory model. rootmeans the.cortexdirectory, andappend()enforces it. The contract used to live in a doc comment, so passing a repo root — the reading the word invites — wrote a dated file to<repo>/memory/, returned the path it had written and exited 0. Nothing reads there, andgenerated.mjsignores only.cortex/index|findings|view, so it was not even gitignored: a confident wrong output rather than a failure.assertCortexRoot()refuses and names what it was given. Keep the check on the write path — it is the reasoncortex-memory.mjscan rejoin therootProblemcheck the other eightindex/CLIs share.claude-code.jsis data, not policy code. Anthropic's Claude Code rules, each with the sentence on its source page that states it. Checkers read values from it and never hard-code a limit. It holds no I/O and must stay that way — the fetching lives intools/cortex-claude-docs.mjs, which a maintainer runs. A rule no official sentence states does not belong here. ADR 0017.
Gotchas
stamp()is re-exported frommemory.jsfor convenience, butdate.jsowns it. There was briefly a second copy after the kernel extraction; do not add a third.paths.test.jsskips its symlink case on Windows — creating a symlink there needs admin. The skip is expected in local runs and in the Windows CI leg.scrub.test.jscarries acortex:allow-secretsmarker. Without it, Cortex reports its own test corpus as a critical finding on every run. If you add a new detector, add its fixture there, assembled at runtime — a realistic literal trips GitHub push protection and blocks the push.
Tests
node --test core/test/*.test.jsarchitecture.test.js and plugin.test.js are drift guards rather than unit tests: they fail when
the layering or the plugin packaging rots, which no application test would notice.
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.

