Claude Code plugin
Installed for one of the two, memory or the code index, it does only that one's part (Modes).
The loom plugin for Claude Code does three things in one install:
- Mounts the Loom tools over MCP: memory, search, the code index, and
loom_opfor every other operation. - Captures the session through lifecycle hooks: tool calls, chat turns, a run record, a working-memory note, a session brief and the session’s facts. The hooks make no model call, and the agent has nothing to remember to do.
- Steers the agent to the code index inside a Loom-indexed repository. Whole-file
reads and tree-wide greps are redirected to
code.*operations, and an edit gets the file’s rules before it, and its blast radius and the tests linked to the file after it.
Installed for one of the two, memory or the code index, it does only that one’s part (Modes).
Source: integrations/claude-code-plugin/, Node ESM scripts with no dependencies. The
Codex build runs the same scripts; see codex.md.
Project instructions for MCP-only sessions
An MCP connection makes tools available; it does not require the agent to choose
them. When using Loom without the plugin’s routing hooks, add retrieval guidance
to the project’s existing CLAUDE.md. Preserve its other instructions and name
the paths the index actually covers:
When Loom MCP is configured, use its tools for supported context lookups:
- loom_code_search for behavior; loom_code_symbol for a definition or path:line;
loom_code_outline for structure; loom_code_grep for text; loom_code_callers for callers.
- Read returned bodies and linked lessons before retrieving more. Follow named
callees with loom_code_symbol. Discover deferred tools with ToolSearch.
- Use loom_search for relevant history, decisions and documents. Check source
references, freshness and code-link state before relying on a recalled fact.
- Avoid repeating a successful Loom lookup locally. Explain missing context
before falling back. Use local tools for unindexed or edited files, editing,
tests, builds and Git, or when Loom is unavailable.
When Loom is absent, use the available local tools. Skip retrieval when the
conversation already contains the evidence needed.
This guidance leaves the agent in charge of its solution and verification. It does not guarantee tool selection or fewer calls. Inspect the session trajectory to distinguish successful retrieval, tool errors and local fallback.
The software factory template is shared across its five arms, including the baseline without Loom. Its protocol retains the exact instructions and their hash. Keep these instructed measurements separate from measurements with no project guidance.
Data handling
This section covers the Claude Code plugin and the Codex plugin, which run the same scripts; Codex wires all but the token-usage hook. The hooks and the plugin’s scripts send data only to the Loom server the plugin is configured with; the two skills named at the end of this section are the exceptions. The plugin sends:
- whatever the agent passes to a Loom MCP tool: memories it saves, search and code queries;
- the repository’s identity. The owner and name of each git remote go to
code.reposto find its code index, with the host of a remote on github.com; the MCP entry says which of them the server names to GitHub. The owner and name of the matched remote go with every observation, run record and session brief; the branch andHEADcommit go with each brief, and the absolute working directory with the run record. Observations and session memory are tagged with the checkout’s directory name and a hash of the repository, and observations also carry the working subdirectory; - prompts: the first 2,000 characters (20,000 to the code index), to fetch recalled memories for them
(
context.pack) and, where this Loom holds the checkout’s own repository in its code index, to search that index (code.search;prompt_pack=offstops it);LOOM_PROMPT_CONTEXT=offstops both, and the server keeps the text of a code-index search for 180 days (what a prompt gets); - each tool call’s input, output or error (
observe.record), and the paths of files read or edited, for the code shunt, file rules and blast radius; a symbol name taken from a redirected grep pattern (code.symbol); and the search query of aghissue search the tracker shunt answers (tracker.duplicate_check), with the owner and name of a repository the command names (code.repos); - for each bulk file read or grep in an indexed repository that the code shunt redirects or
lets through, the tool name, file path and line range, and an estimate of the tokens it
kept out of the context or let in (
code.outcome;LOOM_SHUNT_REPORT=offstops it); - chat turns (
conversation.append), which the server stores only when the namespace has conversation logging on; - the session’s last turns (up to 200), to
memory.set_from_messages, which keeps them as source evidence for the facts it extracts whatever the logging setting is, with up to 80,000 characters of the session’s Loom tool arguments and results, and with the paths and last-write times, never the content, of the checkout’s files that changed since the session began: tracked files and untracked files git does not ignore, whatever wrote them, at most 50. A tracked file of code also carries the names of the definitions its changed lines are in, at most four of 120 characters each, read from the hunk headers and the added definition lines ofgit diff -U0(LOOM_SESSION_MEMORY=offstops all of it); - a run record (the first prompt as its goal, the last reply) and a working-memory note (goal, git status, files edited, last reply);
- a session brief at each compaction and at session end: the client’s compaction summary
of the whole context window (up to 15,000 characters) and a log of the session’s events,
with each ask and reply, command, file read or edited, search pattern, web address or
query, subagent prompt, error, todo list, other tool’s name, and pull request and commit
identifier. The server stores none of it, summary or log, when the namespace has
conversation logging off (
LOOM_SESSION_BRIEF=offstops sending it); - token usage and the model name (Claude Code only);
- after each edit in an indexed checkout, the outline of that file’s uncommitted diff
against
HEAD, tocode.impact(LOOM_BLAST_RADIUS=offstops it); - the first time a session changes a file in an indexed checkout, with an edit tool or a
shell command that names it, the outline of that file’s uncommitted diff, to
code.test_gate(LOOM_TEST_GATE=offstops it). Where the install turns the gate’s stop on (stop_test_gate), it goes once more at the Stop of a session that ran no test since its last code change, for the files it changed. WithLOOM_TEST_GATE=blockthe outline goes at Stop only, for the files the session changed, or for the whole uncommitted tree when the client gives no transcript. A diff’s outline, up to 200,000 characters, is its file paths, its hunk line ranges and, in a code file, the last identifier before the first(of each hunk header’s context, usually the enclosing function’s name. Git takes that context from a line above the hunk in the old file, which an earlier hunk of the same diff may have changed; no other part of a changed line is sent; - with no credential, at the first session, your OS user name and host name, to request a
self-signup token (refused unless the server allows self-signup;
LOOM_AUTO_SIGNUP=offstops it); - in agent mode, the workload’s identity token and
LOOM_CLIENT_ID, to the server’s/oauth/token, in exchange for a Loom token.
The plugin’s mode narrows the list. In code mode the hooks send no tool call’s
input, output or error, no chat turn, no session turns for extraction and no list of
changed files, no working-memory note and no brief, and fetch no recalled memory. They
still send each prompt’s text as a code-index search where the checkout is indexed
(code.search; prompt_pack=off stops it), the run record (the first prompt and the last reply;
LOOM_RUN_LEDGER=off stops it), token usage and the model name (LOOM_USAGE=off stops
it), and the code-index items above: a redirected grep’s symbol, the read and grep
records, diff outlines and the repository’s identity.
In memory mode they send nothing to the code index: no remote’s owner and name to
code.repos, no redirect, no read or grep record and no diff outline.
What the hooks do lists the hooks behind these requests. A
client-side redaction removes common credential shapes from the prompts, tool calls, turns,
run records, notes and briefs the hooks send. It is best effort, not a guarantee. MCP tool
arguments and a brief the loom-session skill saves are sent without it.
The server keeps this in its own databases (ClickHouse, and Postgres when the operator stores memories there). It passes text to an LLM or embedding provider only if its operator configured one (models and keys). Deleting data is covered in retention and erasure. Users whose grants allow them to read a stored row, and the server’s operator, can read it. Namespaces and sharing describes access control.
The plugin keeps the token it saves (a copy of the one the hooks were given, or a
self-signup token, in ~/.loom/config.json; in agent mode the exchanged one in
~/.loom/agent-token-<hash of LOOM_CLIENT_ID>.json) and its other state in ~/.loom/,
mode 0600, until you remove it.
Its files in the system temp directory, which can hold prompt and reply text, are
also mode 0600. After a tool call and at the end of a reply one of them holds the
event as the client sent it, tool input and output included and not yet redacted,
until the process that records it has finished. A queued write or event whose
process stopped before sending it stays until you replay or delete it;
loom-status counts these and names the directory. A write the
server refuses, or that cannot reach the server, is discarded. A batch of the per-file
read and grep records above that fails to send is discarded too. Chat turns that fail
are sent again at the end of the next reply, and a brief’s events at the next brief
save. At session start the plugin tries to remove other state files untouched for a
day. They can remain longer, especially when no new session starts. The log of which
tool calls the plugin redirected or let through (no prompt or file content) stays until
you remove it (LOOM_SHUNT_LOG=off stops it).
In a checkout that configures pytest, one more file in that directory, mode 0600, holds
the result of the session’s last pytest run as pytest writes it (test names, failure
messages and tracebacks): the plugin adds its result-file option to PYTEST_ADDOPTS for
the session’s shell commands so that pytest writes it. The file is sent nowhere and is removed when the
session ends; a digest of at most 700 characters, redacted, goes to the model after a
failing run whose output was cut (the test report;
LOOM_TEST_REPORT=off stops it).
Where the code plane is on and LOOM_MCP_CODE_SCOPE is not off, Claude Code’s
SessionStart also writes loom-mcp-project-<hash>.json in the system temp directory
(normally /tmp/loom-mcp-project-<hash>.json on Linux), mode 0600. It holds the
checkout’s absolute working directory, session ID, native client PID, parent PID,
process name and OS process creation marker. It contains no credential or transcript.
The MCP header helper uses it to find this client’s checkout and code namespace. It
survives SessionEnd. A later Claude Code SessionStart checks a file that is over 12
hours old, removes it once its client has exited and refreshes it while the client runs.
This is best-effort cleanup, with no deletion deadline. Codex does not write or read
this artifact.
To match that native client identity, the plugin reads /proc/<pid>/stat and
/proc/sys/kernel/random/boot_id on Linux. On macOS it runs:
ps -p <pid> -o ppid= -o lstart= -o ucomm=
On Windows it resolves System32\cscript.exe under the absolute, drive-qualified
SystemRoot from the parent OS environment. It runs that host with
//nologo //E:JScript //B, the plugin’s assets/mcp-project-win32.js file and the
validated PID as separate arguments. Missing or malformed SystemRoot supplies no
scope; the executable is never searched for in the checkout. That static helper queries
local WMI for Name, ParentProcessId and CreationDate. It requires exactly one
result and returns the name, parent PID and an exact UTC FILETIME creation marker. A
blocked script host or WMI query supplies no checkout scope; the plugin does not enable
components or change scripting policy.
Each subprocess has a one-second timeout and a 16 KiB output limit. These queries read
the process name, parent PID and creation marker, without collecting process command
lines or environments. The header helper checks at most three ancestors, through known
shells to the nearest client, and waits nominally 1.5 seconds for its checkout context
(LOOM_MCP_CONTEXT_WAIT_MS); one process query can finish after that interval.
SessionStart’s cleanup queries the client of a context file over 12 hours old, at most
three per start and each file at most twice a day. A node launcher that starts Node as
a child process instead of replacing itself puts a process the walk does not know
between the client and the hooks; the context then matches nothing, and the connection
gets no implicit code scope. Codex’s fixed MCP entry skips these process queries.
Two skills reach other services, each only when you ask for it. The loom-status skill
can install Node.js from NodeSource through apt, dnf or yum, or from apk or Homebrew, and
runs that installer only after you agree. The improve-loom-for-my-repo skill searches
the ClickHouse/loom GitHub issues for each finding it reports and, after you approve,
files its report there, or adds it as a comment on the issue that already reports it. The
issue is public, and holds the report as shown to you: the server version, namespace,
indexed commit and how much of the repository is indexed, and for each finding a
reproduction with its queries, symbols and file names.
Requirements
- A reachable Loom server (quickstart).
- Claude Code 2.1.139 or newer, the first that runs a hook’s
argswith no shell. An older one drops them and runsnodewith the hook’s payload as its program: every hook fails with aSyntaxError. Claude Code reads a repository’sAGENTS.mdfrom 2.1.277 (2.1.281 on every model provider): on an older client, a repository that keeps the instruction block inAGENTS.mdneeds aCLAUDE.mdthat imports it. - Node.js 18 or newer as
nodeon thePATHClaude Code starts with. Every hook isnodewith the script’s path as its argument, which Claude Code spawns with no shell, and the MCP header helper isnode "${CLAUDE_PLUGIN_ROOT}/bin/loom-mcp-headers.mjs". ThatPATHis Claude Code’s own: started from a terminal it is the shell’s, but started from the Dock or a desktop launcher on macOS it is only/usr/bin:/bin:/usr/sbin:/sbin, which holds no Node from Homebrew, the nodejs.org installer or a version manager. Then setPATHin theenvblock of~/.claude/settings.jsonto the whole search path with that Node’s directory first, such as"PATH": "/opt/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbin". Theenvblock applies to every Claude Code session, terminal ones too, so it needs the whole path, not only Node’s directory. If a hook saysnodewas not found, run theloom-statusskill; it diagnoses read-only and offers to install Node, running the installer only when you say yes. - Supported platforms: macOS (Apple silicon, Intel), Linux (x86_64, arm64; glibc or musl;
WSL 2 included) and Windows (x86_64, arm64), with or without Git Bash: the hooks need no
shell, and the header helper runs under
shon macOS and Linux andcmd.exeon Windows. A hook that finds nonodelets the session continue; Claude Code shows it as a hook error. Without Git Bash, commands run through Claude Code’s PowerShell tool are captured and the test gate reads the paths they name. - A writer token for the namespace the session writes to. A viewer token lets the tools read, but the server refuses every capture.
Install
The install steps are in connect a coding agent. In short:
claude plugin marketplace add ClickHouse/loom # or a path to a local clone
claude plugin install loom@loom \
--config "server_url=https://loom.example.com/mcp?toolset=coding&schema_profile=plugin" \
--config token=<writer JWT>
Install either this plugin or loom-code-skill, not both; the plugin already ships the
loom-code skill. Update with claude plugin update loom@loom: hooks ship with the
plugin, not the server.
| Option | Default | Meaning |
|---|---|---|
server_url |
$LOOM_BASE_URL/mcp?toolset=coding&schema_profile=plugin, else http://localhost:7777/mcp?toolset=coding&schema_profile=plugin |
Full MCP endpoint; include the proxy prefix and desired toolset. The default is used as written, so set LOOM_BASE_URL with no trailing slash |
token |
empty | a writer JWT, stored as a sensitive value |
local_first |
false |
true stands the code shunt down (same as LOOM_CODE_LOCAL_FIRST=on) |
prompt_pack |
auto |
auto, on or off: the code index’s pointers for a prompt, at auto where this Loom holds the checkout’s own repository (same as LOOM_PROMPT_PACK; below) |
prompt_recall |
first |
first, on or off: the memory recall for a prompt (same as LOOM_PROMPT_RECALL) |
prompt_context |
true |
false stops everything the plugin adds to a prompt, code pointers and memory recall (same as LOOM_PROMPT_CONTEXT=off) |
stop_test_gate |
false |
true holds the end of a session that changed code and ran no test since, once (same as LOOM_TEST_GATE=stop; the test gate) |
test_report |
true |
false stops the result-file option the plugin adds to PYTEST_ADDOPTS and the failure digest (same as LOOM_TEST_REPORT=off; the test report) |
The endpoint query chooses the listing, for example ?toolset=coding+tracker, and
mode. Without a recognized toolset the server chooses its configured default.
The hooks do not infer that default.
An origin-only server_url needs reconfiguration with
/mcp?toolset=coding&schema_profile=plugin appended (after any proxy prefix). The
SessionStart hook reports an invalid endpoint. Hooks make no requests and add no test
report until the endpoint is valid, but Claude Code can still attempt an unauthenticated
MCP connection.
Claude Code asks once for optional settings. Keep the default endpoint or supply a complete URL. An empty token uses the lookups below.
- Install token and
LOOM_API_KEY. Claude Code gives the plugin’s MCP header helper neither the install options norLOOM_API_KEYorLOOM_API_KEY_FILE, so the first hook of a session copies the token the hooks were given (LOOM_API_KEY, else the option, else the fileLOOM_API_KEY_FILEnames) and the URL into~/.loom/config.json(0600). It does so only when no token is saved (config.json,~/.loom/token), and never replaces one: when the hooks use another token, fromLOOM_API_KEYor the named file, the Loom tools send the saved one and the primer says to save the hooks’ token inconfig.json. - No credential at all. On a server with
LOOM_SELF_SIGNUP=open, the first session signs the machine up: token to~/.loom/config.json, a claim code to~/.loom/claim-<namespace>.txt, and the primer says how to claim the namespace (once, at/oauth/agent-claim, with a password of your own).LOOM_AUTO_SIGNUP=offdisables this. Otherwise the primer says how to get a token. - One MCP entry only. Do not add a user-scope
loomentry as well: every tool would be listed twice, and that copy carries no code scope.
The instruction block
An agent follows its project’s instruction file. It rarely calls a tool because a tool
listing, a skill’s description or a server’s startup instructions suggest it. In a
repository whose CLAUDE.md says nothing about Loom, the code index is connected and the
agent rarely searches it.
Setup writes the missing lines where prompts get no code pointers, and none
where they do. In a session in the repository, run:
/loom:loom-setup
The skill runs only when you invoke it. It runs the plugin’s bin/loom-setup.mjs, which
writes one block between two markers into the repository’s CLAUDE.md (at the root, or
under .claude/ where the repository keeps it there) and creates the file when there is
none. Where CLAUDE.md imports AGENTS.md with a line @AGENTS.md, the block goes into
AGENTS.md, so a repository that Codex also works in keeps one copy. A block that one of
those files already holds stays in that file. Nothing outside the markers changes, apart
from the two CLAUDE.md cases below, the block takes the file’s line endings, and no
server is called. The block applies from the next session. Commit the file: teammates get
the block from the repository.
Claude Code reads a repository’s AGENTS.md (at the root, or under .claude/) only where
it finds no CLAUDE.md that holds text; text inside HTML comments does not count. The
rule was checked on Claude Code 2.1.333; in a session, /context lists the instruction
files it loaded. In a repository that has AGENTS.md and no CLAUDE.md, or one without
text, setup therefore writes the block into AGENTS.md and creates no CLAUDE.md: a
CLAUDE.md holding only the block would replace the repository’s own instructions in
every session. Where prompts get no pointers and a CLAUDE.md holds only the block beside
an AGENTS.md with text of its own, the session-start line and /loom:loom-status say
that AGENTS.md is not read, and the next /loom:loom-setup deletes that CLAUDE.md and
puts the block in AGENTS.md. A CLAUDE.md with a line of your own stays, and so does the
rule that it replaces AGENTS.md: import AGENTS.md from it to have both read.
Claude Code has that rule from 2.1.277, and from 2.1.281 on every model provider and with
telemetry off, as the default of its Project instructions setting in /config. An
older client reads AGENTS.md only through a CLAUDE.md that imports it, and so does one
whose setting reads CLAUDE.md alone (claude-md on Claude Code 2.1.333). Setup and
/loom:loom-status read the repository’s files, not the client’s version or that setting:
on such a client they still write the block into AGENTS.md and report it as held. There,
add a CLAUDE.md at the root holding the line @AGENTS.md and commit it: every client
then reads both files, and the block stays in AGENTS.md. Where the setting drops project
instructions (managed-only), Claude Code loads no instruction file of the repository, so
no block in it reaches a session.
A file of your own ends the reading of AGENTS.md in the same way: a CLAUDE.local.md in
the repository, or a CLAUDE.md, .claude/CLAUDE.md or CLAUDE.local.md in a folder above
it. The CLAUDE.md of Claude Code’s own configuration folder (~/.claude/CLAUDE.md, or the
folder CLAUDE_CONFIG_DIR names) is not such a file, also for a checkout under your home
folder: the client reads it in every checkout, and AGENTS.md beside it.
The client knows its own CLAUDE.md by the spelling of HOME (USERPROFILE on Windows)
or of CLAUDE_CONFIG_DIR as written, and walks up from the checkout’s path as the file
system names it. A file it passes is its own where its path, or the path its symbolic links
resolve to, is that spelling: a ~/.claude/CLAUDE.md that links to a dotfiles checkout is
its own, and so is a CLAUDE.md above the checkout that links to a plain
~/.claude/CLAUDE.md. One that reaches a dotfiles file, directly or through
~/.claude/CLAUDE.md, is a file of yours above the checkout. Where the spelling differs,
in letter case or through a symbolic link, the file counts as one of yours above the
checkout (checked on Claude Code 2.1.335 on macOS only).
Where a file of your own holds text, Claude Code reads the repository’s AGENTS.md only
through a file that imports it. Setup picks the block’s file from the repository alone, so
it names AGENTS.md on that machine too. Where a file of your own imports that AGENTS.md
(a line @ and its path: from that file’s folder, from the home folder as ~/, or
absolute; not inside a fenced code block), Claude Code reads it and setup adds nothing
more. From a file above the checkout, Claude Code also follows an import whose path differs
only in letter case where the file system ignores it, but none through a linked home
folder, whether or not you approved imports from outside the checkout. From the root’s
CLAUDE.local.md it follows an import of a path inside the checkout through a symbolic
link there or under another letter case (all checked on Claude Code 2.1.335 on macOS only).
Setup counts no other import through a symbolic link. Where prompts get no pointers and no
file of yours imports AGENTS.md, setup adds the line @AGENTS.md to the CLAUDE.md at
the root: it creates the file where there is none, and a CLAUDE.md that held only the
block becomes that one line. Your sessions then read the repository’s AGENTS.md, which
they did not before. Every machine reads the two files, with or without a file of its own
above the checkout, so commit them together.
Where a teammate’s setup wrote the block into AGENTS.md, your machine has such a file and
prompts get no pointers, the session-start line and /loom:loom-status say that the block
is not read and name the file that keeps it unread, and /loom:loom-setup adds the line.
--remove takes the block out and leaves the import line. A block in an AGENTS.md that
a later CLAUDE.md with text
does not import is the one Codex reads: setup under Claude Code writes its own into that
CLAUDE.md, and --remove there leaves the AGENTS.md one to the Codex plugin’s
$loom-setup --remove.
Where prompts get no code pointers (prompt_pack off, or at its
default a checkout whose own repository no lookup has found in an index), and where the
index is still being built or stopped on an error, the block is:
<!-- loom:start (managed by Loom setup: edits here are overwritten) -->
## Loom
- Call `loom_code_search` only when your own search misses the code or the task names no file or symbol.
- `loom_code_edit_context` with `names` (`symbol` or `path:symbol`) reads two or more definitions you can name, and their tests, in one call.
- `loom_code_callers` and `loom_code_impact` give a symbol's callers and tests.
- The index holds committed code: check what it returns against the files.
<!-- loom:end -->
The block is 60 words and 502 bytes. Claude Code does not pass the two marker comments to the model; what it does pass is 410 bytes, read by every request of a session.
The block asks for no first call. The first line says when a search of the index is
worth a request: after the agent’s own search has missed the code, or for a task that
names no file or symbol to search for. The entry loads no tool schema up front, so a
Loom call costs one tool-search request first
(below), and a session told to search the index
ahead of its own lookup pays both requests on every task, also where its own first
command finds the code. The second line names the call that reads several definitions at
once: loom_code_edit_context with the names of two or more definitions returns their
bodies and linked tests in one reply, in place of one request that locates them and
another that reads them. It asks for no call for a single definition, which costs the
agent one command of its own. The third line names the tools that answer with a symbol’s
callers and the tests linked to it.
The block is the same for the code and both modes and names code tools
only. Memory needs no line: the hooks put the session primer and the first prompt’s
recall into the session, and a line asking for loom_context_pack would fetch the same
context again. Besides a checkout whose prompts get pointers, setup writes nothing, and
says why, in three cases:
memorymode, which leaves the code index out: its MCP entry lists no code tool.- A checkout that a session looked up and found in no index, where the search has nothing to answer. Run setup again after the repository is indexed.
- An invalid
server_url, which selects no mode. The SessionStart hook reports it (install).
What a run of setup does and leaves alone:
- Idempotent. A second run changes nothing. After a plugin update changes the
wording the same command replaces the block in place; after the
prompt_packoption changes, or the repository’s index becomes ready, it writes the block or removes it. - Removable.
/loom:loom-setup --removetakes the block out and deletes a file it leaves empty, which its line then names as deleted. - A file it cannot change safely stops it. Setup names the file, exits with an
error and leaves the file as it is in four cases: a start marker with no end marker
after it, or the reverse (a
<!-- loom:startthat is not a whole marker line counts, also in your own text); more than one block; bytes that are not UTF-8; a file that cannot be read. Delete the stray marker line or the extra block, or save the file as UTF-8, and run setup again. - Reported when missing, outdated or not needed. SessionStart says so in one line, once a day for each
checkout, and
/loom:loom-statusshows aninstructionswarning; both name the command. Neither appears in memory mode or in a checkout a lookup found in no index, nor where prompts get pointers and the file holds no block. The SessionStart line appears only when that session’s own lookup found the checkout in an index: not in a checkout with no git remote, withLOOM_CODE_MAP=false, or when the lookup did not answer.LOOM_SETUP_LINE=offdrops the SessionStart line, for a repository that declines the block and for a harness that runs each session in a fresh directory. No hook writes to the repository. - Scripted setup. Run
node <plugin root>/bin/loom-setup.mjsfrom the repository. Setup uses the Claude MCP endpoint’s mode or the mode saved by the last session. Without either, it usesLOOM_MODE.
The block leaves the agent its own tools: it reads working-copy changes locally, and checks what Loom returns against the files. An instruction guides the agent’s choice; it does not prove a lookup occurred.
Where prompts get pointers
Where prompts get the code index’s pointers (prompt_pack: at
its default in a checkout whose own repository is indexed, or on) setup writes no
block, and removes the one it finds as --remove does. Where that deletes a CLAUDE.md
that held only the block, Claude Code reads the AGENTS.md beside it, so a block in
that file goes in the same run. A line that imports AGENTS.md stays, also where the
removal deleted that file: it may be your own. Neither setting covers an index that is
still being built or that stopped on an error: searches of it are incomplete, so a
prompt there may get no pointers. The pointers line of /loom:loom-status warns of
such an index, and setup writes the block there until a lookup finds the index ready.
The prompt hook has searched the
index with the prompt before the agent reads it and put what it found beside the prompt
(what the hooks do, loom-prompt-pack.mjs). The pointer block of
a search answer says on its first line that its paths and line ranges are candidates to
check and that a search is for a task none of them fits. A block in the instruction file
would say that again on every request of every session, and a file setup created for it
would bring the client’s framing of an instruction file with it.
Not every prompt there gets that line. The answer to a named definition, callers or
impact question opens with a line of its own, which names neither the check nor the
search. The hook sends nothing, for example, for a self-contained request, a local-only
change or a memory question, or where the index does not rate its search answer low-risk
and no pick worded it high or medium
(Claude does not call Loom tools has the rest). On a
server with no embedding model, or in a code namespace an administrator has not
calibrated, that can be every search answer no pick stands behind: the checkout then has
neither search pointers nor the block for those prompts, and the pointers line of
/loom:loom-status prints the risk its test search read. With
prompt_context off the hook sends nothing for any prompt: the session has pointers
only where a pipeline put them in the prompt before it started the agent. For a prompt
without that line no line of the instruction file names the search, and nothing the hook
adds to a prompt names loom_code_edit_context. The tool listing names both and the
loom-code skill names the search, and the agent rarely acts on those alone.
Setup reads the prompt_pack option of the last session that started with the plugin,
since Claude Code gives a skill’s shell no install option. Codex and a hand-wired client
have no option: there setup reads LOOM_PROMPT_PACK. Under on it writes no block.
Under auto, the default, it writes none where the hooks’ last repository lookup found
the checkout’s own repository in an index of the Loom they talk to, which is where its
prompts get pointers, and the block anywhere else; it makes no lookup of its own. Under
off it writes the block, and under either other setting where that lookup found an
index that is not ready. Under on a block the file holds otherwise counts as one to remove:
the SessionStart line and /loom:loom-status say so, and /loom:loom-setup takes it
out. Under auto both leave a current block alone: the block is in a file of the
repository that a clone of it and a clone of a fork of it share, and the fork’s prompts
get no pointers. They still name a block from an older plugin or with edits, and a
CLAUDE.md that holds only the block beside an AGENTS.md with text of its own. Commit
the file as the checkouts most of the team works in need it. Setup’s line names what it
read: the prompt_pack setting and, under auto, that Loom indexes the checkout’s own
repository. Under on the choice between writing the block and removing it depends on
the lookup only for an index that is not ready; setup still writes and removes nothing
in a checkout that a lookup of the last ten minutes found in no index.
prompt_context changes none of this. A session that turns
its prompt context off reads the file the repository holds, hears at SessionStart what
a session with the context on would, and leaves the setting setup reads as the
install’s prompt_pack has it.
Claude does not call Loom tools
Count agent tool calls and hook requests separately. In an indexed checkout, unless the
install turns the prompt’s code pointers off (prompt_pack), the
prompt hook searches the code index before Claude chooses a tool and supplies matching
symbols and line ranges, and Claude can use those pointers through a targeted Read
with no explicit Loom tool call.
The test gate also calls code.test_gate itself, after an edit or a shell command that
may have written a file; it names a changed file’s own test, where the file has one,
and does not execute it. Zero explicit calls alone does not establish that Loom was unused.
Check the setup in this order:
- Where prompts get no code pointers, check that the repository’s
CLAUDE.md, or itsAGENTS.mdwhere it has noCLAUDE.mdor one that importsAGENTS.md, holds the instruction block;/loom:loom-setupwrites it. Without it the agent rarely calls a Loom code tool. With it the agent callsloom_code_searchwhen its own search misses the code or the task names no file or symbol. Where prompts get the index’s pointers there is no block, and the agent searches only for a task the prompt’s pointers do not cover. The block namesloom_code_edit_contextfor reading two or more definitions in one call. - Run
claude plugin listand check thatloom@loomis enabled. The plugin and server have separate versions; updating the server does not update the plugin. - Open
/mcpin Claude Code. Check that Loom is connected and listsloom_code_symbol,loom_code_callersandloom_code_search. A connected server without these tools cannot serve Claude’s code lookups. Usetoolset=codingand a mode that includes code inserver_url.toolset=allomits code tools when the server’sLOOM_MCP_CODE_TOOLSis false; it is not a substitute forcoding. - Run
/loom:loom-statusfor runtime, server, token and namespace checks. Never share tokens or authorization headers in a support report. - Check the SessionStart output for the matched repository and code namespace. A new
session whose MCP connection carries the checkout is told neither, so an empty output
there is the working state; otherwise a line says why no index is read (a repository
this Loom does not index, one you are not a reader of, a token that does not name its
namespace, an index still being built). Compare
the indexed commit from
code.index_statuswith the checkout’sgit rev-parse HEAD. A missing remote, an unindexed repository or a failed lookup needs attention before measuring retrieval. See adding repositories. - Check
/hooksfor the plugin’s SessionStart and UserPromptSubmit handlers. A harness using--bare,--safe-modeor disabled hooks does not run the normal plugin path. - Inspect failed tool results as well as attempted calls. In headless
dontAskmode, an unapproved tool is denied. When managed settings setallowManagedPermissionRulesOnly, a command-line--allowedToolslist cannot grant access. Have the policy owner approve the intended Loom tools; do not rename the registration or disable the policy to evade the denial.
When a headless harness restricts --tools, include ToolSearch to preserve deferred
MCP tool loading. Omitting it loads the MCP schemas into context up front; it does not
show whether the task needed those tools. --allowedTools controls permission and
cannot restore a tool omitted from --tools. See Claude Code tool search.
In the coding toolset the server requests upfront loading for
loom_code_edit_context and loom_code_grep, and for loom_code_symbol
outside the compact shapes (schema_profile=compact or plugin). Clients can discover the other code tools
and, where listed, general search (loom_search) and the dispatcher (loom_op)
when needed.
Other toolsets, a union such as coding+tracker included, request upfront
loading for loom_code_search, loom_code_grep, loom_code_symbol,
loom_search and loom_op where listed. The published plugin’s entry names
schema_profile=plugin on the coding toolset: the toolset in the compact
shapes, without the tools the hooks and the startup instructions make redundant (modes). Without the header below, the server loads three code tools
up front on that profile: those two and loom_code_search. In code mode
the entry lists the code tools alone; in memory mode it lists no code tool and
loads none up front.
Nothing tells every session to call a Loom tool:
the instruction block names the search for code the agent’s
own search misses and for a task that names no file or symbol, and the pre-edit
read for two or more definitions the agent can name; where the prompt hook
brings the index’s pointers with the prompt there is no block, and a search answer’s
pointers ask for a search only when none of them fits. Every request of a session
re-reads each schema loaded up front, called or not, so the entry’s header helper asks
the server to load none up front (X-Loom-Tool-Loading: on-demand). Every tool stays listed
for tool search, a Loom call costs one tool-search request first, and
the startup instructions say nothing about the code tools (in code mode there are none).
In an indexed checkout whose connection carries it, the plugin’s text in the first
request in code mode is about 1,050 bytes before a prompt’s pointers: the three skill
descriptions and the tool names.
With prompt_pack off, or in a checkout no index holds, no pointers are added
to that request, and where setup wrote the block it is 410 bytes more. The
three schemas would be about 4,000 bytes more. A server that does not read the
header keeps its own loading and its own startup instructions.
LOOM_MCP_ALWAYS_LOAD_TOOLS=auto selects the defaults above. Supply a comma-separated
list of operations such as code.symbol or synthetic tool names such as loom_op
to select a different set. An empty value leaves loading to the host. The model
chooses calls and the server enforces permission in every mode.
MCP connections receive routing for the available Loom capabilities, including
memory, documents, code, issues, tasks and records. Prefer a fitting listed tool;
use loom_op help to discover an unlisted operation. The assistant toolset has
only its listed read tools. This guidance does not depend on plugin hooks.
The plugin’s own connection gets one
paragraph instead, because its hooks say the rest when it applies: the
checkout’s code namespace at session start, the Loom call in place of a local
read they refuse, a file’s memories at its first local read or before an edit
and recalled memories beside the prompt. In a one-plane mode the paragraph is that plane’s sentence.
A first-step memory pack requires a default memory namespace; code tools use
the supplied code scope. Instructions guide tool choice and do not prove a
lookup occurred.
Loom returns the complete MCP initialization instructions without a character cap.
The client can apply its own limits. In Claude Code,
CLAUDE_CODE_MAX_MCP_DESCRIPTION_LENGTH
controls the client limit for server instructions and tool descriptions.
The plugin’s loom-mentor skill can load automatically when the relevant Loom
operation is unclear. It covers capabilities beyond code and memory and defers
to a fitting tool the agent already knows. Existing context can satisfy a task;
tool routing does not require extra lookups or authorize writes.
Managed settings can also set hook environment variables. Clearing the launcher’s environment does not clear those settings; inspect the effective configuration and respect its policy. See settings precedence.
LOOM_CODE_SHUNT=off disables code-read substitution. Automatic code pointers on
prompts are sent in an indexed checkout unless prompt_pack or LOOM_PROMPT_PACK=off
turns them off. Prompt-time
memory recall has its own LOOM_PROMPT_RECALL control, and LOOM_PROMPT_CONTEXT=off
turns both off (what a prompt gets). Record these choices in
comparisons; enabling the code hooks alone does not establish a benchmark improvement.
Where it is on, the prompt pack selects one bounded lookup for a clear named definition, callers or
impact question, and uses search for concepts. Named implementation or behavior
questions can receive the definition body within the existing 600-token server budget;
pure location and signature questions receive pointers. Large definitions remain
elided and need a focused read. Returned bodies are delimited as untrusted data.
It skips explicit memory questions,
local-only changes, self-contained requests and a turn the host writes itself when a
background command ends (one that opens with <task-notification>). Ambiguous or empty typed answers do
not trigger another automatic lookup. Search pointers are sent only when
the index labels its own answer low-risk (or, with LOOM_PROMPT_PACK_MIN_CONF
set, from that confidence) and never when it abstains. An answer the server’s pick
worded high or medium is not held to the label: with the variable unset it sends its
first pick alone where the label is not low
(model-picked pointers). Under either gate each unit of
the answer is held to the place test on its own, and only the units that pass, the
answer’s places to edit, are sent, one pointer per place, because the model re-reads the
pointers on every later request: a unit that is not a place is not carried by one that
is, and an answer with no place sends nothing. In Python, C and C++, TypeScript and
JavaScript, Go, Rust and Java source a unit is a place when it is a definition (a
function or method, a class, a named symbol); the file’s leading comments and imports
and its module-level code are not, and neither is any unit of a source file the index
could not parse. A unit of any other file is a place: a notebook, a component file, SQL,
shell, configuration, and source the index reads as text (Kotlin, Ruby, PHP, C#, Swift).
A document is a place when the request asks for documentation or the prompt names the
file: .md, .mdx, .markdown, .rst, .adoc, a change log, release notes or a
README by its name (CHANGES, HISTORY and NEWS as written, changelog,
release notes and readme in any letter case), and a .txt file of a doc, docs
or documentation directory that is not a requirements, constraints or CMake file. A
unit of another file a fix is not made in is a place only when the prompt names the
file: a Python migration file named by its number under migrations, a C or C++ file
in a directory below a directory named external, at any depth
(lib/external/zlib/inflate.h), and at the top of the repository the extern and
release directories, their documents too, and setup.py, fabfile.py, noxfile.py
and pyproject.toml. Any other file under an external directory is source. A
migration written by hand in SQL or another language is source. A file is
named, spelled as its path spells it, by the path or a tail of two
or more of its segments under any directory, by its base name after ./, or by a bare
base name that has an extension and no directory before it: CHANGES as a word names no
file. A mention anywhere in the prompt counts, also in a sentence that tells the agent
what not to edit and in a pasted traceback: the hook does not read which way a mention
points. Naming a
file lifts the rule on its path, not the rule on definitions. A test counts when the
request asks for tests or the prompt names the test’s file. For a request that asks for tests
module-level code, and a unit of a source file the index could not parse, count too: a
pytest fixture in conftest.py and a CI definition written as assignments are
module-level code outside any test directory. The hook reads whether a request asks for
tests as the search ranking does: from every search term (a word or a part of an
identifier) of a request of at most 48 terms, and from the first 16 of a longer one, so
an issue that names a test where the fault showed does not ask for tests. Whether a
request asks for documentation is read from the same terms: one of doc, docs,
documentation, documented, readme, changelog, release, releases, guide,
tutorial and manual, the words for which the search ranking lifts its penalty on
documents. A request to change a page that holds none of them gets no pointer to a
document it does not name. A test is a
file under a test, tests, __tests__, spec, specs, test-data, testdata or test_data directory or with a test-style name, so source a framework keeps in a directory named
test and design documents in a directory named specs count only for such a request
or by name.
No pointer’s range lies inside another’s. A range and the ranges the answer holds inside
it (a class and its own methods) are one place: each innermost definition the prompt
names stays (the last segment of its name, four characters or more, as a whole word),
else the range when the prompt names it, else the one the index ranked first. What is
chosen so, when it is a range of more than 200 lines, gives way to the first-ranked
definition the answer holds inside it, which is the part of it the search matched, so a
long class the prompt names is sent as that method; with none inside it, it is sent as
its first line, the definition’s signature, with its length
(path:643 Permutation (372 lines)). The highest-ranked place in the file of the answer’s
first result is listed first, also when that result is no place itself or is sent as a
definition ranked below another file’s; the other places keep the index’s order, as all
do when that file has no place. The low-risk label says the index holds code about
the prompt, not that the pointers are where a fix is made, and no field of the answer
tells the two apart. The place test reads a unit’s path and kind and does not tell them
apart either: an answer that holds only other places is sent.
The pointers are candidates, and
the text does not tell the model to stop searching. The prompt waits for the lookup
no longer than LOOM_PROMPT_PACK_TIMEOUT_MS (2.5 s), which the repository lookup and
the answer share: pointers that have not arrived by then are skipped. A searched prompt
that reads as a bug report has LOOM_PROMPT_PACK_PICK_TIMEOUT_MS (6 s) instead, whatever
the first variable says, and a repository lookup that is not cached can end up to
1.5 s past either bound on a slow server
(the pick). A search with no semantic leg
(a server with no embedding model, or a vector leg that failed or missed its deadline)
reads medium (confidence 0.5), so it sends no search pointer but the first pick of an
answer the pick worded high or medium. LOOM_PROMPT_PACK_MIN_CONF=0.5 sends search pointers for
every indexed-code answer whose confidence is 0.5 or more, such a search’s included, but not
for one the pick worded low. A code namespace an
administrator has not calibrated can read answerable prompts medium or high risk,
and with the variable unset then sends only the first pick of an answer the pick worded
high or medium
(code.calibrate). Supply a task inside <issue>...</issue> when a harness adds instructions;
the existing query helper extracts that block. It also reads a prompt that opens as labelled
lines (repo: ..., base_commit: ..., problem_statement: ...): one to twelve labelled lines
whose value is one word, then a line labelled issue, task, problem, question, request
or query (or one of these with statement, description, text or body). The search text
is that line’s value, to the end of the prompt, without the sentences that tell the agent how
to work or answer; a value shorter than 12 characters leaves the whole prompt as the search
text. A YAML block marker after the label (|, >-) and quotes around the whole value are
not part of the value. The lines above it are left out whatever they hold (file: src/a.py,
or task: T-123 above a problem_statement: line). One line may stand above the labelled
lines and is left out too: a lead-in that has no label of its own and ends in a file path and
a colon (Fix the issue described in ../task.yaml:). The file path is the line’s last word.
A word that opens with // or has a colon before its first slash is not one: a URL with a
scheme (https://example.org/api.json:) or a remote (git@example.org:team/app.git:), but
not a drive letter (C:/work/task.yaml:). A URL with no scheme (example.org/api.json:)
reads as a file path. A prompt with any other first line (a question that ends in a colon,
in such a word or in a dotted name with no path, such as Node.js: or ci.yml:, a labelled
line of prose), with a labelled line of prose above the request, or with the labelled lines
further down, is searched as written.
A request that holds three or more Markdown heading lines (# to ######, then text)
outside fenced blocks is a filled-in form. The search text leaves out those lines and the
_No response_ lines of empty fields: a repository keeps the same headings in its issue
template and in the code that writes a report for one, and the search ranks those first.
What is left is searched when it has 12 characters and more than one word; otherwise the
request is searched as written. The request the plugin sends with its lines keeps its
headings.
Memory recall’s default first mode makes one attempt on the first qualifying prompt,
even if the answer is empty or abstains. A clear named definition, caller or impact
question skips default recall and leaves that attempt available. Mixed requests for
saved memory, decisions, conventions or lessons still qualify, as do conceptual tasks.
Use on when recall on each qualifying prompt, including named code questions, is wanted.
Whether a prompt qualifies, names a definition or asks for saved memory is read from the same
text as the code pointers’ search: the inside of an <issue> block, or the request line’s
value of a prompt that opens as labelled lines. A request there that opens Use only the provided source gets neither recall nor pointers, and one that opens Remember ...
qualifies for recall and gets no pointers. A turn the host writes itself when a background
command ends qualifies for neither. The memory search itself is sent the whole prompt.
A recalled memory that is linked to a file of the checkout is added whole at the prompt
only when the prompt names that file or definition, or asks for saved memory. A prompt
names it by the path, the file name, or the last segment of the definition’s name when
that has four characters or more, in any letter case and not inside a longer identifier.
Otherwise the prompt gets one line for the record, its key and the file, and the session
counts the record as shown: loom_memory_get reads it whole by that key, and
loom_search finds it.
The file-context hook adds the record’s own line after a local read of that file and before an edit of it: 220 characters at most under its key, among the file’s other records in a block of 300 tokens. A record the prompt got whole is not printed again at its file, unless it is a decision or a constraint. What that hook does not cover:
- a read that the code shunt denies and answers from the index adds no line, and neither does a read through a Loom code tool, whose answer can carry the record as a linked lesson instead;
- the hook looks up 40 files a session at most, and stops after three lookups the server did not answer;
- a subagent’s read puts the line in the subagent’s context.
A record is shortened to that one line only in a checkout of a repository this Loom
indexes, when the record is in the session’s namespace or the repository’s code
namespace, is linked to code of that repository, and has six linked places at most. In
a checkout with no remote, with LOOM_FILE_CONTEXT=off, and for a record no longer than
the line, the prompt gets the record whole. Decisions and procedures are always added
whole.
The plugin’s startup instructions name no tool to call first, and its loom-code
skill can load automatically. The agent follows the repository’s own instruction file
more reliably than either: where prompts get no code pointers,
the instruction block is the project’s policy on when to
search the index, and /loom:loom-setup writes it.
A saved fact and an established code reference are separate outcomes. Check the returned metadata before claiming a link or change tracking; a file path in prose alone does not confirm either. Required recall and validation belong to the application’s orchestration; instructions guide the model’s choices.
For headless Claude Code, keep the project setting source enabled: passing
--setting-sources '' excludes the project’s CLAUDE.md as well as its settings.
When reporting a comparison, include the plugin and server versions, model, repository
and indexed commits, listed code tools, hook output, explicit tool calls, failed requests,
cost and elapsed time. Keep the task and test budgets equal between arms. To isolate
the test gate’s contribution, compare a baseline, the plugin with LOOM_TEST_GATE=off,
and the full plugin. Index the issue’s starting commit so the real fix is not searchable.
Who owns the calls and validation
| Path | Who chooses the operation | Evidence to check |
|---|---|---|
| SDK or HTTP stages | Application code invokes the stage directly. | A valid scoped result and the controller’s validation. |
| Plugin hooks | Configured handlers run on matching CLI events. | Hook event, server request, returned context and delivery. |
| Model tools backed by SDK or MCP | The model decides whether to investigate. | The actual call and a valid result, not a listed tool. |
Exposing an SDK binding does not force the model to use it. Zero model-selected MCP calls can still include automatic hook requests. A request attempt alone does not prove success or useful context. Required retrieval or validation belongs to a controller that runs the stage and rejects missing or invalid results; a tool listing or a prompt instruction does not enforce the gate. See agent integration.
Normal claude -p runs can discover project settings, plugins and hooks. --bare
skips discovery: explicit MCP configuration or plugin flags can still load tools,
but hooks do not run, even when explicitly configured. Calling a model API directly
runs only the client program, without CLI hooks. See headless usage.
Hook context does not appear
The file-context hook runs on PostToolUse, after Read, Grep and Bash, and on
PreToolUse, before Edit, Write, MultiEdit and NotebookEdit. After a read it looks
up each file of the checkout the call read: the file Read names, a Grep of one file,
and in a shell command a file read whole or by a line range (cat, sed -n, head,
tail) or searched by name (grep pattern file). A command the hook cannot follow, such
as a script that opens the file, starts no lookup. The hook emits context only when
memory.for_file renders matching memories, decisions or constraints. When the checkout
has a remote, your own rows are asked for by repository and not by the project: tag: by
the repo:<id> tag of each of its remotes and of the repository its index matched. A row
written in another repository is then not shown, even when both checkouts have the same
folder name or the same LOOM_PROJECT_NAME, nor is a row that carries the project: tag
alone; a worktree under another folder name gets the repository’s rows. A checkout with no
remote asks by the project: tag. On a deployment whose default scope is all_mine
(LOOM_MEMORY_SEARCH_DEFAULT_NAMESPACE_SCOPE), the lookup of a checkout with a remote
also returns the rows you wrote in your other namespaces, the ones prompt recall reads; a
row from one names its namespace. A file is looked up
once per session and agent context, including an empty answer; a compaction clears that,
and before an edit a file shown more than LOOM_FILE_CONTEXT_TTL_MIN minutes ago is
looked up again. A record is printed once per session and agent context as well: one the
prompt gave whole, or one printed with the same line in another file’s block, is left out
of a later block, and a block with nothing else to print is not added. A record’s line
says the state of its code in that file, so a record whose code changed in a second file
is printed there. A team rule, a decision and a constraint are printed under every file
they name: the block’s first line is what says the rule holds for that file. A compaction
clears what was printed, and before an edit a record printed more than
LOOM_FILE_CONTEXT_TTL_MIN minutes ago is printed again. Leaving a record out needs a
server that names the rows a block prints (printed on memory.for_file); a block from
one that does not is added whole. An empty answer does not count while the checkout’s
last repository
lookup is one the server did not answer: a fork whose parent only the server names is
then asked for by its own id alone, so the file is looked up again at its next read or
edit. Reads look up at most three files per call and 40 per session, and stop
after three lookups the server did not answer.
The blast-radius hook runs on PostToolUse after Edit, Write and MultiEdit.
It stays quiet for untracked files, empty diffs, repeated impact results, an unavailable
index or a failed request. Edits performed through Bash, including scripts using
python or sed, do not match either edit hook.
The test gate’s line does follow a shell edit. It runs on PostToolUse after Bash and
PowerShell, and rides the blast-radius hook after Edit, Write and MultiEdit. It
emits Loom test for <file>: <command> the first time the
session changes a file, and only when the command names the file’s path, the file
differs from HEAD, it was written after the session began, and the file has a test of
its own with a runner the checkout configures (the test gate). It
stays quiet for a file with no such test, one whose test an earlier line named or the
command itself ran, a comment-only change, an untracked file, a file already asked about in the session, an
unavailable index or a request that failed twice, and always with LOOM_TEST_GATE=block
or off. A command that only reads (grep, cat, sed -n, git diff and the like,
with nothing redirected to a file) wrote no file: it gets no line, starts no git
process and sends no request.
Headless sessions support hookSpecificOutput.additionalContext; ordinary visible
assistant output does not prove whether that context reached the model. Capture
--debug hooks,mcp output privately and redact tokens and authorization headers before
sharing it. Include the hook event, tool name, hook output and relevant stream events.
Correlate them with server requests to memory.for_file, code.impact and
code.test_gate to distinguish
hook matching, request execution, nonempty context and delivery to the agent.
Configuration
Where the hooks find the server and the identity. The MCP endpoint selects the
control-plane base, including its proxy prefix. Credentials and identity follow the
lookups below (lib/loom-client.mjs):
| What | Lookup order |
|---|---|
| server | the base of server_url; its default uses LOOM_BASE_URL, else http://localhost:7777 |
| token | LOOM_API_KEY → token option → the file LOOM_API_KEY_FILE names → config.json token → ~/.loom/token (with LOOM_API_KEY_FILE unset) |
| org | LOOM_ORG → config.json org → the token’s org claim → default |
| namespace | LOOM_NAMESPACE → config.json namespace → the token’s first non-wildcard namespace → coding |
| agent | LOOM_AGENT → config.json agent → claude-code |
Store the remote server’s token in one file for the hooks, helper and CLI
(LOOM_CONFIG_FILE moves it):
{ "url": "https://loom.example.com", "token": "<writer JWT>", "namespace": "my-team" }
The MCP entry does not read it: its URL is the server_url install option, whose
default appends /mcp?toolset=coding&schema_profile=plugin to LOOM_BASE_URL, else
localhost. Set the endpoint too; a config file alone does not select the plugin’s
destination.
Project scoping. The project is the basename of the git toplevel
(LOOM_PROJECT_NAME overrides it). With the default LOOM_PROJECT_SCOPE=tag, every
project writes to one namespace and each row carries a project:<name> tag.
LOOM_PROJECT_SCOPE=namespace makes the project name the namespace instead. Rows also
carry repo:<id>, a hash of a remote’s normalised URL: the remote the checkout’s index
matched, else upstream, else origin, else the first remote (LOOM_REPO_REMOTE
overrides the remote), and the file-context hook asks by the checkout’s repo: tags (the
override’s alone when it is set) and not by the project tag, so two clones of different
repositories with the same directory name, or with one LOOM_PROJECT_NAME, do not share
file memory.
Modes
With schema_profile=plugin, the endpoint’s mode query parameter selects which planes
the hooks use. It also narrows the MCP listing when the toolset includes coding. For a
code-only session:
claude plugin install loom@loom \
--config "server_url=https://loom.example.com/mcp?toolset=coding&schema_profile=plugin&mode=code"
| Mode | The hooks | The MCP entry lists |
|---|---|---|
both (default) |
capture the session, recall memory and answer from the code index | 19 tools: the coding toolset without four of its tools |
memory |
capture the session and recall memory; no request reaches the code index | 7 tools: the listing without its code tools, and the duplicate check |
code |
answer from the code index; nothing of the session is captured, recalled or extracted | 13 tools: the code tools alone |
- Code mode captures nothing: no tool observation, chat turn, brief, working-memory
note or session hand-off. The server has no session to extract facts from, so it makes
no model call for one. The hooks read no memory either: no primer pack, no recall and
no file memories. The code shunt, the prompt’s code pointers, the blast radius and the
test gate work as in
both; the shunt’sghissue-search redirect and the mentor hints, which each name the other plane’s tools, are off. - Memory mode sends no
code.*request and lists noloom_code_*tool: no redirect of a read or grep, no code pointers, no blast radius, no test gate, and noX-Loom-Code-Scopeheader. The file lookup covers your own namespace. A repository’s team rules are found through its code index, so they needboth. - Every mode keeps the run ledger:
run.beginwith the first prompt,run.completewith the last reply, andcost.record_turnswith the token usage.LOOM_RUN_LEDGER=offandLOOM_USAGE=offturn them off. SessionStart also probesGET /v1/healthin every mode, for the hooks’ request bound. - An event starts one hook process in every mode. At a prompt, after a tool call, at
Stop, at SessionEnd and before a compaction that process is the launcher (
hooks/loom-record.mjs), which loads a script the session waits for only where the mode runs its plane. In code mode a shell command starts no hook before it, unless it runsgh, and the launcher after it, which runs the test line, only for a command that may have written a file, and the test report, only for one that starts a test runner or shows a pytest refusing the report’s option; an edit runs the blast radius; a Stop runs the test gate where the install asks for it (stop_test_gate). After a call that has only memory’s scripts to wait for the launcher loads none of them. The recording scripts are loaded in every mode, and each checks its plane itself: one whose plane is off sends no request and prints nothing. - The entry leaves out the tools of the
codingtoolset whose op a hook runs in that mode. Inbothandmemory:loom_context_pack(SessionStart and the prompt hook load the pack) andloom_working_memory_set(Stop and PreCompact write the note). Inbothalone:loom_tracker_duplicate_check(the issue-search redirect asks the tracker record; it needs the code plane, so memory mode keeps the tool). Each op still runs throughloom_op, for example{"op": "context.pack", "arguments": {"query": "<task>"}}. The entry also leaves outloom_activate, which returns the Loom-first rules and the authored profile: the entry’s startup instructions carry the profile and one paragraph in place of the rules. A client that connects without the plugin’s profile lists all four. The listing follows the entry’s URL, not the session’s hooks: where a hook is switched off (LOOM_INJECT_CONTEXT=false,LOOM_PROMPT_RECALL=off,LOOM_WORKING_MEMORY=off,LOOM_TRACKER_SHUNT=off,LOOM_CODE_SHUNT=off), and for the redirect in a checkout that is not indexed or underclaude --bare, no hook runs the op andloom_opis the way to it. - No mode declares the
resourcescapability: theloom://primerresource holds whatloom_activatereturns, which the startup instructions make redundant in the same way, so the entry lists no resource.bothandmemorydeclaretoolsandprompts. Code mode lists no prompt either and declarestoolsalone: Claude Code 2.1.332, connected to a server that declarestoolsalone and to no server that declares resources, asks for neither list and leaves the names of its three resource tools out of the session’s requests. - The three skills are listed in every mode: a skill’s description is fixed text the client loads at start. Each says when to load its skill in one line of at most 160 bytes, 480 for the three.
- The listing needs a server that reads
?mode=(MCP reference). An older server ignores it and lists both planes; the hooks follow the mode either way.
Omit mode to use both planes. A toolset without a coding part keeps its MCP listing
even when the hooks use one plane. The Claude Code plugin follows its endpoint, not
LOOM_MODE; where LOOM_MODE names another mode, the session’s primer says so. Codex
and hand-wired clients use LOOM_MODE for their hooks; it does not change their MCP
listings.
The MCP entry and its header helper
The plugin’s .mcp.json uses the complete server_url value. The header helper runs in
the plugin root, so it reads checkout context from SessionStart’s private state rather
than its working directory. It sends:
Authorization: Bearer <token>, fromconfig.jsontoken, then~/.loom/token: of the hooks’ lookup, Claude Code keepsLOOM_API_KEY,LOOM_API_KEY_FILEand the install option from the helper (see above). Claude Code connects the MCP entry while the SessionStart hook is still running, so with no token the helper waits up to 5 s (LOOM_MCP_HOOK_WAIT_MS) for that hook to save one, then performs the same first-session sign-up.X-Loom-Code-Scope: <org>/<namespace>, the code namespace the project’s checkout resolves to. The server applies it to everycode.*call that names no namespace, so the model does not have to pass one.LOOM_MCP_CODE_SCOPE=offdisables it, and an entry in memory mode sends none and looks no repository up.X-Loom-Tool-Loading: on-demandfor aschema_profile=pluginendpoint outside memory mode. The server then marks no tool schema to load up front. This header does not depend on checkout context or the presence of a Loom instruction block.
The MCP header helper uses the latest SessionStart checkout directory, held with the session identifier, client PID, parent PID, process name and OS process creation marker in a private temporary file. This file contains no token and survives session end. It is keyed to the client process’s creation identity. The helper checks only its own live process ancestors and waits for a bounded interval. An unavailable process identity, missing context, unindexed checkout or failed repository lookup leaves the connection without an implicit code scope; pass org and namespace explicitly in that case. A helper error does not prevent Claude Code from attempting an MCP connection. A later Claude Code SessionStart removes the file once its client has exited (Data handling).
The checkout’s repository is found from its remotes (origin, then upstream, then the
rest) through code.repos. The plugin names a remote on github.com as
github.com/<owner>/<name> and any other by owner and name alone. The server looks the
names up among the repositories it indexes. When none has an index you can read, it asks
GitHub whether a remote named on github.com is a fork, so a GitHub fork with no index of
its own resolves to its parent’s index when you can read that one;
LOOM_CODE_FORK_UPSTREAM_LOOKUP_ENABLED=false on the server stops that request. The
server names a remote on any other host to no outside service, so a fork there gets its
parent’s index through an upstream remote that names the parent, or through
LOOM_CODE_REPO. So does a GitHub fork whose remote does not spell the host, such as an
SSH host alias (git@github-work:<owner>/<name>). An older server asks GitHub about the
first three remotes whatever their host. A plugin older than 1.2.126 names every remote by
owner and name alone, so with this server a GitHub fork with no upstream remote reads
as not indexed until the plugin is updated.
LOOM_CODE_REPO=<owner>/<name> or a bare name (or the code_repo option, or
code_repo in ~/.loom/config.json) is the fallback candidate after the remotes: it
serves a session outside any git checkout, or a checkout with no index, and gives it
that repository’s index and scope header. Name the indexed repository there: the server
does not ask GitHub about a fork named as <owner>/<name>, which reads as not indexed,
and resolves one named by its URL (https://github.com/<owner>/<name>) to its parent’s
index, as it does a remote. The helper’s repository lookup is bounded at 2.5 s, after
its wait of up to 1.5 s (LOOM_MCP_CONTEXT_WAIT_MS) for the session context. A miss
leaves the scope header absent.
See code index overview and the MCP reference for how the server uses the scope.
What the hooks do
The wiring is hooks/hooks.json; hooks/HOOKS.md has per-hook notes.
| Event | Script | Effect | Off switch |
|---|---|---|---|
| SessionStart | loom-session-start.mjs |
one budgeted context.pack primer (working-memory note, profile, the session’s memory stack, recent runs with LOOM_CONTEXT_RUNS; and the memories, decisions and procedures a search for the project finds or, where a new or cleared conversation’s prompts get the recall, the pinned and newest ones, listed), one line naming an indexed checkout’s code namespace and the repository’s memory tag (left out in a new session whose MCP connection carries the checkout: the server then applies both), a line naming the project’s saved session briefs, a task-inbox line (task.counts), a few lines naming the collections the token can read (collection.list), and a line when the instruction block needs setup |
LOOM_INJECT_CONTEXT=false, LOOM_CODE_MAP=false, LOOM_TASK_INBOX_LINE=off, LOOM_COLLECTIONS_LINE=off, LOOM_SETUP_LINE=off |
| UserPromptSubmit | loom-prompt-pack.mjs |
no request with prompt_pack off; at its default no prompt text unless this Loom holds the checkout’s own repository (what a prompt gets); otherwise up to three code.search pointers for the prompt, only when the index rates its answer low-risk or the pick worded it high or medium (with LOOM_PROMPT_PACK_MIN_CONF set, from that confidence instead) and then only the answer’s places to edit, one pointer per place: a definition, a unit of a file the hook does not hold to definitions, a document or a test when the prompt names it or asks for documentation or tests, a Python migration or a release script only if named, and module-level code when it asks for tests; below them the test line for a pointer whose definition the prompt names (the test gate) |
off unless prompt_pack or LOOM_PROMPT_PACK=on; LOOM_PROMPT_CONTEXT=off |
| UserPromptSubmit | loom-prompt-recall.mjs |
one bounded context.pack recall for the prompt (memories, decisions, procedures), injected only when memory does not abstain: whole records, and none of code as it was before a commit the checkout already has; of a record linked to a file of the checkout that the prompt does not name, one line: its key and the file |
LOOM_PROMPT_RECALL=first (default) / on / off; LOOM_PROMPT_CONTEXT=off |
| UserPromptSubmit | loom-run.mjs |
opens the session’s run (run.begin, run_id = cc-<session_id>, goal = the first prompt); the prompt does not wait for it |
LOOM_RUN_LEDGER=off |
PreToolUse (Read, Grep; Bash for a command that runs gh) |
loom-code-shunt.mjs |
the code shunt and the tracker shunt (next section) | LOOM_CODE_SHUNT=off, LOOM_TRACKER_SHUNT=off |
| PostToolUse (Read, Grep, Bash) | loom-file-context.mjs |
what Loom knows about each file the call read (memory.for_file): your rules and the repository’s shared rules and design decisions, on the read’s result; once per file per session and agent context, without the records the session already holds |
LOOM_FILE_CONTEXT=off |
| PreToolUse (Edit, Write, MultiEdit, NotebookEdit) | loom-file-context.mjs |
the same block before an edit of a file not shown yet in this agent context, or shown more than 30 min ago | LOOM_FILE_CONTEXT=off |
| PostToolUse (Loom tools) | loom-mentor-hint.mjs |
lifts a result’s hint into context, once per hint code per session |
LOOM_MENTOR_HINTS=off |
| PostToolUse (Edit, Write, MultiEdit) | loom-blast-radius.mjs |
one line from code.impact: callers, tests reaching the change, co-change files not yet touched; on a file’s first edit, the test gate’s line beside it in place of the tests |
LOOM_BLAST_RADIUS=off |
| PostToolUse (Bash, PowerShell) | loom-test-gate.mjs |
for a file the command changed that has a test of its own, that test’s command and what the index knows of it (code.test_gate); once per file and per test per session, on the tool result; nothing for a file with no such test or after a command that only reads (the test gate) |
LOOM_TEST_GATE=off |
| PostToolUse, PostToolUseFailure (Bash) | loom-test-report.mjs |
after a test command whose output names no failure’s reason, a digest of the result file its pytest run wrote: totals and failures grouped by message; no request (the test report) | LOOM_TEST_REPORT=off |
| UserPromptSubmit | loom-record.mjs |
the prompt’s one process: runs loom-prompt-pack and loom-prompt-recall in the hook and prints their context as one answer, writes the run’s begin to the session’s run state, and hands the prompt’s recording scripts (loom-run, the namespace audit) to a detached process |
each script’s own |
| PostToolUse, PostToolUseFailure, PreCompact, Stop, SessionEnd | loom-record.mjs |
the event’s one process: runs the scripts the session waits for in the hook (the PostToolUse rows above, each for its tools, the test report after a failed call too, and the Stop gates below) and prints their answers as one, and runs the event’s recording scripts (the other rows for those events) in one process: detached after a tool call the capture script records something of, at Stop and at SessionEnd, so the session does not wait for their requests and the client cannot cancel them, and in the hook itself before a compaction | each script’s own |
| PostToolUse, PostToolUseFailure (any tool) | loom-capture.mjs |
one episodic observation per tool call (observe.record); a failed call is typed error |
none |
| Stop, SessionEnd | loom-conversation.mjs |
appends new chat turns to the conversation plane (conversation.append) |
LOOM_CAPTURE_CONVERSATIONS=false |
| Stop | loom-usage.mjs |
posts the session’s token usage to cost.record_turns |
LOOM_USAGE=off |
| Stop | loom-test-gate.mjs |
off unless the install turns it on (stop_test_gate, or LOOM_TEST_GATE=stop): for changes this session made, blocks “done” once with the tests code.test_gate says the change obliges, unless a test runner ran since the last code change or your latest prompt ends with “Do not run the tests”; with LOOM_TEST_GATE=block, unless pytest ran the named tests to its summary line and nothing was edited or run since (the test gate) |
LOOM_TEST_GATE=off |
| Stop | loom-validate-gate.mjs |
blocks once when namespace.validate finds errors or warnings on the memory keys this session wrote |
LOOM_VALIDATE_GATE=off |
| Stop | loom-namespace-health.mjs |
one line when namespace.audit finds a critical misuse of the namespace, pointing at the loom-optimize skill; the audit is asked once per session, by the first prompt’s detached process, and told at a Stop |
LOOM_NAMESPACE_HEALTH=off |
| Stop, PreCompact | loom-working-memory.mjs |
refreshes the working-memory note (session:<project>): goal, git status, files edited, last reply; the primer of a new conversation on another branch than the note names leaves it out |
LOOM_WORKING_MEMORY=off |
| Stop, PreCompact, SessionEnd | loom-capture.mjs |
crystallises the session (observe.crystallize) |
none |
| PreCompact, SessionEnd | loom-session-brief.mjs |
revises the branch’s session brief (session.brief_save, key auto/<project>/<branch>) |
LOOM_SESSION_BRIEF=off |
| SessionEnd | loom-run.mjs |
closes the run (run.complete, outcome: none, the last reply as the final response) |
LOOM_RUN_LEDGER=off |
| SessionEnd | loom-session-memory.mjs |
hands the session’s turns to memory.set_from_messages(defer=true), which extracts facts and writes the session summary; a session with under 40 bytes (UTF-8) of user and assistant text is not sent and gets neither |
LOOM_SESSION_MEMORY=off |
The plugin’s hooks and its MCP header helper (the script that adds the token to Loom’s MCP
requests) run node, git and grep on your machine: git reads the checkout’s
remotes, branch, HEAD commit, status and diffs, and grep searches uncommitted files
for the pattern of a grep the plugin redirects to the code index. The loom-session
skill’s brief script also runs git log for the commits since the last brief. The test
gate (the hook that names the test of a file you change) runs no Python:
for a pytest test it picks the interpreter of the checkout’s virtualenv, the active one
(VIRTUAL_ENV) or a python3 or python on PATH, checking that the interpreter’s file
exists without running it.
The plugin names the oldest Loom server its hooks support (MIN_SERVER_VERSION in lib/server-version.mjs). SessionStart reads the server’s version from the GET /v1/health answer it already requests and, when that version is older, prints one loom: line naming both versions and asking for a server upgrade. The session goes on either way; an unreachable server, an answer other than 2xx, a server that reports no version, or a version that is not SemVer prints nothing. The loom-status skill (bin/loom-client-status.mjs) reports the same as a warning. The minimum rises with the release that first serves what a hook needs, so between that hook’s merge and that release a server of the previous release gets no warning.
Why the run closes with outcome: none. The hook knows the session ended, not
whether it succeeded, and it never guesses which memories the agent relied on. An agent
that knows its outcome calls run.complete itself.
What is stored where.
- Conversation turns are stored only when the namespace has conversation logging on
(off for a new namespace;
conversation.set_logging).conversation.appendsucceeds even when it drops a turn. See conversations and sessions. - Raw observations become durable memories only when the server runs the
observe_extractworker (LOOM_OBSERVE_EXTRACT_ENABLED=true, which needs LLM and embedder credentials; see configuration). - Session memory is independent of logging:
memory.set_from_messageswrites facts and a summary, and keeps the turns it was given as their source evidence.
Safety. A hook never blocks the agent on the network.
- The scripts that only record (the run’s open and close, tool observations, conversation
turns, usage, the working-memory note, session memory, the session brief) do not hold
the session at a prompt, after a tool call, at Stop or at SessionEnd: one launcher
(
hooks/loom-record.mjs) writes the event to a private file, starts one detached process that runs them, and exits. A tool call the capture script records nothing of is handed to no process: a meta tool in every mode, and in code mode every call of a session that asked the index nothing. That process outlives the hook and the client’s process, so a session’s close lands after the client has exited and the client cannot cancel it. It does not outlive a machine or container that is torn down when the client exits, which loses what the process had not sent by then: such a host setsLOOM_SESSION_END_WAIT=true, and the SessionEnd hook sends the session’s close itself (SessionEnd budget, below). - The launcher also runs, in its own process, the scripts whose answer the session waits
for and prints what they answered as one answer, so an event starts one process: at a
prompt the two lookups (the code pointers and the recall), after a tool call the file’s
memory, the mentor hint, the blast radius and the test line (the last only after a
command that may have written a file), at Stop the gates the install runs.
Each script’s text is unchanged and on a line of its own; gates that hold the same stop
give one block. A script that throws, or is still running when the wait for its answer
is over, has no answer, and the others keep theirs. Before
a tool call the host starts the one script wired for the tool, and before a shell
command none unless the command runs
gh. - Before a compaction the launcher runs the event’s scripts itself and returns when they have, so the working-memory note is written before the compaction’s primer reads it.
- The namespace audit is asked once per session by the first prompt’s detached process, and the first Stop that finds its verdict tells it. A Stop asks in place only when that process died before its answer.
- Their writes are fire-and-forget; slow ones (conversation, session memory, session
brief) go to a detached flusher (
hooks/loom-flush.mjs). - Every request aborts after 5 × the
/v1/healthround trip, clamped to 3–8 s and cached six hours per server.LOOM_HOOK_TIMEOUT_MSandLOOM_HOOK_EXIT_MSoverride it. - Errors are swallowed. Only the primer waits for a body; if it fails, the session starts without it. With no token or no server, every hook exits 0.
SessionEnd budget. Claude Code shares about 1.5 s across all SessionEnd hooks and
ends the ones still running. The plugin’s one entry, the launcher, hands the event to a
detached process and returns, so it needs no more: the run’s close, the extraction’s
start, the last turns, session memory and the brief are sent by a process the client
does not end. A machine or container torn down the moment the client exits ends that
process too. With LOOM_SESSION_END_WAIT=true in the session’s environment the hook
sends them itself and returns when the run’s close is answered, about half a second
against a server that answers at once; CLAUDE_CODE_SESSIONEND_HOOKS_TIMEOUT_MS raises
the client’s budget for a slower one
(headless sessions).
What a prompt gets
Two lookups can answer a prompt before the model reads it. Each sends the first 2,000
characters of the prompt, secrets redacted, to the server, and what comes back is added
to the request as additional context. The code search also sends a prompt of more lines
or characters with its lines, redacted and cut at 20,000 characters: the index reads the
frames of a pasted traceback and the names a prompt spells as code from that text. A
server with LOOM_CODE_SEARCH_REPORT_PROSE on also searches a long bug report by the
prose of that text, without the code it pastes.
| Install option | Variable | Default | Effect |
|---|---|---|---|
prompt_pack |
LOOM_PROMPT_PACK |
auto |
auto: where this Loom holds the checkout’s own repository, each prompt is searched in its index and up to three pointers are added (loom-prompt-pack.mjs); elsewhere no prompt text is sent. on: each prompt is searched in whatever index Loom matched to the checkout. off: never. |
prompt_recall |
LOOM_PROMPT_RECALL |
first |
first: memory is asked once, on the first qualifying prompt of a session (loom-prompt-recall.mjs). on: every one. off: never, and the SessionStart primer of a new session searches memory for the project instead of listing its pinned and newest rows. |
prompt_context |
LOOM_PROMPT_CONTEXT |
on | Off: neither lookup runs, whatever the two rows above say. Nothing is added to a prompt and its text goes to no lookup. |
A variable outranks its option. Codex and a hand-wired client have no install option and set the variable.
- At
auto, the default, a prompt goes only to the index of the checkout’s own repository. The hook reads what the last repository lookup found for the checkout: the entry the SessionStart hook writes, which the hooks around a read, a search or an edit renew once it is ten minutes old.- The checkout’s own repository is in an index the session reads: the prompt is
searched. That is the repository at the checkout’s
originremote, host included. The server says which host each entry’s repository is on (repo_keyincode.repos, from the entry’s remote), and the plugin compares it with the host and path of the origin. A server that does not send it is taken at its word only for an entry added by its remote, which is namedowner/nameon GitHub andhost/owner/nameon any other host. An entry the operator configured is named freely, so on such a server it is not searched underauto(a server before 1.4.0);prompt_packonsearches it. The host is the one the remote’s URL spells, so a remote written with an alias of the SSH configuration (git@work:owner/name) is not recognised;/loom:loom-statusshows the host it read. - Loom matched another repository’s index to the checkout: the prompt is not sent
to it. That covers the
upstreamremote’s index or another remote’s, the index of the repository the origin is a fork of, the onecode_reponames, and one whose owner and name match on another host. - This Loom holds no index of it, or none the session reads: for ten minutes after that answer the hook sends no request at all. An install that uses Loom for memory alone, or a Loom that does not hold the repository, sends the code index no prompt text.
- No lookup has answered in the last ten minutes, or the one the session made as
it started ran out of time: the hook asks itself, so the one prompt of a headless
run still gets its pointers. The lookup is one
code.reposnaming the checkout’s remotes (owner and name, with the host of one on github.com) and, for a repository it lists, onecode.index_statusnaming its namespace; neither carries prompt text. A lookup that fails sends nothing, and the prompt hook asks again no sooner than ten minutes later. - A repository that becomes indexed gets pointers from the first prompt after a lookup finds it: ten minutes after the last answer at the latest.
- The checkout’s own repository is in an index the session reads: the prompt is
searched. That is the repository at the checkout’s
- The lookup’s answer is kept per server and per token. Which repositories a Loom lists depends on the server and on the caller, so the entry’s file is named by the checkout, the server asked and the token. Two sessions in one checkout that talk to different Looms, or as different principals, never read each other’s answer.
onandoff.onsearches whatever index the lookup matched to the checkout: the checkout’s own, else theupstreamremote’s, another remote’s, a fork’s parent’s or the onecode_reponames; it also looks up a checkout whose entry has lapsed.--config prompt_pack=off, orLOOM_PROMPT_PACK=off, sends nothing for any prompt: the agent still has the code tools, and the instruction block says when to search. The hook has only the prompt’s text to search with, and no rule it can apply tells a list that names the code a task changes from one that does not, so the pointers are candidates to check. A pipeline with no plugin builds the same block with the SDK orloom pointers(the recipe).- The search starts no model call but the query’s embedding and, for a bug report,
the pick and its cause sentence. The request names
llm_legs: "none"and, for a prompt that does not read as a bug report,rerank: "none", as the SDK recipe does, so a deployment whose defaults name a reranker (LOOM_CODE_SEARCH_RERANK_DEFAULT) or a model-backed leg runs neither for a prompt. The pick, for a bug report on a server that names a pick model, and the pick model’s second call for the cause sentence after a pick that saidhighare the only other model calls. /loom:loom-statussays why pointers do or do not arrive. Itspointerscheck gives the mode (offwhenprompt_contextor the install’s mode rules the pointers out), the option as set, whether this Loom holds the checkout’s own repository, whether the token reads that index, the index’s stage, and the risk one test search read. The check asks the hooks’ server with the checkout’s remotes and one fixed question, never a prompt. It warns where something keeps pointers away that you can change or wait for: an index you are not a reader of, a token that does not name the index’s namespace, an index still being built, an index that is another repository’s. A fixed question about no repository in particular can readmediumin a healthy index; withLOOM_PROMPT_PACK_MIN_CONFunset a prompt gets pointers when its own answer readslow, and a bug report also when the server’s pick words its answerhighormedium.- A searched prompt is kept for 180 days. Where a prompt is searched, the server stores
its search text (at most 2,000 characters, after the plugin’s redaction)
as the
queryof a row inloom.code_search_trace, under the repository’s code namespace, with the ids and paths of the results. The plugin’s search names no user, so the row’suser_idis-, unless the token is narrowed to one user: the server then writes that user’s id. For a restricted repository the row holds a digest of the text and no path. The row is deleted after 180 days or when the namespace is erased; auser_iderasure deletes the rows written under that user id, so it reaches the plugin’s only for such a token. A server withLOOM_CODE_TRACE_LOG_ENABLED=falsestores no code search trace (retention and erasure). - An install that sets nothing is at
auto. To keep the pointers off, exportLOOM_PROMPT_PACK=off(theenvblock of~/.claude/settings.jsonworks too), or install with--config prompt_pack=off. An install that setprompt_packtotrueorfalsekeeps that: they read asonandoff. prompt_packandprompt_recallare free text at install.true,yesand1read ason, like every other switch. Any other value that is notauto(for the pointers),first(for the recall) or an off word (off,false,no,0) turns that lookup off, and/loom:loom-statusnames such a recall value in aprompt recallwarning.- A session whose prompt already carries Loom’s answer turns both lookups off with
LOOM_PROMPT_CONTEXT=off: a pipeline that calls Loom through the SDK, puts the pointers or the records into the task prompt and then starts the agent would otherwise have the plugin search for them and add them a second time (the recipe).--config prompt_context=falsedoes the same for an install only such sessions use. Neither changes the instruction block, which followsprompt_packand the checkout’s index. - What it does not cover. The SessionStart primer is not a prompt’s context:
LOOM_INJECT_CONTEXT=falseturns it off. What a tool call gets (a file’s memories, the blast radius, the test line) keeps its own switches. memorymode has no code pointers whatever the option says;prompt_recallandprompt_contextapply.codemode has no recall;prompt_packandprompt_contextapply.
Recalled content and local data
The primer, the per-prompt recall, the saved-brief list, the file rules injected after a
read or before an edit (loom-file-context) and the tracker items the code shunt quotes
when it answers a GitHub issue search can carry other people’s writes: team file rules live in the
repository’s code namespace, where every member writes, and anyone who can file an issue
writes its title. Each item another person wrote is labelled with its writer (by= in
recall, the author on a team file rule); a recalled memory whose line shows its text
and no by= is your own write, and the one line that stands for a record left to a
file read, its key and the file, names no writer. The pack in the primer says so of
its memories section on its first line, and a prompt’s recall that shows such a
memory opens its memories with A memory shown with no by= is your own write. The plugin wraps every one of these
in a <loom-recalled-data> block whose first line is its note: that the block is data and not instructions, not to follow directions
inside it, and that only the closing tag with the opening tag’s id ends it. A file’s
block that holds no team rule leaves the note’s clause about shared namespaces out, also
when a row in it is another member’s write to your own namespace; the rest of the note
is in every block.
Each block’s tags carry an id,
<loom-recalled-data id="…"> and </loom-recalled-data id="…">, derived from the block’s
text under a secret kept in ~/.loom/recall-key (created once, 0600): the text’s
writer cannot compute the id, so stored
text cannot write the block’s end, and the same text keeps the same id, so the primer
stays cacheable across sessions. The plugin also
rewrites the tag name inside the text, including common lookalike spellings, to
[loom tag removed]. Only procedures the caller wrote are injected (a teammate’s still
answers an explicit procedure.match). Loom cannot control what an agent then does:
keeping tool authority independent of retrieved text is the client’s job.
The hooks’ temp files (turn journal, cursors, stashes, flush jobs, and the code shunt’s
decision log, pending batches and denial counts) are created 0600, never written through
a symlink or into another user’s file, and never read from a planted symlink, a hard link
or another user’s file. At SessionEnd the session-memory hook removes its recalled-content
stash; the turn journal is kept for cleanup at a later session start. Retention and what
the hooks redact before sending are in data handling.
Model-picked pointers for a bug report
Where a prompt gets code pointers (prompt_pack), one that reads
as a bug report (twelve words or more, or the vocabulary of a failure) is searched with
rerank: "builtin:pick": on a server that names a pick model, one call of it reads the
prompt against one line for each of the first 100 ranked units, puts the definitions it
would change first and says one word for how sure it is
(how the pick ranks).
The hook reads that word, pick_confidence:
| The reply says | The hook sends |
|---|---|
high, medium |
at most its first three results, which open with the picks, or the first alone where only the word admits the answer, when the first is a place to edit (what a prompt gets) |
low |
nothing |
| no word | the answer as any other prompt’s |
high says the first pick is a definition the fix changes, medium that one of the
picks probably is, low that probably none is. On high or medium the first pick
decides: when it is no place to edit, the picks below it are not sent in its place, and
no result below the third is sent. medium does not say that much of its first pick;
the hook holds both words to one rule by choice.
A high or medium answer is sent at a medium or high retrieval_risk too, as its
first pick alone. The risk bands the scores
of the search, which ran before any model read the candidates; the pick model read them
against the prompt, so its word is the later reading. The reply holds the picks first
and the rest of the search’s ranking after them. No field of it names how many picks
there are and no unit is marked as one: the count in its score_explanation text is
taken before the server gives each definition one slot and cuts the page at top_k, so it
does not say which units of the page are picks. The first unit is the one the reply
proves a pick, and the units after it are sent only where the low-risk label, or a set
LOOM_PROMPT_PACK_MIN_CONF the answer meets, admits them. An answer that abstains is not
sent, and a LOOM_PROMPT_PACK_MIN_CONF that is set is a floor under a picked answer as
under any other.
A reply carries no word when the server made no pick, when its inference gateway refused the pick’s call for the caller, and when the page’s first unit is not the pick’s first, which keeps the picked order. Any other prompt is searched with no pick.
Under the pointers of a high answer the hook prints one more line when the reply
carries a sentence (pick_cause):
Cause (a candidate a model wrote from the indexed code, not checked): <sentence>.
After a pick it is confident of, the server’s
pick model reads the request and the code of the first three picks its reply carries
and states in one sentence which definition is at fault and why
(the cause sentence). It
reads no fix, so the sentence is a candidate to check, as the pointers are, and the
line’s label tells the session so: a model wrote the sentence and nothing checked it. It can name
a definition with no pointer above it: the call reads the reply’s picks, and the block
lists only those that pass the place test, one for a range and the ranges inside it, and
only the first where only the pick’s word admits the answer. A reply
with no sentence leaves the block as it is: a medium answer, a model that could not tell from the code,
a call the server skipped, cut or lost, and a server that sends none. The hook prints a
sentence of at most 600 characters, the most the server serves, and drops a longer one.
- The server names the model, and is the one switch. Set
LOOM_CODE_SEARCH_PICK_MODELto the provider’s smallest model. A server without it makes no pick and says no word, and a bug report gets the pointers any other prompt would, in the search’s own time. The plugin has no option for the pick. - A bug report’s bound is 6 s. It is
LOOM_PROMPT_PACK_PICK_TIMEOUT_MSon every server, where other prompts have 2.5 s. A bug report here is a prompt the hook searches for: a named question asks for no pick and keepsLOOM_PROMPT_PACK_TIMEOUT_MS, whatever it reads as. With a pick model the prompt waits two to three seconds more for the model call, and the server pays for about 7,000 input tokens. The cause sentence after ahighpick is a second call inside the same bound: the prompt waits for that call too, which reads at most 6,000 characters of the request and 9,000 of code and answers in at most 150 tokens. The server starts it only with 2.6 s of its deadline left after the pick, which with this bound is a repository lookup, a search and a pick that ended within about 3.1 s; otherwise the pointers come without the sentence. An install that wants it more often raises this variable.LOOM_PROMPT_PACK_TIMEOUT_MSdoes not bound a bug report: an install that set it lower to keep prompts quick, or higher for a slow link, sets this variable too. Set under about 2.9 s plus what the repository lookup and the search take, it leaves no time for a pick: the server starts one only with 2.6 s of its deadline left, and the bug report then gets the ranking with no word. - A slow repository lookup can pass the bound. The prompt waits no longer than its bound where the repository lookup is cached. A lookup that is asked gives each of its requests 500 ms at least, whatever is left of the bound, so on a slow server the hook ends later: 500 ms past the bound when the listing used it up and the index’s status is still asked for, and 1.5 s past it at most (7.5 s for a bug report, 4 s for another prompt), when the lookup waited the whole bound for another process’s lookup of the checkout and then made its own three requests. No search is sent after a lookup that used the bound up.
- Under Claude Code the launcher’s wait ends both bounds. The launcher that runs the hook stops waiting for its answer after twice the hooks’ request bound plus nine seconds: 15 s where the request bound is its 3 s floor. Neither bound holds past that, and the deadline below is taken from the variable: with a bound set above the launcher’s wait, a pick still running then is no answer.
- The server is told when to stop. The search carries what is left of the bound,
less 300 ms and 60 s at most, as its
deadline_ms. The server skips a pick it has too little time left to start and cuts one still running shortly before the deadline; either way, after a failed call and after one its inference gateway refused for the caller, it answers with its ranking and no word. - A long prompt asks too. Twelve words or more make a bug report, so a long prompt
that reports no failure pays the call, and gets no pointers where the model says
lowof it. - What the word was worth where it was measured. On bug reports of public
repositories the model said
highormediumof about nine reports in ten. The first of its picks that is a place to edit was in a file the fix changed for about four in five of those: more than nine in ten onhigh, about two in three onmedium. Onlowit was about one in three, and for the ranking with no pick about half. The replies were scored with no deadline, so a pick the server skips or cuts is not in these figures. - A long report with no word of a failure measured the same. About three of the
reports in ten held none and were asked for the pick by their length alone. The model
said
lowof fewer than one in ten of them, as of the others, and itshighormediumpicks were right as often. Of the three it saidlowof, the ranking with no pick was right for one at most. - A long prompt that asks for no change is not measured. Every prompt measured
reports a change to make. For a long question, or an instruction about something
other than the code, neither how often the model says
lownor what the ranking it then withholds was worth is known. - Those repositories are ones a model may know. About three quarters of the pick’s gain was on reports where the model could name the changed function with no index, so the gain on private code is unconfirmed.
Tuning knobs
Beyond the off switches in the table:
| Variable | Default | Effect |
|---|---|---|
LOOM_CONTEXT_TOKEN_BUDGET |
1200 |
token budget of the SessionStart primer |
LOOM_CODE_MAP_TOKEN_BUDGET |
0 |
token budget of the code map in the primer; 0 leaves the map out |
LOOM_CONTEXT_RUNS |
false |
include recent runs in the primer; LOOM_CONTEXT_RUNS_LIMIT (8) bounds them |
LOOM_PROMPT_RECALL_MIN_CONF |
0.5 |
minimum retrieval_confidence before the prompt recall injects anything |
LOOM_PROMPT_RECALL_MAX_CHARS |
1600 |
cap on the injected recall; a record that does not fit is left out, the first is cut when none fits |
LOOM_PROMPT_CONTEXT |
on |
off: nothing is added to a prompt, neither code pointers nor recall (the prompt_context option) |
LOOM_PROMPT_RECALL |
first |
the prompt recall: first, on or off (the prompt_recall option) |
LOOM_PROMPT_PACK |
auto |
auto adds code pointers to a prompt where this Loom holds the checkout’s own repository, on searches whatever index Loom matched to the checkout, off never (the prompt_pack option) |
LOOM_PROMPT_PACK_TOP_K |
3 |
pointers per prompt |
LOOM_PROMPT_PACK_TIMEOUT_MS |
2500 |
the bound of a prompt that asks for no pick: the repository lookup and the answer of its code pointers |
LOOM_PROMPT_PACK_MIN_CONF |
unset | a retrieval_confidence gate for search pointers (low risk is 0.7 up); unset, that label, which a pick worded high or medium passes |
LOOM_PROMPT_PACK_PICK_TIMEOUT_MS |
6000 |
the bound of a searched prompt that reads as a bug report, in place of that one: its search asks for the server’s pick, a model call; under Claude Code, no longer than the launcher waits |
LOOM_FILE_CONTEXT_TTL_MIN |
30 |
minutes before an edit fetches the same file’s context again |
LOOM_BLAST_DEPTH |
1 |
code.impact depth for the blast-radius line |
LOOM_TEST_GATE |
unset | stop: also hold a stop with no test run since the last code change (the stop_test_gate option); block: no line at edit time, and a stop passes only on the named tests; off: no gate |
LOOM_TEST_GATE_DEPTH |
2 |
hops the test gate follows (1–3) |
LOOM_TEST_REPORT |
on |
off: no result-file option in PYTEST_ADDOPTS and no failure digest after a cut pytest run (the test_report option) |
LOOM_OBSERVE_DEDUPE_S |
60 |
a repeated read in this window is not observed again; 0 disables |
LOOM_OBSERVE_SKIP_TOOLS |
a built-in list | comma-separated tool names (with * globs) that produce no observation |
LOOM_PLUGIN_SCRATCHPAD |
unset | 1 appends each turn’s one-line conclusion to the run’s scratchpad working-memory block |
LOOM_SESSION_BRIEF_KEY |
auto/<project>/<branch> |
the key the session brief is saved under |
integrations/claude-code-plugin/README.md documents the remaining knobs.
The test gate
The test gate names a file’s own test when the agent changes the file, and says nothing about tests when the file has none. In an indexed checkout, the tool call that first changes a file comes back with two extra lines when Loom has such a test to name:
Loom test for src/app/router.py: .venv/bin/python -m pytest -q -rf tests/test_router.py
It is the one test file named for that file. With -q -rf the last lines are one `FAILED <file>::<test>` line per failing test, then the totals.
-
What it names. One test, and only a test that is the file’s own:
- the one tracked file named after the edited file:
test_<stem>.pyor<stem>_test.pyfor Python,<stem>_test.go,<stem>_test.rs, and<stem>.test.<ext>or<stem>.spec.<ext>for TypeScript and JavaScript. The stem has three characters or more and is not__init__, and two files with such a name name none; - a test an imported coverage run measured executing the change
(
A coverage run measured it executing code this change touches.); - the edited file itself, when it is a test (
It is the test file the change edits.).
A test
code.test_gatereaches only through the call graph, the mined test map or another definition of the file is not named. In recorded sessions those were other modules’ tests more often than the file’s. - the one tracked file named after the edited file:
-
Only a runner the checkout uses. The index derives
pytest <path>from a test file’s name, and a repository that runs its tests another way fails that command at set-up. So the line is sent for a pytest command only where the checkout configures pytest for the test:pytest.ini,.pytest.ini,pytest.toml,.pytest.toml, aconftest.py, a[tool.pytest…]table inpyproject.toml,[pytest]intox.inior[tool:pytest]insetup.cfg, in the test’s folder or one above it. It also needs an interpreter: the checkout’s.venvorvenv, an active virtualenv, orpython3orpythononPATH, named without starting it.LOOM_CODE_TEST_GATE_RUN_TEMPLATESon the server gives your own harness a command. -
A path without a command where the root holds a tox, nox or make file. Where the checkout configures no pytest for the test and its root holds
tox.iniwith a[tox]or[testenv…]section,noxfile.py, or aMakefilewith a target whose name starts withtest, the line names the test and says which of them was found:Loom test for src/app/router.py: tests/test_router.py It is the one test file named for that file. No command is given: the checkout configures no pytest for it, and its tox.ini has a `[tox]` or `[testenv…]` section.The line says what was found and no more. Loom does not read what that file runs, so a
Makefiletarget namedtestdatacounts; a make assignment (tests := a) does not. -
A command to copy, written the way the checkout runs pytest.
pytest <path>is printed as<python> -m pytest <options> <path>. Each part is read from the checkout’s files, nothing is started, and a part that is not found is left out:-
-q -rfwhere pytest’s settings file for the test sets noaddopts. With those flags the output ends with oneFAILED <file>::<test>line per failing test and then the totals, which the line says. Where the repository set its own options, the line adds none to them. -
the repository’s own
-nform, where pytest-xdist is installed for the interpreter and the repository’s instructions run pytest with-n autoor-n logical:CLAUDE.md,AGENTS.md,CONTRIBUTING,README,Makefile,tox.ini,noxfile.pyandpyproject.tomlat the root, then the CI workflows. A number of workers is not copied: it is the count of the machine the command was written for. Neither is a command its line comments out, or one a word rules out (Never use `pytest -n auto`,`pytest -n auto` is not safe here). The word is read anywhere before the command on its line, whatever ends a sentence there:Do not use xdist here. `pytest -n auto` deadlocks.gives no-nform, and so doesThis is not hard. Run `pytest -n auto`.. In a Markdown or reStructuredText file it is also read on the lines above the command, in the command’s sentence, up to 1,024 characters back. A prohibition in a sentence that ended on a line above or in another list item, or in words other thannot,never,no,cannot,avoid,withoutand a word inn't, is not read. The line names the file it read, here in a checkout that sets its ownaddopts:Loom test for src/app/router.py: .venv/bin/python -m pytest -n auto tests/test_router.py It is the one test file named for that file. CLAUDE.md runs pytest with -n auto.An
addoptsthat sets-nalready applies to every run, so the command adds none.
A command over 200 characters is not sent.
-
-
Otherwise nothing. A file with no test of its own, a checkout that shows no runner for it, no interpreter for a pytest command, or a prompt that ends by saying not to run tests: the tool result carries no line about tests. Loom does not list the other tests the index reaches, and does not name the changed functions the index links no test to.
-
With the prompt, where it gets pointers. A prompt whose pointers include a definition the prompt names (the last part of its name, four characters or more, as a whole word) gets the same two lines below the pointers, for that pointer’s file, when the file is Python source with exactly one test file named after it and the checks above hold. It adds no request, the same prompt at the same commit gets the same text, and the edit of that file then adds no line.
LOOM_TEST_GATE=offorblocksends none. -
When. Once per file and once per test per session, on the result of the edit tool or shell command that changed the file. It costs no model request. A file is asked about at its first change only, so a function changed later in the same file is not named. A test that shell command itself runs is not named on its own result: any pytest run in the checkout that names the file counts, whatever its other options; a run of a part of it (
<path>::<test>,-k <name>,-m <mark>,--lf,--sw,--deselect,--collect-only) does not. A shell command that only reads wrote no file, so the session waits for no git call and no request after it; a file changed out of the hooks’ sight, by a formatter run that names no file, is named at the next command that names it and may have written. -
At the end of the session, only if you turn it on. By default no stop is held: a session that changed code and ran no test ends without being asked to run one. A held stop costs the session at least one more model request and the time of a test run. Install with
--config stop_test_gate=true(or setLOOM_TEST_GATE=stop) to have a session that ran no test since its last code change held once per distinct change, with the tests the change obliges and the functions the index links no test to. Any test run since that change lets the stop pass: a shell command that starts a test runner and finished no earlier than the newest write among the code files the session changed. A documentation or prose file (.md,.rst, a changelog, a.txtfile underdocs/) written after the run holds nothing. The gate reads that command for a runner’s name only. Which tests ran and how they went cannot be read reliably from shell commands, so that judgement stays with the agent and with CI. A repository’s own runner counts when the command starts it, as inpython tests/runtests.py app.testsorbin/test pkg/core. The plugin README lists the runners under Stops that pass.
To hold the stop until the named tests ran on the final tree, set LOOM_TEST_GATE=block
in the environment Claude Code starts in. The gate then prints nothing at edit time, and
blocks “done” once per distinct change unless the transcript already answers the ask; the
plugin README lists the exact conditions under Answered stops. That mode also holds a
session that ran the tests in a way the gate does not read. LOOM_TEST_GATE=off turns
the gate off.
The test report
A session that pipes pytest into tail sees the totals and not why a test failed, and
spends a model request on running the same tests again to read it. The plugin has pytest
write a result file on every run of the session, and after a test command whose output was
cut it adds the failure reasons to that command’s result. It sends no request and stores
nothing in Loom. It is pytest only.
Loom adds its result-file option to PYTEST_ADDOPTS for the session’s shell commands:
--junitxml=<file> -o junit_family=xunit1, where the file is the session’s own, mode
0600, in the system temp directory. xunit1 is the family of result file that pytest’s
record_property and record_xml_attribute fixtures accept: with a result file in
pytest’s default family a test that takes one of them warns, and fails where the checkout
turns warnings into errors (filterwarnings = error, -W error). At session start, in a checkout that configures pytest (one of pytest’s
settings files with its section, or a conftest.py, at the root or in tests or test),
the plugin writes one line to the file Claude Code names in CLAUDE_ENV_FILE, whose text
Claude Code runs before each shell command of the session (checked on Claude Code
2.1.334). The line keeps the options the
variable already holds and adds its own only where the command can write the file and the
file is the user’s own and no link. It sets no other variable, and no hook rewrites a
command or runs a test.
With a result file set, pytest names it in one line of its summary, - generated xml file: <file> -, 60 to 110 characters by the temp directory’s path, on every run that is not quiet (-q), a passing
one too. A command that shows that part of pytest’s output shows the line.
Loom adds no option:
- on Windows, and under a client that names no
CLAUDE_ENV_FILE, such as Codex; - with an invalid
server_url: the hooks stop before it; - in a checkout with none of pytest’s settings files and no
conftest.py; - where the checkout’s
addopts, or thePYTEST_ADDOPTSthe session started with, names a result file (--junitxml,--junit-xml) or turns off the pytest plugin that writes one (-p no:junitxml); - where the temp directory’s path would need quoting in a shell;
- to a command Claude Code runs in its sandbox, which cannot write the temp directory: pytest runs as it would without the plugin.
After a shell command that starts a test runner, whatever its exit status, the hook reads
the result file only when a pytest run of that command wrote it, at most 2 MB. The hook
adds nothing where no test failed, and nothing where the visible output already names a reason:
one of pytest’s E lines, or FAILED or ERROR summary lines with their messages, none
of them cut. In a pipe pytest cuts a summary line’s message to 80 columns and ends it with
..., which is not a reason. Otherwise the tool result carries:
Loom test report, the session's last pytest run: 16 failed, 8 passed.
- 12x ValueError: quantity must not be negative, got -1
first: tests.test_pricing.TestRefund::test_partial[2]
raised in shop/pricing.py:41
- 4x TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'
first: tests.test_pricing.TestTotals::test_sum[5]
raised in shop/totals.py:57
Failures that share a message are one group, the most frequent first, at most three, and
the rest are counted. A group has its count, its message as one line cut at 200
characters, its first test and, for a file of the checkout, the last path:line of the
traceback. The digest is at most 700 characters and is redacted before it is cut.
What it does not tell apart:
- a command that runs pytest twice reports the last run;
- a run whose command line names a result file of its own keeps it and gets no digest;
that file is written in the
xunit1family, whatever the settings file says, unless the command names one (-o junit_family=xunit2); - a pytest that a test starts inherits the option;
- pytest’s settings are read at the root and in
testsortestonly: where a settings file in another folder names a result file in itsaddopts, the session’s option replaces it, since pytest readsPYTEST_ADDOPTSafter a settings file; - a pytest run started by a command that reads as no test runner, or by one that runs in the background, writes the file unread, and the next test command’s result carries its digest: the digest names the run as the session’s last pytest run.
Claude Code reads the session’s file once, so a line cannot be taken out of a running
session. A pytest that refuses the option (one started with -p no:junitxml) is handled
through the result file instead. That run ends with unrecognized arguments and exit
status 4. The hook reads the refusal from the command’s text where the command itself
names -p no:junitxml, which holds when the command cut its output, and otherwise from
the output of any shell command that shows it, a test runner or not. It removes the file,
so the line adds nothing, and tells the session to run the command again. A command that
names the option therefore fails once. Where a Makefile, tox, nox or a script passes
-p no:junitxml to pytest, each run fails until one shows its output. The hook
keeps the refusal for a day, through the session’s end: a compaction or a resume in that
time does not bring the option back. PYTEST_ADDOPTS= pytest ... runs one command
without the option.
To turn the report off, install with --config test_report=false or set
LOOM_TEST_REPORT=off in the environment Claude Code starts in. It takes effect at the
session’s next start. The file is removed when the session ends, and a day after its last
write if the session has not ended by then: a session that runs no pytest for a day gets
no option and no digest after that.
The code shunt
Inside an indexed checkout, loom-code-shunt.mjs denies a bulk read and puts the
index’s answer in the denial: a file’s functions, methods, classes and structs with their
lines and headers, a symbol’s definition, the tracker’s verdict. A denial costs the agent a
request, so the hook gives one only when it holds that answer in full.
Under Claude Code the shunt judges the Read and Grep tools. A shell command starts no
hook before it and is never denied, whatever it reads or searches: the one exception is a
command that runs gh, which the shunt reads for an issue search. The shell rows of the
table apply under Codex, whose shell is its only way to read a file.
| Tool call | Denied when |
|---|---|
Read of a whole file |
the file is indexed, unmodified, longer than LOOM_SHUNT_MAX_LINES (800), and outlined in full by the index |
Read with offset / limit, or a sed -n / head / tail / awk slice |
the span exceeds LOOM_SHUNT_READ_CAP (0 = off); at most twice per file per session |
cat, bat, nl or tac of a whole file in Bash |
the whole-file rule, when the read is the whole command |
| a grep for one symbol name in one file | once per symbol per session, when the index holds exactly one definition |
gh issue list --search, gh search issues |
once per query, answered by tracker.duplicate_check with the closest reported items |
Everything else passes: targeted reads, greps over a directory, single-file greps, files
you modified or have not committed, unindexed repositories, and any call the index does
not answer in full within 2.5 s. A Bash command of several parts (;, &&, ||, a newline or a pipe) is
never denied, because a denial withholds every part; its reads and greps are still
counted. A shell command the shunt is started for with no read, no search of files and
no issue search in it is not judged, and costs no git call while the checkout’s
repository lookup is current; once it is ten minutes old, the command renews it. The
same command passes on
the next try after a symbol or tracker-shunt denial.
Staleness does not turn the shunt off: an unmodified file is answered as of its indexed
commit, and the deny text names the commit. To search your working tree instead, set
local_first / LOOM_CODE_LOCAL_FIRST=on; the shunt stands down and the primer skips the
code map.
Repository detection is cached ten minutes. A lookup that does not answer within
LOOM_SHUNT_RESOLVE_TIMEOUT_MS (8 s) is retried after a minute rather than cached as
“not indexed”. Decisions are logged to $TMPDIR/loom-shunt-log-<hash of the uid>.log
(LOOM_SHUNT_LOG=off disables) and reported to the server as code.outcome rows
(LOOM_SHUNT_REPORT=off disables). LOOM_SHUNT_GREP=off and LOOM_SHUNT_BASH=off exempt
the Grep tool and the Bash tool respectively.
claude --bare skips hooks, so none of this runs there; the
grep shim covers that case. The operations are described in
code index operations.
Skills
| Skill | Loads when | Does |
|---|---|---|
loom-code |
about to grep or open files in an indexed repository | which code.* op replaces the reflex and how to read its answer |
loom-memory |
a fact is stated, decided or corrected; the end of a substantial task | what is durable memory and what is scratchpad, how to write a fact a later session can trust, the end-of-task review |
loom-mentor |
which operation serves documents or records; a hint; “what can Loom do” | the situation → plane → op map and what each hint code means |
loom-optimize |
“optimize my namespace”, “memory search is bad”, a namespace-health line | namespace.audit, a plan the owner approves, memory.move with redirects (guide) |
loom-session |
“save this session”, “resume”, “where was I on this branch” | lists the saved briefs, restores the one the user picks (the brief with the client’s compaction summary, or with --transcript every recorded turn as well), or saves one; it never loads a brief unasked |
loom-setup |
only when you run /loom:loom-setup; the model cannot load it |
writes, updates or removes the instruction block in CLAUDE.md, or in the AGENTS.md that Claude Code reads (bin/loom-setup.mjs); where prompts get the index’s pointers it writes none and removes the one it finds |
loom-status |
a tool says unauthenticated, the primer is missing, “is Loom working?” | checks the Node runtime (installs it only on your yes), runs the client check, names the one fix |
improve-loom-for-my-repo |
the end of a session in which the code tools missed | turns the session’s misses into reproducible findings for maintainers |
loom-session runs bin/loom-brief.mjs (list, get [N | KEY] [--transcript],
save); nothing in it runs on its own.
Checking it works
- After a few tool calls, the dashboard shows the session’s observations and,
with logging on, its conversation.
run.getoncc-<session_id>replays the run. /loom:loom-statusrunsbin/loom-client-status.mjsfrom the plugin: the server it would call, which lookup supplied the token and whether the MCP tools send that token to that server, whether the token is accepted and can write the namespace, capture batches that never reached the server, whether the checkout’s instruction file holds the instruction block where it needs one, and why a prompt in this checkout does or does not get code pointers (thepointerscheck). It needs nothing but the plugin.loom doctor --client(the operator CLI, from a source checkout or the server image) adds the Claude Code and Codex wiring checks.
Troubleshooting
Start with /loom:loom-status; it names the cause in one line. It runs its checks with
sh: on Windows without Git Bash, run node <plugin root>/bin/loom-client-status.mjs
instead. A session start that prints nothing is the working state where the session’s
MCP connection carries the indexed checkout and there is no memory to prime. A checkout
no index holds, one with no git remote and a lookup the server did not answer each
still print their line, unless LOOM_INJECT_CONTEXT=false or LOOM_CODE_MAP=false is
set.
| Symptom | Cause | Fix |
|---|---|---|
a hook error says node was not found |
no node on the PATH Claude Code starts with |
set PATH in the env block of settings.json to the whole search path with that Node’s directory first, such as "PATH": "/opt/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbin", or the loom-status skill; restart |
every hook error quotes [stdin]:1, a SyntaxError |
Claude Code older than 2.1.139 drops args |
update Claude Code |
| hooks fail and nothing is captured, though Node is installed | the first node on that PATH is older than 18 |
put Node.js 18+ first on that PATH, or run the loom-status skill; restart |
| MCP server “needs authentication” | no Node for the header helper, or no token found | the loom-status skill names which |
| no primer, nothing captured | server unreachable, or no token found | loom-status; check ~/.loom/config.json |
| prompts get no code pointers | the pointers check of loom-status names it |
index the repository on this Loom, join its namespace, or wait for the index; for an index that is another repository’s (a fork’s parent’s), --config prompt_pack=on |
| tools answer, captures do not | the token is viewer-only on the write namespace | mint a writer token |
| Conversations page empty | conversation logging is off for the namespace | the Record conversations switch on the dashboard’s Conversations page, or conversation.set_logging |
| a hook added in a new release never fires | the installed plugin is older than the server | claude plugin update loom@loom |
| every tool listed twice | a user-scope loom MCP entry beside the plugin |
claude mcp remove loom |
| reads denied in a repo you work on locally | the checkout is indexed and the file is unmodified | --config local_first=true or LOOM_CODE_LOCAL_FIRST=on |
Hook cancelled at exit |
SessionEnd hooks ran past the client’s budget | update the plugin (its entry hands the event off); with LOOM_SESSION_END_WAIT set, raise CLAUDE_CODE_SESSIONEND_HOOKS_TIMEOUT_MS |
Other clients
hooks/hooks.generic.json maps the same lifecycle events to the same scripts for any
client that runs a command with the hook payload as JSON on stdin; replace
${LOOM_PLUGIN_DIR} with the plugin directory’s absolute path. The scripts probe several
common payload field names, and read the client name from their third argument
(… PostToolUse codex) or LOOM_CLIENT; unnamed, they assume Claude Code. For a client
that can only export a transcript, see
transcript capture hooks.
Related
- Codex plugin: the same scripts with Codex wiring.
- MCP clients: connecting without the plugin.
- Agent integration guide.
- Operations reference: every op the hooks call.