[KongchangAI]
· 4 min read· 2,291 words

How to Write Specs So AI Doesn't Go Off Track: OpenSpec + grill-me in Practice

How to Write Specs So AI Doesn't Go Off Track: OpenSpec + grill-me in Practice

Specs written by AI can also go off track; control how to ask, how to write, and what the result looks like.

The article notes that AI-generated specs can also go off track: the plan for the same requirement differs each time, and the spec may look complete but miss key constraints. The author proposes SD Flow, combining OpenSpec and grill-me, with the core of controlling "how to ask, how to write, and what the result should look like." At the asking level, distinguish which facts AI checks itself, which options AI brings recommendations for, and which impacts humans judge, attacking "heavy constraints" first and judging when to stop by evidence rather than rounds. At the writing level, drop decision minutes first and then write documents at once from the minutes, avoiding contradictions among documents, and use content fingerprints to prevent passive modification. At the result level, specs must pass general and layered domain rules and include diagrams like context diagrams and state machines to force AI to walk through the process. The author stresses that humans must have expectations first and make decisions personally; AI only helps find and write them down.

AI writing code is increasingly common, but one core pain point persists: the specification document (Spec) itself is also written by AI, and it can go off track just the same. For the same requirement, the plan generated each time may differ; the spec looks complete, but key questions weren't asked, and you can't tell at a glance whether it's right or wrong. In a recent share, Bilibili creator "老大千里" (Boss Qianli) focused on three things—"how to ask, how to write, and what the result should look like"—and proposed a practical workflow combining OpenSpec and grill-me, called SD Flow. He stated bluntly: if you don't have an expectation in your mind and answer every question with the recommended option, the final plan is the AI's plan, not yours.

Why isn't a spec alone enough?

The previous episode's idea of using specs to keep AI from guessing has proven effective, but new problems followed: the spec is generated by AI, and it only asks questions it "thinks of." Under the same requirement, the plan differs each time; the spec looks complete but may miss key constraints. The author points out that to get a reliable spec, you must simultaneously control three things: how to ask, how to write, and what the result should look like.

This also explains a Bilibili viewer's question—why not just use grill-me instead of OpenSpec? The author's answer: they complement rather than substitute for each other. OpenSpec manages the spec lifecycle (how to write, how to archive, how to handle changes), while grill-me manages how to ask (extracting the decisions in your head one by one). In the workflow of grill-me's author Matt Pocock himself, the next step after interrogation is also to organize the conversation into a Spec.

Spec-Driven Development is a working paradigm that has emerged in recent years with AI coding tools: before letting AI write code, first fix "what to do, what not to do, and what the constraints are" in a structured specification document, then use the spec as the single source of truth to drive implementation and acceptance. It is the opposite of the traditional "write code first, document later" approach, emphasizing documentation first, traceability, and reviewability. OpenSpec is one of the tools implementing this paradigm; it splits the spec into multiple documents such as proposals, specs, designs, and tasks, and manages their lifecycle. The key assumption of this paradigm is: the quality of the spec determines the quality of the output. Therefore, when the spec itself is generated by AI, the spec's ability to "ask the right questions" becomes the new bottleneck—which is why the article emphasizes that "how to ask" must also be controlled.

SD Flow: evolving from four steps to six steps

The author initially combined the two into a four-step process: first use the Explorer command to have a divergent chat with AI to set the problem boundaries and solution direction; then use OpenSpec to generate four documents—proposal, spec, design, and tasks—in one go; then use grill with Docs to interrogate the plan item by item; finally record ADRs (decision records) and a glossary, and go back to modify the four documents.

But in practice, going back to modify documents is error-prone. So the author customized SD Flow, with the core change being drop the minutes first, then write the documents: after exploration, reconcile the goals and scope once and drop a temporary decision minutes; interrogate using grill with Docs, filling each decision into the minutes as it is made; during interrogation, anything determined to be used later is turned into ADRs and a glossary; only at the end are the OpenSpec specification documents written from the minutes in one go.

