5.5 KiB
name, description
| name | description |
|---|---|
| plan | Interactive planning session that generates PRD (prd.json) and sprint contracts for the agent loop. Run /agent-loop:init first. |
/plan — Generate PRD and Sprint Contracts
Interactive planning session that produces all artifacts needed for the autonomous agent loop.
Prerequisites
.loop/directory must exist withconfig.json(run/agent-loop:initfirst if not)- User should have a clear idea of what they want to build/explore/fix
Usage
/loop-plan <optional feature description>
Examples:
/loop-plan Add OAuth authentication with Google and GitHub/loop-plan Explore the payment processing system/loop-plan Fix all critical security issues from the audit
Instructions
Step 1: Understand the Request
If the user provided a feature description, use it. Otherwise ask:
"What would you like to work on? Describe it in 1-3 sentences."
Step 2: Codebase Analysis
Read key project files to understand existing patterns:
- Relevant source directories for the feature
- Existing tests to understand testing patterns
- Configuration files for conventions
- Recent git history (
git log --oneline -20) for active work
Step 3: Clarifying Questions
Ask 3-5 targeted questions based on what you found in the code. These should be questions where the answer isn't obvious from the codebase. Examples:
- "I see you have both REST endpoints and GraphQL. Should this feature use REST or GraphQL?"
- "The existing auth uses JWT. Should I add OAuth alongside it or replace it?"
- "I found two competing patterns for data validation. Which should I follow?"
Do NOT ask questions you can answer from the code. Only ask when human judgment is needed.
Step 4: Generate PRD (prd.json)
Create .loop/prd.json with properly-sized, dependency-ordered stories.
Story Sizing Rules (CRITICAL):
- Each story must be completable in ONE context window (~100K tokens of work)
- Target: 1-3 files changed per story
- Too big: "Build the authentication system" → split into migration, endpoint, middleware, UI, tests
- Too small: "Add import statement" → combine with the story that needs it
Dependency Ordering:
- Schema/database changes first (they block everything)
- Backend logic (depends on schema)
- Frontend components (depend on backend)
- Integration/wiring (depends on components)
- Polish/edge cases (depends on core being done)
Required Fields Per Story:
{
"id": "US-001",
"title": "Short descriptive title",
"description": "As a [role], I want [feature] so that [benefit].",
"acceptanceCriteria": [
"Specific, verifiable criterion",
"Another criterion",
"Typecheck passes"
],
"priority": 1,
"passes": false,
"notes": "",
"rejections": 0
}
Acceptance Criteria Rules:
- Every criterion must be independently verifiable (not "works well" — "returns 200 with valid token")
- Always include "Typecheck passes" (or equivalent for the language)
- UI stories must include "Verify UI renders and responds to interaction"
- API stories must include status code expectations
- Database stories must include migration success check
Step 5: Generate Sprint Contracts
For each story, create .loop/contracts/{story-id}.contract.md:
# Sprint Contract: {Story ID} — {Story Title}
## What Will Be Built
Concrete description of the deliverable. Not the user story — the actual thing being built.
## Done Conditions
- [ ] Condition 1 (specific, testable)
- [ ] Condition 2
- [ ] All acceptance criteria from prd.json met
## Evaluation Criteria
What the evaluator will specifically check:
- [ ] Check 1
- [ ] Check 2
- [ ] No regressions in [specific area]
## Out of Scope
Things explicitly NOT part of this story:
- Thing 1
- Thing 2
## Key Files
Files likely to be created or modified:
- path/to/file.ext — what changes
- path/to/other.ext — what changes
## Dependencies
- Depends on: [story IDs that must be done first, or "none"]
- Blocks: [story IDs that depend on this one, or "none"]
Step 6: Initialize Progress File
Create .loop/progress.md from the template with an initial Codebase Patterns section populated from what you learned during analysis:
# Progress
## Codebase Patterns
- [Pattern you discovered during analysis]
- [Convention you noticed]
- [Testing approach used in the project]
---
## Session Log
### Planning Session
Date: YYYY-MM-DD HH:MM
**PRD created:** {N} stories for "{feature description}"
**Estimated iterations:** {N stories + ~30% for evaluator rejections}
**Key decisions:**
- [Decision 1 and why]
- [Decision 2 and why]
---
Step 7: Present Summary
Show the user a summary:
Plan Ready
Stories Est. Iterations Mode Branch {N} {N+30%} {mode} {branchName} Story Overview:
- US-001: {title} (priority 1)
- US-002: {title} (priority 2) ...
Review the stories in
.loop/prd.jsonand contracts in.loop/contracts/. Adjust anything you'd like, then run:/agent-loop:run # Interactive (recommended) .loop/loop.sh # Headless
Step 8: Wait for Feedback
Ask the user:
Ready to start? I can begin implementing now, or you can adjust the plan first.
- If the user confirms (yes, go, start, implement, etc.) → invoke
/agent-loop:runto begin the loop immediately - If they want changes (split a story, reorder, add/remove, change criteria) → make the changes, re-present the summary, and ask again