codebase-memory-distill

codebase-memory-distill is a skill for Claude Code, Codex from SauliusDev/glyph. It costs 31 tokens per session (1,436 once invoked), scanned A, original, MIT.

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

Written for no agent in particular: nothing here depends on one. Also seen: mentions subagents.

Good fit 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.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/sauliusdev/glyph/codebase-memory-distill
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.

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.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for codebase-memory-distill

README.md
[![agentmods](https://agentmods.dev/badge/skills/sauliusdev/glyph/codebase-memory-distill/github.svg)](https://agentmods.dev/skills/sauliusdev/glyph/codebase-memory-distill)
Your own site
<a href="https://agentmods.dev/skills/sauliusdev/glyph/codebase-memory-distill"><img src="https://agentmods.dev/badge/skills/sauliusdev/glyph/codebase-memory-distill/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for codebase-memory-distill

Your own site · 80×15
<a href="https://agentmods.dev/skills/sauliusdev/glyph/codebase-memory-distill"><img src="https://agentmods.dev/badge/skills/sauliusdev/glyph/codebase-memory-distill.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
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. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00031 $0.01436
Opus 5.5 $0.00012 $0.00574
Sonnet 5.5 $0.00006 $0.00287
Haiku 4.5 $0.00003 $0.00144

Measured 1mo ago against content hash b9c62fce8ea4, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, 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 1mo ago.

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. 1mo ago 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 (1 stars, last pushed 2mo ago), licensed MIT. It adds 31 tokens to every session and 1,436 once invoked, about $0.0001 per session on Opus 5.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

kb-builder

Build an Obsidian-compatible knowledge base from public web sources using the TinyFish CLI. Use this skill when a user wants a builder-grade markdown knowledge base on a technical topic, asks for a structured research vault, or wants a topic compiled from live public sources into interlinked markdown files. Supports…

tinyfish-io/tinyfish-cookbook · 158 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

weknora-shared

Use when driving a WeKnora RAG server through the weknora CLI as an agent — authenticating, managing knowledge bases / documents / sessions / agents, running search or chat, or interpreting the CLI's JSON envelopes and exit codes. Read this before any other weknora- skill.

Tencent/WeKnora · 68 tokens

weknora-rag-search

Use when retrieving from or asking questions against a WeKnora knowledge base via the weknora CLI — and especially when unsure whether to use chat, session ask, or search chunks for a given goal.

Tencent/WeKnora · 54 tokens

powercontext-project-context

A project-memory guide for searching, saving, correcting, and transferring durable context through the PowerContext service. It distinguishes ordinary conversation from information that should persist between sessions.

oceanbase/powercontext · 59 tokens

02-project-memory

Build the project's memory of its architecture, conventions, and decisions, and wire it into your AI tools. Use when the user wants to set up or refresh project memory, or rewire it into a tool. Not for editing one existing memory file.

ai-driven-dev/framework · 54 tokens