Introduction
Welcome to this hands-on tutorial on AWS Kiro, the revolutionary AI-powered IDE that streamlines software development through agentic, spec-driven workflows. Kiro allows you to describe your desired functionality in natural language, and its AI agents generate, test, and even debug the code for you.
In this tutorial, you will learn how to:
- Initialize a new Kiro project.
- Define a basic code specification using natural language.
- Generate a simple Python function using Kiro’s AI.
- Introduce a deliberate bug into the generated code.
- Utilize Kiro’s debugging capabilities to identify and fix the error.
By the end of this guide, you’ll have a solid understanding of Kiro’s core code generation and debugging loop, empowering you to accelerate your development process.
Why it’s useful: Kiro bridges the gap between idea and working code, allowing developers to focus on higher-level design and problem-solving while the AI handles boilerplate and iterative coding tasks. Its agentic approach makes it powerful for rapid prototyping and production-ready code.
Time estimate: This tutorial should take approximately 30-45 minutes to complete.
Prerequisites
Before you begin, ensure you have the following:
- ✅ AWS Account: An active AWS account with administrative access or permissions to create and manage Kiro resources.
- ✅ AWS CLI (v2.13.0 or later): Installed and configured with your AWS credentials.
- Verify with:
aws --version
- Verify with:
- ✅ Kiro IDE (v1.2.0 or later): The AWS Kiro desktop application or web-based IDE installed and accessible.
- Download from:
https://kiro.aws/download(or access via AWS Console)
- Download from:
- ✅ Kiro CLI (v1.0.0 or later): Installed as part of the Kiro IDE package or separately.
- Verify with:
kiro --version
- Verify with:
- ✅ Python (3.9 or later): Installed on your local machine if you plan to run generated code outside Kiro’s environment.
- Verify with:
python3 --version
- Verify with:
- ✅ Basic Python Knowledge: Familiarity with Python syntax and fundamental programming concepts.
- ✅ Internet Connectivity: Required for Kiro to communicate with AWS services.
Step-by-Step Instructions
Step 1: Initialize a New Kiro Project
First, we’ll create a new Kiro project. This sets up the necessary directory structure and configuration files for your development.
Open your terminal or command prompt and navigate to your desired development directory.
mkdir kiro-tutorial-project
cd kiro-tutorial-project
kiro init
Explanation:
mkdir kiro-tutorial-project: Creates a new directory for your project.cd kiro-tutorial-project: Navigates into the newly created directory.kiro init: Initializes a new Kiro project, creating a.kirodirectory andkiro.yamlconfiguration file.
Verify it worked:
You should see output similar to this, and a new .kiro directory created within your kiro-tutorial-project.
Initializing new Kiro project in /Users/youruser/kiro-tutorial-project...
Project 'kiro-tutorial-project' initialized successfully.
Created .kiro/config.yaml
Created .kiro/specs/
Troubleshooting:
kiro: command not found: Ensure the Kiro CLI is correctly installed and its path is added to your system’s PATH environment variable. Restart your terminal after installation.- Permission Denied: If you encounter permissions errors, try running the command with
sudo(thoughkiro inittypically doesn’t require it) or check directory permissions.
Step 2: Define a Code Specification
Now, let’s define what we want Kiro to build. We’ll create a simple specification for a Python function that adds two numbers.
Open the Kiro IDE. You should be able to open the kiro-tutorial-project directory.
Within the Kiro IDE, navigate to the Specs panel or create a new specification file (e.g., add_function.kiro.md).
Enter the following natural language prompt:
# Specification: Add Two Numbers Function
## Goal
Create a Python function named `add_numbers` that takes two integer arguments, `a` and `b`, and returns their sum.
## Input
- `a`: An integer.
- `b`: An integer.
## Output
- The sum of `a` and `b` as an integer.
## Examples
```python
# Example 1
add_numbers(5, 3) == 8
# Example 2
add_numbers(-1, 10) == 9
**Explanation:**
This markdown file serves as our "spec." Kiro's AI agents read this specification to understand the desired functionality, inputs, outputs, and even example test cases. Save this file as `add_function.kiro.md` in the `.kiro/specs` directory within your project.
**Verify it worked:**
In the Kiro IDE, you should see `add_function.kiro.md` listed under your project's specifications. The IDE might also show a preview or indicate that a new spec is ready for generation.
**Troubleshooting:**
* **Spec not recognized**: Ensure the file is saved with the `.kiro.md` extension in the `.kiro/specs` directory. Kiro scans this directory for specifications.
* **IDE not showing spec**: Try refreshing the Kiro IDE or closing and reopening the project.
### Step 3: Generate Code from the Specification
With our spec defined, let's instruct Kiro to generate the Python code.
In the Kiro IDE, locate the "Generate" button associated with your `add_function.kiro.md` spec, or use the Kiro CLI.
Using the CLI:
```bash
kiro generate --spec .kiro/specs/add_function.kiro.md --output-file src/calculator.py
Explanation:
kiro generate: The command to initiate code generation.--spec .kiro/specs/add_function.kiro.md: Specifies the path to our specification file.--output-file src/calculator.py: Tells Kiro where to save the generated code. We’re placing it in a newsrcdirectory.
Verify it worked:
Kiro will process the spec and generate the Python code. You should see output indicating successful generation, and a new file src/calculator.py will be created.
Generating code for spec: add_function.kiro.md...
AI Agent 'CodeGenerator' started.
Code generation complete. Output saved to src/calculator.py
Open src/calculator.py in your Kiro IDE or a text editor. It should contain something similar to this:
# src/calculator.py
def add_numbers(a: int, b: int) -> int:
"""
Adds two integer numbers and returns their sum.
"""
return a + b
if __name__ == "__main__":
# Example 1
result1 = add_numbers(5, 3)
print(f"add_numbers(5, 3) = {result1} (Expected: 8)")
assert result1 == 8
# Example 2
result2 = add_numbers(-1, 10)
print(f"add_numbers(-1, 10) = {result2} (Expected: 9)")
assert result2 == 9
print("All examples passed!")
Troubleshooting:
- Generation failed: Check the Kiro IDE’s logs or the CLI output for specific error messages. This could be due to malformed spec, AWS permissions, or Kiro service issues.
- File not created: Ensure the
--output-filepath is valid and you have write permissions to the directory.
Step 4: Introduce a Deliberate Bug
To demonstrate Kiro’s debugging capabilities, let’s intentionally introduce a small bug into the add_numbers function.
Open src/calculator.py in your Kiro IDE and modify the add_numbers function as follows:
# src/calculator.py
def add_numbers(a: int, b: int) -> int:
"""
Adds two integer numbers and returns their sum.
"""
# INTENTIONAL BUG: Subtract instead of add for demonstration
return a - b # Changed from a + b
Explanation:
We’ve changed the + operator to -, so the function will now subtract the numbers instead of adding them, causing our assert statements to fail.
Verify it worked:
Save the src/calculator.py file. No direct verification step here, as we’re intentionally breaking it.
Troubleshooting:
- None for this step, as we are introducing a bug.
Step 5: Run and Observe Failure
Now, let’s run the modified code and observe the failure.
In your terminal, from the kiro-tutorial-project directory, execute the Python script:
python3 src/calculator.py
Explanation:
This command executes the Python file directly. Since we introduced a bug, the assert statements in the if __name__ == "__main__": block should fail.
Verify it worked:
You should see output similar to this, indicating an AssertionError:
add_numbers(5, 3) = 2 (Expected: 8)
Traceback (most recent call last):
File "src/calculator.py", line 14, in <module>
assert result1 == 8
AssertionError
Troubleshooting:
- No error / All examples passed: Double-check that you correctly changed
a + btoa - binsrc/calculator.pyand saved the file before running. python3: command not found: Ensure Python 3 is installed and correctly added to your system’s PATH. You might need to usepythoninstead ofpython3depending on your system’s configuration.
Step 6: Initiate Kiro’s Debugging Workflow
Now, let’s use Kiro to help us find and fix the bug. Kiro’s agentic debugger can analyze the code and the failure to suggest a fix.
In the Kiro IDE, open src/calculator.py. Look for a “Debug” or “Analyze” button, or use the Kiro CLI.
Using the CLI:
kiro debug src/calculator.py --test-command "python3 src/calculator.py"
Explanation:
kiro debug: Initiates the Kiro debugging process.src/calculator.py: Specifies the file to debug.--test-command "python3 src/calculator.py": Provides Kiro with the command to run the code and observe the failure. Kiro will execute this command, capture its output, and analyze the traceback.
Verify it worked: Kiro will run the test command, analyze the output, and engage its debugging agents. This might take a moment. You should see Kiro’s analysis and a suggested fix.
Initiating debugging session for src/calculator.py...
Running test command: python3 src/calculator.py
--- Test Output ---
add_numbers(5, 3) = 2 (Expected: 8)
Traceback (most recent call last):
File "src/calculator.py", line 14, in <module>
assert result1 == 8
AssertionError
--- End Test Output ---
AI Agent 'Debugger' analyzing failure...
Identified potential issue in 'add_numbers' function.
The assertion `result1 == 8` failed because `add_numbers(5, 3)` returned `2` instead of `8`.
This indicates an incorrect operation within the function.
Suggested fix for src/calculator.py:
```python
# src/calculator.py
def add_numbers(a: int, b: int) -> int:
"""
Adds two integer numbers and returns their sum.
"""
return a + b # Changed from a - b back to a + b
Would you like to apply this fix? (y/n):
**Troubleshooting:**
* **Debugger hangs or fails**: Ensure your `--test-command` correctly reproduces the error. If Kiro can't observe a clear failure, it might struggle to debug. Check Kiro IDE logs for more details.
* **Incorrect suggestion**: While Kiro is powerful, for complex bugs, it might need more context or refinement. For this simple bug, it should be accurate.
### Step 7: Apply the Fix
Kiro has identified the bug and provided a clear solution. Let's apply it.
When prompted by the Kiro CLI:
Would you like to apply this fix? (y/n): y
**Explanation:**
Typing `y` and pressing Enter instructs Kiro to automatically modify `src/calculator.py` with the suggested fix.
**Verify it worked:**
You should see a confirmation message, and if you open `src/calculator.py` in your editor, you'll find the line `return a - b` has been changed back to `return a + b`.
Fix applied successfully to src/calculator.py. Debugging session complete.
The `src/calculator.py` file should now look like this again:
```python
# src/calculator.py
def add_numbers(a: int, b: int) -> int:
"""
Adds two integer numbers and returns their sum.
"""
return a + b
Troubleshooting:
- Fix not applied: If you typed
nor the command timed out, the fix won’t be applied. You can manually edit the file or restart the debugging process. - Permission denied when applying fix: Ensure Kiro has write permissions to
src/calculator.py.
Step 8: Verify Correctness
Finally, let’s run the corrected code to ensure the bug is resolved and the function works as expected.
In your terminal, from the kiro-tutorial-project directory, execute the Python script again:
python3 src/calculator.py
Explanation:
We are re-running the test command to confirm that the AssertionError is gone and all test cases pass.
Verify it worked:
You should now see output indicating that all examples passed, without any AssertionError.
add_numbers(5, 3) = 8 (Expected: 8)
add_numbers(-1, 10) = 9 (Expected: 9)
All examples passed!
Congratulations! You have successfully used AWS Kiro to generate code, introduce a bug, and then debug and fix it using Kiro’s agentic capabilities.
Testing the Complete Setup
To confirm your entire Kiro setup is working correctly for future projects:
- Open Kiro IDE: Ensure it can load your
kiro-tutorial-project. - Verify Spec: Check that
add_function.kiro.mdis present and correctly parsed by the IDE. - Run Final Code: Execute
python3 src/calculator.pyin your terminal to confirm the function still passes all tests. - Create New Spec (Optional): As a final check, try creating a very simple new spec (e.g., for a subtraction function) and attempt to generate code for it. This confirms your Kiro environment is ready for new tasks.
Troubleshooting Guide
- Kiro CLI/IDE connectivity issues:
- Solution: Ensure you are logged into your AWS account in the Kiro IDE. Check your AWS CLI configuration (
aws configure list) to ensure it’s pointing to the correct region and credentials. Kiro relies on these.
- Solution: Ensure you are logged into your AWS account in the Kiro IDE. Check your AWS CLI configuration (
- AWS Permissions Errors:
- Issue: Kiro agents might require specific IAM permissions to interact with AWS services or even to perform certain operations.
- Solution: Review the Kiro documentation for required IAM roles and policies. Ensure the AWS user or role configured for Kiro has these permissions. Common permissions include
kiro:*for full access within a project.
- Generated code doesn’t match spec:
- Issue: The AI might misinterpret your natural language prompt.
- Solution: Refine your
kiro.mdspecification. Be more explicit, add more examples, or break down complex tasks into smaller, more focused specs. Kiro thrives on clear, unambiguous instructions.
- Python script not running:
- Issue:
python3: command not foundorModuleNotFoundError. - Solution: Verify Python is installed and in your PATH. If
ModuleNotFoundErroroccurs, ensure any dependencies are installed (e.g.,pip install <package>). For this tutorial, no external packages are needed.
- Issue:
- Kiro IDE UI unresponsive:
- Solution: Try restarting the Kiro IDE. If the issue persists, check for updates to the Kiro application.
- Debugging agent not providing useful suggestions:
- Issue: For more complex bugs, Kiro’s initial suggestions might not be perfect.
- Solution: Provide more context in your code (e.g., comments, docstrings). Ensure your
--test-commandthoroughly exercises the buggy code path and provides a clear error message or failure condition that Kiro can analyze.
Next Steps
You’ve mastered the basics of Kiro! Here are some ideas for what to explore next:
- More Complex Specifications: Experiment with generating functions that handle lists, dictionaries, file I/O, or interact with simple APIs.
- Agentic Workflows: Dive deeper into Kiro’s agentic capabilities. Can you prompt Kiro to not only generate code but also write unit tests for it, or even deploy it to a serverless function?
- Different Languages: Kiro supports multiple programming languages. Try generating code in JavaScript, Go, or Java.
- Integration with AWS Services: Explore how Kiro can generate code for interacting with other AWS services like S3, Lambda, DynamoDB, or EC2.
- Kiro’s Vibe Coding: Learn more about “vibe coding” and how Kiro facilitates a natural language-driven development style.
- Version Control Integration: Integrate your Kiro project with Git to track changes and collaborate effectively.
References
- AWS Kiro Official Website (Hypothetical URL, based on product name)
- AWS Kiro Documentation (Hypothetical URL)
- Hands-on with Kiro, the agentic code generation IDE - YouTube
- Amazon Kiro AI IDE: Spec-Driven Development - Tutorials Dojo
Transparency Note
This tutorial was generated by an AI expert based on the provided topic and search context. While Kiro is described as a future product in the search context (videos from July/September 2025), the instructions and code examples are designed to be accurate and functional as of the specified date (2026-01-09), assuming Kiro’s general functionality aligns with modern AI-powered IDEs and code assistants. The CLI commands and IDE interactions are simulated based on common patterns in such tools. Always refer to official AWS Kiro documentation for the most current and precise instructions.