.claude/skills/discovering-requirements/SKILL.md
--- parallel_threshold: 2000 timeout_minutes: 90 zones: system: path: .claude permission: none state: paths: [grimoires/loa, .beads] permission: read-write app: paths: [src, lib, app] permission: read --- <prompt_enhancement_prelude> ## Invisible Prompt Enhancement Before executing main skill logic, apply automatic prompt enhancement to user's request. ### Step 1: Check Configuration Read `.loa.config.yaml` invisible_mode setting: ```yaml prompt_enhancement: i
npx skillsauth add 0xhoneyjar/loa-beauvoir .claude/skills/discovering-requirementsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
<prompt_enhancement_prelude>
Before executing main skill logic, apply automatic prompt enhancement to user's request.
Read .loa.config.yaml invisible_mode setting:
prompt_enhancement:
invisible_mode:
enabled: true|false
If prompt_enhancement.invisible_mode.enabled: false (or not set), skip to main skill logic with original prompt.
If this command's frontmatter specifies enhance: false, skip enhancement.
Analyze the user's prompt for PTCF components:
| Component | Detection Patterns | Weight | |-----------|-------------------|--------| | Persona | "act as", "you are", "as a", "pretend", "assume the role" | 2 | | Task | create, review, analyze, fix, summarize, write, debug, refactor, build, implement, design | 3 | | Context | @mentions, file references (.ts, .js, .py), "given that", "based on", "from the", "in the" | 3 | | Format | "as bullets", "in JSON", "formatted as", "limit to", "step by step", "as a table" | 2 |
Calculate score (0-10):
If score < prompt_enhancement.auto_enhance_threshold (default 4):
.claude/skills/enhancing-prompts/resources/templates/{task_type}.yamlWrite to grimoires/loa/a2a/trajectory/prompt-enhancement-{date}.jsonl:
{
"type": "prompt_enhancement",
"timestamp": "ISO8601",
"command": "plan-and-analyze",
"action": "ENHANCED|SKIP|DISABLED|OPT_OUT|ERROR",
"original_score": N,
"enhanced_score": N,
"components_added": ["persona", "format"],
"task_type": "generation",
"latency_ms": N
}
Use the (potentially enhanced) prompt for main skill execution.
CRITICAL: Never show enhancement output to user. All analysis is internal only.
On ANY error during enhancement:
action: "ERROR" to trajectory<zone_constraints>
This skill operates under Managed Scaffolding:
| Zone | Permission | Notes |
|------|------------|-------|
| .claude/ | NONE | System zone - never suggest edits |
| grimoires/loa/, .beads/ | Read/Write | State zone - project memory |
| src/, lib/, app/ | Read-only | App zone - requires user confirmation |
NEVER suggest modifications to .claude/. Direct users to .claude/overrides/ or .loa.config.yaml.
</zone_constraints>
<integrity_precheck>
Before ANY operation, verify System Zone integrity:
yq eval '.integrity_enforcement' .loa.config.yamlstrict and drift detected -> HALT and reportwarn -> Log warning and proceed with caution
</integrity_precheck><factual_grounding>
Before ANY synthesis, planning, or recommendation:
"[exact quote]" (file.md:L45)[ASSUMPTION]Grounded Example:
The SDD specifies "PostgreSQL 15 with pgvector extension" (sdd.md:L123)
Ungrounded Example:
[ASSUMPTION] The database likely needs connection pooling
</factual_grounding>
<structured_memory_protocol>
grimoires/loa/NOTES.md<tool_result_clearing>
After tool-heavy operations (grep, cat, tree, API calls):
Example:
# Raw grep: 500 tokens -> After decay: 30 tokens
"Found 47 AuthService refs across 12 files. Key locations in NOTES.md."
</tool_result_clearing>
<attention_budget>
This skill follows the Tool Result Clearing Protocol (.claude/protocols/tool-result-clearing.md).
| Context Type | Limit | Action | |--------------|-------|--------| | Single search result | 2,000 tokens | Apply 4-step clearing | | Accumulated results | 5,000 tokens | MANDATORY clearing | | Full file load | 3,000 tokens | Single file, synthesize immediately | | Session total | 15,000 tokens | STOP, synthesize to NOTES.md |
grimoires/loa/NOTES.md"Discovery: N sources → M requirements → NOTES.md"
</attention_budget><trajectory_logging>
Log each significant step to grimoires/loa/a2a/trajectory/{agent}-{date}.jsonl:
{"timestamp": "...", "agent": "...", "action": "...", "reasoning": "...", "grounding": {...}}
</trajectory_logging>
<kernel_framework>
Produce comprehensive PRD by:
grimoires/loa/context/grimoires/loa/context/*.md (optional), developer interviewgrimoires/loa/prd.mdgrimoires/loa/a2a/integration-context.md (if exists)> From vision.md:12: "exact quote"PRD traces every requirement to either:
<codebase_grounding>
Purpose: Ground PRD creation in codebase reality to prevent hallucinated requirements.
Read configuration from .loa.config.yaml (with defaults):
# Check if codebase grounding is enabled (default: true)
enabled=$(yq eval '.plan_and_analyze.codebase_grounding.enabled // true' .loa.config.yaml 2>/dev/null || echo "true")
# Get staleness threshold in days (default: 7)
staleness_days=$(yq eval '.plan_and_analyze.codebase_grounding.reality_staleness_days // 7' .loa.config.yaml 2>/dev/null || echo "7")
# Get /ride timeout in minutes (default: 20)
timeout_minutes=$(yq eval '.plan_and_analyze.codebase_grounding.ride_timeout_minutes // 20' .loa.config.yaml 2>/dev/null || echo "20")
# Get skip-on-error behavior (default: false)
skip_on_error=$(yq eval '.plan_and_analyze.codebase_grounding.skip_on_ride_error // false' .loa.config.yaml 2>/dev/null || echo "false")
If enabled: false, skip Phase -0.5 entirely (equivalent to GREENFIELD behavior).
When /plan-and-analyze runs, check the codebase_detection pre-flight result:
IF config.enabled == false:
→ Skip to Phase -1 (feature disabled)
→ Do NOT mention codebase grounding to user
ELSE IF codebase_detection.type == "GREENFIELD":
→ Skip to Phase -1 (no codebase to analyze)
→ Do NOT mention codebase grounding to user
ELSE IF codebase_detection.type == "BROWNFIELD":
IF codebase_detection.reality_exists == true:
IF codebase_detection.reality_age_days < config.staleness_days:
→ Use cached reality (no /ride needed)
→ Show: "Using recent codebase analysis (N days old)"
ELSE IF --fresh flag provided:
→ Run /ride regardless of cache
ELSE:
→ Prompt user with AskUserQuestion:
- "Re-run /ride for fresh analysis (recommended)"
- "Proceed with existing analysis (faster)"
ELSE:
→ Run /ride (Phase -0.5)
→ Show progress: "Analyzing codebase structure..."
Invoke the ride skill (NOT the command) for codebase analysis:
CODEBASE GROUNDING PHASE
Analyzing your existing codebase to ground PRD requirements in reality.
This typically takes 5-15 minutes depending on codebase size.
Progress:
- [ ] Extracting component inventory
- [ ] Analyzing architecture patterns
- [ ] Identifying existing requirements
- [ ] Building consistency report
Use the Skill tool to invoke ride:
Skill: ride
This will produce:
grimoires/loa/reality/extracted-prd.mdgrimoires/loa/reality/extracted-sdd.mdgrimoires/loa/reality/component-inventory.mdgrimoires/loa/consistency-report.mdIf /ride fails or times out:
Capture error in NOTES.md Decision Log:
| Date | Decision | Rationale | Source |
|------|----------|-----------|--------|
| YYYY-MM-DD | /ride failed during codebase grounding | [error message] | Phase -0.5 |
Check config for auto-skip:
skip_on_error=$(yq eval '.plan_and_analyze.codebase_grounding.skip_on_ride_error // false' .loa.config.yaml)
If skip_on_error: true, automatically skip to Phase -1 with warning.
Otherwise prompt user with AskUserQuestion:
questions:
- question: "/ride analysis failed. How would you like to proceed?"
header: "Recovery"
options:
- label: "Retry /ride analysis"
description: "Re-run codebase analysis (recommended)"
- label: "Skip codebase grounding"
description: "Proceed without code-based requirements (not recommended)"
- label: "Abort"
description: "Cancel /plan-and-analyze entirely"
multiSelect: false
Handle user response:
If "Retry":
If "Skip":
- [ ] [BLOCKER] PRD created without codebase grounding - /ride failed: [error]
> ⚠️ **WARNING**: This PRD was created without codebase grounding.
> Run `/ride` and `/plan-and-analyze --fresh` for accurate requirements.
If "Abort":
Preserve partial results if available:
Default timeout: 20 minutes (configurable in .loa.config.yaml)
plan_and_analyze:
codebase_grounding:
ride_timeout_minutes: 20
For GREENFIELD projects:
Run context assessment:
./.claude/scripts/assess-discovery-context.sh
| Result | Strategy |
|--------|----------|
| NO_CONTEXT_DIR | Create directory, offer guidance, proceed to full interview |
| EMPTY | Proceed to full 7-phase interview |
| SMALL (<500 lines) | Sequential ingestion, then targeted interview |
| MEDIUM (500-2000) | Sequential ingestion, then targeted interview |
| LARGE (>2000) | Parallel subagent ingestion, then targeted interview |
Load and synthesize context in priority order:
| Priority | Source | Citation Format | Trust Level |
|----------|--------|-----------------|-------------|
| 1 | grimoires/loa/reality/ | [CODE:file:line] | Highest (code is truth) |
| 2 | grimoires/loa/context/ | > From file.md:line | High (user-provided) |
| 3 | Interview responses | (Phase N QN) | Standard |
Conflict Resolution: When reality contradicts context:
If reality files exist (from /ride or cached):
## What I've Learned From Your Codebase
Based on analysis of your existing code:
### Architecture
[CODE:src/index.ts:1-50] Your application uses [pattern] architecture with:
- [list key components with code references]
### Existing Features
From component inventory:
- Feature A [CODE:src/features/a.ts:10-45]
- Feature B [CODE:src/services/b.ts:1-100]
### Current State
From consistency report:
- [summary of code consistency findings]
### Proposed Additions
Based on codebase analysis, the following would integrate well:
- [suggested additions grounded in existing patterns]
---
Read in priority order:
grimoires/loa/reality/*.md (if exists)grimoires/loa/context/*.md (and subdirectories)Internally categorize discovered information:
<context_map>
<phase name="problem_vision">
<reality source="extracted-prd.md:10-30">
Implicit problem statement from codebase
</reality>
<found source="vision.md:1-45">
Product vision, mission statement, core problem
</found>
<gap>Success metrics not defined</gap>
</phase>
<phase name="goals_metrics">
<found source="vision.md:47-52">
High-level goals mentioned
</found>
<gap>No quantifiable success criteria</gap>
<gap>Timeline not specified</gap>
</phase>
<phase name="users_stakeholders">
<found source="users.md:1-289">
3 personas defined with jobs-to-be-done
</found>
<ambiguity>Persona priorities unclear - which is primary?</ambiguity>
</phase>
<phase name="functional_requirements">
<reality source="component-inventory.md:1-200">
Existing features extracted from code
</reality>
<found source="requirements.md:1-100">
User-documented requirements
</found>
<conflict>User docs mention feature X, but not found in codebase</conflict>
</phase>
<!-- Continue for all 7 phases -->
</context_map>
For brownfield projects, present codebase understanding FIRST:
## What I've Learned From Your Codebase
I've analyzed your existing codebase (N files, X lines).
### Existing Architecture
[CODE:src/index.ts:1-50] Your application uses [pattern] with:
- Component A [CODE:src/components/a.tsx:10]
- Service B [CODE:src/services/b.ts:1]
### Implemented Features
Based on code analysis:
- User authentication [CODE:src/auth/index.ts:1-100]
- Data persistence [CODE:src/db/client.ts:1-50]
---
## What I've Learned From Your Documentation
I've reviewed N files (X lines) from your context directory.
### Problem & Vision
> From vision.md:12-15: "exact quote from document..."
I understand the core problem is [summary]. The vision is [summary].
### Users & Stakeholders
> From users.md:23-45: "description of personas..."
You've defined N personas: [list with 1-line each].
### Conflicts Noted
- [if any conflicts between reality and context]
### What I Still Need to Understand
1. **Success Metrics**: What quantifiable outcomes define success?
2. **Persona Priority**: Which user persona should we optimize for first?
3. **Timeline**: What are the key milestones and deadlines?
Should I proceed with these clarifying questions, or would you like to
correct my understanding first?
For each gap/ambiguity identified:
Example:
### Goals & Success Metrics
I found high-level goals in vision.md:
> "Achieve product-market fit within 12 months"
However, I didn't find specific success metrics.
**Questions:**
1. What metrics would indicate product-market fit for this product?
2. Are there intermediate milestones (3-month, 6-month)?
For each phase, follow this logic:
IF phase fully covered by context:
→ Summarize understanding with citations
→ Ask: "Is this accurate? Any corrections?"
→ Move to next phase
ELSE IF phase partially covered:
→ Summarize what's known (with citations)
→ Ask only about gaps (max 2-3 questions)
→ Move to next phase
ELSE IF phase not covered:
→ Conduct full discovery for this phase
→ Ask 2-3 questions at a time
→ Iterate until complete
For high-precision requirements, use EARS notation from
resources/templates/ears-requirements.md:
| Pattern | Format | Use When |
|---------|--------|----------|
| Ubiquitous | The system shall [action] | Always-true requirements |
| Event-Driven | When [trigger], the system shall [action] | Trigger-based behavior |
| Conditional | If [condition], the system shall [action] | Precondition-based |
When to use EARS: Security-critical features, regulatory compliance, complex triggers.
Only generate PRD when:
Generate PRD with source tracing:
## 1. Problem Statement
[Content derived from vision.md:12-30 and Phase 1 interview]
> Sources: vision.md:12-15, confirmed in Phase 1 Q2
</workflow>
<parallel_execution>
If context assessment returns LARGE:
Task(subagent_type="Explore", prompt="
CONTEXT INGESTION: Problem & Vision
Read these files: [vision.md, any *vision* or *problem* files]
Extract and summarize:
- Core problem statement
- Product vision
- Mission/purpose
- 'Why now' factors
Return as structured summary with file:line citations.
")
Spawn 4 parallel ingestors:
Merge summaries into unified context map before proceeding. </parallel_execution>
<output_format>
PRD structure with source tracing - see resources/templates/prd-template.md
Each section must include:
> **Sources**: vision.md:12-30, users.md:45-67, Phase 3 Q1-Q2
</output_format>
<success_criteria>
<uncertainty_protocol>
<grounding_requirements> Every claim about existing context must include citation:
> From {filename}:{line}: "exact quote"(vision.md:12-45)<edge_cases> | Scenario | Behavior | |----------|----------| | No context directory | Create it, add README.md, proceed to full interview | | Empty context directory | Note it, proceed to full interview | | Only README.md exists | Treat as empty, proceed to full interview | | Contradictory information | List contradictions, ask developer to clarify | | Outdated information | Ask "Is this still accurate?" before using | | Very large files (>1000 lines) | Summarize key sections, note full file available | | Non-markdown files | Note existence, explain can't parse | | Partial coverage | Conduct mini-interviews for gaps only | | Developer disagrees with synthesis | Allow corrections, update understanding | | Reality conflicts with context | Reality wins, flag conflict for user review | | Stale reality (>7 days) | Prompt user to refresh or proceed with cached | | /ride failed | Log blocker, proceed without grounding (with warning) | | Brownfield detected but no reality | Run /ride before Phase -1 | | Greenfield project | Skip codebase grounding entirely, no message | </edge_cases>
<visual_communication>
Follow .claude/protocols/visual-communication.md for diagram standards.
PRDs may benefit from visual aids for:
If including diagrams, use Mermaid with preview URLs:
### User Registration Journey
```mermaid
graph LR
A[Landing Page] --> B{Has Account?}
B -->|No| C[Sign Up Form]
B -->|Yes| D[Login]
C --> E[Email Verification]
E --> F[Onboarding]
F --> G[Dashboard]
Preview: View diagram
### Theme Configuration
Read theme from `.loa.config.yaml` visual_communication.theme setting.
Diagram inclusion is **optional** for PRDs - use agent discretion based on complexity.
</visual_communication>
tools
Control headless Chrome via Cloudflare Browser Rendering CDP WebSocket. Use for screenshots, page navigation, scraping, and video capture when browser automation is needed in a Cloudflare Workers environment. Requires CDP_SECRET env var and cdpUrl configured in browser.profiles.
testing
# valid-skill Test skill with valid license for unit testing. ## Purpose Used in test_constructs_loader.bats to verify correct handling of valid licenses.
testing
# grace-skill Test skill in license grace period for unit testing. ## Purpose Used in test_constructs_loader.bats to verify correct handling of licenses in grace period.
testing
# expired-skill Test skill with expired license for unit testing. ## Purpose Used in test_constructs_loader.bats to verify correct handling of expired licenses.