Simple Spec Driven Development
Learn how basic spec prompts help humans and AI’s collaborate to write better code, faster
Prerequisites
Overview
This training will teach you how to use spec-driven development to write code. We will:
Create a hand-written spec file
Run the
specprompt on itReview the spec, answer its questions, make suggestions
Once we are satisfied with the result, we will start a new context and run the
spec-checkpromptOnce satisfied with the
spec-checkand the implementation, we will instruct the AI to start implementing the spec in a phased approachAt each phase, we will check things out and make sure it looks right
Create a spec file
Create a folder for your specs. Example:
/spec.Create a spec file with the number of your ticket and a brief description. Example:
/spec/221-my-basic-feature.mdHandwrite a spec file with as much detail as you can about what the feature is and how you might accomplish it
For https://bitovi.atlassian.com/browse/FOO-221 I'm build the allow editing button of https://www.figma.com/design/yRyWXdNtJ8KwS1GVqRBL1O/branch/KxgPt0v1fI8ZxJYxR9Wnfe/User-onboarding-designs?node-id=246-10957&t=VNwbTaCK9jG0XAhV-0 It allows editing, by setting the `process_status` to "editing" (LOOKUP) We will need to make an `allowEditing` in packages/fe/src/api/fetchApplicationRecords.ts that will do a PATCH to application records with `process_status=updating` We will need the application mock handler ( packages/fe/src/api/mocks/handlers/applications.ts ) to set `process_status` to `updating`. When the process_status is updating the application details page will need to change to the read-only version.
The hand written spec file should detail the technical changes that need to be made. How would you implement this? What things need to be considered?
Tips:
Make sure you have Atlassian and/or Figma’s MCP servers configured and started.
Add the paths to files or folders where things will need to change.
Don’t worry too much about formatting. The AI will clean it up. Chain-of-thought is ok, but make sure the thoughts are clear.
If you have other prompts the implementation should be aware of (example: generators), add the paths to those prompts.
Copilot instructions can help. It's good to have it in place.
Run the spec prompt
Add https://github.com/bitovi/ai-enablement-prompts/blob/main/writing-code/specs/spec.prompt.md to
.github/prompts/spec.prompt.mdCreate a new context.
Make sure you have your spec file open and focused in VSCode
Type
/specin your agent and hit enter
This will generate your spec.
Review and Improve the Spec
Depending on the complexity, the generated spec might be between 100s to over 1000 lines long. There might be a lot to review and big changes to make.
To review it and improve it, we suggest the following pattern:
Do a quick review / spot check. Scan the spec, does it look right? Did it get concepts right?
If you see anything large, tell the agent what it got wrong and have it update the spec accordingly.
Scroll to the bottom and look at the questions. Answer all of the questions inline. After completing the questions, tell the prompt:
I have answered your questions. Please review my questions and incorporate into the spec. If you have additional questions, please include them in a `## Questions` section at the bottom of the page.Once questions have been answered, now do a thorough, top-to-bottom review. When the spec gets things wrong, prompt the AI to make improvements.
Once the prompt feels right, go to the next step.
Agent checks the spec
Before implementing, it’s useful to have the AI do one additional review.
Add https://github.com/bitovi/ai-enablement-prompts/blob/main/writing-code/specs/spec-check.prompt.md to
/.github/prompts/spec-check.mdStart a new context
Make sure to open your spec.
Run
/spec-check.md
If the agent reports or finds serious problems with the spec, address them as we did in the “Review and Improve the Spec” section. If large changes are needed, you might want to run /spec-check multiple times.
Once you and the AI are happy with the spec, it’s time to implement it.
Implement the spec
Tell the AI to start implementing the spec. Here’s a prompt that will make it run with todos:
Please implement this spec. Create a todo list for each phase and/or step of the implementation plan.
After each step, pause and let me check the results before continuing.
At the end please verify everything works by re-running the build, tests and linting.