Skip to content
locusgraphPublic

About

LocusGraph memory plugins for coding agents

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

LocusGraph plugins

Long-term memory for coding agents, backed by the LocusGraph engine's MCP server at https://api.locusgraph.com/mcp.

Every adapter is a thin layer over that one server: an MCP entry, a rules file, and hooks where the platform has them. There is no per-platform server code.

Platforms

Platform Folder MCP Rules Auto-recall Paid-tool guard
Claude Code claude-code/ .mcp.json skill SessionStart hook PreToolUse hook
Cursor cursor/ .cursor/mcp.json .cursor/rules/locusgraph.mdc sessionStart hook beforeMCPExecution hook
Codex codex/ config.toml AGENTS.md SessionStart hook PreToolUse hook
OpenCode opencode/ opencode.json AGENTS.md no rules only
Gemini CLI gemini/ gemini-extension.json GEMINI.md no excludeTools
VS Code Copilot vscode/ .vscode/mcp.json .github/copilot-instructions.md no rules only

Planned next: Hermes, OpenClaw, Cline / Roo / Kilo, Windsurf, Zed, Claude Desktop, ChatGPT, Vercel AI SDK, LangChain, n8n.

Skills

Claude Code ships these. Every one uses free tools; the only cost is the writes they make.

Skill Fires when Writes
locusgraph-memory any task that could use past context as needed
locusgraph-handoff "wrap up", "hand off", end of day, switching machines 1, handoff:<repo>, overwritten
locusgraph-decision a choice is settled ("let's go with X") 1, decision:<repo>__<slug>, linked to what it reverses
locusgraph-known-fix an error appears, or a non-obvious bug is fixed 1 after the fix passes, fix:<repo>__<symptom>
locusgraph-project-brief "catch me up", "onboard me", "what did we decide" none
locusgraph-seed "seed memory", or a brief that comes back nearly empty up to 10, only those approved, each naming its source file or commit
locusgraph-review "clean up memory", conflicting recall only what the user approves
locusgraph-skills a task with a stored practice (deploy, release, a runbook), or a step of it fails lessons and rewrites the user approves
locusgraph-skill-import "import this skill", a SKILL.md or runbook to store one per approved step or rule, plus skill:<name>

Repository memories are named <type>:<repo>__<slug> and linked to project:<repo>, where <repo> is the directory name of the git root, lowercased, with anything outside a-z0-9_- turned into _. The engine stores ids in that form but looks them up as sent, so the plugin writes them that way from the start. Session-start recall boosts project:<repo> and reserves room for handoff:<repo> with coverage_context_ids, so a new session starts with that repository's decisions and always gets the last handoff: a boost only adds candidates, and a generic query can crowd the handoff out.

The skills that write a repository memory first store an anchor, project:<repo>, holding one sentence on what the repository is. It is written once: a second attempt is refused because the id already holds a memory, and the skills read that refusal as "already there". The anchor matters because the engine binds a related_to edge only to a context some memory owns; without it every link to project:<repo> stays unresolved, and graph expansion cannot walk from one of the repository's memories to the rest.

A stored skill is skill:<name> with its steps (step:<name>__<nnn>_<slug>, numbered in tens), rules (rule:<name>__<slug>) and lessons (lesson:<name>__<slug>). Steps and rules extends the skill. A lesson extends the step it adds to, contradicts a step that is wrong now, or reinforces one proven in a new case; the engine raises or lowers that step's confidence to match, and recall marks a contradicted step. Folding lessons into a step replaces it and raises the skill's version. The other platforms get the same lookup from the Skills section of the rules.

The sources live in skills/; npm run build copies them into claude-code/skills/.

Free by default

Tool Cost
retrieve_memories, list_contexts, delete_memory free
store_event one unit of the writes allowance per memory, no LLM
observe, deep_recall spend credits on a server-side LLM

Every adapter points at /mcp?tools=free and tells the agent not to call the paid tools. Where the platform has hooks, the guard enforces it: a call to observe or deep_recall is refused unless LOCUSGRAPH_PAID=1 is set.

Until the engine honours ?tools=free, the parameter is ignored and the paid tools are still listed. On platforms without hooks, only the rules file stands between the agent and a paid call.

Install

One click for the MCP server in Cursor or VS Code:

Install in Cursor Install in VS Code Install in VS Code Insiders

The buttons add the server only. The rules that tell the agent when to recall and store come from lg init cursor or lg init vscode. lg links --engine dev prints the same links for the dev engine.

