{
  "markdown": "# /lean — Route cheap, review smart\n\nA Claude Code skill that turns your strongest model into a **conductor**: it routes\neach step of a task to the cheapest capable model, and escalates *only the\nload-bearing pieces* to a pricier tier that reviews for pitfalls a cheaper model\nmisses. Decomposes work, assigns Haiku/Sonnet/Opus/Fable per step, reviews\nsurgically, and persists the plan.\n\n## Why\n\nCoding agents default to the top model for everything — including reading files,\nrunning tests, and mechanical refactoring that cheaper tiers handle just fine. The\nfix isn't only \"use a cheaper model\"; it's two-directional:\n\n- **Route down** — cheap tiers draft tractable work (most of it).\n- **Route up — but surgically** — a cheaper model drafting a load-bearing seam will\n  miss subtle pitfalls; a pricier reviewer catches them early. Reviewing\n  *everything* one tier up roughly doubles cost, so the whole value is in the\n  **gating**: review only the impactful pieces, and reserve the top tier for the\n  ≤2 apex junctions per task where it's earned.\n\n```\n/lean migrate 8 API endpoints to v2\n```\n\n```\n## Lean Execution Flow\n\n| # | Piece              | Draft  | Gate   | Reviewer | Why review        | What                          |\n|---|--------------------|--------|--------|----------|-------------------|-------------------------------|\n| 1 | Explore endpoints  | Haiku  | 0      | —        | machine-checkable | Read all 8, summarize patterns|\n| 2 | Migrate /users     | Sonnet | 0      | —        | tests assert it   | Rewrite with v2 + new auth    |\n| 3 | Validation gate    | Haiku  | 0      | —        | —                 | Run tests + lint              |\n| 4 | Shared auth middleware | Sonnet | 2-HIGH | Opus | consumed by all 8 | Review the seam before scaling|\n| 5 | Migrate remaining  | Sonnet | 0      | —        | same pattern      | Apply to remaining 7          |\n| 6 | Final gate         | Haiku  | 0      | —        | —                 | Full test suite               |\n\nTop-tier touches: none — Opus review on the one shared seam is enough here.\n```\n\nMost rows have no reviewer. That's the point — review is the surgical exception.\n\n## How it routes — three gates per piece\n\n1. **Gate 0 — machine-checkable?** If tests / a parser / a query can fully assert\n   correctness, the cheapest capable model drafts it + a cheap validation gate runs.\n   No judgment review. *Most work lands here.*\n2. **Gate 1 — approach decided?** If the approach is novel *and* high-blast, the top\n   tier authors it directly. Novel but low-blast → just decide inline (iteration\n   beats deliberation).\n3. **Gate 2 — blast radius sets the review tier**, decoupled from who drafted:\n   LOW → ship the draft · HIGH (production branch / DB / a consumed contract /\n   irreversible) → mid-tier review · APEX (a wrong design propagates into schema /\n   public API / security boundary) → top-tier review of the single highest-impact\n   segment.\n\n## Features\n\n- **Three-gate router** — verifiability → tractability → blast radius, applied per piece\n- **Draft → review escalation** — load-bearing pieces reviewed one tier up for *judgment & pitfalls*, not just \"does it run\"\n- **The net-negative rule** — draft→review only pays for bulk; a small/single-file seam gets drafted directly by the higher tier (the round-trip would cost more)\n- **Surgical top-tier use** — capped at ≤2 apex touches/task, with a structured review brief + repo probe rights so the review is deep, not a shallow paste-read\n- **Engagement floor** — below ~3 steps / 2 files, the conductor stays out of the way\n- **Staged execution** — test on one item, validate, then scale to all\n- **Validation gates** — a cheap model validates between every stage (catch errors cheap)\n- **Plan persistence** — writes `.lean-plan.md` so the flow survives context compaction\n- **Auto-nudge hook** — optional companion that suggests `/lean` and a cheaper model when it detects complex tasks\n\n## Install\n\n### Option 1: Copy the skill (simplest)\n\n```bash\ncp -r skills/lean ~/.claude/skills/lean\n```\n\n### Option 2: Clone and symlink\n\n```bash\ngit clone https://github.com/civillizard/claude-lean-skill.git ~/.claude/skills/lean-repo\nln -s ~/.claude/skills/lean-repo/skills/lean ~/.claude/skills/lean\n```\n\nRestart Claude Code after installing.\n\n### Optional: Install the auto-nudge hook\n\nAdd to your `~/.claude/settings.json`:\n\n```json\n{\n  \"hooks\": {\n    \"PreToolUse\": [\n      {\n        \"matcher\": \"Agent\",\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \"python3 ~/.claude/skills/lean-repo/hooks/task-model-guard.py\"\n          }\n        ]\n      }\n    ]\n  }\n}\n```\n\nThe hook does two things:\n1. **Suggests lighter models** when a subagent spawns without an explicit `model` parameter\n2. **Nudges `/lean`** when it detects a multi-step task and no `.lean-plan.md` exists\n\nIt never blocks — only suggests.\n\n## Drafter Routing Reference (Gate 0)\n\nThe default drafter for tractable, machine-checkable work:\n\n| Task Type | Drafter | Why |\n|-----------|---------|-----|\n| Single file search/read (1-2 calls) | **Direct** | Subagent overhead not worth it |\n| Multi-step file research (3+ files) | **Haiku** | Read-only, no reasoning needed |\n| Codebase mapping | **Haiku** | Mechanical enumeration |\n| Content extraction from large files | **Haiku** | Filter and summarize |\n| Well-defined code generation | **Sonnet** | Capable when spec is clear |\n| Writing/updating tests | **Sonnet** | Follows existing patterns |\n| Mechanical plan execution | **Sonnet** | Steps pre-defined |\n| Refactoring with clear transform | **Sonnet** | Transformation well-defined |\n| Validation/testing | **Haiku** | Just run tests, report |\n\nWhen a piece is *not* machine-checkable, Gate 1/2 decide whether it's authored or\nreviewed by a pricier tier — see the [skill](skills/lean/SKILL.md) for the full logic.\n\n## Why not just report the savings?\n\nEarlier versions of this skill ended with a per-step dollar \"savings report.\" It was\ndropped: the per-token estimates were guesswork, and a cheaper run that ships a\nsubtle bug isn't a saving. **The routing + surgical review discipline is the\nsaving** — you pay frontier prices only on the pieces where being wrong is\nexpensive, and cheap prices everywhere else.\n\n## Works on subscription, API, or hybrid\n\nThe routing applies however you're billed — only the *unit you're conserving* changes:\n\n- **API (pay-per-token):** cheaper tiers cost fewer dollars; you pay frontier prices only on the load-bearing pieces.\n- **Subscription (Claude Code on a Pro/Max plan):** usage limits are weighted by model — the top tier draws down your 5-hour and weekly limits far faster than Haiku/Sonnet. Routing down stretches how much you get done before hitting a limit, and the surgical reviews spend your scarce top-tier budget only where it matters.\n- **Hybrid (subscription with API fallback, or mixing both):** both effects apply — and the engagement floor + ≤2 top-tier cap keep either budget from being burned on orchestration overhead.\n\nIn all three, the draft → review ladder is also a **quality** mechanism (catch pitfalls early), which pays off regardless of how you're billed.\n\n## Portability\n\nDesigned for Claude Code, but the patterns transfer to other AI coding tools:\n\n| Component | Claude Code | Other tools |\n|-----------|-------------|-------------|\n| Tier ladder | Haiku / Sonnet / Opus / Fable | mini / standard / frontier (your provider's tiers) |\n| Subagent spawning | Agent tool with `model` | Cursor: @agent, Copilot: #agent |\n| Plan persistence | `.lean-plan.md` | Works anywhere (plain markdown) |\n| Validation gates | cheap Bash agent | Any cheap model can validate |\n| Top-tier review brief | frontier model + repo probe rights | Any tool with a strongest tier + tool access |\n| Auto-nudge hook | PreToolUse hook | Claude Code specific |\n\nThe three gates, the net-negative rule, staging, and the review brief work with any\nAI coding tool — only the tier names need remapping.\n\n## Pairs Well With\n\n- **[recursive-decomposition-skill](https://github.com/massimodeluisa/recursive-decomposition-skill)** — For tasks that overflow context (10+ files, 50K+ tokens). /lean optimizes cost + quality; recursive-decomposition handles scale.\n- **[planning-with-files](https://github.com/OthmanAdi/planning-with-files)** — For persistent state across long sessions. /lean persists to `.lean-plan.md`; planning-with-files adds hooks for auto-reading plans.\n\n## Examples\n\nSee the [`examples/`](examples/) directory for sample flows.\n\n## License\n\nMIT\n\n## Author & Contact\n\n**Mamdoh AlOqiel** — Riyadh, Saudi Arabia\n\n- **Email:** [mao@6ra3.com](mailto:mao@6ra3.com)\n- **Issues & feedback:** [GitHub Issues](https://github.com/civillizard/claude-lean-skill/issues)\n- **Contributions:** Pull requests welcome — open an issue first to discuss bigger changes\n\nOpen to collaboration on Claude Code tooling, token optimization, and AI workflow automation.\n",
  "bytes": 8942,
  "sha": "3b8bb6a4c34cea37e6422fd14eaeec7d8038ae84726a24c32bd5e76f57be6f0e",
  "repo_slug": "civillizard/claude-lean-skill",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/plg_civillizard_claude_lean_skill_lean_4f25f956/readme"
}