Teach And Trim
A weekly process that sharpens agent rules and skills by folding lessons and corrections into existing principles, archives removed lines word for word, and opens a draft PR for approval. The process ensures lesson files do not grow in size and preserves all critical rules and dates.
Editor's Note
Before running, create a fresh branch from the latest base using `git fetch origin main` and `git worktree add -b docs/teach-and-trim-$(date +%Y-%m-%d) ../teach-and-trim origin/main`. Ensure you gather the week's lessons using `git log --since='8 days ago' --stat -- <your lesson file paths>` and check for corrections in memory or notes files modified in the last 7 days.
When to Use It
- Weekly maintenance of agent rules and skills
- Distilling lessons into existing principles
- Archiving removed lines for traceability
- Automated PR generation for rule updates
SKILL.md
SkillsHunter provides this listing for informational purposes only. Review the skill’s source, license, and required permissions before use. You are responsible for deciding whether to install or run it. Terms of Use
Teach and trim
The idea: when a lesson lands, find the reason behind it and fold that reason into the rule or skill it belongs to, so the file gets sharper, not longer. A good update often makes the file shorter.
Most teams capture lessons well and then stack them: a new bullet for every incident, until the rules file is too long for anyone (or any model) to read. Agent rule files are loaded into every session, so every extra line costs tokens forever and hides the rules that matter.
One run = one draft docs PR + one short note to you. Nothing merges without your word.
What counts as a lesson file
Whatever your agents read as standing instructions, for example:
CLAUDE.md,AGENTS.md,GEMINI.md,.cursorrules,.cursor/rules/*;- rule files under your
.claude/folder; - skill folders (
skills/*/SKILL.md,.claude/skills/*,.agents/skills/*).
Hard rules
- At most 3 lesson files per run. The files you touch may not get bigger in total.
- Every line you remove from a lesson file goes word for word into an archive file, for
example
docs/lessons-archive/<name>.md, under## Archived <date> from <path>. Archives are append-only. Nothing is ever lost. - Never drop a "never do this" rule or the date of the incident behind it. You may merge two such rules only if every date survives.
- Never touch frontmatter blocks, protected blocks or annotations your tools rely on.
- If a check fails, fix or drop that change. Never bypass it.
- Stage explicit paths only. Never
git add -Ain a tree other sessions share.
Steps
0. Workspace. Make a fresh branch in its own worktree from the latest base:
git fetch origin main
git worktree add -b docs/teach-and-trim-$(date +%Y-%m-%d) ../teach-and-trim origin/main
cd ../teach-and-trim
1. Gather the week, cheaply. Never read whole chat transcripts.
- Lessons that landed:
git log --since='8 days ago' --stat -- <your lesson file paths>. - Corrections you gave the agent: your agent's memory or notes files changed in the last 7
days (
find <memory dir> -name '*.md' -mtime -7), and any "lesson" or "learned" lines in this week's commit messages or PR descriptions. - Sizes before:
wc -c <your lesson files>. Write the numbers down.
2. Pick up to 3 files, in this order:
- The always-loaded file that grew most this week (it is paid for in every session).
- The file that owns the week's strongest correction.
- The largest lesson file, one slice of it (see step 4).
3. Fold, don't stack. For each lesson, find the principle that already covers it. Reword
that principle so it covers the new case, and add the incident date to it, for example
(2026-08-19, 2026-10-14). Delete the now-duplicate bullet. Add a new bullet only when no
principle covers the lesson, and keep it to three parts: the claim, the observation that would
prove it wrong, and a date. Move any story or narrative to the archive.
A correction that belongs to no file in the repo stays in the agent's memory. List it in the note to the user.
4. One slice of an oversized file. If one lesson file is far too big, do not rewrite it in
one go. Take the next 10 to 15 sections in order. For each, fold its claim into one dated line
under the principle it belongs to, or merge it into a line already there. Move every slice
line, headings included, word for word to the archive under one ## Archived <date> heading.
Build the archive text from git show HEAD:<path>, not from memory. One slice per run. Note in
the PR where the next slice starts.
5. Check. Before you commit:
-
Sizes after:
wc -cagain. The touched files together must not be bigger. -
Nothing lost: every removed line is in the archive. One quick check:
git diff -U0 HEAD -- <lesson file> | grep '^-[^-]' | sed 's/^-//' | while IFS= read -r line; do [ -z "$line" ] && continue grep -qxF -- "$line" <archive file> || echo "NOT ARCHIVED: $line" done -
Every "never" rule and every date that was there before is still there (in the rule file or, for a merged rule, in the merged line).
6. Ship. Commit only the changed paths, push, and open a draft PR. The body lists, per file: which lesson, which principle it joined, bytes before and after. Say "Docs only. Nothing deployable." Mark it ready once the checks pass.
7. Tell the user, in plain words: one line per change, the size before and after, the PR link, and one question: merge it? Merge only on their word, then remove the worktree.
A quiet week (nothing to fold, nothing to trim) ends with a one-line note and no PR.
When it runs
Weekly. A good slot is the day before your model usage allowance resets, so the run spends capacity that would expire anyway. Any scheduler works: your agent app's scheduled tasks, cron, or a CI job that opens the PR.
teach-and-trim from DevDad's Toolbox. AGPL-3.0-or-later (c) 2026 DevTribe Labs.
View original Markdown
---
name: teach-and-trim
description: A weekly loop that makes your agent rules and skills sharper instead of longer. It folds the week's lessons and corrections into the principle each belongs to, archives every replaced line word for word, and opens one draft docs PR for you to approve. Use for a scheduled weekly run, or when someone says "teach and trim", "distill the lessons", "the rules are getting long" or "fold this correction into the skill".
metadata:
license: AGPL-3.0-or-later
copyright: "2026 DevTribe Labs"
homepage: https://github.com/DevDadTribe/toolbox
---
# Teach and trim
**The idea:** when a lesson lands, find the reason behind it and fold that reason into the rule
or skill it belongs to, so the file gets sharper, not longer. A good update often makes the
file shorter.
Most teams capture lessons well and then stack them: a new bullet for every incident, until the
rules file is too long for anyone (or any model) to read. Agent rule files are loaded into
every session, so every extra line costs tokens forever and hides the rules that matter.
**One run = one draft docs PR + one short note to you.** Nothing merges without your word.
## What counts as a lesson file
Whatever your agents read as standing instructions, for example:
- `CLAUDE.md`, `AGENTS.md`, `GEMINI.md`, `.cursorrules`, `.cursor/rules/*`;
- rule files under your `.claude/` folder;
- skill folders (`skills/*/SKILL.md`, `.claude/skills/*`, `.agents/skills/*`).
## Hard rules
- At most **3 lesson files** per run. The files you touch may not get bigger in total.
- Every line you remove from a lesson file goes **word for word** into an archive file, for
example `docs/lessons-archive/<name>.md`, under `## Archived <date> from <path>`. Archives
are append-only. Nothing is ever lost.
- Never drop a "never do this" rule or the date of the incident behind it. You may merge two
such rules only if every date survives.
- Never touch frontmatter blocks, protected blocks or annotations your tools rely on.
- If a check fails, fix or drop that change. Never bypass it.
- Stage explicit paths only. Never `git add -A` in a tree other sessions share.
## Steps
**0. Workspace.** Make a fresh branch in its own worktree from the latest base:
```bash
git fetch origin main
git worktree add -b docs/teach-and-trim-$(date +%Y-%m-%d) ../teach-and-trim origin/main
cd ../teach-and-trim
```
**1. Gather the week, cheaply.** Never read whole chat transcripts.
- Lessons that landed: `git log --since='8 days ago' --stat -- <your lesson file paths>`.
- Corrections you gave the agent: your agent's memory or notes files changed in the last 7
days (`find <memory dir> -name '*.md' -mtime -7`), and any "lesson" or "learned" lines in
this week's commit messages or PR descriptions.
- Sizes before: `wc -c <your lesson files>`. Write the numbers down.
**2. Pick up to 3 files**, in this order:
1. The always-loaded file that grew most this week (it is paid for in every session).
2. The file that owns the week's strongest correction.
3. The largest lesson file, one slice of it (see step 4).
**3. Fold, don't stack.** For each lesson, find the principle that already covers it. Reword
that principle so it covers the new case, and add the incident date to it, for example
`(2026-08-19, 2026-10-14)`. Delete the now-duplicate bullet. Add a new bullet only when no
principle covers the lesson, and keep it to three parts: the claim, the observation that would
prove it wrong, and a date. Move any story or narrative to the archive.
A correction that belongs to no file in the repo stays in the agent's memory. List it in the
note to the user.
**4. One slice of an oversized file.** If one lesson file is far too big, do not rewrite it in
one go. Take the next 10 to 15 sections in order. For each, fold its claim into one dated line
under the principle it belongs to, or merge it into a line already there. Move every slice
line, headings included, word for word to the archive under one `## Archived <date>` heading.
Build the archive text from `git show HEAD:<path>`, not from memory. One slice per run. Note in
the PR where the next slice starts.
**5. Check.** Before you commit:
- Sizes after: `wc -c` again. The touched files together must not be bigger.
- Nothing lost: every removed line is in the archive. One quick check:
```bash
git diff -U0 HEAD -- <lesson file> | grep '^-[^-]' | sed 's/^-//' | while IFS= read -r line; do
[ -z "$line" ] && continue
grep -qxF -- "$line" <archive file> || echo "NOT ARCHIVED: $line"
done
```
- Every "never" rule and every date that was there before is still there (in the rule file
or, for a merged rule, in the merged line).
**6. Ship.** Commit only the changed paths, push, and open a draft PR. The body lists, per
file: which lesson, which principle it joined, bytes before and after. Say "Docs only.
Nothing deployable." Mark it ready once the checks pass.
**7. Tell the user, in plain words:** one line per change, the size before and after, the PR
link, and one question: merge it? Merge only on their word, then remove the worktree.
A quiet week (nothing to fold, nothing to trim) ends with a one-line note and no PR.
## When it runs
Weekly. A good slot is the day before your model usage allowance resets, so the run spends
capacity that would expire anyway. Any scheduler works: your agent app's scheduled tasks, cron,
or a CI job that opens the PR.
---
*`teach-and-trim` from [DevDad's Toolbox](https://github.com/DevDadTribe/toolbox). AGPL-3.0-or-later (c) 2026 DevTribe Labs.*
Community Reviews & Field Notes
Tried this skill on your own project? Share the model you used and the results you got.