codebase-memory-distill

A guide for collecting inline @agent notes from source code and turning repeated lessons, decisions, and safeguards into reusable rules. It is intended for preserving useful knowledge from one software project for future projects.

In plain words
What is it for?
Use it at project close, periodically during a long-running project, or before starting a related project to review notes, group recurring ideas, and promote durable rules.
Why use it?
It prevents important codebase knowledge from being lost in scattered comments or forgotten when a project ends.

Skill for Claude CodeCodex

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 skills/sauliusdev/glyph/codebase-memory-distill
Any agent
npx skills add SauliusDev/glyph --skill codebase-memory-distill
Clone the repo
git clone --depth 1 https://github.com/SauliusDev/glyph

Made for: Claude Code, Codex.

Per session 31 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,436 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.00031 $0.01436
Opus 5 $0.00015 $0.00718
Sonnet 5 $0.00006 $0.00287
Haiku 4.5 $0.00003 $0.00144

Measured yesterday against content hash b9c62fce8ea4, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

codebase-memory-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 yesterday.

The scan reads SKILL.md. This mod also ships 1 executable file (scripts/scan-agent-notes.sh), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

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.

skills/codebase-memory-distill/SKILL.md · 157 lines

How it starts

The opening of the file, as written. The whole thing — 157 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Codebase Memory — Distill

Harvest the inline @agent: notes a project accumulated (lessons, decisions, invariants, gotchas), find the ones that recur or generalize beyond this codebase, and distill them into reusable rules for the next project.

Inline notes are the raw feed; distilled rules are the compounding payoff. Run this at project close, or periodically on a long-lived codebase.

Applies the "deterministic collection + LLM judgment" principle: a script harvests every note exhaustively, then an LLM cross-reads them and proposes which deserve promotion to rules.

Distillation (end of project)

At project close, harvest the memory with the paired codebase-memory-distill skill, or directly:

grep -rn "@agent:" --include='*.*' .

Cluster recurring lesson/invariant/decision notes and promote the durable ones into reusable rules for the next project. Inline notes are the raw feed; the distilled rules are the compounding payoff.

When to Use

  • End of a project — capture what was learned before it scatters.
  • Periodically on a long-running codebase (e.g. quarterly).
  • Before starting a sibling project that shares stack/domain.

How It Works

Three phases.

Phase 1: Harvest (Deterministic Collection)

bash {skill-dir}/scripts/scan-agent-notes.sh {project-root}

Outputs JSON: every @agent: note with path, line, tag, date, revisit_if, text, plus a by_tag count.

Present a one-screen summary:

Codebase Memory Distill — Phase 1: Harvest
──────────────────────────────────────────
Notes found: {N}   (lesson {a}, decision {b}, invariant {c}, gotcha {d})
Root: {project-root}

Proceeding to distillation...

If 0 notes: stop and say so — nothing to distill.

Phase 2: Distill (LLM Judgment)

Feed the harvested notes to a subagent. The job: separate durable, generalizable knowledge from project-local knowledge, and draft rules for the former.

Cluster notes by theme first (e.g. "time/timezone", "numeric precision", "concurrency/ordering", "data leakage"). A theme hit by 2+ notes — even across different files — is a strong promotion signal.

Read the full file on GitHub · 157 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. yesterday First seen · 157 lines · 31 tokens per session scan A b9c62fce8ea4

Subscribe to this mod's changes

codebase-memory-distill is a skill published in the GitHub repository SauliusDev/glyph (2 stars, last pushed 29d ago), licensed MIT. It adds 31 tokens to every session and 1,436 once invoked, about $0.0002 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-31.

Related

Other skills, from other repositories

docs-writer

Draft or rewrite Strands Agents documentation pages. Use when writing new doc pages, rewriting pages that failed audit, drafting sections for existing pages, or writing blog posts and release notes about Strands. Also triggers on "write a doc", "draft a page", "rewrite the quickstart", "add a tutorial for X"…

strands-agents/harness-sdk · 74 tokens

docs-reviewer

Review documentation drafts for voice consistency, structure, and terminology before PR submission. Use after completing a draft, when checking if docs are ready to ship, or automatically after docs-writer produces output. Also triggers on "review this draft", "check my docs", "is this ready to ship", "review before…

strands-agents/harness-sdk · 68 tokens

docs-planner

Identify documentation gaps and prioritize the docs backlog. Use when planning a docs improvement sprint, after signals surface repeated friction, when new SDK features ship without docs, or for periodic health assessment. Also triggers on "plan docs work", "what docs need writing", "prioritize the backlog", "docs…

strands-agents/harness-sdk · 73 tokens

self-improve-with-tinyfish

Enables Hermes to create new reusable skills for itself by researching live web sources with TinyFish Search and Fetch, analyzing source coverage, writing SKILL.md files, and installing them into Hermes memory. Use when the user asks Hermes to learn, teach itself, upgrade itself, or save a reusable capability.

tinyfish-io/tinyfish-cookbook · 68 tokens

skill-creator

Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.

CreminiAI/skillpack · 64 tokens

case-study

Craft a portfolio case study with narrative arc, process evidence, and outcomes. Use when telling a project's story to an external audience. For an internal stakeholder deck, use presentation-deck.

Owl-Listener/designer-skills · 41 tokens