Prompt Enricher
Runs automatically as Phase 0.2, after context-gatherer and before idea-explorer questions.
Purpose: transform the raw user prompt into a grounded, constraint-aware brief that prevents the spec from ignoring known realities of the codebase.
Entry conditions
context.md must exist in .claude/feature-state/{slug}/ (run context-gatherer first)
- Generates
enriched-prompt.md and saves to .claude/feature-state/{slug}/
- Load if already exists (resume flow)
Step 1: Detect constraints from codebase
Read context.md and extract constraints relevant to the feature:
- Architectural constraints: What patterns must be followed? (e.g., "All API routes use verifyAuthRequest")
- Data constraints: What data model rules exist? (e.g., "soft delete only, never hard delete")
- Infrastructure constraints: What infrastructure is confirmed vs. uncertain? (e.g., "Stripe webhook is not configured in production")
- Dependency constraints: What libraries are already in use that shape the approach?
Step 2: Identify ambiguities
From the prompt + context, list decisions that have multiple valid interpretations:
Examples:
- "Use the existing checkout flow or create a new direct-connect mechanism?"
- "Should connection be pending/approved or immediate?"
- "Is this feature for trainers or students or both?"
- "Real-time list updates or on-load only?"
Step 3: Suggest likely edge cases by feature type
Auto-detect the feature type from the prompt and inject standard edge cases:
| Feature type detected |
Auto-suggested edge cases |
| Connection/relationship |
What if already connected? What if connection is rejected? |
| Auth/permissions |
What if token expired? What if user not found? Rate limit? |
| List/query |
Empty result? Pagination? Combined filters? Sort order? |
| Form/input |
Required vs optional fields? XSS/injection? Max length? |
| External integration |
Timeout? Partial failure? Idempotency? |
| Delete/remove |
Soft delete? Orphaned references? Permission check? |
| Notification |
What if FCM token missing? Duplicate notification? |
| Payment |
Idempotency? Webhook replay? Network failure mid-transaction? |
Step 4: Suggest scope boundaries
Based on the prompt and the project's "Out of Scope" section in PROJECT.md:
- In scope (inferred from prompt + context)
- Likely out of scope (YAGNI — things often requested but not essential)
- Deferred (good ideas for a future iteration)
Step 5: Generate enriched-prompt.md
Save to .claude/feature-state/{slug}/enriched-prompt.md:
## Enriched Prompt
### Original Prompt
Allow personal trainers to connect with students after checkout
### Discovered Constraints
- All API routes must call verifyAuthRequest() before any operation (PROJECT.md)
- Firestore: soft delete only — status: 'archived', never hard delete
- Stripe webhook (handleCheckoutComplete) already creates trainer-student links
- FCM token not guaranteed — push notifications are optional
### Ambiguities to Resolve
- Should this create a NEW connection mechanism or extend the existing checkout flow?
- Is the connection immediate or does it require mutual acceptance?
- Should trainers see ALL their students or only active ones?
- Should students be notified when a trainer connects?
### Likely Edge Cases
- Trainer tries to connect with a student already connected → already-connected state
- Student belongs to multiple trainers → one-to-many or one-to-one relationship?
- Trainer with no students → empty state in CMS list
- Connection made, then Stripe payment reversed → what happens to the link?
- Real-time list update vs. stale view when trainer is on the CMS page
### Suggested Scope Boundaries
**In scope:**
- Trainer can see their connected students in /cms/students
- Student appears after successful checkout (existing mechanism)
- trainerId persisted on student Firestore document
- Student list loads on trainer CMS page
**Likely out of scope (YAGNI):**
- Student can view which trainer they're connected to (separate feature)
- Real-time listener for connection status (polling is sufficient for v1)
- Trainer can disconnect a student (follow-up feature)
**Deferred:**
- Push notification when connection is made (requires FCM token guarantee)
- Multiple trainers per student
Step 6: Inject into idea-explorer context
This file is made available to idea-explorer as its starting brief.
When the enriched prompt exists, the first question from idea-explorer must reference it:
Based on what I found in the codebase, here's what we're working with:
[Summary of enriched-prompt.md key sections]
My first question: [first question anchored in the ambiguities above]
Edge case injection by feature type detection
Feature type is detected from keywords in the prompt:
| Keywords |
Detected type |
| connect, link, assign, bind, invite, follow |
connection/relationship |
| login, auth, token, session, password, verify |
auth/permissions |
| list, search, filter, query, paginate, find, show all |
list/query |
| create, add, submit, form, input, register |
form/input |
| stripe, payment, subscription, checkout, invoice |
payment |
| delete, remove, archive, deactivate |
delete/remove |
| notify, notification, push, email, alert |
notification |
| webhook, API, external, integration, sync |
external integration |
Multiple types can be detected for a single feature.
1---2name: prompt-enricher3description: Phase 0.2 — Enriches the raw user prompt with discovered constraints, ambiguities, likely edge cases, and suggested scope boundaries. Runs after context-gatherer, before idea-explorer questions. Generates enriched-prompt.md in the state directory.4---5
6# Prompt Enricher
7
8Runs **automatically as Phase 0.2**, after context-gatherer and before `idea-explorer` questions.
9Purpose: transform the raw user prompt into a grounded, constraint-aware brief that prevents the spec from ignoring known realities of the codebase.
10
11## Entry conditions
12
13- `context.md` must exist in `.claude/feature-state/{slug}/` (run context-gatherer first)
14- Generates `enriched-prompt.md` and saves to `.claude/feature-state/{slug}/`
15- Load if already exists (resume flow)
16
17## Step 1: Detect constraints from codebase
18
19Read `context.md` and extract constraints relevant to the feature:
20
21- **Architectural constraints**: What patterns must be followed? (e.g., "All API routes use verifyAuthRequest")
22- **Data constraints**: What data model rules exist? (e.g., "soft delete only, never hard delete")
23- **Infrastructure constraints**: What infrastructure is confirmed vs. uncertain? (e.g., "Stripe webhook is not configured in production")
24- **Dependency constraints**: What libraries are already in use that shape the approach?
25
26## Step 2: Identify ambiguities
27
28From the prompt + context, list decisions that have multiple valid interpretations:
29
30Examples:
31- "Use the existing checkout flow or create a new direct-connect mechanism?"
32- "Should connection be pending/approved or immediate?"
33- "Is this feature for trainers or students or both?"
34- "Real-time list updates or on-load only?"
35
36## Step 3: Suggest likely edge cases by feature type
37
38Auto-detect the feature type from the prompt and inject standard edge cases:
39
40| Feature type detected | Auto-suggested edge cases |
41|----------------------|--------------------------|
42| Connection/relationship | What if already connected? What if connection is rejected? |
43| Auth/permissions | What if token expired? What if user not found? Rate limit? |
44| List/query | Empty result? Pagination? Combined filters? Sort order? |
45| Form/input | Required vs optional fields? XSS/injection? Max length? |
46| External integration | Timeout? Partial failure? Idempotency? |
47| Delete/remove | Soft delete? Orphaned references? Permission check? |
48| Notification | What if FCM token missing? Duplicate notification? |
49| Payment | Idempotency? Webhook replay? Network failure mid-transaction? |
50
51## Step 4: Suggest scope boundaries
52
53Based on the prompt and the project's "Out of Scope" section in PROJECT.md:
54
55- **In scope** (inferred from prompt + context)
56- **Likely out of scope** (YAGNI — things often requested but not essential)
57- **Deferred** (good ideas for a future iteration)
58
59## Step 5: Generate enriched-prompt.md
60
61Save to `.claude/feature-state/{slug}/enriched-prompt.md`:
62
63```markdown
64## Enriched Prompt
65
66### Original Prompt
67Allow personal trainers to connect with students after checkout
68
69### Discovered Constraints
70- All API routes must call verifyAuthRequest() before any operation (PROJECT.md)
71- Firestore: soft delete only — status: 'archived', never hard delete
72- Stripe webhook (handleCheckoutComplete) already creates trainer-student links
73- FCM token not guaranteed — push notifications are optional
74
75### Ambiguities to Resolve
76- Should this create a NEW connection mechanism or extend the existing checkout flow?
77- Is the connection immediate or does it require mutual acceptance?
78- Should trainers see ALL their students or only active ones?
79- Should students be notified when a trainer connects?
80
81### Likely Edge Cases
82- Trainer tries to connect with a student already connected → already-connected state
83- Student belongs to multiple trainers → one-to-many or one-to-one relationship?
84- Trainer with no students → empty state in CMS list
85- Connection made, then Stripe payment reversed → what happens to the link?
86- Real-time list update vs. stale view when trainer is on the CMS page
87
88### Suggested Scope Boundaries
89**In scope:**
90- Trainer can see their connected students in /cms/students
91- Student appears after successful checkout (existing mechanism)
92- trainerId persisted on student Firestore document
93- Student list loads on trainer CMS page
94
95**Likely out of scope (YAGNI):**
96- Student can view which trainer they're connected to (separate feature)
97- Real-time listener for connection status (polling is sufficient for v1)
98- Trainer can disconnect a student (follow-up feature)
99
100**Deferred:**
101- Push notification when connection is made (requires FCM token guarantee)
102- Multiple trainers per student
103```
104
105## Step 6: Inject into idea-explorer context
106
107This file is made available to `idea-explorer` as its starting brief.
108When the enriched prompt exists, the first question from `idea-explorer` must reference it:
109
110```
111Based on what I found in the codebase, here's what we're working with:
112
113[Summary of enriched-prompt.md key sections]
114
115My first question: [first question anchored in the ambiguities above]
116```
117
118## Edge case injection by feature type detection
119
120Feature type is detected from keywords in the prompt:
121
122| Keywords | Detected type |
123|----------|--------------|
124| connect, link, assign, bind, invite, follow | connection/relationship |
125| login, auth, token, session, password, verify | auth/permissions |
126| list, search, filter, query, paginate, find, show all | list/query |
127| create, add, submit, form, input, register | form/input |
128| stripe, payment, subscription, checkout, invoice | payment |
129| delete, remove, archive, deactivate | delete/remove |
130| notify, notification, push, email, alert | notification |
131| webhook, API, external, integration, sync | external integration |
132
133Multiple types can be detected for a single feature.