/loom:loom-optimizefrom ClickHouse Loom
Audits a Loom namespace and reworks rows with redirects so old keys stay readable. Triggered by 'optimize my loom namespace', 'audit memory', poor recall, or namespace health cues.
Ships in ClickHouse Loom. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description, though model invocation is off: only you can start it.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Run by the owner's agent over its own namespace, after the data is there.
The invariant: a writer never loses a key it still reads. Retiring old keys
by hand is how a running writer breaks (found: false, a local fallback,
two stores that disagree), so this skill moves rows and never deletes them.
Two ops do the work, both through loom_op unless your tool list shows
them (HTTP /v1/<op> otherwise): namespace.audit says what is wrong;
memory.move moves a row to a new key and leaves a redirect —
memory.get(from_key) still answers with the old value plus
canonical_key, follow=true serves the new row, and search and list show
only the new one. keep_redirect defaults to true; never pass false
(that tombstones the old key).
The store also asks for this skill by itself: a
namespace_health block in context.pack at session start, and one line
from the loom-namespace-health Stop hook at session end, each naming the
critical finding codes. Either one is the cue to start at Step 1.
namespace.audit {org, namespace, window_seconds: 604800, sample_limit: 5}
Show summary as one line (live_rows, live_bytes, version_bytes,
unembedded_rows, gets / searches / sets, get_search_ratio) and the
findings as a table: code | severity | count | share | bytes | remedy. If
healthy is true and no finding is warning or critical, say so and stop
— an info finding is a note for the writer, not a rework. A finding of kind
system_state (telemetry_unavailable, index_backlog) is the deployment's
state, never a rework: name it to the owner and leave it out of the plan.
Map each finding code the audit returned to its remedy with the tables in
reference.md beside this file (audit findings, and the three mentor hints
that are data changes: documents_as_memories, checkpoints_as_memory,
records_for_identities). Habit findings are writer changes: no data moves;
list them for the owner as a checklist.
Every section carries: the count and bytes from the finding, three
example keys before → after taken from the finding's samples, the exact
ops it will call with their arguments, and what it will not do:
memory.delete;memory.move;Write the plan as a knowledge document and show it:
knowledge.upsert {source_uri: "loom://<org>/<namespace>/_optimize/plan-<YYYYMMDD>",
title: "Optimize plan <namespace> <YYYYMMDD>", content: <the plan>}
Apply nothing until the owner approves in this conversation, in words. A plan shown is not a plan approved; "looks fine, go ahead" is. If they approve some sections and not others, apply only those.
dry_run: true; read the
returned to_key, redirected and advisories back to the owner.created_at order so
revisions of one key land as versions of the new key.if_match_sha256 from the audit sample or the memory.get you just
did wherever it is available; a 409 means the row changed under you —
pause the section, re-read the row, and ask before continuing.memory_id, version and content_sha256; a
reply without them is a move that did not happen — say so, do not count
it.Re-run namespace.audit with the same window. Append the after-numbers to
the plan document (same source_uri, knowledge.upsert again) as a
before/after table, and hand the owner the writer changes as a checklist:
one json.dumps, claim-first values, readable keys, knowledge.upsert for
anything over ~2 KB, working_memory.* for leases and pointers, the same
key for a revision, no index rows.
Say plainly: every old key still answers memory.get with its old value
and a canonical_key; follow: true returns the new row; search and list
already show only the new rows. Once the writer has moved to the new keys,
the owner can tombstone the old ones with memory.delete — that is their
call, later, and not part of this skill.
memory.move; the old key redirects.memory.delete, ever, from this skill, and no keep_redirect: false.sets in the window says whether it is writing); rows from
the last hour are out of scope regardless.mentor.brief's
evidence) returned get a plan section, with their counts.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
loom, namespace-audit, memory-move, redirects, namespace-health
Other plugins' skills for the same job
npx claudepluginhub clickhouse/loom --plugin loom7 skills in this plugin
/improve-loom-for-my-repoUse at the END of a session in which loom's code tools were used, when the user asks to improve loom, report what it got wrong, or asks "why did loom miss that". Harvests THIS session's own transcript — where loom answered, where you fell back to grep or whole-file reads, what you couldn't trust — and turns each gap into a reproducible finding the loom maintainers can act on. First sessions count most. NOT for filing bugs about repos loom doesn't index, and NOT for gaps this session did not actually hit.
/loom-codeUse the moment you are about to grep, glob, or open files to answer a question about a loom-indexed codebase — "where is X", "how does X work", "who calls Y", "is it safe to change Z", "what does this stack trace touch". The tell is linguistic: if you just thought "let me search the codebase", "let me grep for that", or "let me read a few files", that sentence is the trigger — code.grep covers exact literals too. NOT for repos loom hasn't indexed (a code.search that abstains on everything is the tell), and NOT for your own uncommitted files (grep those; pass your diff to code.impact for blast radius).
/loom-memoryUse when you are about to write something to Loom, when the user states, decides or corrects a fact, and at the END of any substantial task before you report done. Decides what is durable memory versus scratchpad, how to write a fact so a future session can trust it, how to read what Loom hands back (persisted or not, conflict, abstain, verified or stale), and how to run the end-of-task memory review. NOT for code questions (loom-code), NOT for "is this already reported?" / duplicate or bisect checks (call loom_search or loom_tracker_duplicate_check directly — nothing to read first) and NOT for filing loom defects (improve-loom-for-my-repo).