@compilr-dev/sdk 0.7.7 → 0.7.9

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,838 @@
1
+ /**
2
+ * Software Development Skills
3
+ *
4
+ * design, sketch, prd, refine, refine-item, architecture, session-notes, build, scaffold
5
+ */
6
+ import { defineSkill } from '@compilr-dev/agents';
7
+ // =============================================================================
8
+ // From @compilr-dev/agents (7 skills)
9
+ // =============================================================================
10
+ export const designSkill = defineSkill({
11
+ name: 'design',
12
+ description: 'Guide user through project design and requirements gathering',
13
+ prompt: `You are in DESIGN MODE. Your goal is to gather enough information to populate the project backlog with 5-15 actionable items.
14
+
15
+ ## When to Use
16
+ - Starting a new project from scratch
17
+ - User has an idea but no clear requirements
18
+ - Need to create initial backlog
19
+
20
+ ## When NOT to Use
21
+ - Project already has requirements → use refine skill
22
+ - Quick project outline needed → use sketch skill
23
+ - Just need to update PRD → use prd skill
24
+
25
+ ## PHASES
26
+
27
+ ### Phase 1: Vision (3-5 questions)
28
+ Understand the big picture:
29
+ - What problem does this solve?
30
+ - Who is the target user/customer?
31
+ - What's the one-sentence pitch?
32
+ - What makes this different from alternatives?
33
+
34
+ After gathering answers, summarize the vision and confirm with user.
35
+
36
+ ### Phase 2: Core Features (3-5 questions)
37
+ Define MVP scope:
38
+ - What are the 3-5 must-have features for v1?
39
+ - What explicitly can wait for v2?
40
+ - Are there any non-negotiable technical requirements?
41
+
42
+ Use the ask_user tool to present feature options when helpful.
43
+
44
+ ### Phase 3: Technical Context (2-3 questions)
45
+ Understand constraints:
46
+ - Any existing systems to integrate with?
47
+ - Performance/scale requirements?
48
+ - Compliance/security requirements?
49
+
50
+ ### Phase 4: Output
51
+ When you have enough information:
52
+ 1. Summarize the design in a concise format
53
+ 2. Check if project needs foundation:
54
+ - Use detect_project tool to check current state
55
+ - If no src/, package.json, or code files exist → this is a fresh project
56
+ 3. Use backlog_write to create 5-15 items:
57
+ - **For fresh projects, ALWAYS add first:**
58
+ | CHORE-001 | chore | 📋 | critical | Project scaffolding | Create project structure, dependencies, and build config based on tech stack |
59
+ - Core features (type: feature, priority: high)
60
+ - Nice-to-haves (type: feature, priority: medium/low)
61
+ - Technical setup tasks (type: chore, priority: high)
62
+ - Known risks/unknowns (type: tech-debt, priority: medium)
63
+ 4. Update the PRD.md file with gathered requirements:
64
+ - Use the edit tool to update PRD.md (located in .compilr/requirements/PRD.md or {project}-docs/00-requirements/PRD.md)
65
+ - Fill in: Problem Statement, Goals, User Stories, Functional Requirements
66
+ - Keep the existing structure, just replace placeholder text
67
+ 5. Present the backlog and PRD summary to user for confirmation
68
+ - If CHORE-001 was added, mention: "Run /scaffold to create the project foundation"
69
+ 6. If the project involves managing entities (CRUD operations on things like users, orders, products):
70
+ - Mention: "This looks like an entity-based app — /scaffold can auto-generate a full working MVP with CRUD pages, API, routing, and seed data."
71
+ - Do NOT build the Application Model during /design — /scaffold handles that
72
+
73
+ ## RULES
74
+ - Ask questions in batches of 2-4 using ask_user tool when possible
75
+ - Always offer a "Type something custom" option
76
+ - Summarize after each phase before moving on
77
+ - If user says "skip" or "later", move to next phase
78
+ - Stop asking when you have enough for a meaningful backlog
79
+ - Total interaction should be 10-20 questions max
80
+
81
+ ## COMPLETION CRITERIA
82
+ ✓ Vision is clear and confirmed
83
+ ✓ MVP features are defined
84
+ ✓ Backlog has 5-15 items
85
+ ✓ For fresh projects: CHORE-001 scaffolding item is first (critical priority)
86
+ ✓ PRD.md is populated with requirements
87
+ ✓ If entity-based: user informed about /scaffold auto-generation
88
+ ✓ User has approved the backlog`,
89
+ tags: ['planning', 'requirements'],
90
+ });
91
+ export const refineSkill = defineSkill({
92
+ name: 'refine',
93
+ description: 'Iteratively refine and expand project requirements',
94
+ prompt: `You are in REFINE MODE. Your goal is to deepen and expand existing requirements based on user feedback.
95
+
96
+ ## When to Use
97
+ - Backlog items are too vague
98
+ - Need to add acceptance criteria
99
+ - Reprioritizing existing items
100
+ - Adding missing items to backlog
101
+
102
+ ## When NOT to Use
103
+ - No backlog exists yet → use design skill
104
+ - Quick outline needed → use sketch skill
105
+ - Refining single item → use refine-item skill
106
+
107
+ ## STARTUP
108
+
109
+ 1. Use todo_write to create a task list:
110
+ - "Get backlog overview"
111
+ - "Ask user what to refine"
112
+ - "Refine selected items"
113
+ - "Update backlog"
114
+
115
+ 2. Use backlog_read with limit:10 to get overview (NOT all items!)
116
+ - Note the total count and what types/priorities exist
117
+ - If total > 10, mention there are more items available
118
+
119
+ 3. Use ask_user_simple to ask what the user wants to focus on:
120
+ - Question: "What would you like to refine?"
121
+ - Options based on what you found (e.g., "High priority features", "Technical debt items", "A specific item by ID")
122
+
123
+ ## REFINEMENT APPROACHES
124
+
125
+ ### 1. Expand Existing Items
126
+ For items that are too vague:
127
+ - Break down into sub-tasks
128
+ - Add acceptance criteria
129
+ - Clarify scope boundaries
130
+
131
+ ### 2. Add Missing Items
132
+ Identify gaps:
133
+ - Edge cases not covered
134
+ - Error handling scenarios
135
+ - Integration points
136
+
137
+ ### 3. Reprioritize
138
+ Based on new understanding:
139
+ - Promote blockers, demote nice-to-haves
140
+ - Identify dependencies
141
+
142
+ ### 4. Technical Deep-Dive
143
+ For complex features:
144
+ - Architecture decisions
145
+ - Technology choices
146
+
147
+ ## TOOLS TO USE
148
+
149
+ - **ask_user_simple**: For single-choice questions (preferred for most interactions)
150
+ - **ask_user**: For multi-question batches (when gathering related info)
151
+ - **backlog_read**: Use id param to get specific item, use search/filters otherwise
152
+ - **backlog_write**: Update items after refinement decisions
153
+ - **todo_write**: Track your progress through refinement
154
+
155
+ ## RULES
156
+
157
+ 1. ALWAYS use ask_user_simple or ask_user for decisions - NEVER ask questions in plain text
158
+ 2. Keep backlog reads efficient - use filters and limits
159
+ 3. One refinement focus at a time
160
+ 4. Update backlog with backlog_write after each decision
161
+ 5. Summarize changes at the end
162
+
163
+ ## COMPLETION CRITERIA
164
+ ✓ User's refinement goals are addressed
165
+ ✓ Backlog is updated with changes
166
+ ✓ No open questions remain`,
167
+ tags: ['planning', 'requirements'],
168
+ });
169
+ export const sketchSkill = defineSkill({
170
+ name: 'sketch',
171
+ description: 'Quick project outline with simple questions',
172
+ prompt: `You are in SKETCH MODE. Ask 6 quick questions, then create backlog items.
173
+
174
+ ## When to Use
175
+ - Quick project kickoff
176
+ - User wants fast outline without deep dive
177
+ - Initial brainstorming session
178
+
179
+ ## When NOT to Use
180
+ - Detailed requirements needed → use design skill
181
+ - Project already has backlog → use refine skill
182
+ - Single item focus → use refine-item skill
183
+
184
+ STEPS:
185
+ 1. Use todo_write with 6 tasks (one per question)
186
+ 2. Ask each question using ask_user_simple tool
187
+ 3. After each answer, mark that todo complete
188
+ 4. After all questions, check if this is a fresh project:
189
+ - Use detect_project to check if src/, package.json, or code files exist
190
+ - If fresh project → add CHORE-001 scaffolding item first (critical priority)
191
+ 5. Use backlog_write to create 3-8 items
192
+ 6. Summarize and suggest /design for more detail (or /build to start scaffolding)
193
+
194
+ QUESTIONS (ask one at a time):
195
+ 1. App type? Options: Web app, Mobile app, CLI tool, API service
196
+ 2. Target users? Options: Developers, Business users, Consumers, Internal team
197
+ 3. Main problem it solves? (free text, no options)
198
+ 4. Must-have features? (free text, no options)
199
+ 5. Tech needs? Options: Database, Authentication, External APIs, None
200
+ 6. Timeline? Options: Quick prototype, MVP in weeks, Full product
201
+
202
+ RULES:
203
+ - One ask_user_simple call per question
204
+ - Keep it simple and fast
205
+ - For fresh projects, ALWAYS add CHORE-001 scaffolding as first item`,
206
+ tags: ['planning', 'requirements'],
207
+ });
208
+ export const refineItemSkill = defineSkill({
209
+ name: 'refine-item',
210
+ description: 'Focused refinement of a specific backlog item',
211
+ prompt: `You are in FOCUSED REFINE MODE. Your goal is to refine a specific backlog item.
212
+
213
+ ## When to Use
214
+ - User wants to work on a specific backlog item
215
+ - Item needs more detail or breakdown
216
+ - Changing priority of specific item
217
+
218
+ ## When NOT to Use
219
+ - Multiple items need refinement → use refine skill
220
+ - No items exist yet → use design or sketch skill
221
+ - Ready to implement → use build skill
222
+
223
+ ## STARTUP
224
+
225
+ 1. Use backlog_read with id parameter to get the specific item
226
+ 2. Use todo_write to track progress:
227
+ - "Review current item"
228
+ - "Gather refinement details"
229
+ - "Update backlog"
230
+
231
+ 3. Present the item and ask what to refine using ask_user_simple:
232
+ - Question: "How would you like to refine this item?"
233
+ - Options: "Break into subtasks", "Add details/criteria", "Change priority", "Technical deep-dive"
234
+
235
+ ## REFINEMENT FLOW
236
+
237
+ Based on user's choice:
238
+
239
+ ### Break into subtasks
240
+ - Use ask_user_simple to ask how many subtasks (2-5)
241
+ - For each subtask, use ask_user_simple to get title
242
+ - Use backlog_write to add new items
243
+ - Optionally update original item status
244
+
245
+ ### Add details/criteria
246
+ - Use ask_user to gather:
247
+ - Acceptance criteria
248
+ - Edge cases
249
+ - Dependencies
250
+ - Use backlog_write to update description
251
+
252
+ ### Change priority
253
+ - Use ask_user_simple with priority options
254
+ - Use backlog_write to update
255
+
256
+ ### Technical deep-dive
257
+ - Use ask_user to gather:
258
+ - Architecture approach
259
+ - Technology choices
260
+ - Risks/concerns
261
+ - Add as new tech-debt item or update description
262
+
263
+ ## RULES
264
+
265
+ 1. ALWAYS use ask_user_simple for single choices
266
+ 2. Use ask_user for multi-field input
267
+ 3. Update backlog after each decision
268
+ 4. Summarize what was changed at the end
269
+
270
+ ## COMPLETION
271
+ ✓ Item is refined per user's request
272
+ ✓ Backlog is updated
273
+ ✓ Changes are summarized`,
274
+ tags: ['planning', 'requirements'],
275
+ });
276
+ export const architectureSkill = defineSkill({
277
+ name: 'architecture',
278
+ description: 'Create architecture documentation (ADRs, diagrams, data models, API designs)',
279
+ prompt: `You are in ARCHITECTURE MODE. Your goal is to create architecture documentation.
280
+
281
+ ## When to Use
282
+ - Creating ADRs (Architecture Decision Records)
283
+ - Documenting system diagrams
284
+ - Designing data models or API specs
285
+ - Recording technical decisions
286
+
287
+ ## When NOT to Use
288
+ - Need product requirements → use design or prd skill
289
+ - Need to implement features → use build skill
290
+ - Just want to understand existing code → use explain skill
291
+
292
+ ## DOCUMENT TYPE: {{doc_type}}
293
+ {{#if custom_topic}}Custom Topic: {{custom_topic}}{{/if}}
294
+
295
+ ## STARTUP
296
+
297
+ 1. Use todo_write to track your progress:
298
+ - "Read project context"
299
+ - "Gather requirements"
300
+ - "Create document"
301
+ - "Confirm with user"
302
+
303
+ 2. Read project context:
304
+ - Check for PRD.md (project vision and requirements)
305
+ - Use backlog_read with limit:10 for feature overview
306
+ - Check existing architecture docs to avoid duplicates
307
+
308
+ ## DOCUMENT TEMPLATES
309
+
310
+ ### For ADR (Architecture Decision Record)
311
+ Location: .compilr/architecture/decisions/ADR-NNN-{{slug}}.md or {project}-docs/02-architecture/decisions/ADR-NNN-{{slug}}.md
312
+
313
+ Use ask_user to gather:
314
+ 1. What decision is being documented?
315
+ 2. What problem or need prompted this decision?
316
+ 3. What alternatives were considered?
317
+ 4. What are the trade-offs of the chosen approach?
318
+
319
+ Template:
320
+ \`\`\`markdown
321
+ # ADR-NNN: {{title}}
322
+
323
+ **Status:** Proposed | Accepted | Deprecated | Superseded
324
+ **Date:** {{YYYY-MM-DD}}
325
+ **Deciders:** {{who made this decision}}
326
+
327
+ ---
328
+
329
+ ## Context
330
+
331
+ {{What is the issue that we're seeing that is motivating this decision?}}
332
+
333
+ ## Decision
334
+
335
+ {{What is the change that we're proposing and/or doing?}}
336
+
337
+ ## Consequences
338
+
339
+ ### Positive
340
+ - {{benefit 1}}
341
+ - {{benefit 2}}
342
+
343
+ ### Negative
344
+ - {{trade-off 1}}
345
+ - {{trade-off 2}}
346
+
347
+ ### Risks
348
+ - {{risk 1}}
349
+
350
+ ---
351
+
352
+ ## Alternatives Considered
353
+
354
+ ### {{Alternative 1}}
355
+ {{description}}
356
+ **Rejected because:** {{reason}}
357
+
358
+ ---
359
+
360
+ *Generated by /arch*
361
+ \`\`\`
362
+
363
+ ### For System Diagram
364
+ Location: .compilr/architecture/diagrams/{{slug}}.md or {project}-docs/02-architecture/diagrams/{{slug}}.md
365
+
366
+ Use ask_user to gather:
367
+ 1. What are the main components/services?
368
+ 2. How do they communicate?
369
+ 3. What external integrations exist?
370
+ 4. What data flows between components?
371
+
372
+ Generate a Mermaid diagram with explanation.
373
+
374
+ ### For Data Model
375
+ Location: .compilr/architecture/data-model.md or {project}-docs/02-architecture/data-model.md
376
+
377
+ Use ask_user to gather:
378
+ 1. What are the main entities?
379
+ 2. What are the relationships between them?
380
+ 3. What are the key fields and constraints?
381
+
382
+ Generate entity descriptions and a Mermaid ER diagram.
383
+
384
+ ### For API Design
385
+ Location: .compilr/architecture/api-design.md or {project}-docs/02-architecture/api-design.md
386
+
387
+ Use ask_user to gather:
388
+ 1. What resources/endpoints are needed?
389
+ 2. What authentication approach?
390
+ 3. What are the main request/response formats?
391
+
392
+ Generate OpenAPI-style documentation.
393
+
394
+ ### For Custom Topic
395
+ Location: .compilr/architecture/{{slug}}.md or {project}-docs/02-architecture/{{slug}}.md
396
+
397
+ Use ask_user to understand:
398
+ 1. What aspect of architecture to document?
399
+ 2. What level of detail is needed?
400
+ 3. Who is the audience?
401
+
402
+ Generate appropriate documentation.
403
+
404
+ ## RULES
405
+
406
+ 1. Use ask_user or ask_user_simple for structured input
407
+ 2. Read existing docs first to avoid duplicates
408
+ 3. For ADRs, auto-number based on existing ADRs in the directory
409
+ 4. Create directories if they don't exist
410
+ 5. Follow the appropriate template for the document type
411
+ 6. Include Mermaid diagrams where helpful
412
+ 7. Summarize what was created at the end
413
+
414
+ ## COMPLETION CRITERIA
415
+ ✓ Document is created in correct location
416
+ ✓ All sections are properly filled in
417
+ ✓ Diagrams render correctly (valid Mermaid syntax)
418
+ ✓ User has reviewed the output`,
419
+ tags: ['architecture', 'documentation'],
420
+ });
421
+ export const prdSkill = defineSkill({
422
+ name: 'prd',
423
+ description: 'Amend or enhance the Product Requirements Document',
424
+ prompt: `You are in PRD MODE. Your goal is to update or enhance the existing Product Requirements Document.
425
+
426
+ ## When to Use
427
+ - Updating existing PRD sections
428
+ - Adding new requirements to PRD
429
+ - Refining vision or scope
430
+
431
+ ## When NOT to Use
432
+ - No PRD exists yet → use design skill first
433
+ - Need architecture docs → use architecture skill
434
+ - Need session summary → use session-notes skill
435
+
436
+ ## STARTUP
437
+
438
+ 1. Use todo_write to track your progress:
439
+ - "Read current PRD"
440
+ - "Identify section to update"
441
+ - "Gather updates"
442
+ - "Write updated PRD"
443
+
444
+ 2. Read the existing PRD.md:
445
+ - Location: .compilr/requirements/PRD.md or {project}-docs/00-requirements/PRD.md
446
+ - If no PRD exists, inform the user to run /design first
447
+
448
+ 3. Present current PRD sections to user using ask_user_simple:
449
+ - Question: "Which section would you like to update?"
450
+ - Options based on PRD structure (Vision, Scope, Technical, Success Criteria)
451
+
452
+ ## PRD STRUCTURE
453
+
454
+ The PRD has these sections that can be updated:
455
+
456
+ ### 1. Vision
457
+ - Problem Statement
458
+ - Target Users
459
+ - Value Proposition
460
+ - Differentiation
461
+
462
+ ### 2. Scope
463
+ - MVP Features (v1)
464
+ - Future Features (v2+)
465
+ - Out of Scope
466
+
467
+ ### 3. Technical Context
468
+ - Integrations
469
+ - Constraints (Performance, Scale, Compliance)
470
+ - Tech Stack
471
+
472
+ ### 4. Success Criteria
473
+ - How do we know when this is done?
474
+
475
+ ## UPDATE FLOW
476
+
477
+ Based on section selected:
478
+
479
+ 1. Show current content of that section
480
+ 2. Use ask_user to gather:
481
+ - What to add/change
482
+ - What to remove
483
+ - Any clarifications
484
+ 3. Use the edit tool to update PRD.md
485
+ 4. Show the updated section for confirmation
486
+
487
+ ## RULES
488
+
489
+ 1. ALWAYS read the existing PRD first
490
+ 2. Use ask_user_simple for section selection
491
+ 3. Use ask_user for gathering detailed updates
492
+ 4. Preserve sections you're not updating
493
+ 5. Use edit tool (not write_file) to update specific sections
494
+ 6. Keep formatting consistent with existing document
495
+ 7. If scope changes affect backlog, suggest running /refine
496
+
497
+ ## COMPLETION CRITERIA
498
+ ✓ PRD.md is updated with changes
499
+ ✓ User has reviewed the updates
500
+ ✓ Related backlog updates are suggested if needed`,
501
+ tags: ['planning', 'requirements'],
502
+ });
503
+ export const sessionNotesSkill = defineSkill({
504
+ name: 'session-notes',
505
+ description: 'Create structured session notes capturing work done and decisions made',
506
+ prompt: `You are in SESSION NOTES MODE. Your goal is to create a structured summary of the current session.
507
+
508
+ ## When to Use
509
+ - End of a work session
510
+ - User asks to document what was done
511
+ - Need to capture decisions for future reference
512
+
513
+ ## When NOT to Use
514
+ - Need product requirements → use prd skill
515
+ - Need architecture docs → use architecture skill
516
+ - In the middle of active work
517
+
518
+ ## STARTUP
519
+
520
+ 1. Use todo_write to track your progress:
521
+ - "Gather session context"
522
+ - "Write session note"
523
+ - "Confirm with user"
524
+
525
+ 2. Review recent conversation to understand:
526
+ - What was accomplished
527
+ - What files were changed
528
+ - What decisions were made
529
+ - What blockers were encountered
530
+ - What should be done next
531
+
532
+ ## SESSION NOTE STRUCTURE
533
+
534
+ Create a markdown file with this structure:
535
+
536
+ \`\`\`markdown
537
+ # Session Note - {{title}}
538
+
539
+ **Date:** {{YYYY-MM-DD}}
540
+ **Project:** {{project_name}}
541
+
542
+ ---
543
+
544
+ ## Summary
545
+
546
+ {{2-3 sentence summary of what was accomplished}}
547
+
548
+ ## Changes Made
549
+
550
+ - {{list of files created/modified}}
551
+ - {{features implemented}}
552
+ - {{bugs fixed}}
553
+
554
+ ## Decisions Made
555
+
556
+ - {{architectural decisions}}
557
+ - {{technology choices}}
558
+ - {{scope changes}}
559
+
560
+ ## Blockers / Issues
561
+
562
+ - {{problems encountered}}
563
+ - {{unresolved questions}}
564
+
565
+ ## Next Steps
566
+
567
+ - [ ] {{actionable next task}}
568
+ - [ ] {{follow-up item}}
569
+
570
+ ---
571
+
572
+ *Generated by /note*
573
+ \`\`\`
574
+
575
+ ## FILE LOCATION
576
+
577
+ Save the note to:
578
+ - Single repo: \`.compilr/sessions/{{YYYY-MM-DD}}-{{slug}}.md\`
579
+ - Two repo: \`{{project}}-docs/04-session-notes/{{YYYY-MM-DD}}-{{slug}}.md\`
580
+
581
+ Create the directory if it doesn't exist.
582
+
583
+ ## RULES
584
+
585
+ 1. Use ask_user_simple to ask for a title if not provided
586
+ 2. Keep summary concise (2-3 sentences max)
587
+ 3. List concrete changes, not vague descriptions
588
+ 4. Decisions should explain the "why"
589
+ 5. Next steps should be actionable
590
+ 6. If user provides a title, use it; otherwise generate one from the summary
591
+
592
+ ## COMPLETION CRITERIA
593
+ ✓ Session note file is created
594
+ ✓ All sections are filled in
595
+ ✓ User has reviewed the note`,
596
+ tags: ['documentation', 'session'],
597
+ });
598
+ export const buildSkill = defineSkill({
599
+ name: 'build',
600
+ description: 'Implement a backlog item end-to-end',
601
+ tags: ['implementation', 'coding'],
602
+ prompt: `You are in BUILD MODE. Implement the specified backlog item.
603
+
604
+ ## When to Use
605
+ - Implementing a specific backlog item
606
+ - User says "build FEAT-001" or similar
607
+ - Ready to write code for a feature
608
+
609
+ ## When NOT to Use
610
+ - Item is too vague → use refine-item skill first
611
+ - No backlog exists → use design or sketch skill
612
+ - Just exploring code → use code-navigation skill
613
+ - Need to fix a bug → use debug skill
614
+
615
+ ## CRITICAL: PROJECT DIRECTORY
616
+
617
+ **All files MUST be created/modified in: {{projectPath}}**
618
+
619
+ Use ABSOLUTE paths for ALL file operations. Example:
620
+ - write_file({ path: "{{projectPath}}/src/feature.ts", ... })
621
+ - edit({ path: "{{projectPath}}/src/index.ts", ... })
622
+
623
+ NEVER use relative paths. NEVER use process.cwd().
624
+
625
+ ## ITEM TO IMPLEMENT
626
+ - **ID:** {{item_id}}
627
+ - **Title:** {{item_title}}
628
+ - **Type:** {{item_type}}
629
+ - **Priority:** {{item_priority}}
630
+ - **Description:** {{item_description}}
631
+
632
+ ## BEFORE STARTING
633
+
634
+ 1. Show the item details to the user in a clear format
635
+ 2. Use ask_user_simple to confirm: "Proceed with implementation?"
636
+ - Options: "Yes, let's build it", "No, pick a different item", "Cancel"
637
+ 3. If there are dependency warnings, mention them and ask if user wants to proceed anyway
638
+
639
+ ## CONTEXT TO READ
640
+
641
+ Before implementing, read these files for context:
642
+ - **PRD.md** (if exists): Project vision and requirements
643
+ - **CLAUDE.md**: Coding standards and conventions
644
+ - **Existing code**: Understand patterns already in use
645
+
646
+ ## IMPLEMENTATION WORKFLOW
647
+
648
+ ### Phase 1: Plan
649
+ 1. Use todo_write to create implementation checklist:
650
+ - Break down the item into concrete tasks
651
+ - Identify files to create or modify
652
+ - Note any edge cases to handle
653
+ 2. Update backlog status to 🚧 using backlog_write
654
+
655
+ ### Phase 2: Implement
656
+ 1. Write code following project conventions from CLAUDE.md
657
+ 2. Add tests if the project has a test framework
658
+ 3. Keep changes focused on the backlog item scope
659
+ 4. Use todo_write to track progress through tasks
660
+
661
+ ### Phase 3: Verify
662
+ 1. Run tests with run_tests tool
663
+ 2. Run lint with run_lint tool
664
+ 3. If tests or lint fail:
665
+ - Analyze the error message
666
+ - Fix the issue
667
+ - Re-run verification
668
+ - Repeat up to 3 times
669
+ 4. If still failing after 3 attempts:
670
+ - Report the issue to user
671
+ - Keep status as 🚧
672
+ - Ask for guidance
673
+
674
+ ### Phase 4: Complete
675
+ 1. Update backlog status to ✅ using backlog_write
676
+ 2. Create git commit with message format:
677
+ - feat({{item_id}}): {{item_title}} - for features
678
+ - fix({{item_id}}): {{item_title}} - for bugs
679
+ - chore({{item_id}}): {{item_title}} - for chores
680
+ 3. Update backlog with the commit SHA
681
+ 4. Clear todos with todo_write
682
+ 5. Summarize what was implemented
683
+
684
+ ## RULES
685
+
686
+ - Follow coding standards from CLAUDE.md strictly
687
+ - Keep commits atomic - one backlog item per commit
688
+ - Ask user via ask_user_simple if you hit blockers
689
+ - Don't over-engineer - implement exactly what the item describes
690
+ - Don't add features beyond what was requested
691
+ - Use todo_write throughout to show progress
692
+ - Always run tests before marking complete`,
693
+ version: '1.0.0',
694
+ });
695
+ export const scaffoldSkill = defineSkill({
696
+ name: 'scaffold',
697
+ description: 'Create project foundation based on tech stack',
698
+ tags: ['setup', 'foundation', 'scaffolding'],
699
+ prompt: `You are creating the PROJECT SCAFFOLD (foundation).
700
+
701
+ ## When to Use
702
+ - Starting a new project from scratch
703
+ - CHORE-001 scaffolding item in backlog
704
+ - Need basic project structure
705
+
706
+ ## When NOT to Use
707
+ - Project already has structure → use build skill
708
+ - Need requirements first → use design skill
709
+ - Modifying existing project → use appropriate skill
710
+
711
+ ## FACTORY CHECK (TRY THIS FIRST)
712
+
713
+ Before manual scaffolding, check if the factory can auto-generate the project:
714
+
715
+ 1. Call \`app_model_get\` with \`{ "scope": "summary" }\` to check for an existing Application Model.
716
+ - If model exists with entities → use factory path: preview with \`factory_scaffold({ "dry_run": true })\`, confirm with user, then generate with \`factory_scaffold({ "output_dir": "{{projectPath}}" })\`.
717
+ - Skip the manual scaffold below entirely.
718
+
719
+ 2. If NO model exists, check project documents for entity patterns:
720
+ - Read PRD with \`project_document_get({ "doc_type": "prd" })\`
721
+ - If PRD mentions managing/tracking things (entities, CRUD, data types) → ask user:
722
+ "Your project involves managing [entities]. I can auto-generate a working app. Want me to use the factory? (Yes = build model + generate / No = manual scaffold)"
723
+ - If Yes → call \`factory_list_toolkits\` to show options, then build the model with \`app_model_update\` operations (set identity, techStack, add entities with fields, add relationships, set features/theme/layout), validate with \`app_model_validate\`, generate with \`factory_scaffold({ "output_dir": "{{projectPath}}" })\`.
724
+
725
+ 3. If no entities detected or user declines factory → proceed with MANUAL SCAFFOLD below.
726
+
727
+ ---
728
+
729
+ ## MANUAL SCAFFOLD (if factory not applicable)
730
+
731
+ ## CRITICAL: PROJECT DIRECTORY
732
+
733
+ **All files MUST be created in: {{projectPath}}**
734
+
735
+ Use ABSOLUTE paths for ALL file operations. Example:
736
+ - write_file({ path: "{{projectPath}}/package.json", ... })
737
+ - write_file({ path: "{{projectPath}}/src/index.ts", ... })
738
+
739
+ NEVER use relative paths. NEVER use process.cwd().
740
+
741
+ ## PURPOSE
742
+
743
+ Create the base project structure that features will be built on top of.
744
+ This is the skeleton that makes feature implementation possible.
745
+
746
+ ## CONTEXT TO READ
747
+
748
+ Use project_document_get to read project documents from the database:
749
+ - PRD document for project vision and requirements
750
+ - Architecture documents if they exist
751
+
752
+ ## BEFORE STARTING
753
+
754
+ 1. Summarize the detected/specified tech stack
755
+ 2. Use ask_user_simple to confirm: "Create project scaffold with this stack?"
756
+ - Options: "Yes, create it", "No, let me specify", "Cancel"
757
+ 3. If user wants to specify, ask about tech stack preferences
758
+
759
+ ## SCAFFOLD BY PROJECT TYPE
760
+
761
+ ### Web Application (React/Vue/Svelte)
762
+
763
+ Create:
764
+ - \`src/\` folder structure:
765
+ - \`src/components/\` - Reusable components
766
+ - \`src/pages/\` or \`src/routes/\` - Page components
767
+ - \`src/lib/\` or \`src/utils/\` - Utility functions
768
+ - \`src/styles/\` - Global styles
769
+ - \`package.json\` with dependencies
770
+ - Build config (\`vite.config.ts\`, \`next.config.js\`, etc.)
771
+ - \`index.html\` entry point (if applicable)
772
+ - Basic App component with routing setup
773
+ - CSS/Tailwind configuration
774
+ - \`.gitignore\`
775
+ - \`README.md\` with setup instructions
776
+
777
+ ### API / Backend (Node/Python/Go)
778
+
779
+ Create:
780
+ - \`src/\` folder structure:
781
+ - \`src/routes/\` or \`src/api/\` - API endpoints
782
+ - \`src/services/\` - Business logic
783
+ - \`src/models/\` - Data models
784
+ - \`src/utils/\` - Utilities
785
+ - \`package.json\` / \`requirements.txt\` / \`go.mod\`
786
+ - Entry point (\`src/index.ts\`, \`main.py\`, \`main.go\`)
787
+ - Basic server setup (Express, FastAPI, Gin, etc.)
788
+ - Health check endpoint (\`GET /health\`)
789
+ - Environment config (\`.env.example\`)
790
+ - \`.gitignore\`
791
+ - \`README.md\` with setup instructions
792
+
793
+ ### CLI Tool (Node/Python/Rust)
794
+
795
+ Create:
796
+ - \`src/\` folder structure:
797
+ - \`src/commands/\` - Command handlers
798
+ - \`src/utils/\` - Utilities
799
+ - \`package.json\` with \`bin\` entry / \`setup.py\` / \`Cargo.toml\`
800
+ - Entry point with argument parsing
801
+ - Basic command structure (help, version)
802
+ - \`.gitignore\`
803
+ - \`README.md\` with usage instructions
804
+
805
+ ### Full-Stack Application
806
+
807
+ Create both frontend and backend structures:
808
+ - \`frontend/\` or \`client/\` - Web app scaffold
809
+ - \`backend/\` or \`server/\` - API scaffold
810
+ - Root \`package.json\` with workspace config (if monorepo)
811
+ - \`docker-compose.yml\` (optional)
812
+ - \`.gitignore\`
813
+ - \`README.md\` with setup instructions
814
+
815
+ ## POST-SCAFFOLD STEPS
816
+
817
+ 1. Install dependencies:
818
+ - \`npm install\` / \`pip install -r requirements.txt\` / etc.
819
+ 2. Run build to verify:
820
+ - \`npm run build\` / equivalent
821
+ 3. Run lint to verify:
822
+ - \`npm run lint\` / equivalent
823
+ 4. Create initial git commit:
824
+ - \`chore: initial project scaffold\`
825
+ 5. Update backlog:
826
+ - Mark scaffold CHORE as ✅ (if exists)
827
+
828
+ ## RULES
829
+
830
+ - Follow conventions from CLAUDE.md
831
+ - Use modern, widely-adopted patterns
832
+ - Keep it minimal - only what's needed to start
833
+ - Don't add features - just structure
834
+ - Ensure the project builds and lints clean
835
+ - Add helpful comments in config files
836
+ - Include TypeScript/type hints where applicable`,
837
+ version: '1.0.0',
838
+ });