The migration from ad-hoc prompts to a subagent library | Claude Code Toolkit
Deep dives

The migration from ad-hoc prompts to a subagent library

For a year, our team used Claude Code with ad-hoc prompts — each engineer building their own. It worked until it didn't. This is the story of migrating to a shared subagent library: the trigger, the extraction methodology, the mistakes, and where we landed.

MK
Mateo K. September 13, 2026 · 12 min read

For our first year with Claude Code, our team used ad-hoc prompts. Each engineer built their own. The senior engineers had personal collections of 20-30 prompts they'd refined over months. Newer engineers wrote each prompt fresh, often less effectively. Quality varied wildly across the team. Nobody thought this was a problem — until we tried to figure out why the same task produced very different results depending on who was asking Claude to do it.

This post is the migration from that state to a shared subagent library. Nine months in. About 40 subagents now, versioned, tested, shared across the team. Along the way we made most of the mistakes there are to make; some of them cost real time to unwind. This is what worked, what didn't, and the specific mechanics that turned "everyone doing their own thing" into "consistent quality across the team."

The trigger

The tipping point wasn't a single incident. It was noticing a pattern over three sprints:

  • Two engineers did essentially the same task ("write a migration for schema change X"). One produced a clean, review-worthy PR in 20 minutes. The other took 90 minutes and produced something with three issues that got caught in review. Their tools were identical; their prompts were very different.
  • A junior engineer asked how a senior engineer approached PR reviews with Claude. Senior shared their 800-word prompt. Junior applied it, got much better results. Which raised the question: why did the junior need to ask? Why wasn't this shared?
  • We onboarded a new engineer. They spent their first two weeks essentially rediscovering prompt patterns that existed on other engineers' laptops. Wasted time; wasted quality.

None of these was a crisis. Together they were a pattern: the team's accumulated prompt-craft wasn't compounding. Each engineer's learning stayed on their own laptop. New engineers started from zero. When someone left, their prompts left with them.

The migration to a subagent library was the fix for this pattern. Shared prompts become subagents; the subagents live in the repo; the team's prompt-craft becomes team property.

The extraction phase

Before writing any subagents, we did an extraction phase: figure out what actually deserves to become a subagent. Not everything in every engineer's prompt collection was worth promoting.

Step 1: The prompt survey

We asked every engineer to share their personal prompt collection. Anonymously, into a shared doc. About 15 engineers contributed. Total: roughly 200 prompts of various sizes and shapes.

The immediate observation: massive overlap. The same "review this PR" workflow appeared 8 times in slightly different phrasings. "Write tests for this function" appeared 6 times. "Investigate this error" appeared 5 times. Not identical — each engineer had their own tweaks — but clearly the same underlying tasks.

This was the first evidence of the problem. Fifteen engineers had independently built variants of the same 20-30 prompts. All the divergence was noise; the underlying tasks were converged.

Step 2: The clustering

We clustered the 200 prompts by underlying task. Clusters ranged from "8 variants of PR review" to "1 unique prompt for a very specific thing one engineer does." Roughly:

  • ~25 tasks with 3+ variants — clearly team-level; strong subagent candidates
  • ~15 tasks with 2 variants — probably team-level once socialized
  • ~60 tasks with 1 variant each — either personal preference or niche use case

