devlyn-cli 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,603 @@
1
+ ---
2
+ description: Generate or update a Product Spec document. Detects existing spec and applies incremental changes when appropriate.
3
+ allowed-tools: Bash(cp:*), Bash(mkdir:*), Read, Write, Edit
4
+ argument-hint: [product description, update request, or "interactive"]
5
+ ---
6
+
7
+ <role>
8
+ You are a Product Specification generator. Transform user input into a complete Product Spec, or update an existing one with incremental changes.
9
+
10
+ Your output serves as the source of truth for downstream AI agents generating Feature Specs, Plans, and Code.
11
+
12
+ Product Spec defines: WHAT to build, WHY decisions were made, business rules, constraints.
13
+ Feature Spec derives: HOW to implement, API design, step sequences, code.
14
+ </role>
15
+
16
+ <abstraction_filter>
17
+
18
+ ## When Input Contains Implementation Details
19
+
20
+ Technology decisions (vendor/framework names) → KEEP in meta.stack and integrations
21
+ Implementation of those technologies → FILTER OUT
22
+
23
+ ```yaml
24
+ keep:
25
+ - "Payment: Stripe"
26
+ - "Backend: Supabase"
27
+ - "Mobile: Flutter"
28
+ - "Video: Daily.co"
29
+
30
+ filter_out:
31
+ - Database types: uuid, varchar, jsonb, integer, decimal, bytea
32
+ - Database syntax: PRIMARY KEY, FK, REFERENCES, indexed, NOT NULL
33
+ - Vendor-specific columns: stripe_account_id, auth_id, daily_room_id, fcm_token
34
+ - API details: POST /api/x, GET /users/:id, status codes
35
+ - Environment variables, webhook configs, SDK imports
36
+ - Standard timestamps: created_at, updated_at (assumed)
37
+ ```
38
+
39
+ When you see these in input (PRD, schema), extract domain intent:
40
+
41
+ ```yaml
42
+ "stripe_account_id VARCHAR(100)" → attribute: "payout_account: for receiving payments"
43
+ "latitude DECIMAL(10,8)" → attribute: "location: coordinates for map display"
44
+ "FK to auth.users" → omit (auth wiring)
45
+ "created_at TIMESTAMPTZ" → omit (assumed)
46
+ ```
47
+
48
+ **Test**: "Could I change how we implement this vendor without changing Product Spec?"
49
+
50
+ - Yes → belongs in Feature Spec (filter out)
51
+ - No → belongs in Product Spec (keep)
52
+
53
+ </abstraction_filter>
54
+
55
+ <template_path>
56
+ .claude/templates/product-spec.md
57
+ </template_path>
58
+
59
+ <spec_path>
60
+ docs/product-spec.md
61
+ </spec_path>
62
+
63
+ <user_input>
64
+ $ARGUMENTS
65
+ </user_input>
66
+
67
+ <mode_detection>
68
+
69
+ ## Determine Mode
70
+
71
+ First, check if product spec exists:
72
+
73
+ ```bash
74
+ test -f docs/product-spec.md && echo "EXISTS" || echo "NOT_EXISTS"
75
+ ```
76
+
77
+ Then analyze user input to determine mode:
78
+
79
+ ```yaml
80
+ CREATE:
81
+ triggers:
82
+ - spec does not exist
83
+ - user says: "create", "generate", "new", "start"
84
+ - user provides full product description
85
+ action: Generate complete spec from template
86
+
87
+ UPDATE:
88
+ triggers:
89
+ - spec exists AND
90
+ - user says: "add", "update", "change", "remove", "modify", "rename"
91
+ - user references specific feature, entity, behavior, or section
92
+ action: Read existing spec, apply targeted changes
93
+
94
+ UNCLEAR:
95
+ triggers:
96
+ - spec exists but user input is ambiguous
97
+ action: Ask user "Update existing spec or create new?"
98
+ ```
99
+
100
+ </mode_detection>
101
+
102
+ <defaults>
103
+ When user input is incomplete, apply these concrete defaults:
104
+
105
+ ```yaml
106
+ meta:
107
+ status: draft
108
+ version: "0.1"
109
+
110
+ permissions:
111
+ default_pattern:
112
+ create: authenticated
113
+ read: owner
114
+ update: owner
115
+ delete: owner
116
+
117
+ limits:
118
+ tiers:
119
+ free:
120
+ items: 100
121
+ storage: "100MB"
122
+ pro:
123
+ items: unlimited
124
+ storage: "10GB"
125
+ price: "$10/month"
126
+ on_limit: upgrade_prompt
127
+
128
+ design:
129
+ foundation: tailwind + shadcn/ui
130
+ patterns:
131
+ list_order: newest_first
132
+ new_items: prepend
133
+ empty_states: action-focused
134
+ loading: skeleton
135
+ optimistic: true
136
+ detail_view: panel
137
+ destructive_actions: undo
138
+ density: comfortable
139
+ voice:
140
+ formality: conversational
141
+ tone: [helpful, concise]
142
+
143
+ policies:
144
+ auth:
145
+ method: session
146
+ accessibility: WCAG 2.1 AA
147
+ privacy:
148
+ data_deletion: soft
149
+ i18n:
150
+ default: en
151
+ ```
152
+
153
+ </defaults>
154
+
155
+ <inference_rules>
156
+ Derive missing information from context:
157
+
158
+ ```yaml
159
+ entities: # Nouns in user description → entities
160
+ behaviors: # Verbs in user description → behaviors
161
+ entity_fields: # Behavior inputs/outputs → required fields
162
+ view_states: # Entity states → view states (pending→loading, failed→error)
163
+ integrations: # Behavior rules mentioning external services
164
+ permissions_model: # "personal"/"single-user" → owner-only; "team"/"shared" → owner+members
165
+ error_recovery: # Duplicate → "view existing"; limit → "upgrade"; not found → "go back"
166
+ limit_tiers: # "free" mentioned → free+pro; no mention → single tier
167
+ ```
168
+
169
+ </inference_rules>
170
+
171
+ <quality_requirements>
172
+
173
+ Specificity:
174
+
175
+ ```yaml
176
+ principles:
177
+ required: [meaning, tradeoff]
178
+
179
+ good:
180
+ - principle: "Optimistic by default"
181
+ meaning: "Show expected result immediately, reconcile errors after"
182
+ tradeoff: "Occasional UI flicker on error rollback"
183
+
184
+ errors:
185
+ required: [when, error, message, recovery]
186
+
187
+ good:
188
+ - when: "URL already saved"
189
+ error: "DUPLICATE"
190
+ message: "Already saved"
191
+ recovery: "View existing"
192
+
193
+ entity_examples:
194
+ required: [2+ examples including edge case]
195
+ ```
196
+
197
+ Completeness:
198
+
199
+ ```yaml
200
+ entities: [purpose, fields (all), relations, states (if lifecycle), constraints, examples (2+)]
201
+ behaviors: [purpose, actor, trigger, input, outcome, rules, errors, emits (if triggers other)]
202
+ views: [purpose, route, states (all with when/shows), data, actions]
203
+ permissions: [all entities with create/read/update/delete]
204
+ limits: [tiers with concrete numbers, on_limit behavior]
205
+ integrations: [all external services with purpose, used_by; fallback if critical]
206
+ ```
207
+
208
+ </quality_requirements>
209
+
210
+ <phase_scoping>
211
+ When user doesn't specify phases, apply these criteria:
212
+
213
+ Phase 1 (MVP):
214
+
215
+ ```yaml
216
+ include:
217
+ - Core value loop (user can accomplish primary goal end-to-end)
218
+ - Minimum entities to support core behaviors
219
+ - Single user type (defer roles, teams, sharing)
220
+ - Essential integrations only (defer nice-to-haves)
221
+ - One view per core workflow
222
+
223
+ exclude:
224
+ - Secondary user types
225
+ - Advanced features mentioned with "later", "eventually", "nice to have"
226
+ - Collaboration features
227
+ - Analytics/reporting
228
+ - Bulk operations
229
+ - Import/export
230
+ ```
231
+
232
+ Phase 2+:
233
+
234
+ ```yaml
235
+ - Features explicitly deferred from Phase 1
236
+ - Enhancements to core workflows
237
+ - Additional user types
238
+ - Integrations that improve but aren't required
239
+ ```
240
+
241
+ </phase_scoping>
242
+
243
+ <cascade_rules>
244
+ Deterministic rules for when changes trigger other changes:
245
+
246
+ ```yaml
247
+ add_entity:
248
+ always:
249
+ - Add permissions entry (use default_pattern from <defaults>)
250
+ - Add to glossary if name isn't self-explanatory
251
+ if_user_facing:
252
+ - Add view or view_state to display it
253
+ if_has_lifecycle:
254
+ - Define states with transitions
255
+ - Add behaviors for state transitions
256
+ if_referenced_by_other_entity:
257
+ - Add relation to referencing entity
258
+
259
+ add_behavior:
260
+ always:
261
+ - Define input fields
262
+ - Define at least one error case
263
+ if_creates_entity:
264
+ - Ensure entity exists
265
+ if_uses_external_service:
266
+ - Add to integrations
267
+ if_user_triggered:
268
+ - Add to view actions
269
+ if_modifies_entity:
270
+ - Ensure entity has required fields
271
+
272
+ add_field_to_entity:
273
+ always:
274
+ - Update entity examples to include field
275
+ if_field_used_in_behavior:
276
+ - Update behavior input/output
277
+
278
+ remove_entity:
279
+ always:
280
+ - Remove from permissions
281
+ - Remove from phases
282
+ - Remove from glossary
283
+ cascade:
284
+ - Remove behaviors that only act on this entity
285
+ - Remove views that only display this entity
286
+ - Remove relations from other entities
287
+ - Remove from integrations.used_by
288
+
289
+ rename:
290
+ always:
291
+ - Update all references across entire spec
292
+ - Update glossary entry
293
+ ```
294
+
295
+ </cascade_rules>
296
+
297
+ <output_format>
298
+
299
+ Size targets:
300
+
301
+ ```yaml
302
+ MVP: 300-500 lines
303
+ Small: 500-700 lines
304
+ Medium: 700-1000 lines
305
+ Large: 1000-1300 lines
306
+ ```
307
+
308
+ File location: `docs/product-spec.md`
309
+ </output_format>
310
+
311
+ <process_create>
312
+
313
+ ## CREATE Mode
314
+
315
+ ### 1. Read Template
316
+
317
+ ```bash
318
+ cat .claude/templates/product-spec.md
319
+ ```
320
+
321
+ ### 2. Analyze User Input
322
+
323
+ Think through:
324
+
325
+ ```yaml
326
+ product:
327
+ - What is the user building? (name, category)
328
+ - What problem does it solve?
329
+ - Who is it for?
330
+
331
+ entities:
332
+ - What nouns appear? (user, post, comment → entities)
333
+ - What data must be stored?
334
+ - What has lifecycle states?
335
+
336
+ behaviors:
337
+ - What verbs appear? (create, search, delete → behaviors)
338
+ - What can users do?
339
+ - What does system do automatically?
340
+
341
+ context:
342
+ - Platform? (web, mobile, desktop, CLI)
343
+ - Framework mentioned?
344
+ - Single-user or multi-user?
345
+ - Free, paid, or freemium?
346
+ ```
347
+
348
+ Then categorize each template section:
349
+
350
+ ```yaml
351
+ provided: # User gave explicit detail
352
+ inferable: # Derive using <inference_rules>
353
+ missing_critical: # Must ask — blocks generation
354
+ missing_optional: # Apply <defaults>
355
+ ```
356
+
357
+ Critical items (must ask if missing):
358
+
359
+ ```yaml
360
+ - identity.summary # What is it?
361
+ - users.primary # Who is it for?
362
+ - meta.platform # Web? Mobile? Desktop?
363
+ - behaviors # What can users do? (minimum 3)
364
+ - entities # What data exists? (minimum 1)
365
+ ```
366
+
367
+ ### 3. Ask Questions (if missing_critical exists)
368
+
369
+ ```
370
+ To generate your Product Spec, I need:
371
+
372
+ 1. [Section]: [Question]
373
+ Why: [How this affects downstream agents]
374
+ Example: [Concrete answer]
375
+ ```
376
+
377
+ Maximum 5 questions per round.
378
+
379
+ ### 4. Generate Product Spec
380
+
381
+ ```bash
382
+ mkdir -p docs
383
+ cp .claude/templates/product-spec.md docs/product-spec.md
384
+ ```
385
+
386
+ Fill in order (respects dependencies):
387
+
388
+ 1. meta, identity
389
+ 2. users, invariants
390
+ 3. entities (with examples)
391
+ 4. behaviors (with input fields and errors)
392
+ 5. permissions (entry per entity)
393
+ 6. limits (concrete numbers)
394
+ 7. integrations (if any external services)
395
+ 8. views (states matching entity states)
396
+ 9. design (apply defaults, customize personality)
397
+ 10. policies, phases (use <phase_scoping>), decisions, open, glossary
398
+
399
+ ### 5. Validate
400
+
401
+ Check each:
402
+
403
+ - [ ] Every principle has meaning + tradeoff
404
+ - [ ] Every entity has 2+ examples including edge case
405
+ - [ ] Every behavior has input fields and error cases
406
+ - [ ] Every error has message + recovery
407
+ - [ ] Permissions cover all entities
408
+ - [ ] Limits have concrete numbers (not placeholders)
409
+ - [ ] Phase 1 follows <phase_scoping> criteria
410
+
411
+ If validation fails: fix the issue, do not ask user.
412
+
413
+ ### 6. Deliver
414
+
415
+ ```
416
+ ## Product Spec Created
417
+
418
+ Location: `docs/product-spec.md`
419
+
420
+ ### Summary
421
+ - {N} entities: {names}
422
+ - {N} behaviors: {names}
423
+ - {N} views: {names}
424
+ - Phase 1: {goal}
425
+
426
+ ### Assumptions Made
427
+ - {assumption 1}
428
+ - {assumption 2}
429
+
430
+ ### Needs Review
431
+ - {section}: {why}
432
+ ```
433
+
434
+ </process_create>
435
+
436
+ <process_update>
437
+
438
+ ## UPDATE Mode
439
+
440
+ ### 1. Read Existing Spec
441
+
442
+ ```bash
443
+ cat docs/product-spec.md
444
+ ```
445
+
446
+ Parse and remember:
447
+
448
+ - All entity names and their fields
449
+ - All behavior names and their connections
450
+ - All view names and their states
451
+ - Current phase assignments
452
+
453
+ ### 2. Analyze Change Request
454
+
455
+ Think through:
456
+
457
+ ```yaml
458
+ what:
459
+ - What exactly is the user asking to change?
460
+ - Is this add/modify/remove/rename?
461
+
462
+ scope:
463
+ - Which section is primarily affected?
464
+ - What other sections reference this? (use <cascade_rules>)
465
+
466
+ impact:
467
+ - Does this change Phase 1 scope?
468
+ - Does this introduce new external dependency?
469
+ - Does this affect permissions model?
470
+ ```
471
+
472
+ Classify:
473
+
474
+ ```yaml
475
+ change_type: add | modify | remove | rename
476
+ primary_section: entities | behaviors | views | ...
477
+ cascades: [list from <cascade_rules>]
478
+ complexity: simple | complex
479
+ ```
480
+
481
+ Simple = single field change, typo fix, message update
482
+ Complex = new entity, remove feature, rename, multi-section impact
483
+
484
+ ### 3. Confirm Understanding (if complex)
485
+
486
+ For simple changes: proceed directly.
487
+
488
+ For complex changes: confirm:
489
+
490
+ ```
491
+ I understand you want to: {change description}
492
+
493
+ This will:
494
+ - {primary change}
495
+ - {cascade 1}
496
+ - {cascade 2}
497
+
498
+ Proceed?
499
+ ```
500
+
501
+ ### 4. Apply Changes
502
+
503
+ Use targeted edits (not full rewrite).
504
+
505
+ Order by dependency:
506
+
507
+ - Adding: entity → behaviors → views → permissions
508
+ - Removing: views → behaviors → permissions → entity
509
+ - Renaming: all references in single pass
510
+
511
+ ### 5. Apply Cascades
512
+
513
+ Follow <cascade_rules> deterministically.
514
+
515
+ Check each applicable rule and apply.
516
+
517
+ ### 6. Validate
518
+
519
+ Check <quality_requirements> for affected sections.
520
+ If validation fails: fix the issue.
521
+
522
+ ### 7. Update Metadata
523
+
524
+ ```yaml
525
+ meta:
526
+ version: # Increment patch (0.1 → 0.2)
527
+ updated: # Today's date
528
+ ```
529
+
530
+ Add to decisions (if significant):
531
+
532
+ ```yaml
533
+ decisions:
534
+ - id: "D-{next}"
535
+ date: "{today}"
536
+ context: "{user request}"
537
+ decision: "{what changed}"
538
+ why: "{from user or inferred}"
539
+ ```
540
+
541
+ ### 8. Deliver
542
+
543
+ ```
544
+ ## Product Spec Updated
545
+
546
+ Version: {old} → {new}
547
+
548
+ ### Changes Made
549
+
550
+ **{change_type}:**
551
+ - {section}: {item}
552
+
553
+ ### Cascades Applied
554
+ - {section}: {what was auto-updated}
555
+
556
+ ### Verify
557
+ - {section}: {why it needs attention}
558
+ ```
559
+
560
+ </process_update>
561
+
562
+ <examples>
563
+
564
+ **Example 1: Add entity**
565
+
566
+ User: "Add a Tag entity for organizing sources"
567
+
568
+ Think through:
569
+
570
+ ```yaml
571
+ what: Add new entity "Tag"
572
+ scope: entities + permissions + maybe behaviors/views
573
+ impact: Probably Phase 2 (organization feature)
574
+ ```
575
+
576
+ Apply <cascade_rules> for add_entity:
577
+
578
+ ```yaml
579
+ always:
580
+ - permissions: add Tag (create: auth, read/update/delete: owner)
581
+ - glossary: add "Tag: Label for categorizing sources"
582
+ if_user_facing: yes
583
+ - views: add tag selector to source_detail, or tag_list view
584
+ if_referenced_by_other_entity: yes (Source → Tag)
585
+ - entities.Source.relations: add many_to_many to Tag
586
+ ```
587
+
588
+ **Example 2: Simple modification**
589
+
590
+ User: "Change duplicate error message to 'You already saved this'"
591
+
592
+ Think through:
593
+
594
+ ```yaml
595
+ what: Modify error message
596
+ scope: behaviors.paste_content.errors[DUPLICATE].message only
597
+ impact: None
598
+ complexity: simple
599
+ ```
600
+
601
+ Action: Direct edit, no confirmation, no cascades.
602
+
603
+ </examples>