Yashveer Singh
Connect
<- All posts
AI Integration and Vibe Coding Rescue11 min read

The Prompt as a Spec: How to Build Software With AI Tools Responsibly

Using a prompt as a spec means writing the context, constraints, and expected behavior into the prompt the same way you would write a technical specification. The model then generates code against a defined target rather than guessing intent from a few words. Teams that do this get reproducible, reviewable output. Teams that skip it get code that works once and breaks under any variation. The discipline is cheap. The alternative is not.

Written by Yashveer Singh, founder of Yashveer Labs.

What you actually need to know

  • A prompt is a specification. If the prompt is vague, the output is vague. The discipline of writing a clear prompt is the same discipline as writing a clear technical requirement.
  • AI coding tools do not know your codebase, your team's conventions, or the edge cases in your data. You have to supply that context explicitly in the prompt.
  • The code an AI tool generates needs the same review process as code from a junior engineer. Skipping review because it looked right on first read is how bugs get shipped.
  • Storing prompts in version control alongside generated code is a practice that most teams skip and almost all teams eventually wish they had adopted.
  • The failure mode is not that the AI produces bad code. The failure mode is that the team produces bad specs and then blames the AI for the result.
Prompting approachOutput qualityReviewabilityReproducibility
Single sentence, no contextVaries widelyDifficultLow
Multi sentence with framework and patternConsistent for simple casesModerateMedium
Full spec with constraints and examplesConsistent across variationsHighHigh
Spec stored in repo and versionedConsistent and recoverableHighestHighest

The core argument

The premise that AI coding tools will replace software specifications is wrong. They have done the opposite. They have made the quality of your specification the single biggest factor in the quality of your output. A senior engineer who knows how to write a tight specification gets dramatically better results from these tools than a junior engineer who types a sentence and hopes. The gap between those two outputs is not the AI. It is the spec.

I have seen this in my own work on client codebases. The teams getting genuine productivity gains from AI coding tools have developed a discipline around prompt writing that looks a lot like requirement writing. They specify the framework, the pattern they want to follow, the inputs and outputs, the edge cases they care about, and sometimes a worked example from an existing part of the codebase. The AI generates against that specification. The result is code that fits the codebase and handles the cases that matter.

The teams that are not getting value, or worse, generating technical debt faster than before, are using one sentence prompts and then iterating through confusion until the code compiles. That process produces working code in the same way that a random walk eventually gets you somewhere. The destination is not reliably useful.

There is a second dimension to responsible use: what happens after the code is generated. The teams that treat AI output as a draft subject to full review are building better software. The teams that merge AI output without review because it passed tests are shipping systems nobody understands. That second category is the origin story of most vibe-coded codebases.

The prompt spec discipline

What belongs in every prompt for code generation

The language and version. The framework and any relevant library constraints. The specific function or component you are asking for, with types if applicable. The pattern from the existing codebase you want to match, with an example if the codebase is complex. Any constraints on what the code should not do: no additional dependencies, no external calls, no state mutation outside defined boundaries. What a correct result looks like for a simple input.

That is approximately two hundred words of context for most tasks. It takes five to ten minutes to write. Engineers who do it consistently report that their rework rate on AI generated code drops significantly after the first week.

How to handle the parts of the spec you do not know yet

If you cannot write the constraint, you do not know it yet. That is useful information. Writing the prompt forces the same clarifying work that a good specification forces. If I cannot write down what the edge cases are, I have not thought about them. The prompt writing process is also a design review process. Engineers who treat it that way build better habits than engineers who use it to skip thinking.

Storing prompts in the repo

I keep a directory called prompts or ai-specs in the repo for any feature where the generated code is substantial. Each file contains the prompt, the date, the model, and the file that was generated. When the generated code needs to be updated, I have the original intent. When a new engineer extends the feature, they can read why it was built the way it was. This costs almost nothing and has rescued me from two situations where significant refactoring was needed and the original intent was otherwise lost.

What it requires

