← Back to library

Shrink a million-line codebase with an orchestrated swarm

Teknium of Nous Research asked his everyday Hermes agent to refactor Hermes. Using a standing goal and a skill built from months of corrections, it carved the repo into 36 chunks and launched 1,393 subagents, up to 218 at once, over about nineteen hours. Non-test Python fell 34.4%. The main run's model bill came to roughly $19,300.

  • OutcomeClear years of deferred cleanup in days by letting one orchestrator split the repo and dispatch many workers, then review and fix what they got wrong.
  • SetupAn afternoon+
  • LevelAdvanced
  • CreditTeknium
View original
Works with
Custom agent

Published Oct 23, 2026Updated Oct 23, 2026AI dry run on sample input: passed Oct 23, 2026Source verified Oct 23, 2026

When should you use it?

  • Cleanup keeps losing to feature work
  • Huge files and long branching slow debugging
  • You have reviewers for a big pull request

Not for: Codebases without tests; Teams that cannot review a very large change

What do you need, and what do you get?

You need

  • An agent with a skill encoding your coding standards
  • A machine to host many workers
  • Community or team reviewers

You get

  • A large simplification pull request
  • Smaller files and shared helpers
  • New guidance for future workers

How does it work, step by step?

  1. Grow a skill firstLet the agent save lessons from your daily corrections so standards are written down.
  2. Set a standing goalGive a clear target such as a minimum line reduction and broken-up files.
  3. Partition the workThe coordinating agent sizes up the repo and hands each worker a separate slice with a written brief.
  4. Review hardHuman reviewers found deleted names that outside plugins still imported, plus altered error handling.
  5. Feed back lessonsAdd guidance on file size and complexity so later workers follow it.

The prompt

Our own prompt, inspired by Teknium and written to work in Custom agent. Values in lime are placeholders.

Prompt0 variables
Goal: simplify [directory] without changing behavior. Targets: break files over [N] lines, unify duplicated helpers, flatten long if-else chains. Follow the rules in [skill]. Divide the work into non-overlapping groups and write an assignment per group. Do not remove any public name without checking external usage. Report line counts before and after.

Inspired by Teknium: Refactoring Hermes with 1,393 agents. The prompt above is written by playbooks.bot in our own words; nothing from the original is quoted.

What can go wrong?

  • Workers each started their own language server, using gigabytes of memory.
  • Splitting files raised module count and some import times.

Our take

Teknium of Nous Research asked his everyday Hermes agent to refactor Hermes itself: a standing goal plus a skill built from months of corrections carved the repo into 36 chunks and launched 1,393 subagents, up to 218 at once, over about nineteen hours. Non-test Python fell roughly a third; the main run's model bill came to about $19,300. The honest list of what reviewers caught is more useful than the headline numbers. Expect breakage at public interfaces and in error handling, and plan review around those. The real enabler was the skill grown from everyday corrections; without it the swarm would have had no taste. Start smaller: one directory, one goal, one reviewer. Cap concurrency and spend before any large run. Require tests to stay green after each chunk merges. Feed reviewer findings back into the skill so the next pass improves. Never point a swarm at production secrets. Measure behavior, not only line count.

Where the time goes back: Work estimated at months to years of engineering ran in days for a five-figure model bill.

FAQ

How did it land?
As a single change, merged once a resumed session and two community review passes had fixed the problems.
Did it fix everything?
No. Some files remain very large and coupling between pieces was not fully resolved.

Source and credit

Inspired by Teknium. We describe the idea in our own words, link to the original, and wrote the prompt ourselves; nothing is quoted.

Inspired by
Refactoring Hermes with 1,393 agents
Creator
Teknium
Published on
nousresearch.com
Original date
Sep 15, 2026
License
Not openly licensed (the poster keeps all rights), so we quote nothing and link to the original
Originally for
Custom agent
AI dry run
Oct 23, 2026: passed. Dry-run tested by our AI test agent on sample input. PASS: Gates held on desk check; no live sends or purchases.
AI dry run on sample data; not run with live connected accounts. The playbooks.bot test agent filled the prompt with synthetic inputs, produced the output and checked it against the page's stated outputs and guardrails.
Verified
Oct 23, 2026: source link resolves to the original, the credited creator published it, our excerpt or prompt matches it, and the license allows our use.

Are you the creator? Claim or correct this page.

More in Operations & Admin

All 203 Operations & Admin playbooks →

Related playbooks

Operations & AdminWorkflow✓ AI dry run

Add a merge check for every way coding agents break code

Keep a running list of the specific ways coding agents have damaged your repository, from hollow tests and invented fake responses to deleted files and silenced type errors, and turn each one into an automated gate that blocks the merge, so the same mistake cannot slip through review twice.

Credit: u/alexmarquardt on r/ClaudeCode

An afternoon+
Operations & AdminWorkflow✓ AI dry run

Build a first web app as a non-coder, one model per job

Split a weekend app build across tools: an app agent for the scaffold, one model for requirements, another for fixes, and expert review before charging anyone.

Credit: u/mrcsvlk on r/replit

An afternoon+
Operations & AdminWorkflow✓ AI dry run

Let a chat model plan and write coding-agent prompts

Plan features in a chat project, have it write the exact prompt for your coding agent, paste back the agent's output, and keep both on the same version number.

Credit: u/Lost-Application4693 on r/codex

Under an hour
Operations & AdminWorkflow✓ AI dry run

Split huge coding jobs among planner and worker agents

Keep a very large software project moving for weeks with many agents in parallel, without them stalling on shared locks or dodging the hard work.

Credit: Wilson Lin

An afternoon+