| name | source-command-plan-and-analyze |
| description | Launch PRD discovery with automatic codebase grounding and context ingestion. For brownfield projects, automatically runs /ride analysis before PRD creation. Reads existing documentation from grimoires/loa/context/ before interviewing. Initializes Sprint Ledger and creates development cycle automatically.
Use --fresh flag to force re-running /ride even if recent reality exists. |
source-command-plan-and-analyze
Use this skill when the user asks to run the migrated source command plan-and-analyze.
Command Template
Plan and Analyze
Purpose
Launch structured PRD discovery with automatic codebase grounding and context ingestion. For brownfield projects (existing codebases), automatically runs /ride analysis before PRD creation to ensure requirements are grounded in code reality.
Codebase Grounding (Phase -0.5)
For brownfield projects (>10 source files OR >500 lines of code):
- Auto-detects codebase type (GREENFIELD vs BROWNFIELD)
- Runs /ride automatically if brownfield and no recent reality exists
- Uses cached reality if <7 days old (configurable)
- Loads reality files as highest-priority context
Grounding Decision Flow
BROWNFIELD + no reality → Run /ride (Phase -0.5)
BROWNFIELD + fresh reality (<7 days) → Use cached (skip /ride)
BROWNFIELD + stale reality (>7 days) → Prompt user
BROWNFIELD + --fresh flag → Force re-run /ride
GREENFIELD → Skip directly to Phase -1
Using --fresh Flag
/plan-and-analyze --fresh
Context-First Behavior
- Codebase grounding: Loads reality files from
/ride (if brownfield)
- Scans
grimoires/loa/context/ for existing documentation
- Synthesizes all sources with reality as highest priority
- Maps to 7 discovery phases
- Only asks questions for gaps and strategic decisions
Invocation
/plan-and-analyze
/plan-and-analyze --fresh
Pre-Discovery Setup (Optional)
mkdir -p grimoires/loa/context
cp ~/project-docs/vision.md grimoires/loa/context/
cp ~/project-docs/user-research.md grimoires/loa/context/users.md
/plan-and-analyze
Context Directory Structure
grimoires/loa/context/
├── README.md # Instructions for developers
├── vision.md # Product vision, mission, goals
├── users.md # User personas, research, interviews
├── requirements.md # Existing requirements, feature lists
├── technical.md # Technical constraints, stack preferences
├── competitors.md # Competitive analysis, market research
├── meetings/ # Meeting notes, stakeholder interviews
│ └── *.md
└── references/ # External docs, specs, designs
└── *.*
All files are optional. The more context provided, the fewer questions asked.
Discovery Phases
Phase 0: Context Synthesis (NEW)
- Reads all files from
grimoires/loa/context/
- Maps discovered information to 7 phases
- Presents understanding with citations
- Identifies gaps requiring clarification
Phase 1: Problem & Vision
- Core problem being solved
- Product vision and mission
- Why now? Why you?
Phase 2: Goals & Success Metrics
- Business objectives
- Quantifiable success criteria
- Timeline and milestones
Phase 3: User & Stakeholder Context
- Primary and secondary personas
- User journey and pain points
- Stakeholder requirements
Phase 4: Functional Requirements
- Core features and capabilities
- User stories with acceptance criteria
- Feature prioritization
Phase 5: Technical & Non-Functional
- Performance requirements
- Security and compliance
- Integration requirements
Phase 6: Scope & Prioritization
- MVP definition
- Phase 1 vs future scope
- Out of scope (explicit)
Phase 7: Risks & Dependencies
- Technical risks
- Business risks
- External dependencies
Context Size Handling
| Size | Lines | Strategy |
|---|
| SMALL | <500 | Sequential ingestion, targeted interview |
| MEDIUM | 500-2000 | Sequential ingestion, targeted interview |
| LARGE | >2000 | Parallel subagent ingestion |
Prerequisites
- No prerequisites - this is the entry point for new projects
- For brownfield projects,
/ride runs automatically (no manual step needed)
- Use
/mount only if you need manual control over codebase analysis
Outputs
| Path | Description |
|---|
grimoires/loa/prd.md | Product Requirements Document with source tracing |
PRD Source Tracing
Generated PRD includes citations:
## 1. Problem Statement
[Content derived from vision.md:12-30 and Phase 1 interview]
> Sources: vision.md:12-15, confirmed in Phase 1 Q2
Error Handling
| Error | Cause | Resolution |
|---|
| "PRD already exists" | grimoires/loa/prd.md exists | Delete/rename existing PRD |
| "/ride failed" | Codebase analysis error | Retry, skip, or abort via prompt |
| "/ride timeout" | Analysis took >20 minutes | Use cached if exists, or skip |
/ride Error Recovery
If /ride fails during brownfield grounding:
- Retry: Re-run
/ride analysis
- Skip: Proceed without codebase grounding (not recommended)
- Abort: Cancel
/plan-and-analyze entirely
If you choose Skip, a warning is logged to NOTES.md blockers section.
Sprint Ledger Integration
This command automatically manages the Sprint Ledger:
- First Run: Initializes
grimoires/loa/ledger.json if not exists
- Creates Cycle: Registers a new development cycle with PRD title as label
- Active Cycle Check: If a cycle is already active, prompts to archive or continue
Ledger Behavior
/plan-and-analyze
/plan-and-analyze
Commands for Ledger Management
| Command | Purpose |
|---|
/ledger | View current ledger status |
/ledger history | View all cycles |
/archive-cycle "label" | Archive current cycle manually |
Flatline Protocol Integration (v1.17.0)
After PRD generation completes, the Flatline Protocol may execute automatically for adversarial multi-model review.
Automatic Trigger Conditions
The postlude runs if ALL conditions are met:
flatline_protocol.enabled: true in .loa.config.yaml
flatline_protocol.auto_trigger: true in .loa.config.yaml
flatline_protocol.phases.prd: true in .loa.config.yaml
What Happens
- Knowledge Retrieval: Searches local grimoires for relevant context
- Phase 1: 4 parallel API calls (GPT review, Opus review, GPT skeptic, Opus skeptic)
- Phase 2: Cross-scoring between models
- Consensus: Categorizes improvements as HIGH_CONSENSUS, DISPUTED, or LOW_VALUE
- Presentation: Shows results and offers integration options
Output
Results are saved to grimoires/loa/a2a/flatline/prd-review.json
Manual Alternative
If auto-trigger is disabled, run manually:
/flatline-review prd
Error Handling
If Flatline fails, the PRD is still valid. A warning is surfaced but workflow continues.
Next Step
After PRD is complete: /architect to create Software Design Document