Let's talk about them one by one

ADR (Architecture Decision Record) is a lightweight way to keep a record of decisions, usually in the form of Markdown files. Each record contains: the decision context (Context), the decision content (Decision), the alternatives and reasons for rejection, and the consequences of the decision (Consequences). Its value lies not in the document itself, but in enabling later readers (including yourself months later and the AI) to understand "why it is this way and not that way," avoiding the situation where a decision that actually had good reasons is overturned without knowing it. In SD Flow, ADRs handle the long-term retention of decisions determined during interrogation that will be used later, forming a division of labor with the temporary decision minutes: the minutes cover the whole process, while ADRs only preserve key decisions that need long-term reference.

How to ask: distinguish whom to ask, what to ask first, and when to stop

The core of the interrogation phase is three questions. Whom to ask? Facts that can be found in the code—AI looks them up itself; where multiple options are available—AI researches and brings a recommendation; the impact of writing something into the system on users and subsequent development—you judge; only requirements, constraints, and preferences that only you know are asked of you. What to ask first? Attack the "heavy constraints" first—the premise that multiple options depend on; if it falls, the related options must be re-evaluated. When to stop asking? Not by how many rounds, but by whether each heavy constraint has evidence: file names and line numbers in the code, command output, or your own confirmation.

Here I mainly focus on three questions

The author gives an example of a data processing tool: when batch importing Excel, if a few of ten records have incorrect formats, AI follows the existing code and recommends rejecting the entire batch. But from the user's perspective, the author chose "import the correctly formatted ones as usual, flag the incorrectly formatted ones and clearly state which row has which error." For the same question, different choices lead to completely different subsequent work. The recommendation is from AI, but what the user experience should be is for you to judge.

How to write: minutes first, write once

The author ran a round using the "power project" with the old process and, after interrogation, went back to modify the four documents—only to find two contradictory statements: the glossary said "at most one notification per over-temperature event," while the spec said "devices still over-temperature after a service restart will send another notification." The same thing stated differently in two documents; following either one makes the other wrong.

The new process reverses this: at the start of interrogation, create the branch and change directory, and place a draft minutes recording four things—what was decided, which options were cut and why, heavy constraints and evidence, and places where risks were knowingly accepted. Each item is written in on the spot as it is settled; if interrupted midway, only content after the last write is lost. After wrapping up, write out the four documents one by one from the minutes, run validation after each, and after all four are written, check them against the minutes item by item: are any decisions missing, are any constraints written backwards, was anything added that isn't in the minutes? When the minutes are finalized, a content fingerprint is also computed; the claim is to compare it before archiving to prevent the minutes from being quietly modified.

Then from the minutes, write the four documents

Content Hash / Fingerprint refers to a fixed-length digest value (such as SHA-256) computed from document content; any tiny change in content results in a completely different fingerprint. In spec archiving scenarios, record a fingerprint when finalizing, then recompute and compare before archiving—this cheaply detects whether the minutes have been quietly modified. This is not encryption and cannot prevent intentional tampering followed by recomputing the fingerprint, but it effectively prevents "unconscious drift"—for example, AI casually modifying the minutes in a later round without anyone noticing, causing the spec to become disconnected from the basis for decisions. For multi-person collaboration or long-cycle projects, this lightweight check is a low-cost insurance for ensuring "spec traceability."

What the result should look like: general rules + domain rules

Spec content falls into two categories. General rules apply to all spec documents; the four most important: write success metrics (what to measure, what to achieve); when writing what not to do, attach an assumption that can be overturned; check facts in the code before writing, don't rely on memory; for option choices, clearly state the rejected options and reasons. Domain rules are determined by the technical domain involved in the requirement; SD Flow lists more than twenty cases. The rule list is layered: the bottom layer is general rules, above that are domains such as backend, embedded, and frontend, and above that are specific languages, chips, and frameworks (such as Go, ESP32, React). Writing Go code means passing through all three layers: general, backend, and Go. These domain rules can be extended—add to whichever area you frequently stumble in.

