ystack 0.1.0

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,549 @@
1
+ ---
2
+ name: scaffold
3
+ description: >
4
+ Scaffold documentation structure from a plan. Two modes: (1) full-project — takes a
5
+ markdown plan describing all modules and their relationships, produces doc stubs, module
6
+ registry, Mermaid architecture diagrams, and Beads epics. (2) single-module — adds one
7
+ new module to an existing project. Use this skill when the user says 'scaffold',
8
+ '/scaffold', 'scaffold docs', 'scaffold project', 'set up the docs', 'add a module',
9
+ 'new module', 'scaffold module', 'turn this plan into docs', 'bootstrap project',
10
+ or provides a high-level plan they want to turn into structured documentation.
11
+ user-invocable: true
12
+ ---
13
+
14
+ # /scaffold — Scaffold Documentation from a Plan
15
+
16
+ Two modes:
17
+ - **Full project** (`/scaffold` with a project plan) — scaffold all modules for a new project
18
+ - **Single module** (`/scaffold <module-name>` in an existing project) — add one new module
19
+
20
+ **You produce structure, not detail.** Module overviews get purpose statements and feature stubs. The detail fills in later via `/docs` as features are implemented.
21
+
22
+ ---
23
+
24
+ ## Mode Detection
25
+
26
+ 1. If `ystack.config.json` exists AND the user provides a module name or a module-level plan (not a full project plan):
27
+ → **Single-module mode** (jump to [Single-Module Flow](#single-module-flow))
28
+
29
+ 2. Otherwise:
30
+ → **Full-project mode** (continue below)
31
+
32
+ ## Phase 0: Get the Plan
33
+
34
+ 1. If the user passed a file path, read it:
35
+ ```bash
36
+ cat <path-to-plan.md>
37
+ ```
38
+
39
+ 2. If the user pasted the plan inline, use that.
40
+
41
+ 3. If no plan was provided, ask:
42
+ > Provide a project plan — a markdown document describing the modules, their features,
43
+ > and how they connect. This can be rough. Example:
44
+ >
45
+ > ```markdown
46
+ > # MyApp
47
+ >
48
+ > ## Auth
49
+ > - Email/password login
50
+ > - OAuth (Google, GitHub)
51
+ > - Connects to: Database, API
52
+ >
53
+ > ## Payments
54
+ > - Stripe integration
55
+ > - Wallet with balance
56
+ > - Connects to: Auth, Database
57
+ > ```
58
+
59
+ ## Phase 1: Parse the Plan
60
+
61
+ Extract structured data from the freeform plan.
62
+
63
+ ### Extract modules
64
+
65
+ For each module, identify:
66
+ - **Name** — the module identifier (e.g., "Auth", "Payments")
67
+ - **Features** — bullet points under the module (e.g., "Email/password login", "Stripe integration")
68
+ - **Connections** — other modules this one references (from "Connects to:", "depends on", "uses", "calls", or contextual mentions)
69
+ - **Type** — classify as `app` or `package`:
70
+ - `app` = has a UI, runs as a server, or is a user-facing entry point (dashboard, API server, docs site)
71
+ - `package` = a library consumed by apps or other packages (auth, payments, database, shared types)
72
+
73
+ ### Extract system-level info
74
+
75
+ - **Project name** — from the top-level heading or first line
76
+ - **Project description** — from any introductory text before the first module
77
+ - **Cross-cutting concerns** — things mentioned as shared (database, auth, API gateway, shared types)
78
+
79
+ ### Handle ambiguity
80
+
81
+ Plans are freeform. Handle common patterns:
82
+
83
+ | Input pattern | Interpretation |
84
+ |--------------|---------------|
85
+ | `## Module Name` with bullets | Module with features |
86
+ | `### Sub-section` under a module | Sub-module (group under parent) |
87
+ | `- Connects to: X, Y` | Dependencies on modules X and Y |
88
+ | `- Uses X for Y` | Dependency on module X |
89
+ | `Database` / `DB` mentioned | Shared database package |
90
+ | `API` mentioned as a connection | API server app |
91
+ | Feature mentions another module | Implicit dependency |
92
+
93
+ If the plan structure is genuinely unclear, ask one clarifying question — don't ask five.
94
+
95
+ ### Present the parsed structure
96
+
97
+ Before generating anything, show the user what you extracted:
98
+
99
+ ```
100
+ I've parsed your plan into:
101
+
102
+ Modules (6):
103
+ apps/
104
+ api — API server (3 features)
105
+ dashboard — User dashboard (4 features)
106
+ packages/
107
+ auth — Authentication (3 features)
108
+ payments — Payment processing (2 features)
109
+ db — Database schema and client
110
+ shared — Shared types and utilities
111
+
112
+ Connections:
113
+ auth → db
114
+ payments → auth, db
115
+ dashboard → auth, payments, api
116
+ api → auth, payments, db
117
+
118
+ Does this look right? I'll generate the doc structure from this.
119
+ ```
120
+
121
+ **Wait for confirmation.**
122
+
123
+ ## Phase 2: Generate Architecture Diagram
124
+
125
+ Create a system-level Mermaid diagram showing all modules and their connections.
126
+
127
+ ### Diagram rules
128
+
129
+ - Use `graph TB` (top-to-bottom) for systems with clear layers (apps on top, packages below)
130
+ - Use `graph LR` (left-to-right) for pipeline-style systems
131
+ - Group with `subgraph`:
132
+ - `subgraph Apps` for apps
133
+ - `subgraph Packages` for packages
134
+ - Label edges with what flows between modules:
135
+ ```
136
+ auth -->|"sessions, tokens"| api
137
+ payments -->|"balance, transactions"| dashboard
138
+ ```
139
+ - If a connection type isn't clear from the plan, use a plain arrow (no label)
140
+ - Keep under 20 nodes — combine utility packages if needed
141
+ - Style future/planned nodes with dashed borders:
142
+ ```
143
+ style future_module fill:#f8f8f8,stroke:#ccc,stroke-dasharray: 5 5
144
+ ```
145
+
146
+ ### Example output
147
+
148
+ ```mermaid
149
+ graph TB
150
+ subgraph Apps
151
+ API[API Server]
152
+ DASH[Dashboard]
153
+ end
154
+
155
+ subgraph Packages
156
+ AUTH[Auth]
157
+ PAY[Payments]
158
+ DB[Database]
159
+ SHARED[Shared Types]
160
+ end
161
+
162
+ DASH -->|"pages, components"| API
163
+ API -->|"routes, middleware"| AUTH
164
+ API -->|"routes"| PAY
165
+ AUTH -->|"schemas, queries"| DB
166
+ PAY -->|"schemas, queries"| DB
167
+ PAY -->|"user identity"| AUTH
168
+ AUTH -->|"types"| SHARED
169
+ PAY -->|"types"| SHARED
170
+ ```
171
+
172
+ ## Phase 3: Generate Doc Pages
173
+
174
+ Create the documentation structure. Each module gets an overview page with stubs.
175
+
176
+ ### Docs directory structure
177
+
178
+ Read `ystack.config.json` `docs.framework` to determine the structure. If no config exists, detect from the project.
179
+
180
+ **Nextra:**
181
+ ```
182
+ docs/src/content/
183
+ ├── _meta.ts # Top-level navigation
184
+ ├── index.mdx # Project home page
185
+ ├── <module-a>/
186
+ │ ├── _meta.ts # Module navigation
187
+ │ └── index.mdx # Module overview
188
+ └── ...
189
+ ```
190
+
191
+ **Fumadocs:**
192
+ ```
193
+ content/docs/
194
+ ├── meta.json # Top-level navigation
195
+ ├── index.mdx # Project home page
196
+ ├── <module-a>/
197
+ │ ├── meta.json # Module navigation
198
+ │ └── index.mdx # Module overview
199
+ └── ...
200
+ ```
201
+
202
+ If the docs directory doesn't exist yet, note that it needs to be created with the Nextra/Fumadocs setup (handled by `npx ystack create`, not this skill).
203
+
204
+ If the docs directory already exists, merge with existing content — don't overwrite.
205
+
206
+ ### Project home page (`index.mdx`)
207
+
208
+ ```markdown
209
+ # <Project Name>
210
+
211
+ > <one-line description from the plan>
212
+
213
+ ## Architecture
214
+
215
+ ```mermaid
216
+ <the architecture diagram from Phase 2>
217
+ ```
218
+
219
+ 1. **<Module A>** — <one-sentence purpose>
220
+ 2. **<Module B>** — <one-sentence purpose>
221
+ ...
222
+
223
+ ## Modules
224
+
225
+ | Module | Type | Purpose |
226
+ |--------|------|---------|
227
+ | [**<Module A>**](/<module-a>) | app | <one sentence> |
228
+ | [**<Module B>**](/<module-b>) | package | <one sentence> |
229
+ ...
230
+ ```
231
+
232
+ ### Top-level navigation
233
+
234
+ **Nextra** (`_meta.ts`):
235
+ ```typescript
236
+ export default {
237
+ index: { title: "Home" },
238
+ "---modules": { type: "separator", title: "Modules" },
239
+ "<module-a-slug>": "<Module A Display Name>",
240
+ "<module-b-slug>": "<Module B Display Name>",
241
+ };
242
+ ```
243
+
244
+ **Fumadocs** (`meta.json`):
245
+ ```json
246
+ {
247
+ "title": "<Project Name>",
248
+ "pages": ["index", "<module-a-slug>", "<module-b-slug>"]
249
+ }
250
+ ```
251
+
252
+ Order modules logically: apps first, then packages, or by dependency order (upstream first).
253
+
254
+ ### Module overview page (`<module>/index.mdx`)
255
+
256
+ For each module, generate a stub overview:
257
+
258
+ ```markdown
259
+ # <Module Name>
260
+
261
+ > <one-sentence purpose derived from the plan>
262
+
263
+ ## Purpose
264
+
265
+ <2-3 sentences expanding on what this module does and why it exists. Derived from the plan's description and the module's features. Keep it high-level — the detail comes later.>
266
+
267
+ ## Scope
268
+
269
+ ### In Scope
270
+ <bullet list of features from the plan>
271
+
272
+ ### Out of Scope
273
+ <leave empty or add obvious exclusions based on module boundaries>
274
+
275
+ ## Dependencies
276
+
277
+ ### Needs
278
+ | Module | What this module needs |
279
+ |--------|-----------------------|
280
+ | [**<Dep A>**](/<dep-a>) | <what it uses — inferred from connections> |
281
+
282
+ ### Provides
283
+ - <what other modules consume from this one — inferred from reverse connections>
284
+
285
+ ## Sub-modules
286
+
287
+ | Sub-module | What it does |
288
+ |------------|-------------|
289
+ | <feature-stub-1> | <one sentence from plan> |
290
+ | <feature-stub-2> | <one sentence from plan> |
291
+
292
+ *Detail pages for each sub-module will be created as features are implemented.*
293
+ ```
294
+
295
+ ### Module navigation
296
+
297
+ **Nextra** (`_meta.ts`):
298
+ ```typescript
299
+ export default {
300
+ index: "Overview",
301
+ };
302
+ ```
303
+
304
+ **Fumadocs** (`meta.json`):
305
+ ```json
306
+ {
307
+ "pages": ["index"]
308
+ }
309
+ ```
310
+
311
+ Sub-module pages are NOT created yet — just the overview with a stub table. Pages get created by `/docs` as features are built and verified.
312
+
313
+ ### Writing rules for stubs
314
+
315
+ - **Purpose statements** should be concrete: "Handles Stripe integration for wallet top-ups and spend tracking" not "Manages payments"
316
+ - **Feature stubs** are one-liners from the plan — just enough to know what goes here
317
+ - **Dependencies** inferred from connections — if the plan says "Payments connects to Auth", then Payments needs Auth
318
+ - **No implementation detail** — these are design stubs, not code documentation
319
+ - **No planning language** — no "will be implemented", "planned for v1". Write as if describing the finished system: "Handles OAuth login via Google and GitHub"
320
+ - **Cross-reference every module mention** — `[Auth](/auth)` not just "Auth"
321
+
322
+ ## Phase 4: Generate Module Registry
323
+
324
+ Create `ystack.config.json`:
325
+
326
+ ```json
327
+ {
328
+ "project": "<project-name>",
329
+ "docs": {
330
+ "root": "docs/src/content",
331
+ "framework": "nextra"
332
+ },
333
+ "modules": {
334
+ "<module-a-slug>": {
335
+ "doc": "<module-a-slug>",
336
+ "scope": ["<apps-or-packages>/<module-a-slug>/**"],
337
+ "status": "planned"
338
+ },
339
+ "<module-b-slug>": {
340
+ "doc": "<module-b-slug>",
341
+ "scope": ["<apps-or-packages>/<module-b-slug>/**"],
342
+ "status": "planned"
343
+ }
344
+ }
345
+ }
346
+ ```
347
+
348
+ Notes:
349
+ - `status` starts as `"planned"` — changes to `"active"` when first feature is built
350
+ - `scope` uses glob patterns — a module can span multiple packages or be a subdirectory within one
351
+ - Sub-modules are tracked by docs (sub-pages). Features are tracked by Beads (child beads). The registry only tracks modules.
352
+ - `epic` field is added in Phase 5 after Beads creates the epics (omitted if Beads not available)
353
+ - The `doc` path is relative to `docs.root`
354
+
355
+ ## Phase 5: Create Beads Epics
356
+
357
+ If Beads (`bd`) is available:
358
+
359
+ 1. Create an epic per module:
360
+ ```bash
361
+ bd create "<Module Name>" -t epic --metadata '{"doc": "<module-slug>", "ystack": true}'
362
+ ```
363
+
364
+ 2. Create feature beads as children:
365
+ ```bash
366
+ bd create "<Feature description>" -t feature --parent <epic-id>
367
+ ```
368
+
369
+ 3. Add inter-module dependencies where features cross boundaries:
370
+ ```bash
371
+ bd dep add <feature-id> blocks:<dependent-feature-id>
372
+ ```
373
+
374
+ 4. Update `ystack.config.json` with the epic IDs:
375
+ ```json
376
+ {
377
+ "modules": {
378
+ "auth": {
379
+ "epic": "bd-a1b2",
380
+ ...
381
+ }
382
+ }
383
+ }
384
+ ```
385
+
386
+ If Beads is not available, skip this phase and note:
387
+ > Beads not detected. Module registry created without epic tracking.
388
+ > Run `bd init` and re-run `/scaffold` to add Beads integration.
389
+
390
+ ## Phase 6: Present the Result
391
+
392
+ Show the user what was generated:
393
+
394
+ ```
395
+ ## Scaffold Complete
396
+
397
+ ### Architecture
398
+ [the Mermaid diagram]
399
+
400
+ ### Docs Structure
401
+ docs/src/content/
402
+ ├── index.mdx (project overview)
403
+ ├── auth/index.mdx (3 feature stubs)
404
+ ├── payments/index.mdx (2 feature stubs)
405
+ ├── dashboard/index.mdx (4 feature stubs)
406
+ └── api/index.mdx (3 feature stubs)
407
+
408
+ ### Module Registry
409
+ ystack.config.json — 6 modules registered
410
+
411
+ ### Beads
412
+ 6 epics, 15 feature beads created
413
+ Ready front: auth/email-login, db/schema-setup (no blockers)
414
+
415
+ ### Next Steps
416
+ 1. Pick a module to start with — run `bd ready` to see what's unblocked
417
+ 2. `/build <feature>` to plan the first feature
418
+ 3. Doc pages will fill in as features are built via `/docs`
419
+ ```
420
+
421
+ ---
422
+
423
+ ## Single-Module Flow
424
+
425
+ Use this flow when adding a new module to an existing project that already has `ystack.config.json` and a docs site.
426
+
427
+ **Trigger:** `/scaffold <module-name>` or `/scaffold` with a module-level plan (not a full project plan) in a project with an existing `ystack.config.json`.
428
+
429
+ ### Step 1: Get the Module Plan
430
+
431
+ 1. If the user provided a module name with no description, ask:
432
+ > Describe the **<module-name>** module — what it does, its features, and what existing modules it connects to. Example:
433
+ >
434
+ > ```markdown
435
+ > ## Notifications
436
+ > - Email notifications (transactional, marketing)
437
+ > - Push notifications (mobile, web)
438
+ > - Notification preferences per user
439
+ > - Connects to: Auth, Payments
440
+ > ```
441
+
442
+ 2. If the user provided a description (inline or file), use that.
443
+
444
+ ### Step 2: Parse and Confirm
445
+
446
+ Extract from the module plan:
447
+ - **Name** and **slug** (e.g., "Notifications" → `notifications`)
448
+ - **Type** — `app` or `package`
449
+ - **Features** — bullet points
450
+ - **Connections** — which existing modules it connects to (verify these exist in `ystack.config.json`)
451
+
452
+ Read the existing `ystack.config.json` to understand what modules already exist.
453
+
454
+ Present:
455
+ ```
456
+ Adding module to existing project:
457
+
458
+ notifications (package) — 3 features
459
+ Connects to: auth, payments
460
+
461
+ Existing modules: auth, payments, dashboard, api, db
462
+
463
+ Proceed?
464
+ ```
465
+
466
+ **Wait for confirmation.**
467
+
468
+ ### Step 3: Create Doc Page
469
+
470
+ 1. Read the existing docs structure to find the docs root and framework.
471
+
472
+ 2. Create the module overview page using the same template as full-project mode:
473
+ - `<docs-root>/<module-slug>/index.mdx` — overview with Purpose, Scope, Dependencies, Sub-modules
474
+ - `<docs-root>/<module-slug>/_meta.ts` (Nextra) or `meta.json` (Fumadocs)
475
+
476
+ 3. Update top-level navigation to include the new module:
477
+ - Nextra: add entry to `<docs-root>/_meta.ts`
478
+ - Fumadocs: add entry to `<docs-root>/meta.json`
479
+
480
+ 4. Update the project home page (`<docs-root>/index.mdx`):
481
+ - Add the new module to the architecture Mermaid diagram (add node + connection edges)
482
+ - Add row to the modules table
483
+
484
+ ### Step 4: Update Module Registry
485
+
486
+ Read and update `ystack.config.json`:
487
+
488
+ ```json
489
+ {
490
+ "modules": {
491
+ // ... existing modules ...
492
+ "<module-slug>": {
493
+ "doc": "<module-slug>",
494
+ "scope": ["<apps-or-packages>/<module-slug>/**"],
495
+ "status": "planned"
496
+ }
497
+ }
498
+ }
499
+ ```
500
+
501
+ ### Step 5: Create Beads Epic
502
+
503
+ If Beads (`bd`) is available:
504
+
505
+ 1. Create the module epic:
506
+ ```bash
507
+ bd create "<Module Name>" -t epic --metadata '{"doc": "<module-slug>", "ystack": true}'
508
+ ```
509
+
510
+ 2. Create feature beads as children:
511
+ ```bash
512
+ bd create "<Feature description>" -t feature --parent <epic-id>
513
+ ```
514
+
515
+ 3. Add dependencies to existing module beads where connections exist.
516
+
517
+ 4. Update `ystack.config.json` with the epic ID.
518
+
519
+ ### Step 6: Present Summary
520
+
521
+ ```
522
+ ## Module Added: <Module Name>
523
+
524
+ ### Docs
525
+ <docs-root>/<module-slug>/index.mdx — overview with 3 feature stubs
526
+
527
+ ### Registry
528
+ ystack.config.json — module added (status: planned)
529
+
530
+ ### Beads
531
+ 1 epic, 3 feature beads created
532
+
533
+ ### Architecture Diagram
534
+ Updated — <module-slug> connected to auth, payments
535
+
536
+ ### Next Steps
537
+ 1. `/build <feature>` to plan the first feature in this module
538
+ 2. Doc detail will fill in as features are built via `/docs`
539
+ ```
540
+
541
+ ---
542
+
543
+ ## What This Skill Does NOT Do
544
+
545
+ - **Does not scaffold code.** No package.json, no source files, no configs. That's `npx ystack create`.
546
+ - **Does not write detailed specs.** Only stubs — purpose, scope, dependency tables. Detail comes from `/docs` after features are built.
547
+ - **Does not set up Turborepo/Nextra/Ultracite.** That's the installer's job.
548
+ - **Does not create sub-module pages.** Only module overviews with stub tables. Pages are created by `/docs` when features complete.
549
+ - **Does not make up features.** Only includes what the plan describes. If the plan is vague, the stubs are vague.