r/ClaudeCode • • Oct 27 '26

Built with Claude 1000+ specs, ~500k lines of code, none written by hand: how I do spec-first development with Claude Code

Since January 2026 I've been building Agent Smith, an open source agent that turns tickets into pull requests. It's now about 500k lines of code and 10k tests. The challenge I started with was not to write a single line of code myself, and that's still true. Unfortunately it works pretty well, which proves something I didn't want to know: coding is more or less solved.

To make that happen, I built a spec-first development plugin for Claude Code. The short version:

Every spec is a YAML file in the repo with a fixed schema: a goal, steps and a definition of done. Specs move from planned to active to done. The reasoning goes into a separate decisions file, so when an agent picks up the next spec, it can read what was built before, why it was built that way, and why things changed later.

Before any code gets written, a second agent reviews the spec. A script first checks that every file and line the spec cites actually exists. Then the reviewer answers BUILD, BUILD WITH CUTS or REFUSE. It refuses a lot, and most of the time it's right.

Each spec gets its own git worktree, so several agents can run overnight without getting in each other's way. A commit hook runs the full test suite on every spec commit and blocks the commit if anything is red. That hook is why I can skip reading most of the code.

What I learned along the way:

  • My first specs were Markdown. At 100 specs they added up to 250k tokens, just the specs. Claude tends to write a lot that's unnecessary and sometimes even misleading. Moving to YAML brought that down to 15k tokens.
  • The workflow has to be good enough that all I discuss is features, changes, design and architecture. Coding principles have to be enforced by quality gates. Without them, files grow past 500 lines and the code gets buggier.
  • Without a fixed procedure (create, review, apply, deliver) I kept doing the same things over and over: testing every change and finally checking the result of every spec myself.
  • Without a review step that brings evidence for whether a spec can be built at all, I wasted a lot of time.
  • I put procedure into tickets ("first do X, then Y"). The agent turned that into acceptance criteria and failed a run that was actually correct.
  • I let learned memories act as rules. One wrong memory and every later run followed it. Now they're hints, and whether a memory holds up depends on how the runs that used it turned out.

Specs don't need to be as precise as the code they produce. They need to be short, verified, and ideally something several agents can execute in parallel. They pin down intent and architecture. The tests and the commit gate supply the precision.

My job now is mostly deciding what to build and how it should be structured: design and architecture. Programming was more romantic last year, but this works pretty well.

Plugin and method: spec-first.dev, github.com/holgerleichsenring/specification-first-agentic-development
Agent Smith (MIT): agent-smith.org, github.com/holgerleichsenring/agent-smith

How do you handle this? Do you keep specs in the repo, or do they disappear with the chat?

46 Upvotes

36 comments sorted by

•

u/AutoModerator Oct 27 '26

Hey! Thanks for posting to r/ClaudeCode

While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.

For help, project discussions, tips, and general chat, join the ClaudeCode Discord.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

16

u/DriftVoyager 🔆 Max 5x Oct 27 '26

Going from 250k to 15k with YAML specs is really interesting.

All in for anything that cuts down token usage (leave more room for useful context).

Gotta try this one out

8

u/holgerleichsenring Oct 27 '26

may have a look onto the schema of the yaml spec: https://github.com/holgerleichsenring/specification-first-agentic-development/blob/main/templates/context.schema.json

you can have a look onto a lot of specs that had been implemented here: https://github.com/holgerleichsenring/agent-smith/tree/main/.agentsmith/specs/done

the main point is, I do not want to read the spec, the agent should. I "just" talk to claude in the IDE. specs are maintained by the skills in the plugin

4

u/DriftVoyager 🔆 Max 5x Oct 27 '26

Thanks for sharing the links, appreciate it

4

u/f3xjc Oct 27 '26

Yeah a similar experience for me was: I had a changelog and it was always in conflict so I reshaped to individual notes that get assembled later. That change, being allowed to create a fresh file increased verbosity 2-3x

7

u/bzbub2 Oct 28 '26

why would you use this instead of saying "claude solve this ticket <url>". it just feels like ai psychosis to write 500k lines of code for this

1

u/holgerleichsenring Oct 28 '26

oh I tried this and it really doesnt work. Agent smith is just done for exactly this kind of task. I had one ticket where there was "update the library if it is worth it".
that led to agent smith running until the budget hits. The agent couldnt stop as the definition was not clear enough.

the hardest thing from my point of view is to find the right criteria to verify and define "this is right, it is done" or "this is not done, try again" and finally "this is not done, but retrying doesnt help anymore, so break"
and to make this possible, a ticket definition is transformed into specs, specs are checked against with another subagent. that works the best by now from my experience.