One command, for every agent it finds in the project and home directory:

npx @locusgraph/cli init               # lists what it found, writes nothing
npx @locusgraph/cli init --yes         # installs everything it found
npx @locusgraph/cli init cursor codex  # installs only these, no --yes needed
npx @locusgraph/cli init cursor --engine dev   # point at api.dev.locusgraph.com

--engine takes production (the default), dev, or a URL: any https:// origin, or http://localhost / http://127.0.0.1 for a local Worker. Rerunning with another engine rewrites the URL in place, including the Codex table.

Claude Code's plugin reads the engine from LOCUSGRAPH_URL for both the MCP server and session-start recall, so export LOCUSGRAPH_URL=https://api.dev.locusgraph.com before starting Claude Code switches it; lg init claude-code --engine dev prints that line.

It merges into existing mcp.json, opencode.json, .gemini/settings.json, ~/.codex/config.toml, AGENTS.md, GEMINI.md and copilot-instructions.md rather than overwriting them. The rules sit between <!-- locusgraph:start --> and <!-- locusgraph:end -->, so a rerun updates that block and nothing else. A config with comments is refused, not rewritten. Codex is configured in ~/.codex/config.toml, which is global; every other platform is configured per project.

The per-platform steps below do the same by hand.

Sign-in is OAuth. The first tool call opens the browser, and the consent screen picks the graph the token is scoped to.

Claude Code

/plugin marketplace add locusgraph/plugins
/plugin install locusgraph@locusgraph

Nothing else to configure: the consent screen is the only setup. At session start the hook asks Claude to call retrieve_memories once for this repository, and that call goes through the MCP server's OAuth token.

Three things make Claude use memory without relying on it to decide to:

  • No permission prompts for reads. npx @locusgraph/cli init claude-code adds retrieve_memories and list_contexts to permissions.allow in ~/.claude/settings.json, or in $CLAUDE_CONFIG_DIR/settings.json when that is set. store_event and delete_memory still ask.

  • Recall the hook does itself. A hook cannot reuse the MCP token, so by default recall is an instruction Claude may skip. Save a key limited to memory.read on your graph, and the session-start hook fetches the memories over REST and puts them in context directly:

    <print your key> | npx @locusgraph/cli login --graph <graph id>
    

    The key is read from stdin, checked with one free retrieve, and saved to ~/.config/locusgraph/credentials.json (mode 600) for that engine only. See Several graphs for more than one key. lg logout removes them.

  • Skill matching on every prompt. With a saved key, a UserPromptSubmit hook searches stored skill: memories by similarity and, when one scores at least 0.6, adds one line naming it so Claude loads it with locusgraph-skills. It skips slash commands and prompts under three words, and stays silent on no match or any error.

Commands: /locusgraph:why, /locusgraph:remember, /locusgraph:forget.

Cursor

Copy cursor/.cursor/ into the project root, or run npx @locusgraph/cli init cursor. The hooks run node .cursor/hooks/lg.mjs from the project root:

  • sessionStart returns the recall as additional_context. With a key saved by lg login, that is the memories themselves; without one, an instruction to call retrieve_memories once.
  • beforeMCPExecution blocks the paid tools, answering with user_message and agent_message.
  • .cursor/cli.json allows retrieve_memories and list_contexts without a prompt in cursor-agent. The IDE has no file setting for this: allow them under Settings > Agents.

Cursor has no per-prompt hook that can add context (beforeSubmitPrompt can only allow or block), so skill matching on every prompt is Claude Code and Codex only. In Cursor, the Skills section of the rules does the lookup.

Codex

Run npx @locusgraph/cli init codex, then codex mcp login locusgraph, then /hooks in Codex to trust the LocusGraph hooks: Codex runs no hook a user has not reviewed. Init writes:

  • ~/.codex/config.toml: the server, and approval_mode = "approve" for retrieve_memories and list_contexts. Writes keep Codex's default, which asks for a tool that is not read-only.
  • ~/.codex/locusgraph/lg.mjs and ~/.codex/hooks.json: SessionStart recall (plain stdout becomes context), UserPromptSubmit skill matching, and a PreToolUse guard on mcp__locusgraph__(observe|deep_recall). Recall and skill matching use the key lg login saves, as in Claude Code.
  • AGENTS.md in the project: the rules block.