The first 25 became the initial subagent library. The 15 got added over the next few months. The 60 mostly stayed as personal prompts (rightly — most weren't team-relevant).

Step 3: Picking the best variant

For each cluster with multiple variants, we had to pick which one to promote. Not by vote — by measured performance. We ran each variant against a small test set of representative tasks and picked the one that produced best results.

Surprises here: the "best" variants weren't always from senior engineers. Sometimes a junior engineer's fresher take had cleaner structure than a senior's accreted prompt. About 40% of chosen variants came from engineers with under a year of tenure. Prompt-craft is not seniority-correlated.

This step took the longest — running comparisons, discussing which subtle differences mattered. But it produced substantially better initial subagents than picking any single "champion" would have.

The naming and organization

Getting the naming scheme right mattered more than we expected. Bad names make the library unusable regardless of how good the subagents are.

The naming convention

After iterating a few times, we settled on: {verb}-{noun}. Examples: @review-pr, @write-migration, @investigate-flake, @refactor-service. Verb-first because the natural way to think about invoking a subagent is "I want to X the Y."

What we rejected:

  • {noun}-{verb}: @pr-reviewer reads OK in isolation but breaks discovery — you scan for what you want to do, not what you're doing it to.
  • Cute names: @codegoblin, @testninja. Users don't remember them. Boring functional names beat memorable ones for utility.
  • Fully-qualified names: @review-pr-code-quality. Too long to type; the extra qualification isn't needed if the base task is well-scoped.

The verb list stays small: review, write, investigate, refactor, audit, draft, debug, translate. Every subagent uses one of these. Not because we're rigid, but because the constraint forces clarity about what the subagent does.

The organization

Subagents live at .claude/agents/{name}.md — flat directory, no subdirectories. We tried subdirectories (agents/review/, agents/write/) and it added confusion without benefit. Flat is fine at 40 subagents; if we grow to 200, we might revisit.

Each subagent has a companion test file at .claude/agents/{name}.test.yaml. Tests aren't optional; a subagent without tests doesn't ship. This has been the single most valuable discipline we adopted — untested subagents drift; tested ones stay reliable.

What we got wrong the first time

The initial library shipped in about six weeks. It had problems we spent the next three months fixing. Three mistakes worth calling out:

Mistake 1: Too many subagents at launch

We shipped 32 subagents in the initial launch. That was too many for engineers to learn. Adoption was uneven — engineers used the handful they encountered in early tasks, ignored the rest. Later, they'd write ad-hoc prompts for tasks a subagent existed for, because they didn't know the subagent was there.

What we should have done: ship 8-10 subagents covering the most common tasks. Let people learn them thoroughly. Add more only after those are internalized. The library that's used is worth more than the library that's complete.

Mistake 2: No feedback mechanism

For the first two months, subagents were write-once. Engineers who found issues had no obvious way to report them; small bugs accumulated. Some subagents got quietly abandoned by their users because the fixes never landed.

What we should have done: a low-friction feedback mechanism from day one. We eventually built @feedback-subagent that engineers can invoke with "the @X subagent did Y wrong on this task" and it creates an issue with context. Cheap to build, high value for iteration.

Mistake 3: No versioning

When we improved a subagent, we just edited its file. Which meant if the change was wrong, we couldn't easily roll back. And engineers whose workflows depended on specific behaviors got surprised by changes they didn't know had happened.

What we should have done: treat subagent changes like any code change. PR review, changelog entry, rollback plan. We eventually adopted this; the six weeks of "just edit the file" produced several rollback situations we could have avoided.

The governance we settled on

Nine months in, our subagent library governance is:

  • Subagent changes go through PR review like any code change. Two-person approval required for changes to widely-used subagents; one approval for niche ones.
  • Every subagent has a test file that runs in CI. Broken tests block merge.
  • Every subagent has an owner listed in its frontmatter. Owner is responsible for triaging issues and reviewing changes.
  • Quarterly audit for usage. Subagents used fewer than 5 times per month across the team either get promoted (users don't know they exist — improve discovery) or retired.
  • Deprecation process for subagents being removed: 30-day notice, migration guidance if functionality moves to a different subagent, then removal.
  • Changelog file for the subagent library. Team members can see what changed and when.

This looks like a lot of process for what's essentially prompt files. It's justified: the subagent library is now central to how the team works. Broken subagents impact everyone. The governance overhead is small relative to the productivity impact of the library being reliable.

Where we are now

Nine months after starting the migration:

  • 40 subagents in the library. Grew from 32 at launch; net add of 8 (mostly new capabilities), plus some retirement and consolidation.
  • ~85% of team Claude Code work now uses subagents rather than ad-hoc prompts. The remaining 15% is genuinely one-off work that doesn't warrant a subagent.
  • New engineer onboarding time to productive Claude Code use dropped from 2-3 weeks to 3-4 days. They learn the subagent library rather than rediscovering patterns.
  • Task quality variance across engineers dropped substantially. Not eliminated — engineers still bring different judgment to invoking and interpreting results — but the wild swings in output quality are gone.
  • Rate of "we should have a subagent for X" proposals is roughly one per week. Not all become subagents; the discussion itself is valuable.

The number that best captures the impact isn't any of these. It's that we no longer have "senior engineers with amazing Claude Code productivity" vs "junior engineers stumbling." The library equalizes the tooling. Judgment and experience still matter; prompt-craft doesn't.

If you're starting this migration

For teams thinking about the same migration, three specific recommendations:

Start with the prompt survey. You probably have more prompt convergence on your team than you realize. The survey both surfaces the candidates and creates buy-in for the migration.

Ship small, iterate. Launch with 8-10 subagents covering the top-usage tasks. Let people learn them. Expand based on demand, not speculation about what might be useful.

Invest in tests from the start. The single discipline that separates libraries that hold up from libraries that decay. Every subagent gets a test file; broken tests block merge. Not negotiable.

The migration takes months. It's worth it. A shared subagent library is one of those investments that feels heavy up front and completely obvious in retrospect. The gap between "everyone building their own prompts" and "team-shared subagent library" is bigger than it looks from either side.

MK

Written by

Mateo K.

Mateo focuses on platform engineering, agentic workflows, and turning experimental patterns into infrastructure that scales.

Get cctk running in one command

85 slash commands, 12 subagents, 12 MCP integrations, 12 hooks. All the patterns from this post are shipped in cctk.

npx cctk@latest init Get cctk v1.5.2 →