Diagrams are also drawn according to the requirement: structurally, draw context diagrams, container and component diagrams; behaviorally, draw state machines, data flows, decision and sequence diagrams; there are also test coverage diagrams, comparison tables, and task dependency graphs. Drawing diagrams has two benefits: first, it makes the plan easier for people to understand—one diagram is clearer than a large block of text; second, it forces AI to walk through the process step by step, and places it didn't think of are exposed when it draws to that point. The author wrote these requirements into the OpenSpec configuration so that they are included in every generation, rather than relying on AI to remember them itself.

I wrote these requirements into the OpenSpec configuration

In the design of the "power project," eight diagrams were drawn in total. One of them was because a cooldown table was added—once a device has been pushed, it won't be pushed again within ten minutes, and several report requests will read this table simultaneously. AI judged it to be a concurrency scenario and drew an additional sequence diagram, making it easy to check at a glance whether "two messages arrive at the same time, push only once" is the desired effect. Of course, which scenarios and domains the design involves are judged by AI based on semantics, and it can miss things; the author leaves the fallback for missed judgments to the next episode's spec review discussion.

C4 model is a layered visualization method for describing software architecture, proposed by Simon Brown, containing four levels: context diagram (Context, the system's relationships with external actors and systems), container diagram (Container, deployable units such as applications, services, and databases), component diagram (Component, module division within a container), and code diagram (Code, class and interface level, usually not hand-drawn). The "context diagram, container and component diagrams" mentioned in the article are exactly the first three layers of C4. The benefit of layered diagrams is that different readers can choose the abstraction level they need—business stakeholders look at the context diagram, developers look at container and component diagrams—avoiding the situation where one diagram tries to explain both the big picture and the details and ends up unclear on both. This also explains why drawing diagrams can force AI to walk through the process: each lower layer must answer questions not expanded in the upper layer.

Where humans sit in the process

Back to the two phenomena at the beginning: if you only ask what AI thinks of, then first distinguish whom to ask, interrogate item by item, and only listen when there is evidence; if the plan for the same requirement differs each time, then take back into your own hands the decision for each question—let humans decide. SD Flow connects grill-me's "asking" with OpenSpec's "writing and retention" into one line, but the author emphasizes that this is just a practical solution he gradually modified from others' skills, and readers can adapt it following this approach or make their own process.

The most important reminder is: you must have an expectation in your mind for your complete requirement first; AI interrogation helps you find and write down that expectation, not decide it for you. For small changes where the goal and direction are already clear, exploration can be shortened or even skipped, but scope and solution clarification, fact checking, and decision confirmation cannot be omitted. Can a written spec directly generate code? The author leaves this question to the next episode's spec review.

One-line Summary

Specs written by AI can also go off track; you must control three things: how to ask, how to write, and what the result should look like.

Paragraph Summary

The article points out that specification documents generated by AI can also go off track: the plan for the same requirement differs each time, and the spec looks complete but may miss key constraints. The author proposes SD Flow, a workflow combining OpenSpec and grill-me, whose core is simultaneously controlling "how to ask, how to write, and what the result should look like." At the asking level, distinguish which facts AI checks itself, which options AI brings with recommendations, and which impacts humans judge, and attack "heavy constraints" first, judging when to stop by evidence rather than rounds. At the writing level, change to dropping decision minutes first and then writing all documents at once from the minutes, avoiding contradictions among multiple documents, and use content fingerprints to prevent the minutes from being passively modified. At the result level, the spec must pass general rules and layered domain rules, and be accompanied by context diagrams, state machines, and other diagrams to force AI to walk through the process. The author emphasizes that humans must have expectations for the requirement first and make the decisions personally; AI only helps you find and write down those expectations.

#OpenSpec#grill-me#SD Flow#Spec-Driven Development#AI coding#specification document#ADR#C4 model
Share:

Related articles