How to Write a Technical Spec for Claude Code (The Format I Use on Every Build)

David IyaDavid Iya September 10, 2026 9 min read
A sleek wooden desk with a printed technical document covered in handwritten annotations, a mechanical keyboard, a cup of black coffee, and a moody cinematic lamp casting warm directional light
Original image, Claude Code Club

What a Technical Spec for Claude Code Actually Is

A technical spec for Claude Code is a short plain document that defines what you are building, what the agent is allowed to touch, and what done looks like - before you type the first prompt. It is not a project plan, a PRD, or a design doc for a human engineer. It is context for an AI agent that starts fresh every session with no memory of yesterday's decisions, no relationship with your client, and no way to ask a clarifying question without burning your time.

Most builds that go sideways with Claude Code share the same root cause: the agent started with a vague prompt and made a reasonable but wrong assumption about scope, stack, or priority. By session three you are untangling decisions the agent made in session one that nobody explicitly authorized. A spec eliminates that. When Claude Code reads a complete spec at the start of a session, it knows exactly where to go and - just as importantly - where to stop.

The Five Parts of a Working Claude Code Spec

Strip a well-run build down and you will find the same five pieces of context the agent needed to make good decisions. Everything else is either a nice-to-have or noise. Here is the CCC spec skeleton I use on every project.

The five spec sections and what each one does

SectionWhat it tells Claude CodeExample
One-sentence goalWhat the build is for and who uses itA task manager that lets a solo founder track daily priorities, stored in Supabase
Stack and constraintsWhat tools are in, what tools are outNext.js, Tailwind, Supabase. No auth library other than Supabase Auth. No paid APIs.
Feature list with explicit out-of-scopeExactly what to build - and what not to buildIn scope: add task, mark done, delete. Out of scope: recurring tasks, labels, team sharing.
Success criteriaHow the agent (and you) verify it is doneUser can create a task, see it in the list, mark it done, and delete it - all without a page reload.
Starting file treeWhere files go so nothing lands in the wrong placesrc/app, src/components, src/lib/supabase.ts, .env.local

That is the whole spec. One A4 page at most. If you are typing more than that, you are probably documenting decisions the agent could derive from context, or describing the implementation rather than the outcome. The spec defines the target; Claude Code picks the path.

The One-Sentence Goal (and Why It Has to Be One Sentence)

Every spec starts with a single sentence that names the product, the user, and the core job the product does. Not two sentences. Not a paragraph. One sentence, because if you cannot state the build in a sentence, the scope is not defined yet - and you are not ready to write a spec.

A weak goal: 'Build a task management app with productivity features.' A strong goal: 'A web app where a solo founder can add daily priority tasks, mark them done, and see the list persist across sessions using Supabase.' The difference is specificity. The weak version gives Claude Code permission to guess. The strong version gives it nothing to guess about.

Write the goal sentence before anything else. If you are building for a client, derive the sentence from the kickoff call, not from the proposal. The proposal is usually too vague - it is written to be accepted, not to be implemented. The [client kickoff call guide](/blog/client-kickoff-call-ai-build) has the questions that extract the goal sentence before you ever write the spec.

Stack and Constraints: What Claude Code Is and Is Not Allowed to Use

The stack section is where most builders underspecify and then wonder why Claude Code introduced a library they did not want. The agent will pick reasonable defaults when you leave it room - but 'reasonable' to Claude Code might mean a full authentication library when you wanted a simple cookie check, or a full ORM when you wanted a raw Supabase query. The spec names the tools that are in and explicitly bans the substitutes.

Format it as two short lists: 'Use' and 'Do not use.' Example: Use Next.js App Router, Tailwind CSS, Supabase for database and auth, React Query for server state. Do not use Prisma, NextAuth, any UI component library, or any paid third-party API. Two lists, no prose. The agent reads lists faster and violates prose instructions more often.

Constraints also include environment rules: what goes in .env.local versus what is hardcoded, whether the build is for Vercel or somewhere else, and what the agent is not allowed to do to the repository structure. If the client has a monorepo and the agent should only touch a specific folder, that is a constraint. Put it in the spec, not in a prompt three sessions in when the damage is already done.

The Feature List: In Scope and Explicitly Out of Scope

The feature list is two sections, not one. 'In scope' without 'out of scope' is an invitation to build adjacent features the agent thinks are related. The out-of-scope list is where most specifications skip a step and most builds drift.

For in-scope: list each feature as a user action, not a technical task. 'User can add a task with a title' is a feature. 'Create a POST endpoint at /api/tasks' is an implementation detail. Write features; let Claude Code design the implementation. One feature per line, no sub-bullets at the spec stage.

For out-of-scope: name the obvious adjacent features you are deliberately not building this sprint. If the build is a task manager and you know a client might ask for team sharing later, put 'Team sharing, comments, and notifications are out of scope for this build' in the spec now. When Claude Code sees something is explicitly excluded, it stops adding it speculatively. When that exclusion is absent, the agent sometimes adds a feature because it seemed helpful - and you are reverting it in session five.

Success Criteria the Agent Can Actually Verify

A success criterion is a testable statement. Not 'the app works well' - that is a feeling, not a criterion. A testable criterion is: 'A user can create a task, see it appear in the list immediately, mark it complete, and reload the page to find the state persisted.' Claude Code can run that test. It can also generate a test file for it, which is how I get a basic smoke test suite out of the spec with no extra work.

Write one criterion per major user flow, not per endpoint. Four or five criteria are usually enough for a lean build. Keep each one to a single sentence in plain English. If you need a second sentence to explain the criterion, split it into two criteria.