By hand: append codex/config.toml to ~/.codex/config.toml and copy codex/AGENTS.md; the hooks need the CLI, because their command holds the script's absolute path.

OpenCode

Merge opencode/opencode.json into the project's opencode.json and copy AGENTS.md.

Gemini CLI

gemini extensions link ./gemini

VS Code Copilot

Copy vscode/.vscode/mcp.json and vscode/.github/copilot-instructions.md into the project.

Several graphs

The hooks (session-start recall and skill matching) follow the repository's graph:

  1. A repository names its graph in .locusgraph.json at its git root, committed so the whole team uses the same one:

    { "graph_id": "g_work" }
    
  2. Save a key for each graph. The first becomes the default for repositories without the file; --default moves it. An account-wide key (--any) serves any graph without its own key.

    <work key>     | npx @locusgraph/cli login --graph g_work
    <personal key> | npx @locusgraph/cli login --graph g_personal --default
    <account key>  | npx @locusgraph/cli login --any
    npx @locusgraph/cli logout --graph g_work     # one key; plain `logout` removes all
    

The graph is LOCUSGRAPH_GRAPH_ID, else .locusgraph.json, else the default. The key is LOCUSGRAPH_TOKEN, else that graph's saved key, else the account-wide key. A saved key is only ever sent to the engine it was saved for. A version 1 file (one key) still loads, as that key and the default.

The MCP tools are not covered: they use the graph chosen when they were signed in (/mcp in Claude Code). When the graph comes from .locusgraph.json, session start names it, so the agent can say when the tools write somewhere else. Per-repository tools need the engine to accept a graph per call; see the open items below.

Develop

The CLI is TypeScript in cli/src, bundled by esbuild into one lg.mjs that runs on Node 18 with no dependencies. Development needs Node 22.18 or later, which runs scripts/build.ts directly.

cli/src/
  bin.ts              process entry: runs main, writes stdout and stderr, sets the exit code
  main.ts             command table: recall, guard, skill-match, init, links, login, logout
  commands/           one file per command, each returning a CommandResult and doing no I/O to the terminal
  platforms/          one file per agent: detect() and install(); index.ts lists them
  config.ts           engines, MCP URL, paid tool names
  deeplinks.ts        Cursor and VS Code install links, and the README buttons
  engine-flag.ts      --engine, shared by init and links
  env.ts              LOCUSGRAPH_* variables and saved credentials, read once
  credentials.ts      the keys lg login saves, one per graph, readable only by their owner
  repo-graph.ts       the graph a repository names in .locusgraph.json
  engine.ts           the one REST call, POST /v1/memories: recall and skill matching
  files.ts            JSON merge, rules block, TOML table
  hook-input.ts       the JSON a hook receives on stdin
  paid-tools.ts       which tool calls the guard refuses
  workspace.ts        repo name and recall query from git
  generated/rules.ts  rules/*.md joined into one string, written by the build
cli/test/             vitest; bundle.test.ts runs the committed hook bundles

rules/ is the one source for every rules file: its .md files are joined in file-name order, so the number prefix sets the order. skills/ is the one source for every skill. npm run build regenerates the rules files and the README install buttons, copies the skills and licence, and bundles the CLI into claude-code/hooks/lg.mjs, cursor/.cursor/hooks/lg.mjs and cli/dist/lg.mjs.

npm ci
npm run build
npm run check    # build --check, biome, tsc, vitest

check fails when a committed generated file is out of date. Adding a platform is one file in cli/src/platforms/ and one line in its index.ts.

Unverified

Each platform's config shape was written from its documentation, not tested against a running client. Confirm before announcing support:

Platform Check
Cursor beforeMCPExecution input carries tool_name and a deny answer blocks the call; sessionStart additional_context reaches the agent
Codex the hooks run after /hooks trust, and approval_mode = "approve" skips the prompt for the two read tools
Codex remote url servers and codex mcp login work against the engine's OAuth issuer
Gemini CLI excludeTools applies to MCP tools inside an extension
All the engine's OAuth issuer accepts each client's redirect URI and registration
Engine an MCP token that reaches several graphs, and a graph_id argument on each tool, so the MCP tools can follow .locusgraph.json too
Claude Code the 0.6 similarity floor for skill matching fits real skills: no hint on unrelated prompts, a hint on "deploy the api"

Privacy

What the plugins send and where: see PRIVACY.md.

License

MIT. See LICENSE.

About

LocusGraph memory plugins for coding agents

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages