{"data":{"slug":"discovered-89b71b35faa85ecdeb71a5946e6b74b548da561d18401e7d","title":"Teach And Trim","summary":"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.","url":"https:\/\/skillshunter.net\/skills\/discovered-89b71b35faa85ecdeb71a5946e6b74b548da561d18401e7d","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/discovered-89b71b35faa85ecdeb71a5946e6b74b548da561d18401e7d","markdown_url":"https:\/\/skillshunter.net\/skills\/discovered-89b71b35faa85ecdeb71a5946e6b74b548da561d18401e7d.md","download_url":"https:\/\/skillshunter.net\/skills\/discovered-89b71b35faa85ecdeb71a5946e6b74b548da561d18401e7d\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_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.","instructions":"---\nname: teach-and-trim\ndescription: 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\".\nmetadata:\n  license: AGPL-3.0-or-later\n  copyright: \"2026 DevTribe Labs\"\n  homepage: https:\/\/github.com\/DevDadTribe\/toolbox\n---\n\n# Teach and trim\n\n**The idea:** when a lesson lands, find the reason behind it and fold that reason into the rule\nor skill it belongs to, so the file gets sharper, not longer. A good update often makes the\nfile shorter.\n\nMost teams capture lessons well and then stack them: a new bullet for every incident, until the\nrules file is too long for anyone (or any model) to read. Agent rule files are loaded into\nevery session, so every extra line costs tokens forever and hides the rules that matter.\n\n**One run = one draft docs PR + one short note to you.** Nothing merges without your word.\n\n## What counts as a lesson file\n\nWhatever your agents read as standing instructions, for example:\n\n- `CLAUDE.md`, `AGENTS.md`, `GEMINI.md`, `.cursorrules`, `.cursor\/rules\/*`;\n- rule files under your `.claude\/` folder;\n- skill folders (`skills\/*\/SKILL.md`, `.claude\/skills\/*`, `.agents\/skills\/*`).\n\n## Hard rules\n\n- At most **3 lesson files** per run. The files you touch may not get bigger in total.\n- Every line you remove from a lesson file goes **word for word** into an archive file, for\n  example `docs\/lessons-archive\/<name>.md`, under `## Archived <date> from <path>`. Archives\n  are append-only. Nothing is ever lost.\n- Never drop a \"never do this\" rule or the date of the incident behind it. You may merge two\n  such rules only if every date survives.\n- Never touch frontmatter blocks, protected blocks or annotations your tools rely on.\n- If a check fails, fix or drop that change. Never bypass it.\n- Stage explicit paths only. Never `git add -A` in a tree other sessions share.\n\n## Steps\n\n**0. Workspace.** Make a fresh branch in its own worktree from the latest base:\n\n```bash\ngit fetch origin main\ngit worktree add -b docs\/teach-and-trim-$(date +%Y-%m-%d) ..\/teach-and-trim origin\/main\ncd ..\/teach-and-trim\n```\n\n**1. Gather the week, cheaply.** Never read whole chat transcripts.\n- Lessons that landed: `git log --since='8 days ago' --stat -- <your lesson file paths>`.\n- Corrections you gave the agent: your agent's memory or notes files changed in the last 7\n  days (`find <memory dir> -name '*.md' -mtime -7`), and any \"lesson\" or \"learned\" lines in\n  this week's commit messages or PR descriptions.\n- Sizes before: `wc -c <your lesson files>`. Write the numbers down.\n\n**2. Pick up to 3 files**, in this order:\n1. The always-loaded file that grew most this week (it is paid for in every session).\n2. The file that owns the week's strongest correction.\n3. The largest lesson file, one slice of it (see step 4).\n\n**3. Fold, don't stack.** For each lesson, find the principle that already covers it. Reword\nthat principle so it covers the new case, and add the incident date to it, for example\n`(2026-08-19, 2026-10-14)`. Delete the now-duplicate bullet. Add a new bullet only when no\nprinciple covers the lesson, and keep it to three parts: the claim, the observation that would\nprove it wrong, and a date. Move any story or narrative to the archive.\n\nA correction that belongs to no file in the repo stays in the agent's memory. List it in the\nnote to the user.\n\n**4. One slice of an oversized file.** If one lesson file is far too big, do not rewrite it in\none go. Take the next 10 to 15 sections in order. For each, fold its claim into one dated line\nunder the principle it belongs to, or merge it into a line already there. Move every slice\nline, headings included, word for word to the archive under one `## Archived <date>` heading.\nBuild the archive text from `git show HEAD:<path>`, not from memory. One slice per run. Note in\nthe PR where the next slice starts.\n\n**5. Check.** Before you commit:\n- Sizes after: `wc -c` again. The touched files together must not be bigger.\n- Nothing lost: every removed line is in the archive. One quick check:\n\n  ```bash\n  git diff -U0 HEAD -- <lesson file> | grep '^-[^-]' | sed 's\/^-\/\/' | while IFS= read -r line; do\n    [ -z \"$line\" ] && continue\n    grep -qxF -- \"$line\" <archive file> || echo \"NOT ARCHIVED: $line\"\n  done\n  ```\n\n- Every \"never\" rule and every date that was there before is still there (in the rule file\n  or, for a merged rule, in the merged line).\n\n**6. Ship.** Commit only the changed paths, push, and open a draft PR. The body lists, per\nfile: which lesson, which principle it joined, bytes before and after. Say \"Docs only.\nNothing deployable.\" Mark it ready once the checks pass.\n\n**7. Tell the user, in plain words:** one line per change, the size before and after, the PR\nlink, and one question: merge it? Merge only on their word, then remove the worktree.\n\nA quiet week (nothing to fold, nothing to trim) ends with a one-line note and no PR.\n\n## When it runs\n\nWeekly. A good slot is the day before your model usage allowance resets, so the run spends\ncapacity that would expire anyway. Any scheduler works: your agent app's scheduled tasks, cron,\nor a CI job that opens the PR.\n\n---\n\n*`teach-and-trim` from [DevDad's Toolbox](https:\/\/github.com\/DevDadTribe\/toolbox). AGPL-3.0-or-later (c) 2026 DevTribe Labs.*\n","use_cases":["Weekly maintenance of agent rules and skills","Distilling lessons into existing principles","Archiving removed lines for traceability","Automated PR generation for rule updates"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/DevDadTribe\/toolbox\/blob\/5f44c242b6e4997ebc34dec7202932c4aa6701f6\/skills\/teach-and-trim\/SKILL.md","source_commit":"5f44c242b6e4997ebc34dec7202932c4aa6701f6","license":null,"version":null,"listing_approved_at":"2026-11-29","created_at":"2026-11-28T18:42:09.000000Z","updated_at":"2026-11-29T10:53:02.000000Z","seo_title":"Teach and Trim - Weekly Rule Sharpening for Agent Skills","seo_description":"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","seo_keywords":["agent rules","weekly maintenance","rule sharpening","lesson folding","archive lines","PR generation"]}}