distill

A command that records important project knowledge in append-only files under doc/loom/knowledge. It organizes lessons about architecture, reusable patterns, coding conventions, mistakes, concerns, tools, and entry points.

In plain words
What is it for?
Use it after discovering an architectural rule, a recurring pattern, a mistake and its fix, technical debt, or an important project dependency. It routes each insight to the relevant knowledge file.
Why use it?
It reduces the chance that useful decisions or lessons disappear when the session ends or another engineer takes over. Keeping notes in project files makes them available to future agents and people.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/cosmix/loom/distill
Clone the repo
git clone --depth 1 https://github.com/cosmix/loom
Per session 11 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 469 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00011 $0.00469
Opus 5 $0.00005 $0.00234
Sonnet 5 $0.00002 $0.00094
Haiku 4.5 $0.00001 $0.00047

Measured 2d ago against content hash 4030d9592f3f, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

distill scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

commands/distill.md · 20 lines

What it actually says

Add any information that is deemed important for a future agent or human engineer working on this project to doc/loom/knowledge, focusing on architectural insights, conventions, and mistakes made (and their resolution if available).

Route each insight to the right file (the files are append-only — add, don't rewrite):

  • architecture.md — component relationships, data flow, module/dependency graph
  • patterns.md — reusable architectural patterns found in the codebase
  • conventions.md — naming, structure, and coding standards
  • mistakes.md — what went wrong, the misleading signal, root cause, prevention rule, and fix
  • concerns.md — tech debt, warnings, known issues
  • stack.md / entry-points.md — dependencies/tooling and key files to read first

If doc/loom/knowledge/INDEX.md exists, the layout is hierarchical: each file above is a tier-1 summary, and per-category directories (architecture/, mistakes/, ...) hold tier-2 topic files for deeper detail. Route by size — a finding that fits in roughly 40 lines or fewer goes inline into the tier-1 file above; anything larger goes to loom knowledge update <category>/<slug>, leaving a 2-4 line summary plus a link in the tier-1 file. INDEX.md regenerates automatically on every knowledge write, so there is nothing to run at the end.

Consumers of what you write here do not read these files end to end: each stage session gets a per-stage Knowledge Brief that loom knowledge context assembles by pulling in whichever sections retrieval judged relevant to that stage's task. Write to be retrieved in slices, not read start to finish — prefer one self-contained ## section per finding, naming the concrete symbols and paths inline, because a section is the unit retrieval selects. A finding scattered across sections, or missing its own heading, may never surface to the agent that needs it.

Only record what is non-obvious and durable. Do NOT record ephemeral task details, procedural steps, or anything already captured in the code, git history, or these files. Convert any relative dates to absolute.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 20 lines · 11 tokens per session scan A 4030d9592f3f

Subscribe to this mod's changes

distill is a command published in the GitHub repository cosmix/loom (54 stars, last pushed 3d ago), licensed MIT. It adds 11 tokens to every session and 469 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.