Getting Started with Spec-driven Development Using Kiro

Getting Started with Spec-driven Development Using Kiro

Source: Dev.to

Creating a Simple Voting API ## What You’ll Build ## Pre-requisites ## Create a Project Folder and Start Developing! ## Kiro Credits ## Working in a Structured Way ## Other Practical Use-cases Curious to learn how Kiro could be your development partner for spec-driven development? Here's my simple tutorial to help you get started. A simple REST API where users can: Download and install the Kiro IDE for your operating system 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 3) To begin a spec driven development session, select Spec from the options 4) Enter a natural language prompt into the chat window, here's what I used: 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: 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: 7) After that, if the requirements look good to you, click 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! 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. 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. 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! 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. 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. 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. 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. 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): 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: 17) Finally I can try interacting with my API : My poll ID is: 1f46ff20-88e0-4349-a31a-ce588c187b62 and I'll use it in the next command to cast a vote. I can also view the votes that have been cast. 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. 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! 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! Templates let you quickly answer FAQs or store snippets for re-use. Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink. Hide child comments as well For further actions, you may consider blocking this person and/or reporting abuse CODE_BLOCK: 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 CODE_BLOCK: 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 CODE_BLOCK: 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 CODE_BLOCK: 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 CODE_BLOCK: 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 CODE_BLOCK: 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 CODE_BLOCK: python main.py & Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: python main.py & CODE_BLOCK: python main.py & COMMAND_BLOCK: curl http://localhost:8000/ Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: curl http://localhost:8000/ COMMAND_BLOCK: curl http://localhost:8000/ - Create a poll with options - Vote on a poll - View poll results