PracticeTime investmentImpact on output quality
Writing a full prompt spec before generating5 to 15 minutes per featureHigh
Storing prompts in version controlSetup once, 2 minutes per useHigh for maintainability
Reviewing AI output like a junior PR15 to 30 minutes per PRCritical
Running the full test suite on generated codeAutomated after setupRequired for confidence
Adding edge case tests for generated logic30 to 60 minutes per featureHigh for production reliability

What to look for when reviewing AI generated code

  • Does the generated function match the signature and typing conventions of the rest of the codebase?
  • Are all external dependencies already present in the project, or did the AI introduce something new?
  • Are the edge cases handled, or does the code only work for the happy path the prompt described?
  • Is there any logic that the reviewer cannot explain? That is a signal to understand before merging.
  • Does the generated code duplicate something that already exists in the codebase?
  • Are there any hardcoded values that should be configuration?
  • Does it handle errors, or does it assume everything succeeds?

Expert opinion

The engineers I have worked with who get the most out of AI coding tools are the ones who write the best specs. That is not a coincidence. The discipline of specifying precisely what you want is the same discipline whether you are writing for a human engineer or a language model. The tool did not create that discipline, it just made the quality of the specification more visible in the output.

>

Yashveer Singh, founder of Yashveer Labs

How this played out on a real project

A team I worked with was building a document processing pipeline. They had been using an AI coding assistant for three months and were frustrated that the output quality varied so much between engineers on the team. One engineer's PRs from the AI were clean and merged quickly. Another's consistently required significant rework. The difference was not the tool. The first engineer was writing two hundred word prompt specs that described the pattern to follow and the edge cases to handle. The second was writing one sentence prompts and iterating.

We ran a half day workshop where the whole team wrote prompt specs together for a new feature, following the discipline of the first engineer. The output from the workshop prompts required about forty percent less review time than the team's average for AI generated PRs. The team adopted a simple template for prompt specs, stored them in the repo, and made it part of their PR process. Within a month the variance across engineers had dropped noticeably. For the related question of what happens when teams skip this discipline and inherit a vibe-coded codebase, see vibe coding rescue. For the code review side, AI assisted code review covers how to structure the review pass on top of the generation step.

Common mistakes

  1. Writing a one sentence prompt and iterating through confusion instead of writing the spec first.
  2. Treating the first AI output that compiles as done. It is a first draft.
  3. Letting the AI introduce dependencies without checking whether they are already in the project or whether a simpler alternative exists in the existing stack.
  4. Not storing the prompt alongside the generated code, which leaves future engineers with no record of why something was built the way it was.
  5. Generating the same type of function multiple times without creating a prompt template, which produces inconsistent implementations across the codebase.
  6. Using AI to generate security sensitive code without a detailed review from someone who understands the threat model.
  7. Generating a large feature in one prompt instead of breaking it into units that can each be reviewed independently.
  8. Assuming the AI knows the edge cases in your data. It knows general programming patterns. It does not know your users.

A 30 day plan

  1. Week one. Pick one current feature in development. Write a full prompt spec before generating any code. Compare the output to a feature you built without a spec. Note the difference in review time.
  2. Week two. Create a prompt spec template for the two or three most common code patterns in your stack. Store them in the repo.
  3. Week three. Add prompt storage to your PR process. Any PR that includes substantial AI generated code should link to the prompt spec.
  4. Week four. Audit one month of AI generated PRs. Identify which ones required the most rework. Read the prompts that produced them. The pattern is usually a missing constraint or a missing edge case in the spec.

For more on building responsibly with AI tools, see why AI generated code breaks in production and the top five architectural failures in AI assisted codebases.

FAQ

Frequently asked

Author

A note from Yashveer Singh

This was written by me, Yashveer Singh. The reason I write at this length and this depth is that the alternative is generic SEO content, and I am not interested in being one more of those. If you found this post useful, that is by design. If you want to talk about the project you are facing, the work happens through one channel: send a message via Instagram, and I will get back to you with a real answer, not a templated reply.

Related reading