2

u/bzbub2 Oct 28 '26

do you use agent smith to develop agent smith?

2

u/holgerleichsenring Oct 28 '26

Like the question!

actually that would be possible. But it is the other way around. I see two valid kind of development:

- the developers in the IDE

- software factories taking over with having developers checking the PR.

Obviously there are steps after that like checking the CI results, or auto approve PR and checking test system etc.

but the point in the IDE is for me: I use a claude subscription and this is certainly less expensive than using the api tokens.

but the concept is identical. I built agent smith with claude and the methodology and approaches how agent smith executes its work is identical to what I do in IDE. Agent smith also has a "work it out" feature, where it is possible to discuss with the agent that has access to all sources to define the tickets. then tickets are just a representation of the conversation.

6

u/Specialist-Towel-627 Oct 27 '26

Dude, do anything you want just never use fcking YAML.

3

u/holgerleichsenring Oct 27 '26

doing a lot of infrastructure automation in the past I do not hate it that much :-D

2

u/TelephoneSignal3238 Oct 27 '26

Why? Seems much more non-deterministic. I've had Claude output too much stuff sometimes, which it later used again, only for it to turn into a spiral of putrid shit code and performance.

2

u/DCON-creates Oct 27 '26

I use openspec. It's quite powerful and let's me cover planning and handing over implementation to others with not much issue.

4

u/holgerleichsenring Oct 27 '26

I had a look onto it and what I was missing is verification of implementations before it starts to implement and afterwards to correct what hasnt been done "correctly" meaning not applying to the rules. but sure, there is a lot of alternatives.

2

u/Time_Cat_5212 Oct 27 '26 edited Oct 27 '26

You do not need to switch to a markup syntax just to improve spec concision. You can do that with a little markdown (skill, or directly in your AGENTS).

You probably do not need 100 specs. Why would you make your coding tool cross-reference 100 different documents? That's lossy AF. Raises so many questions about whether and how any given agent finds the spec they need for any given change.

Had you considered 1 spec?

Why are you using memory at all? It's just another source of truth to conflict with your spec.

If there's one thing and one only I could contribute to this thread it's "less is more"

4

u/holgerleichsenring Oct 27 '26

I think there's a misunderstanding about what a spec is here. It isn't a section of one big system description. It's one change: goal, steps, definition of done. Once it's done it becomes history, a bit like a commit with its reasoning attached.

So the agent never cross-references 1000 documents. It reads the active spec, the few specs it explicitly requires, their decisions, and an index with one line per finished spec. That's a small, fixed amount of context no matter how big the project gets.

One living spec works when the code can be regenerated from it, like https://www.codeplain.ai/ does. At 500k lines I don't regenerate anything; I change it, one spec at a time. And the done specs keep the "why" in git, which normally never gets written down.

On concision: I did try instructions in Markdown first. They help, but Claude drifts. A schema with length limits is checked by a test, and the test doesn't drift.

Memory is for the few facts that aren't in the code or any spec, like "the staging DB is shared" or how I want something done. It's a hint, not truth. When it conflicts with the spec, the spec wins, and a memory that keeps leading runs wrong loses its standing.

Less is more, agreed. That's why the agent reads one spec instead of all of them.

3

u/Time_Cat_5212 Oct 27 '26 edited Oct 27 '26

Yeah, people definitely use the term spec in many different ways here... the formal definition I was taught is that the spec is the single source of truth for developing a complete program.  It usually is divided into sections scoped for different parts of the program, but those sections don't overlap, they interface.  What you start with if anything, what it needs to do, and what is excluded.

3

u/Ok-Scarcity-20 Oct 29 '26

I think ADR more fitting then spec. Looks like something you are trying to achieve https://github.com/architecture-decision-record/architecture-decision-record

2

u/TelephoneSignal3238 Oct 27 '26

Just how is this different from any other sottware factory? I have the same setup, except that I use Markdown still... which I'm gonna change to YAML now.

3

u/holgerleichsenring Oct 27 '26

I automated it as a plugin with skills to share it with collegues to have the same procedure for everybody. creation should be easy after discussion with claude. review and skip specs that are "not good enough" is a must have to avoid implementation of incorrect specs. the approach delivers moreless autonomously when executing create-spec, review-spec, apply-spec and deliver-spec on his own, even for series of specs, not only one.

did you do the same? interested in it!

3

u/TelephoneSignal3238 Oct 27 '26

Not 1:1, and I think you've got more robustness. :) But yeah, I globally have the same setup of a Kanban-like SDLC like you have.

I made it is as I got sick of getting overengineered awfulness or just plain awful unsecure code mainly.