At the end of every session I paste the success criteria back into the prompt and ask Claude Code to run through them. 'Here are our success criteria. Walk through each one and tell me which pass, which fail, and what is left to do.' It is the most efficient review loop I have found - faster than reading code and more reliable than trusting the agent's last message.

The Starting File Tree

The file tree section is short and often skipped - which is why you keep finding components in the root folder and API handlers inside the wrong directory. Give Claude Code a minimal starting tree and it builds into it rather than around it. Approximately ten to fifteen paths is enough: the main directories, the config files, and the one or two files that need to exist before the build starts.

You do not need to pre-create every file - just name where they go. Example: src/app/page.tsx, src/app/api/tasks/route.ts, src/components/TaskList.tsx, src/lib/supabase.ts, .env.local. Claude Code reads the tree, understands the intended structure, and places new files accordingly. Without the tree, it defaults to its own conventions, which may not match your project, your client's conventions, or the existing codebase you are extending.

If you are building on an existing codebase rather than starting fresh, the file tree section becomes a map of the relevant files - the ones Claude Code should read and the ones it should not touch. Pair it with the constraints section to mark the no-go zones. The [how to use Claude Code on a large existing codebase guide](/blog/claude-code-large-existing-codebase) goes deeper on keeping the agent oriented in a code base it did not build.

How I Load the Spec Into Claude Code

The spec lives in two places: the CLAUDE.md file and the first prompt of every new session. CLAUDE.md is where the durable context goes - stack, constraints, file tree, and the out-of-scope list. These do not change during the build, so they belong in the persistent file the agent reads first. Features and success criteria can go in CLAUDE.md too, but I usually paste them fresh in each session prompt so I can update them as the build evolves without editing the file.

The first message of each session follows a fixed shape: 'Here is the spec for this build. [paste spec]. Today's task is [single concrete next step]. Start by reading the files in [directory] and tell me what you see before writing any code.' That last sentence - read before you write - is the single most valuable habit I have built into my workflow. It stops the agent from diving into implementation based on assumptions and makes it tell me what it actually found in the codebase first.

The Mistakes That Break a Spec

A spec that is too long is almost as bad as no spec. When the context document runs to ten pages, the agent's attention dilutes - it starts weighing section four at less than section one, and the rules buried in the middle get violated first. Keep the spec under one page. If you have that much to say, you have too much scope in one build.

A spec written in the third person is harder for Claude Code to parse than one written as direct instructions. 'The application should allow users to' is weaker than 'Users can.' Direct language processes faster and is less likely to be misread as a description of an existing system rather than a target to build toward.

The worst spec mistake is writing the spec after the build starts. I have done it. You get three sessions in, the agent has taken a turn you did not want, and you try to retroactively document the right direction. It does not work. The agent has already made decisions you would have prevented. Write the spec first, treat it as the mandatory first deliverable on every project, and send it to the client for a quick sign-off before session one. A ten-minute spec review is worth two hours of rework.

Free Claude Code drops, straight to your inbox

Short, practical drops on skills, MCP, agents, prompts, and more. No spam, unsubscribe anytime.

Frequently asked questions

What is a technical spec for Claude Code?

It is a short plain document written before the build starts that gives Claude Code its one-sentence goal, the stack it is allowed to use, a feature list with explicit out-of-scope items, success criteria it can verify, and a starting file tree. It replaces the need to re-explain the project in every session prompt.

How long should a Claude Code spec be?

One page or less. If you are writing more, either your scope is too large for one build or you are documenting implementation details instead of outcomes. The spec defines the target; Claude Code picks the path.

Do I need to write a spec for every Claude Code build?

Yes, even for small ones. A five-feature build with a one-page spec takes twenty minutes to write and saves two or three sessions of cleanup. The smaller the build, the shorter the spec - but the spec still needs to exist before the first prompt.

What is the difference between a spec and a CLAUDE.md file?

The spec is the document you write before the build; the CLAUDE.md is where you store the durable parts of the spec so Claude Code loads them automatically at the start of every session. The stack, constraints, and file tree go in CLAUDE.md. Features and success criteria can go there too, or be pasted fresh each session as they evolve.

What should go in the out-of-scope section?

Name the adjacent features you are deliberately not building in this sprint - the things a client might assume are included or the things Claude Code might speculatively add because they seem related. An explicit out-of-scope list stops scope drift before it starts and doubles as the contract language when a client asks for something that was never agreed.

Last reviewed by David Iya on September 10, 2026

David Iya

Written by

David Iya

Forbes 30 Under 30 · Y Combinator

Keep reading

Claude CodeGetting Started

How Much Does Claude Code Cost Per Month? A Real Builder's Budget

How much Claude Code costs per month depends on which paid Claude plan you are on, because Claude Code is included in the plan rather than billed separately. The floor is the price of a paid Pro plan; heavier daily building lives on the two Max levels. Here is the honest per-month picture, when the API pay-per-token route is cheaper, and the mistake that made my first month cost more than it needed to.

David Iya 9 min
Read article
Claude CodeWorkflows

Claude Code Token Usage: What Actually Eats Your Limit (and How to Make It Last)

Claude Code token usage is driven by how much text goes into and out of the model on every turn - your context, the files it reads, its own output, and the conversation history it drags forward. Most people burn through their limit not by doing more work, but by keeping bloated context and long sessions running. Here is exactly what uses your usage and how to stretch it.

David Iya 10 min
Read article

Ready to build it yourself?

Join Claude Code Club, the #1 community for learning claude code, for $9/month.

← Back to the blog