DEV Community

Cover image for Getting Started with Spec-driven Development Using Kiro
Faye Ellis for AWS Heroes

Posted on

Getting Started with Spec-driven Development Using Kiro

Curious to learn how Kiro could be your development partner for spec-driven development? Here's my simple tutorial to help you get started.

Creating a Simple Voting API

What You’ll Build

A simple REST API where users can:

  • Create a poll with options
  • Vote on a poll
  • View poll results

Pre-requisites

Download and install the Kiro IDE for your operating system

Create a Project Folder and Start Developing!

1) Create a folder in your local file system named Kiro_Voting_API, this will be your project folder

2) Launch Kiro, select File, Open Folder, and open the folder you just created

Launch Kiro, select File and open the folder

3) To begin a spec driven development session, select Spec from the options

Select Spec from the options

4) Enter a natural language prompt into the chat window, here's what I used:

Build a simple poll and voting REST API using Python and FastAPI

Requirements:

- A poll has: id, question, options, votes
- Options are strings
- Votes are counted per option
- Endpoints:
  - POST /polls to create a poll
  - GET /polls/{id} to retrieve a poll and its results
  - POST /polls/{id}/vote to vote for an option
- Store all data in memory
- Return JSON responses
Enter fullscreen mode Exit fullscreen mode

5) Wait for Kiro to create a requirements document based on your prompt, it will create a document containing requirements, user stories and acceptance criteria:

Kiro creates a requirements document

6) To refine the requirements, enter any additional requirements into the chat window to tell Kiro to add whatever you think is missing. Here's what I added:

Add support for displaying poll results as a percentage

Poll results must be calculated as a percentage as well as displaying the raw numbers of votes
Enter fullscreen mode Exit fullscreen mode

7) After that, if the requirements look good to you, click Move to design phase

If the requirements look good move to design phase

8) Kiro will create a design based on the agreed requirements, click on the generated design.md file to view the design document.

Note that Kiro includes error handling and a testing strategy. In practice I found that this added a lot of time and iteration to my implementation steps, as it was validating changes and asking for permission to run tests throughout implementation.

You may prefer reduce the amount of testing and error handling to quickly see something in action, then work on adding the appropriate tests afterwards. It's up to you because you can refine the requirements and design to fit your needs as you go!

View the design document

9) After reviewing the design you can ask Kiro to make any modifications that you like, then when you're ready, click Move to implementation plan. After that, Kiro creates an implementation plan based on the agreed requirements and design.

The Implementation plan is ready and we can now start implementing the feature

10) Kiro has created an implementation plan and created a file named tasks.md. Open this file to view the contents and begin the implementation. You can open it by clicking Task list at the top of the screen, or tasks.md from the folder view on the left.

Open tasks.md to view the implementation plan<br>

11) To begin implementing your feature, click Start task above the first task in your implementation plan. If you allow it to, Kiro will set up everything needed to run your code and begin testing it. Be sure to understand everything that it is doing and ensure you are happy before allowing it!

Kiro can help you implement the feature you just designed<br>

Before installing dependencies, it asks you for permission. Be sure to review the contents of requirements.txt and only click Run to allow it if you are happy to install the dependencies.

Kiro asks permission before installing dependencies, be sure to review them and understand them before allowing it!

12) After that, work through the rest of the steps in the implementation plan. As you go, Kiro will periodically ask for permission to perform tests at each stage to ensure the code runs as expected.

Running tests at each stage to ensure everything is working

13) I ended up aborting the step to add error handling and response formatting during the initial implementation, since I wanted to check the API's basic functionality myself before adding this.

I aborted the addition of error handling at this stage, preferring to add error handling after running my own tests

14) After all the implementation tasks have been completed. Open the README.md file to see the steps to run your API. If anything doesn't make sense, or doesn't work as expected, you can chat with Kiro to ask for help with troubleshooting or interacting with your API.

README.md explains how to use the API

15) From the terminal window in Kiro, making sure I am in the folder where main.py exists, I'll run the application in the background, using the following command, (check the details of your own README file to see how to start your app):

python main.py &
Enter fullscreen mode Exit fullscreen mode

The application starts and runs on localhost

16) In the terminal, hit the enter key to get your cursor back, so you can run the next command in the same terminal window.

Next I'll test that the API is running:

curl http://localhost:8000/
Enter fullscreen mode Exit fullscreen mode

The API is listening on localhost

17) Finally I can try interacting with my API :

Using my API to create a poll

My poll ID is: 1f46ff20-88e0-4349-a31a-ce588c187b62 and I'll use it in the next command to cast a vote.

Casting a vote in my poll

I can also view the votes that have been cast.

Viewing the created poll and votes

Kiro Credits

The Kiro free-tier allows you 50 credits per month, with the most affordable pro-tier providing 1000 per month for $20/month. I can see how you could easily burn through a lot of credits just trying it out, as this entire exercise used up around 33 credits to tackle what I think is a very simple use-case.

Working in a Structured Way

Building this simple voting API was a fun way to understand how Kiro’s spec-driven workflow actually feels in practice. Rather than jumping straight into writing code, Kiro encouraged me to slow down and think about requirements, design, and implementation as distinct steps, and then guided me through each phase in a structured way!

Other Practical Use-cases

A lot of my work involves creating CloudFormation templates, simple Python scripts, IAM policies and other AWS-related code, so having explored the spec-driven workflow I can imagine lots of ways that Kiro can help increase productivity when working with AWS APIs and SDKs. I can't wait to try it out for some of these use cases!

If you try out this exercise or similar for yourself, please let me know what you think!

Top comments (0)