Might share it later this week, currently building a PoC with it and still tweaking it sometimes.

1

u/holgerleichsenring Oct 27 '26

looking forward to seeing it :-)

3

u/Time_Cat_5212 Oct 27 '26

Why change to YAML exactly?

It all gets turned into plain text when the LLM reads it, so in this case you're building a nested list and relying on the LLM's digestion of YAML syntax for... standardization maybe? Shorthand?

Seems like it could help in some areas and be conceptually restrictive in others.

HTML was a trendy way to sling specs a few months ago, and it collapsed under the fact that even though they've been trained on boatloads of HTML, LLMs are built to interpret natural language. It's also way easier for both us and Claude to write specs in English.

2

u/holgerleichsenring Oct 27 '26

Because when Claude writes specs in Markdown, they always get bloated: lots of code samples that go stale, and no fixed structure.

The YAML isn't replacing English, though. The values are still plain sentences: the goal is one sentence, steps are short sentences. YAML just gives them a fixed schema with length limits on the fields. That's what cut the cost: 100 specs went from 250k tokens in Markdown to 15k in YAML, and there are over 1000 now.

The other benefit is that a script can read it. It checks the limits, follows the dependencies between specs, and verifies that every file a spec cites actually exists. You can't do that reliably with free-form Markdown.

And yes, it's restrictive. That's on purpose. A spec only says what to build and why. Anything longer goes into the decisions file.

2

u/Time_Cat_5212 Oct 27 '26

I've been working on the bloat for months. It's definitely a real problem, but there are plenty of ways to address it without switching formats. I don't have stale code samples in my docs, for instance (Opus 5 used to love that kind of shit, and was hard to control).

That said your point about reading YAML with a script is valid and interesting. I'm curious where that script reading process fits into your LLM process, though.

2

u/holgerleichsenring Oct 27 '26

Nice, glad the YAML part was useful. If you have the same setup, the differences are probably in the details, so here's where I'd compare:

  • Is the spec checked against the code before anything is built? Here a script resolves every file and line the spec cites, then a fresh agent can refuse the spec.
  • Is "done" enforced or trusted? A commit hook runs the full suite on every spec commit and blocks it if anything is red.
  • Are decisions recorded per spec (chose / over / why), so the next agent doesn't undo them?
  • Can agents work in parallel without colliding? Each spec has its own worktree, and ids come from the date plus random hex instead of a counter.

That's the method, and it's the open source plugin. Agent Smith is the factory built with it: a server that takes tickets from Azure DevOps, GitLab, GitHub or Jira, works on them in sandboxed containers and opens a PR, with no IDE involved. As far as I can tell, most software factories are GitHub-only, and that was one reason I built my own.

What does your setup look like? Do you also have commit gates or guards in place to try to ensure better quality?

4

u/TelephoneSignal3238 Oct 27 '26

Natural language can still be ambiguous, esspecially in when terms or words have different meanings in different contexts or domains.

Where I work at we are currently moving onto DDD, and one of the things we noticed with LLMs in the old legacy stuff is that it doesn't perform too well if you don't give it precise context. Even worse with work that spans a lot of different domains. We have multiple terms that refer to the same thing for example, and it just produces stuff we never asked for in natural language.

For me, it's not necessarily YAML, it's more about getting proper unambigious context. Whether that's through declerative, ontologies or w/e is out there doesn't matter much from what I've experimented with. LLMs perform best with clean data in general though.

5

u/Time_Cat_5212 Oct 27 '26

I agree, but YAML can be a lot more ambiguous than one might think, too, when it's fed into an LLM. It's not like it's code that's getting compiled. I haven't seen any science demonstrating that markup languages provide more granular control over inference, but I haven't looked for it, either.

I'd expect it to be a little more rigid, almost like a lower temperature setting, but that's a tradeoff; I don't always want that rigidity. I've mocked up pseudocode in YAML before and it worked great, but only when it served me. I've also used my own shorthand with a key in repo, which worked arguably just as well as the YAML, if not better, because the key (supposedly, it's a black box) narrowed the scope to the shorthand I was using and reduced the range of potential inference. And flowcharts through an image model can also work surprisingly well for some things. However, those specs took me twice as long to write.

All this seems to me like a "right tool for the job" problem. Artists use soft pencils when they want gestures and shading over broad areas. They use hard pencils when they want sharp lines and know exactly where the lines need to go. Kinda like that, I'd say.

2

u/TelephoneSignal3238 Oct 27 '26

Yeah, it's mostly experimenting and see what works best for whatever workflow.

But that goes for the deployment of LLMs in general though, even enterprise adoption and implementation.

2

u/zmizzy Oct 27 '26

this one comes with even more slop!!

