consolidate-lessons

consolidate-lessons is a command for Claude Code from runnithan/claudex-setup. It costs 34 tokens per session (1,254 once invoked), scanned A, original, MIT.

A command for cleaning up an archive of lessons stored in files. It merges near-duplicates, separates lessons that contain several unrelated tips, removes outdated files, and refreshes the index.

In plain words
What is it for?
Use it to propose and apply cleanup across the archive, preview changes with a dry run, or limit the work to one category.
Why use it?
Repeated lesson extraction can create duplicates and obsolete entries, making the archive harder to use.

Command for Claude Code

Written for Claude Code: argument-hint in frontmatter. Also seen: mentions subagents.

Part of the claudex-setup plugin — 3 skills, 21 commands, 22 agents shipped together

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/runnithan/claudex-setup/consolidate-lessons
Clone the repo
git clone --depth 1 https://github.com/runnithan/claudex-setup

Made for: Claude Code.

Or install claudex-setup, the plugin that ships this one along with the rest of its 3 skills, 21 commands, 22 agents.

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 consolidate-lessons

README.md
[![agentmods](https://agentmods.dev/badge/commands/runnithan/claudex-setup/consolidate-lessons.svg)](https://agentmods.dev/commands/runnithan/claudex-setup/consolidate-lessons)
Your own site
<a href="https://agentmods.dev/commands/runnithan/claudex-setup/consolidate-lessons"><img src="https://agentmods.dev/badge/commands/runnithan/claudex-setup/consolidate-lessons.svg" alt="Measured on agentmods" height="20"></a>
Per session 34 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,254 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.1 $0.00034 $0.01254
Opus 5 $0.00017 $0.00627
Sonnet 5 $0.00007 $0.00251
Haiku 4.5 $0.00003 $0.00125

Measured 5d ago against content hash f45a2e741e6e, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

consolidate-lessons 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 5d 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.

.claude/commands/consolidate-lessons.md · 52 lines

How it starts

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

Consolidate Lessons

/extract-lessons only ever adds (newer supersedes older on direct contradiction). Over many runs the archive accumulates near-duplicate active lessons and dead superseded files. This command does the periodic cleanup the extract loop can't: it merges overlapping lessons, splits compound ones whose sub-tips are invisible downstream, and prunes stale ones, so INDEX.md stays signal-dense.

Argument: $ARGUMENTS

  • empty (default): propose a consolidation plan and apply it after listing the changes.
  • dry-run: produce the plan only, list proposed merges/prunes, change nothing.
  • a category (e.g. agents): scope consolidation to lessons/<category>/ only.

Steps

  1. Load the archive:

    • Read lessons/INDEX.md and lessons/README.md (for the file format + supersession rules).
    • Glob lessons/**/*.md (exclude INDEX.md, README.md). Read each one's frontmatter (id, status, category, supersedes/superseded_by, created) and TL;DR.
  2. Spawn Explore subagents to find redundancy and buried sub-tips (keep the bulk reading out of main context). One subagent suffices up to ~150 active lessons; above that, fan out over category batches, all launched in one message. Give each the per-lesson {id, category, status, tldr, created} records for its batch plus the full active slug list for dedupe, and ask it to return JSON identifying:

    • merge clusters: 2+ active lessons that cover the same idea and should become one canonical lesson (e.g. several "keep it under 200 lines" lessons). Pick the strongest as canonical; the rest get superseded by it. Same-claim redundancy ONLY: never merge two distinct actionable claims into one body, since that bundling is exactly the burial the split pass below exists to undo.
    • split candidates: an active lesson whose body carries one or more independently-actionable sub-tips absent from its title and TL;DR (a setting, a hook, a keyboard habit inside a bigger workflow's body). The subagent must read candidate bodies, not just TL;DRs. Downstream routing (/optimise habits, /top-tips tracing) reads titles and TL;DRs, so a buried sub-tip never surfaces; this pass is the retroactive counterpart of the /extract-lessons §5 atomicity rule for the corpus mined before 2026-08-29. A split-out tip that duplicates an existing active lesson is not a split, it is already covered: skip it.
    • stale: lessons whose advice is outdated/contradicted or whose feature no longer exists.
    • Tell it: be conservative, only cluster lessons that are genuinely redundant, not merely adjacent. Distinct nuances stay separate.
    {
      "merges": [
        {"canonical_id": "keep-context-lean", "merge_in": ["id-a", "id-b"], "merged_tldr": "...", "merged_body": "...", "reason": "..."}
      ],
      "splits": [
        {"source_id": "compound-lesson-slug",
         "new_lessons": [{"id": "sub-tip-slug", "title": "...", "tldr": "...", "why": "...", "how": "...", "category": "workflows", "tool": "claude-code"}],
         "reason": "..."}
      ],
      "prune_stale": [ {"id": "...", "reason": "..."} ]
    }
    

Read the full file on GitHub · 52 lines

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. 5d ago First seen · 52 lines · 34 tokens per session scan A f45a2e741e6e

Subscribe to this mod's changes

consolidate-lessons is a command published in the GitHub repository runnithan/claudex-setup (1 stars, last pushed 4d ago), licensed MIT. It adds 34 tokens to every session and 1,254 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.