r/ClaudeCode • u/holgerleichsenring • 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?
•
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
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
6
u/Specialist-Towel-627 Oct 27 '26
Dude, do anything you want just never use fcking YAML.
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.
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"
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/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.