P11: Planning Agent Workflow (Structured Development)
P11: Planning Agent Workflow (Structured Development)
type: project id: P11 title: Planning Agent Workflow track: Kiro CLI Mastery difficulty: Intermediate time_estimate: 1 week prerequisites: [P01, P02, P03, P04, P05] knowledge_areas: [Planning Agents, Spec-Driven Development, Requirements Engineering] tools: [Kiro CLI] main_book: โThe Pragmatic Programmer by Hunt & Thomasโ โ
Learning Objectives
By completing this project, you will:
- Understand the separation of planning and execution in AI-assisted development workflows
- Master the
/plancommand and its interactive questioning flow for requirements gathering - Learn to review, modify, and approve AI-generated implementation plans before any code changes
- Develop intuition for when to use planning mode versus direct execution
- Build habits that reduce rework by thinking before coding
Deep Theoretical Foundation
The Problem with โJust Start Codingโ
In traditional development, we often jump directly into code. With AI assistants, this tendency is amplified - we prompt, the AI writes code, we accept. But this leads to:
- Misaligned implementations - The AI solved a different problem than intended
- Wasted context - Tokens spent on incorrect solutions
- Rework cycles - Delete, re-prompt, repeat
- Hidden assumptions - Neither human nor AI explicitly stated requirements
Spec-Driven Development: The Paradigm Shift
Spec-driven development (SDD) is one of 2025โs key new AI-assisted engineering practices. The core insight:
Instead of coding first and writing docs later, you start with a spec - a contract for how your code should behave that becomes the source of truth.
Traditional Flow:
โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ
โ Prompt โ โโโบ โ Code โ โโโบ โ Fix โ โโโ
โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ โ
โ โ
โโโโโโโโโโ
(repeat)
Spec-Driven Flow:
โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ
โ Gather โ โโโบ โ Plan โ โโโบ โ Approve โ โโโบ โ Execute โ
โ Reqs โ โ โ โ โ โ โ
โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ
โ โ โ
โผ โผ โผ
[Questions] [Tasks] [Review]
answered generated complete
The Planning Agent Architecture
Kiro CLI separates โthinkingโ from โdoingโ through distinct agent modes:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ KIRO CLI โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โ
โ โ PLANNING AGENT โ โ EXECUTION AGENT โ โ
โ โ โ โ โ โ
โ โ โข Read-only โ โโโโบ โ โข Write access โ โ
โ โ โข Questions โ plan โ โข Implements โ โ
โ โ โข Research โ handoff โ โข Tests โ โ
โ โ โข Plan tasks โ โ โข Iterates โ โ
โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โ
โ โฒ โ
โ โ Shift+Tab or /plan โ
โ โ โ
โ โโโโโโโโโดโโโโโโโโ โ
โ โ Normal Mode โ (default execution) โ
โ โโโโโโโโโโโโโโโโโ โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Why Separation Matters
The planning agent has a fundamentally different purpose:
| Aspect | Planning Agent | Execution Agent |
|---|---|---|
| File Access | Read-only | Read-write |
| Goal | Understand, clarify | Implement, test |
| Output | Task list | Code changes |
| Risk | Zero (no modifications) | Changes files |
| Interactivity | High (questions) | Lower (doing) |
Real-World Analogy: The Architect and Builder
Consider building a house:
- Without planning: You show up with materials and start building. Halfway through, you realize the bathroom is in the wrong place.
- With planning: An architect creates blueprints. You review them. Only then does construction begin.
The planning agent is your architect. It asks questions, considers the existing structure (codebase), and produces blueprints (task list) before any construction begins.
Historical Context: From Waterfall to Agile to AI-Assisted
1970s Waterfall: Requirements โโโบ Design โโโบ Code โโโบ Test
(months of documentation before coding)
2000s Agile: Sprint [Requirements + Design + Code + Test]
(faster iteration, less upfront planning)
2025 AI-Assisted: Plan Mode โโโบ Approved Tasks โโโบ AI Execution
(structured thinking, rapid implementation)
AI-assisted development brings back structured planning but at a different timescale - minutes instead of months, with the AI handling both planning and execution.
Book Reference
โThe Pragmatic Programmerโ by Hunt & Thomas emphasizes โTracer Bulletsโ and โPrototypesโ - methods to validate understanding before full implementation. The planning agent is the AI-era equivalent: validate the approach before committing to execution.
Complete Project Specification
What Youโre Building
A comprehensive spec-driven development workflow using Kiroโs Planning Agent that:
- Enters plan mode via
/plancommand or Shift+Tab shortcut - Gathers requirements through interactive questioning
- Researches the codebase to understand existing patterns
- Generates a structured implementation plan with clear tasks
- Supports plan modification before approval
- Hands off to execution only after explicit approval
Expected Behavior
$ kiro-cli chat
> /plan
[Planning Agent] Entering plan mode. I will:
1. Gather requirements through questions
2. Research the codebase for context
3. Generate an implementation plan
4. Wait for your approval before executing
What would you like to build?
> "Add user authentication with OAuth2"
[Planning Agent] I have questions to clarify your requirements:
1. Authentication Provider(s):
โ Google only
โ Google + GitHub [Recommended for dev audiences]
โ Custom list (specify)
2. Session Management:
โ JWT tokens (stateless)
โ Server-side sessions
โ Let me decide based on codebase
3. New Users:
โ Auto-create on first login
โ Require pre-registration
โ Admin approval workflow
[Select options or type responses]
> 1:Google+GitHub, 2:JWT, 3:Auto-create
[Planning Agent] Researching codebase...
โโโ Found: src/routes/auth.ts (existing auth)
โโโ Found: src/middleware/requireAuth.ts
โโโ Found: prisma/schema.prisma (User model)
โโโ Analyzing patterns...
IMPLEMENTATION PLAN:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Phase 1: Dependencies and Configuration โ
โ Task 1.1: Install OAuth libraries โ
โ Task 1.2: Add environment variables for OAuth secrets โ
โ Task 1.3: Update .env.example with new variables โ
โ โ
โ Phase 2: Database Changes โ
โ Task 2.1: Add OAuth fields to User model โ
โ Task 2.2: Create migration โ
โ Task 2.3: Update Prisma client โ
โ โ
โ Phase 3: OAuth Routes โ
โ Task 3.1: Create /auth/google routes โ
โ Task 3.2: Create /auth/github routes โ
โ Task 3.3: Implement callback handlers โ
โ โ
โ Phase 4: JWT Integration โ
โ Task 4.1: Create JWT utility functions โ
โ Task 4.2: Update auth middleware โ
โ Task 4.3: Add refresh token logic โ
โ โ
โ Phase 5: Frontend (if applicable) โ
โ Task 5.1: Add OAuth login buttons โ
โ Task 5.2: Handle redirect callbacks โ
โ โ
โ Estimated: 12 files modified, 3 new files โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Options:
[y] Approve and execute
[n] Cancel
[m] Modify plan
[?] Ask questions about the plan
Solution Architecture
Component Overview
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ PLANNING WORKFLOW โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ User Input โ
โ โ โ
โ โผ โ
โ โโโโโโโโโโโโโโโโ โ
โ โ /plan Entry โ Shift+Tab shortcut โ
โ โโโโโโโโฌโโโโโโโโ โ
โ โ โ
โ โผ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ REQUIREMENTS GATHERING โ โ
โ โ โ โ
โ โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โ โ
โ โ โ Question โโโโโบโ Answer โ โ โ
โ โ โ Generator โ โ Collector โ โ โ
โ โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โ โ
โ โ โ โ โ โ
โ โ โโโโโโโโโโฌโโโโโโโโโโ โ โ
โ โ โผ โ โ
โ โ โโโโโโโโโโโโโโโโโโโ โ โ
โ โ โ Requirements โ โ โ
โ โ โ Document โ โ โ
โ โ โโโโโโโโโโโโโโโโโโโ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โผ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ CODEBASE RESEARCH โ โ
โ โ โ โ
โ โ โข File discovery (related code) โ โ
โ โ โข Pattern extraction (coding style) โ โ
โ โ โข Dependency analysis โ โ
โ โ โข Test coverage check โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โผ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ PLAN GENERATION โ โ
โ โ โ โ
โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ
โ โ โ Task List (ordered, with dependencies) โ โ โ
โ โ โ โโโ Phase 1: Foundation โ โ โ
โ โ โ โ โโโ Task 1.1: ... โ โ โ
โ โ โ โ โโโ Task 1.2: ... โ โ โ
โ โ โ โโโ Phase 2: Core โ โ โ
โ โ โ โ โโโ Task 2.1: ... โ โ โ
โ โ โ โโโ Phase 3: Polish โ โ โ
โ โ โ โโโ Task 3.1: ... โ โ โ
โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โผ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ APPROVAL WORKFLOW โ โ
โ โ โ โ
โ โ [Approve] [Modify] [Cancel] [Ask Questions] โ โ
โ โ โ โ โ โ โ โ
โ โ โผ โผ โผ โผ โ โ
โ โ Execute Edit Plan Exit Clarify โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Data Flow
User Request
โ
โผ
โโโโโโโโโโโโโโโโโโโ
โ Parse Intent โ โโโบ What is the user trying to build?
โโโโโโโโโโฌโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโ
โ Generate Qs โ โโโบ What clarifications are needed?
โโโโโโโโโโฌโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโ
โ Collect Answers โ โโโ User provides selections/answers
โโโโโโโโโโฌโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโ
โ Search Codebase โ โโโบ Find related files, patterns
โโโโโโโโโโฌโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโ
โ Generate Plan โ โโโบ Create phased task list
โโโโโโโโโโฌโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโ
โ Present Plan โ โโโบ Show to user for review
โโโโโโโโโโฌโโโโโโโโโ
โ
โโโโโโดโโโโโ
โ โ
Approve Modify
โ โ
โผ โผ
Execute Edit & Re-present
Key Interfaces
| Interface | Purpose | Example |
|---|---|---|
/plan |
Enter planning mode | /plan or Shift+Tab |
| Question UI | Gather requirements | Multi-select, text input |
| Plan Display | Show generated tasks | Boxed task list |
| Approval | Confirm execution | y/n/m/? options |
| Task Format | Structured output | Phase > Task > Details |
Technology Choices
- Kiro CLI chat mode: Primary interface
- Planning Agent: Built into Kiro, activated via
/plan - Task storage: Internal state (or JSON for persistence)
- Codebase access: Read-only during planning
Phased Implementation Guide
Phase 1: Foundation - Understanding Plan Mode
Goal: Learn to enter and use planning mode effectively.
Step 1.1: Activate Planning Mode
# Start Kiro CLI
$ kiro-cli chat
# Enter plan mode (two methods)
> /plan
# OR press Shift+Tab
Hint: The Planning Agent announces itself with โEntering plan modeโ and explains what it will do.
Step 1.2: Practice with a Simple Request
Start with something small:
> /plan
> "Add a health check endpoint that returns server status"
Observe:
- What questions does it ask?
- What files does it research?
- How is the plan structured?
Hint: The Planning Agent is read-only. It cannot modify files - thatโs the key safety feature.
Step 1.3: Understand the Question Types
The Planning Agent asks different types of questions:
Single Choice: โ Option A
โ Option B [Selected]
โ Option C
Multiple Choice: [x] Feature 1
[x] Feature 2
[ ] Feature 3
Free Text: Enter database name: ___________
Confirmation: Proceed with detected pattern? (y/n)
Hint: Answer concisely. The agent uses your answers to refine the plan.
Phase 2: Core Functionality - Working with Plans
Goal: Master plan review, modification, and execution.
Step 2.1: Review Generated Plans
When a plan is generated, examine:
IMPLEMENTATION PLAN:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Phase 1: [Name] โ
โ Task 1.1: [Description] โ
โ Task 1.2: [Description] โ
โ โ
โ Phase 2: [Name] โ
โ ... โ
โ โ
โ Estimated: X files modified, Y new files โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Questions to ask yourself:
- Does this match my understanding?
- Are there missing steps?
- Is the order logical?
Hint: Use ? to ask questions about specific tasks before approving.
Step 2.2: Modify Plans Before Approval
If the plan isnโt quite right:
Options: [y] Approve [n] Cancel [m] Modify [?] Questions
> m
What would you like to change?
> "Add error logging to each task"
# OR
> "Skip the frontend tasks - I'll handle those manually"
# OR
> "Break Phase 2 into smaller steps"
The agent regenerates the plan with your modifications.
Hint: Modification is cheap. Itโs better to fix the plan than fix the code.
Step 2.3: Approve and Execute
When satisfied:
> y
[Planning Agent] Handing off to Execution Agent...
[Execution Agent] Executing Phase 1, Task 1.1...
Observe how tasks execute sequentially, following the plan.
Hint: The plan becomes a checklist. You can interrupt if something goes wrong.
Phase 3: Polish and Edge Cases
Goal: Handle complex scenarios and optimize your workflow.
Step 3.1: Multi-Feature Planning
For complex requests spanning multiple features:
> /plan
> "Refactor the payment module: add Stripe support, implement
subscription billing, and add webhook handling"
The agent should:
- Recognize multiple features
- Ask questions about each
- Create a phased plan addressing all features
Hint: Complex requests benefit most from planning. The agent breaks down complexity.
Step 3.2: Plan with Existing Context
If youโve been working in a codebase:
# Already in a Kiro session with context...
> /plan
> "Now add unit tests for the module we just built"
The Planning Agent uses existing conversation context.
Hint: Context carries over. The agent knows what youโve been working on.
Step 3.3: Handling Ambiguity
When your request is ambiguous:
> /plan
> "Make it faster"
[Planning Agent] I need more context:
1. What specifically needs optimization?
โ Database queries
โ API response times
โ Frontend rendering
โ Build process
2. What's the current performance baseline?
The agent asks clarifying questions rather than guessing.
Hint: Ambiguous prompts get questions, not assumptions. This is a feature.
Testing Strategy
Functional Testing
| Test Case | Expected Behavior |
|---|---|
Enter /plan |
Agent announces plan mode |
| Simple request | Questions generated |
| Answer questions | Codebase research begins |
| Plan generated | Phased task list displayed |
| Approve plan | Execution begins |
| Modify plan | Plan regenerated |
| Cancel plan | Returns to normal mode |
Quality Metrics
- Plan accuracy: Does execution match the plan?
- Question relevance: Are questions useful, not excessive?
- Task granularity: Are tasks appropriately sized?
- Context awareness: Does the plan respect existing code?
Validation Checklist
[ ] Can enter plan mode via /plan
[ ] Can enter plan mode via Shift+Tab
[ ] Questions are relevant to the request
[ ] Codebase research finds related files
[ ] Plan has clear phases and tasks
[ ] Can modify plan before approval
[ ] Can ask questions about the plan
[ ] Execution follows the approved plan
[ ] Can cancel at any point
Common Pitfalls & Debugging
Pitfall 1: Skipping Plan Mode for โSimpleโ Tasks
Problem: Developers bypass planning for tasks they think are simple, then discover complexity.
Solution: Default to planning. The cost is low (minutes), the benefit is high (avoid rework).
# Instead of:
> "Add a button"
# Use:
> /plan
> "Add a button that triggers the export workflow"
Pitfall 2: Over-Answering Questions
Problem: Providing more detail than asked, confusing the agent.
Solution: Answer only whatโs asked. The agent will ask follow-ups if needed.
# Bad:
> "Use JWT tokens and store them in localStorage with a 24-hour
expiration and also use refresh tokens with rotation and..."
# Good:
> "JWT tokens"
# (Agent will ask about storage, expiration, refresh separately)
Pitfall 3: Approving Without Reading
Problem: Rubber-stamping plans without review leads to unwanted changes.
Solution: Always read the plan. Use ? to ask about unfamiliar tasks.
> ?
> "What will Task 2.3 actually change?"
Debugging Tips
# If the plan seems off:
> m
> "Show me what files you found during research"
# If questions don't make sense:
> "I don't understand question 3. Can you rephrase?"
# If execution diverges from plan:
# (Check if codebase changed during planning)
> /plan
> "Re-analyze the current state"
Extensions & Challenges
Extension 1: Plan Templates
Create reusable plan templates for common tasks:
# Save a "New API Endpoint" template
# Reuse with: /plan --template api-endpoint
Extension 2: Plan Versioning
Track plan versions when modifying:
Plan v1: 5 phases, 12 tasks
โผ (modified)
Plan v2: 4 phases, 10 tasks
โผ (modified)
Plan v3: 4 phases, 11 tasks [APPROVED]
Extension 3: Team Plan Sharing
Export plans for team review:
> /plan export plan-oauth.md
# Share with team
> /plan import reviewed-plan-oauth.md
Challenge: Complex Refactoring
Use planning mode for a major refactoring task:
- Request a database migration with schema changes
- Navigate the extensive questioning
- Review a 20+ task plan
- Modify to add rollback steps
- Execute with checkpoints
Real-World Connections
How Professionals Use This
At AWS: The Kiro team used spec-driven development with planning agents to complete an 18-month project in 76 days with 6 developers.
At Large Enterprises: Planning agents are integrated into sprint planning - developers generate implementation plans during backlog refinement.
In Open Source: Maintainers use planning mode to understand contribution impact before approving PRs.
Industry Trends
- GitHub Spec-Kit: Open-source toolkit for spec-driven development
- JetBrains Junie: AI assistant with explicit planning phases
- Anthropic Claude: Plan mode and structured reasoning
Key Insight
โIn planning mode, youโre not asking the AI to start coding yet - youโre asking it to think first.โ - GitHub Engineering Blog
Self-Assessment Checklist
Conceptual Understanding
- Can you explain why separating planning from execution reduces errors?
- What makes the Planning Agent โread-onlyโ and why does that matter?
- How does spec-driven development differ from traditional workflows?
- When should you use plan mode versus direct execution?
Practical Skills
- Can you enter plan mode using both
/planand Shift+Tab? - Can you navigate multi-choice and free-text questions effectively?
- Can you modify a generated plan before approval?
- Can you use
?to ask clarifying questions about plan tasks?
Advanced Competency
- Can you use planning mode for complex, multi-feature requests?
- Can you leverage existing conversation context in planning?
- Can you recognize when a plan needs modification versus approval?
- Can you articulate the plan to a teammate for review?
Mastery Indicators
- You default to planning mode for non-trivial tasks
- You read and understand every task before approving
- You modify plans proactively rather than fixing code reactively
- You can explain your implementation approach before any code is written
- Your execution matches your plans with minimal divergence
Summary
The Planning Agent transforms AI-assisted development from reactive coding to proactive design. By separating โthinkingโ from โdoing,โ you:
- Catch misunderstandings before they become code
- Reduce rework and wasted context
- Build confidence in AI-generated implementations
- Create documentation as a byproduct of planning
Master this workflow, and youโll wonder how you ever coded without it.
Next Project: P12: Kiro Powers Creator - Package and share Kiro capabilities