How to run a software project with an AI agent β from PRD to production. Use this as a starting point for any project.
PRD / Idea
β
βΌ
Phase 0 β Discovery & Exploration
βββ Read existing docs, explore codebase
βββ Ask clarifying questions (what's missing, what's ambiguous)
βββ Check what exists vs what needs building
βββ Run any existing tools to study actual output/behavior
β
βΌ
Sprint Planning (docs/sprint-N/)
βββ plan.md β Sprint goal, scope, decisions, phasing
βββ tasks.md β Task breakdown + difficulty + dependencies + status
βββ final-report.md β Final sprint summary + handoff
βββ AGENTS.md β Delegation guide (for handing off to another LLM)
βββ resources/
βββ architecture.md β Tech stack decisions with pros/cons
βββ data-design.md β Data models, schemas, API contracts
βββ ux-flow.md β Screen designs, user journey (if UI)
βββ api-contract.md β REST/API endpoints, request/response shapes
β
βΌ
Phase 1 β Phase 2 β ... β Phase N
Each phase:
βββ 1. Build the code
βββ 2. Test it (run it, verify output)
βββ 3. Write a phase report (reports/phase-N-report.md)
βββ 4. Update tasks.md (mark completed + add findings)
βββ 5. Ask for commit confirmation
βββ 6. Commit + push
β
βββ (when a gnarly bug burns >2 debug cycles) β write an RCA
β docs/sprint-N/rca/YYYY-MM-DD-<slug>.md
β
βΌ
Retro / Ideas
βββ docs/ideas/future-enhancements.md β backlog for post-MVP
Goal: Understand the problem, the existing codebase, and what needs building.
Read the PRDβ understand the goal, components, dependencies** Explore existing code**β check what's already built, what's missing** Run existing tools**β clone repos, build binaries, test with real data** Ask clarifying questions**β identify gaps, ambiguities, and decisions to make** Study real output**β run scrapers/APIs to understand actual data shapes
- Are there existing repos that need to be cloned? Where?
- What tech stack? Is it decided or needs discussion?
- What's the monorepo structure?
- What's the deployment target? Local? Cloud?
- What data does the system produce/consume?
- What's the MVP scope vs future enhancements?
docs/sprint-N/reports/phase-0-report.md
Containing:
- Manual run instructions
- Test results with real data
- Data structure analysis
- Key findings (surprises, limitations)
- Decisions made
> Status: π‘ Planning | Created: YYYY-MM-DD
> Companion: [`tasks.md`](./tasks.md) Β· previous: [`../sprint-<N-1>/final-report.md`](../sprint-<N-1>/final-report.md) Β· root [`../../AGENTS.md`](../../AGENTS.md)
---
## Context
<What already exists, what the previous sprint delivered, what this sprint builds on.>
## 1. Sprint goal
<One sentence describing what this sprint delivers.>
## 2. Scope
**In scope:**
- ...
**Out of scope:**
- ...
## 3. Key decisions
| Decision | Rationale |
|----------|-----------|
## 4. Phasing
- **Phase 0 β Discovery:** ...
- **Phase 1 β ...:** ...
> Status: π‘ Planning | Created: YYYY-MM-DD
>
> Status legend: β¬ pending | π΅ in_progress | β
completed | β blocked
---
## Phase 1 β <Phase Name>
| ID | Task | Difficulty | Dependencies | Status |
|------|--------------------------------|------------|-------------|--------|
| 1.1 | <Task description> | Easy | β | β¬ |
| 1.2 | <Task description> | Medium | 1.1 | β¬ |
| 1.3 | <Task description> | Hard | 0.2, 1.2 | β¬ |
### Service Summary
- **Runtime:** <Python/Node/Go>
- **Files:** `src/a.py`, `src/b.py`
- **Key output:** <what was produced>
> π Full report: [`reports/phase-1-report.md`](./reports/phase-1-report.md)
---
## Dependency Graph
Phase 0 ββββββββββββββββββββββββββββββββββββββ 0.1 βββΊ 0.3 βββΊ 0.5 β 0.2 βββΊ 0.4 β β Phase 1 ββββββββββββββββββββββββββββββββββββββββ€ 0.2 βββΊ 1.1 βββΊ 1.2 βββΊ 1.5 β
## Summary
| Phase | Tasks | Est. Hours | Status |
|-------------|-------|-----------|--------|
| 0 β Setup | 6 | 1h | β¬ |
| 1 β Core | 5 | 4h | β¬ |
| **Total** | **11** | **5h** | |
Rules:
- Every task has an ID, difficulty (Easy/Medium/Hard), dependencies, and status
- Status emoji: β¬ π΅ β β
- Only one
in_progress
at a time - Mark completed when tested AND working
- Add a dependency graph showing the order
- After each phase completes, add a "Service Summary" with key facts
## 1. Project Structure
project/ βββ services/ β βββ service-a/ # β β βββ service-b/ # β βββ api/ # Entry point βββ data/ # Shared data (gitignored) βββ docs/
## 2. Tech Stack Decisions
### Decision Matrix
| Service | Language | Key Libraries | Why |
|-----------|----------|-------------------|-------------------------------|
| service-a | Node.js | Fastify, Fuse.js | <reason> |
| service-b | Python | pandas | <reason> |
### Why NOT Alternatives
| Rejected | Reason |
|---------------|---------------------------------------|
| Python for X | Would need to port existing library |
## 3. Service Boundaries
### Service-A
- **Input:** <what it receives>
- **Output:** <what it produces>
- **Does NOT:** <responsibilities it avoids>
## 4. Key Architectural Decisions
### Decision 1: <Title>
**Decision:** <What we chose>
**Reasoning:**
- <Point 1>
- <Point 2>
Rules:
- Always explain WHY, not just WHAT
- Include rejected alternatives with reasons
- Document service boundaries (what each service does NOT do)
- Keep it concise β this is for agents to understand context, not a novel
## 1. Input Data Format
### Source: <API / scraper / CSV>
<description>
| Field | Type | Notes |
|-----------|--------|----------------------|
| field_a | string | |
| field_b | int | |
## 2. Data Pipeline
Raw Data β [Stage 1] β [Stage 2] β Output
### Stage 1 β <Name>
- **Input:** <what>
- **Processing:** <how>
- **Output:** <what>
## 3. Output Schema
``` json
{
"field": "value"
}
| Field | Type | Indexed | Notes |
|---|---|---|---|
| id | str | primary | |
| embedding | vector | HNSW | 1024-dim |
**Rules:**
- Show the data at each pipeline stage
- Include actual schema definitions (not just descriptions)
- Note any quirks (duplicate keys, mixed casing, null handling)
- Document what gets embedded vs what goes to metadata
---
### `ux-flow.md` (UI Projects Only)
``` markdown
## 1. Navigation
Home (/) β Search (/search) β Settings (/settings)
## 2. Screen 1 β <Screen Name>
**Behavior:**
- <Error/empty states>
- User lands on Home
- User types query β navigates to Search
- Results populate β user filters
- User clicks item β detail expands Rules:
- ASCII wireframes are good enough β no Figma needed for agent understanding
- Describe behavior, not just layout
- Include all states: , empty, error, success
- Show the happy path AND edge cases
final-report.md
> Status: β
Delivered | YYYY-MM-DD
> Audience: sprint-(N+1) context. Read this + [`AGENTS.md`](../../AGENTS.md) before starting sprint-(N+1).
---
## 1. Sprint goal & outcome
<What we set out to build and what was delivered.>
## 2. Final structure
| Item | Count | Notes |
|---|
| Decision | Rationale |
|---|
| Phase | Tasks | Status |
|---|
π Full reports:
`reports/`
<commands>
<What the next sprint needs to know β integration points, unresolved items, data dependencies.>
AGENTS.md (For Delegating to Another LLM)
This is the most critical document. It's a self-contained implementation guide.
> **For:** Any LLM agent implementing <project>.
> **Context:** <what was already built, what exists, what NOT to rebuild>
---
## 0. What Already Exists (Do NOT Rebuild)
**Endpoints ready to use:**
`POST /search`
β`GET /health`
β
| Layer | Technology |
|---|---|
| Frontend | Astro + React |
| Styling | Tailwind CSS |
<directory tree of files the agent must create>
<numbered list of steps, each with brief code snippet if critical>
Code snippet showing the exact pattern:
function ComponentName({ props }: Props) { // implementation hint } interface RequestType { ... } interface ResponseType { ... }
| Source | What to Copy |
|---|---|
| path/to/file | pattern to reuse |
| Reference | This Project | Why |
|---|
- Task 1
- Task 2
cd service && npm run dev
- <Checklist of what "done" looks like>
Rules for AGENTS.md:
- Include EXACT code snippets for critical logic
- List reference files the agent can copy-paste from
- Include a numbered checklist β agents follow checklists better than prose
- Mention what NOT to do (deviations from reference)
- Include "Done Criteria" so the agent can self-validate
reports/phase-N-report.md (Per-Phase Report)
> Completed: YYYY-MM-DD
---
## 1. How to Run
``` bash
<exact commands to run this phase>
<diagram showing component layout>
| Metric | Value |
|---|---|
| ... | ... |
| Decision | Reason | |---|
| File | Purpose |
|---|---|
| ... | ... |
### `rca/YYYY-MM-DD-<slug>.md` (Root Cause Analysis)
Write one **whenever a non-trivial bug burns more than ~2 debug cycles** (or
anything in prod breaks) β not for trivial fixes, but for the gnarly ones where
"what we thought was the cause wasn't." File under the **current sprint** at
`docs/sprint-N/rca/YYYY-MM-DD-<short-slug>.md`.
```` markdown
> **Date:** YYYY-MM-DD Β· **Severity:** Low/Med/High Β· **Component:** <where>
> **Status:** β
Resolved
## 1. Summary
<2-3 sentences: what happened + the ACTUAL root cause, up top. No burying the lede.>
## 2. Impact
<who/what affected, data or prod impact, duration>
## 3. Symptoms (observed)
| Signal | Value |
|---|---|
## 4. Timeline
| # | Attempt | Outcome | Verdict |
|---|---------|---------|---------|
| 1 | <what we tried> | <result> | real fix / red herring / the cause |
## 5. Root cause
<The actual cause + evidence (file/line, sizes, logs). Be concrete.>
## 6. The fix
``` diff
- <before>
+ <after>
| Metric | Before | After | |---|
<misleading signals, red herrings, what masked the real cause>
- <preventive change / process tweak>
<doc URLs, issue links, file paths>
**Rules for RCA:**
- **Lead with the root cause** in the Summary β don't make the reader wait.
- **Tag every Timeline row** (*real fix* / *red herring* / *the cause*) β the red herrings are the most valuable part for future-you.
- **Capture the symptom signature** (e.g., "X loads 200 but doesn't apply") so the same class of bug is recognizable next time.
- Write it **the same day**, while the debug trail is fresh.
- File under `docs/sprint-N/rca/YYYY-MM-DD-<slug>.md`
> **Note:** `architecture.md`, `data-design.md`, `ux-flow.md`, and `api-contract.md`
> live inside `docs/sprint-N/resources/`. Only `plan.md`, `tasks.md`,
> `final-report.md`, and `AGENTS.md` sit at the sprint root.
---
## 4. Communication Patterns
### Do
- **Ask before committing** β "Confirm and I'll commit"
- **Ask before design decisions** β "Here's my recommendation, thoughts?"
- **Break down tasks before building** β "Let me split this into smaller tasks"
- **Test immediately after building** β run the code, show the output
- **Update docs after every phase** β report + tasks.md update
- **Document findings, not just results** β what surprised you, what failed
- **Write an RCA for gnarly bugs** β if a bug burns >~2 debug cycles (or breaks prod), file `docs/sprint-N/rca/YYYY-MM-DD-<slug>.md`; lead with the root cause and tag red herrings
### Don't
- Never commit without confirmation
- Never assume a library is available β check first
- Never skip the "study real output" step in Phase 0
- Never leave broken tasks marked as β
- Never skip writing the phase report
- **Never keep blind-guessing on a stuck bug** β after ~2 failed attempts, stop and read the actual docs/issues/canonical source, then write an RCA
---
## 5. Difficulty Levels
| Level | Meaning | Example |
|--------|--------------------------------------------------|--------------------------------------------|
| Easy | β€30 min, no unknowns, mostly wiring | "Add endpoint", "Create file structure" |
| Medium | 1-2h, some design decisions, integration work | "Build wrapper", "Normalize data" |
| Hard | 3h+, complex logic, multiple edge cases | "Facility extraction", "SSE streaming" |
---
## 6. Startup Checklist (New Project)
When starting a new project with this workflow:
1. [ ] Create the monorepo structure
2. [ ] Write the PRD or confirm existing one
3. [ ] Run Phase 0 β clone deps, test tools, study real output
4. [ ] Create `docs/sprint-1/` with all planning docs
5. [ ] Break tasks into phases with difficulty + dependencies
6. [ ] Start Phase 1 β build β test β report β commit
7. [ ] After each phase, update `tasks.md` and write `reports/phase-N-report.md`
8. [ ] When delegating, create `AGENTS.md` with checklist + code snippets
9. [ ] After sprint, write `docs/ideas/future-enhancements.md` for backlog
---
## 7. Complete Directory Structure
project/ βββ docs/ β βββ prd.md # Original requirements β βββ ideas/ β β βββ future-enhancements.md # Backlog for later β βββ sprint-<N>/ β βββ plan.md # Sprint goal, scope, decisions, phasing β βββ tasks.md # Task breakdown + status β βββ final-report.md # Final sprint summary + handoff β βββ AGENTS.md # Delegation guide β βββ reports/ β β βββ phase-0-report.md # Discovery findings β β βββ phase-1-report.md # Per-phase reports β β βββ ... β βββ resources/ β β βββ architecture.md # Tech decisions + structure β β βββ data-design.md # Schemas + pipelines β β βββ ux-flow.md # Screens + interaction (UI projects) β β βββ api-contract.md # REST endpoints + shapes β βββ rca/ # Root-cause analyses βββ services/ # Monorepo services βββ api/ # API layer βββ web/ # Frontend (if applicable) βββ data/ # Runtime data (gitignored) βββ .gitignore
---