AI has made writing code much faster. But it also made it easier to produce large amounts of code that don't necessarily solve the problem we were trying to address.
I think that most developers who use AI agents regularly have experienced something like this:
You describe a feature, the agent starts writing code and after a couple of minutes you have a working implementation. Everything looks good until you start reviewing it and realize that the agent misunderstood some requirements, introduced unnecessary abstractions or completely ignored the architecture of your project.
Then you spend another couple of prompts explaining what should have been done differently.
And sometimes the same thing happens again.
That's one of the reasons why I started using spec-driven development in my projects.
In this post, I'd like to explain how I approach it, how I've integrated it into my AI-assisted development workflow and why I think it can be beneficial for both individual developers and teams.
Imagine that you're working on a dashboard and you receive the following task:
Implement saved filters for the dashboard.
Sounds straightforward, right?
But there are already several things that aren't clear.
Should filters persist after a page refresh? Are they stored locally or on the backend? Can users save multiple configurations? What happens if they provide an empty name? Should the feature work across multiple devices?
And those are only the functional requirements.
What about architecture, existing components, API contracts, error handling or testing?
When working without a proper specification, developers have to make these decisions during implementation.
With AI agents, the problem becomes even more noticeable because they can make those assumptions and turn them into hundreds of lines of code before you get a chance to review everything.
In my experience, this is one of the biggest problems with AI-assisted development.
The agent can implement a technically correct solution to a problem that was never properly defined.
And that's exactly what I am trying avoid.
Before starting implementation, I want to have a document that describes what needs to be built, what is outside the scope of the task and how the result should be verified.
For non-trivial changes, my workflow looks like this:
Request → Specification → Critique → Implementation plan → Implementation → Verification
There are a couple of additional steps depending on the complexity of the task, but that's the general structure.
Before preparing a specification, I want the agent to inspect the existing codebase.
That includes the relevant components, project structure, existing tests, architectural rules and dependencies.
Otherwise, the specification itself can introduce incorrect assumptions.
For example, there's no reason to introduce another state management library if the project already has an established solution that covers the requirements.
The same applies to UI components, API communication and testing.
I keep specifications in docs/specs/, with one document for each meaningful feature or change.
The document contains information such as:
I think that non-goals are just as important as goals, especially when working with agents.
Without them, an agent can sometimes introduce additional functionality or unnecessary abstractions because it considers them useful.
But useful doesn't always mean required.
This is probably the most important part of the specification.
Let's go back to the dashboard filters example.
Instead of writing something like:
Filters should work correctly and persist between sessions.
I'd rather describe the expected behavior using something closer to BDD.
For example:
# Saved Dashboard Filters
## Goals
- Allow users to save and reuse filter configurations.
## Non-goals
- Sharing saved filters between users.
## Acceptance criteria
AC-1 [must]
Given a user has selected dashboard filters,
when they save the configuration with a valid name,
then it appears in their saved configurations.
AC-2 [must]
Given a user has saved a filter configuration,
when they reload the dashboard,
then the configuration remains available.
AC-3 [must]
Given a user enters an empty configuration name,
when they attempt to save it,
then a validation error is displayed
and no configuration is created.
## Verification
- Unit tests for validation and state logic.
- E2E tests for saving and restoring filters.
- Manual verification of relevant UI states.
This is a simplified example, of course.
The point is that we now have observable behavior that can be verified.
And we can use the same acceptance criteria during implementation, testing and code review.
One problem I noticed when working with AI is that simply asking an agent to review its own solution isn't always enough.
It can miss the same assumptions it made when preparing that solution.
That's why I've introduced dedicated reviewer agents into my workflow.
For example, spec-critic is responsible for reviewing the specification before implementation.
It looks for things such as missing requirements, ambiguous behavior, unclear acceptance criteria, hidden dependencies and possible scope creep.
If the specification is incomplete, it should be updated before proceeding.
For more complex tasks, I also use architecture-critic to challenge the implementation plan.
The important part is that reviewer agents are read-only.
Their responsibility is to report findings, not modify the implementation they are reviewing.
This separation gives me a more useful review process than asking the same agent to generate, review and approve its own work.
Of course, using a different agent doesn't guarantee that every issue will be detected. It simply introduces another opportunity to challenge decisions before they turn into code.
In my frontend starter, I decided to separate the AI development setup into three different parts.
Rules - persistent constraints
Rules define requirements that should be respected whenever the agent works with a particular part of the project.
For example:
I keep them under .cursor/rules/, separated into core, frontend, testing and tooling.
Skills - repeatable workflows
Skills describe how the agent should approach particular types of work.
For spec-driven development, the skill is responsible for guiding the process from inspecting the project and writing the specification to planning and verifying the implementation.
I also have separate skills for frontend design quality and acceptance verification.
The reason for separating them is that a rule saying "write a specification" doesn't actually explain how that specification should be prepared or reviewed.
Agents - independent reviewers
Finally, there are dedicated reviewer agents:
spec-critic - reviews the specification.architecture-critic - reviews implementation decisions.design-critic - reviews the rendered UI.qa-verifier - checks the implementation against acceptance criteria.They help me identify problems at different stages of development.
The overall workflow is slightly more complex than simply giving an agent a task, but it also gives me considerably more control over the result.
Another thing I find important is distinguishing between technical checks and actual acceptance verification.
Let's say the agent completes a feature and reports that:
That's great.
But does it mean the feature is correct?
Not necessarily.
Those checks don't automatically tell us whether the implementation meets every requirement from the specification.
A feature can pass its tests while still missing an empty state, handling permissions incorrectly or implementing behavior that wasn't requested.
That's why the final step of my workflow is independent acceptance verification.
The qa-verifier compares the actual implementation with the approved specification and creates an acceptance matrix.
For each criterion, it should provide evidence and report whether it passed, failed or couldn't be verified.
For UI-related tasks, I also want to verify the rendered result rather than relying exclusively on static code inspection.
And if a required check fails, the task shouldn't be marked as completed.
The implementing agent addresses the findings, and the verification process runs again.
There are a few benefits I've noticed when organizing development around specifications.
When requirements and constraints are clearly documented, there's less room for interpretation during implementation.
This doesn't mean that unexpected problems disappear, but it helps avoid repeated discussions about decisions that could have been made before writing code.
AI agents work with a more specific contract.
Instead of making architectural and product decisions independently, they can follow documented requirements and existing project standards.
That also makes it easier to identify when the implementation deviates from what was agreed.
Reviewers have a clear reference for the intended behavior.
Rather than trying to reconstruct the original requirements from a PR description or chat history, they can compare the implementation with the specification.
Specifications can also help when returning to a feature after several months.
They explain which decisions were made, what behavior was expected and which requirements were intentionally excluded.
Of course, this only works when the documents are maintained and updated as the implementation evolves.
I don't think spec-driven development should become a mandatory, complicated process for every single code change.
Fixing a typo or adjusting a simple CSS value shouldn't require a lengthy specification, multiple review agents and an implementation plan.
That would introduce unnecessary overhead.
I prefer using a lightweight approach for trivial changes and a more detailed process for features, architectural changes, integrations or anything that can significantly affect application behavior.
There are also a few things worth keeping in mind.
A specification can be wrong.
If the requirements are incorrect, the agent can implement them perfectly and still produce the wrong result. That's why reviewing the specification before coding is so important.
Documentation can become outdated.
If implementation reveals a new requirement or an architectural constraint, the specification needs to be updated. Otherwise, it stops being a reliable reference.
More documentation doesn't necessarily mean better documentation.
A short specification with clear acceptance criteria is usually more valuable than a lengthy document full of assumptions and unnecessary implementation details.
And finally, spec-driven development doesn't replace developers, QA or code reviews.
It gives them a common reference for making and verifying decisions.
I think AI-assisted development is becoming less about how quickly we can generate code and more about how well we can define and verify what needs to be built.
Writing code is only one part of software development.
Understanding the problem, defining requirements, choosing the right architecture and making sure the final result actually works are just as important.
That's why I prefer spending a little more time preparing and reviewing a specification before starting implementation.
It doesn't guarantee that everything will work perfectly, but it makes the development process much more predictable and gives me better control over the code that ends up in the project.
If you'd like to see how I've organized the rules, skills and reviewer agents, the setup is available in my frontend template repository.