3

u/holgerleichsenring Oct 27 '26

think it's pretty structured. ;-)

3

u/just_damz Oct 27 '26

gonna definitely try this. is it me or after 5.5 this sub has become better?

3

u/f3xjc Oct 27 '26

So this is a set of skill that enable an agent to collect specs from the user and implement from them? And that set of skill is itself spec driven?

That's interesting. Maybe I can extract specs from skills and regenerate the skill from spec in order to cut bloat.

4

u/Js4days Oct 28 '26

Specs in repo, done ones kept as history with the "why" attached. Same shape as you, so I'll skip the format fight that's eating the thread. u/Time_Cat_5212 already nailed it: it's all plain text to the model, the win isn't YAML, it's that you hung length limits off a test so the format can't drift and a script can verify the cited files exist. That's a gate wearing a syntax. Everyone else is arguing about the pencil.

I run the same shape (pre-build review gate, worktree per unit, commit hook as the whole reason I don't read the code), just wide instead of deep: one control layer over 182 projects, ~77k lines of hooks and scripts, 142 specialist agents, 22 enforcement hooks (several can kill a commit). Eleven rewrites deep since last November, with ~10,400 task-runs and ~2,900 review findings logged in the ledger behind it. You went deep on one 500k app, I went wide, so I hit the over-time failures earlier. Four I'd bet are coming for you:

"It refuses a lot and most of the time it's right." How do you know? Best line in the post and the scariest. A wrong BUILD is loud: tests go red. A wrong REFUSE is silent, a buildable thing just never gets built and nothing turns red to tell you. Your reviewer only gets graded on the specs that proceeded. I eventually built an actual calibration-miss counter (cheap reviewer says low-risk, adversarial pass says high, flag the gate as miscalibrated past a 50% disagree rate) and it still only catches wrong-BUILDs, because a refused spec produces nothing to disagree with. The only thing that ever surfaced my false-refuse rate was forcing a sample of rejects through by hand, at which point half of them built fine and the reviewer had nothing to say for itself. Do you re-run REFUSEs, or is "mostly right" a vibe?

Related, because it's the same disease: I stopped trusting the agent's claim that it verified anything. Commits in my rig have to carry a validation tag (LIVE / MEASURED / HYPOTHESIZED), and a HYPOTHESIZED commit can't auto-close its task. "Tests pass" and "I ran it against the real thing" are different sentences, and the agent will say the first one with the confidence of the second.

Your commit gate is per-worktree, so green ≠ green. Each overnight worktree runs the full suite and commits on green, green in isolation. Two specs that each pass alone conflict on merge, or quietly break a third thing neither one tested. The hook proves each branch is green, not that main is. Every worktree reports back green and means it, and main is on fire anyway. u/TelephoneSignal3238, this is the actual answer to your "how's this different from a software factory": the difference lives at the merge, not the spec. I ran worktree-per-task exactly like OP and tore it out: it's now in-tree disjoint write sets with a single committer (a "wave integrator" that re-runs the suite at the boundary), worktrees only when write sets genuinely overlap. N green branches don't compose for free.

Your done-index is the next "one wrong memory." You already learned a memory-as-rule poisons every later run and demoted them to hints, good instinct. But the one-line-per-finished-spec index the agent reads is a rule, and the day spec #40 gets superseded by #900, the #40 line is lying to every future run. Same failure, relocated. The trap under it is identity: my index keyed rows on the spec's local id, the id got re-minted on re-create, and I spent an afternoon cancelling ~400 phantom duplicate entries that had quietly bred overnight. Now a row's identity is (project, normalized-subject, creation-sequence) and supersession is an explicit event, never an overwrite. How do you dedup in the index? (u/Time_Cat_5212, this is the "another source of truth to conflict with the spec" you flagged. It's real. It just moved.)

The number I'd kill to see: meter one full create→review→apply→deliver run by stage. I'd bet the orchestration loop dwarfs the specs. You took specs 250k→15k, which is real, but that's the cheap part if your planner's most of the bill. Mine ran ~75% of the tokens even after the workers got an order of magnitude cheaper: the labor got cheap, the manager just kept talking. Which is also why I ended up scoring the orchestrator as its own actor with its own defect class, a bad brief regresses as often as a buggy agent, and at 1000-specs-overnight the real question isn't a spec's token size, it's which spec's reasoning was wrong three weeks ago.

TL;DR: the YAML is the least important thing you did. The walls past 1000 specs are all over-time, not format: you can't see your false REFUSEs, per-worktree green isn't merged-green, your done-index quietly becomes the next poisoned memory, and your planner is probably eating most of the tokens while everyone optimizes spec size.