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,246 @@
1
+ ---
2
+ name: build
3
+ description: >
4
+ Plan a feature by reading documentation and code, surfacing assumptions, capturing
5
+ decisions, and creating an execution plan with goal-backward success criteria. Use this
6
+ skill when the user says 'build', '/build', 'implement', 'add feature', 'plan feature',
7
+ 'I want to build', 'let me build', 'work on', or describes a feature they want to implement.
8
+ This is the entry point for the ystack workflow — it produces a PLAN.md that /go executes.
9
+ user-invocable: true
10
+ ---
11
+
12
+ # /build — Plan a Feature
13
+
14
+ You are the planning phase of the ystack agent harness. Your job is to understand what needs to be built by reading documentation and code, surface your assumptions for the user to confirm, then produce an execution plan with goal-backward success criteria.
15
+
16
+ **You do NOT write code.** You produce a plan that `/go` will execute.
17
+
18
+ ## Phase 0: Locate the Module
19
+
20
+ Identify which module(s) this feature belongs to.
21
+
22
+ 1. Read `ystack.config.json` if it exists. Match the feature to a module by checking `scope` globs:
23
+ ```bash
24
+ cat ystack.config.json
25
+ ```
26
+
27
+ 2. If no config exists or no match found, scan the docs directory structure:
28
+ ```bash
29
+ # Find docs root — check common locations
30
+ # Nextra: docs/src/content/
31
+ # Fumadocs: content/docs/
32
+ ls docs/src/content/_meta.ts 2>/dev/null || ls content/docs/meta.json 2>/dev/null || ls docs/_meta.ts 2>/dev/null
33
+ ```
34
+
35
+ 3. Read the navigation config to understand what modules exist:
36
+ - Nextra: `_meta.ts` files (object keys = sidebar order)
37
+ - Fumadocs: `meta.json` files or frontmatter-based ordering
38
+
39
+ 4. Match the user's feature description to a module. If ambiguous, ask:
40
+ > This could belong to **Payments** or **Managed Ads**. Which module should this feature live in?
41
+
42
+ 5. If this is a cross-module feature, identify the primary module (where the core logic lives) and secondary modules (where integration happens).
43
+
44
+ ## Phase 1: Read the Spec
45
+
46
+ Read the module's documentation page to understand the current design.
47
+
48
+ 1. **Read the module overview** — the `index.mdx` file for the matched module:
49
+ ```
50
+ docs/src/content/<module>/index.mdx
51
+ ```
52
+ Extract: Purpose, Scope (in/out), Sub-modules, Dependencies (needs/provides), Key Contracts.
53
+
54
+ 2. **Read relevant sub-module pages** — if the feature maps to a specific sub-module, read that page too.
55
+
56
+ 3. **Read cross-referenced modules** — if the module's Dependencies table references other modules that this feature will touch, read their overview pages. Follow the cross-reference links in the docs.
57
+
58
+ 4. **Read the contributor guidance** — check if there are relevant conventions:
59
+ - `docs/src/content/contributing/index.mdx` for golden rules
60
+ - Module-specific conventions if they exist
61
+
62
+ **Important:** Read the actual files. Do not guess what docs contain based on file names. The docs are the spec — they tell you what the system IS.
63
+
64
+ ## Phase 2: Read the Code
65
+
66
+ Read the relevant source code to understand the current implementation.
67
+
68
+ 1. **Identify code packages** from the module registry or `CLAUDE.md` Structure section.
69
+
70
+ 2. **Read key files** — focus on:
71
+ - Schema files (database tables, types)
72
+ - API routes (endpoints, request/response shapes)
73
+ - Public interfaces (exported functions, tool definitions)
74
+ - Existing tests (what's already tested)
75
+
76
+ 3. **Do NOT read everything.** Read only what's relevant to the feature. Use the docs to guide which code matters — if the docs say "Payments uses Stripe Customer Balance", read the Stripe integration code, not the entire payments package.
77
+
78
+ ## Phase 3: Surface Assumptions
79
+
80
+ Present your understanding of how to build this feature. Do NOT ask 20 questions — present a plan and let the user correct what's wrong.
81
+
82
+ Format your assumptions as:
83
+
84
+ ```
85
+ Based on the docs and code, here's how I'd approach this:
86
+
87
+ 1. [First concrete step with specific files/tables/endpoints]
88
+ 2. [Second step]
89
+ 3. [Third step]
90
+
91
+ **Assumptions:**
92
+ - [Specific technical assumption — e.g., "Column goes on the `transactions` table, not a new table"]
93
+ - [Design assumption — e.g., "Enum values: duplicate, fraud, requested, other"]
94
+ - [Scope assumption — e.g., "Admin detail view only, not the list view"]
95
+
96
+ **Out of scope** (deferring these):
97
+ - [Thing that's related but not part of this feature]
98
+
99
+ Correct anything that's wrong, or confirm to proceed.
100
+ ```
101
+
102
+ **Rules for assumptions:**
103
+ - Be specific, not vague. "Add a column to the transactions table" not "update the database".
104
+ - Reference actual file paths from the code you read.
105
+ - Reference actual doc sections that inform your approach.
106
+ - If the docs explicitly define a contract or scope boundary, follow it — don't assume differently.
107
+ - If something is listed as "Out of Scope" in the module docs, it's out of scope for this feature too.
108
+
109
+ **Wait for the user to confirm or correct before proceeding to Phase 4.**
110
+
111
+ ## Phase 4: Capture Decisions
112
+
113
+ After the user confirms (or corrects) your assumptions, write the decisions file.
114
+
115
+ Create the directory and file:
116
+ ```
117
+ .context/<feature-id>/DECISIONS.md
118
+ ```
119
+
120
+ Use a short, descriptive ID for the feature (e.g., `refund-reason`, `oauth-support`, `dashboard-charts`). If Beads is available (`bd` CLI), use the bead ID instead.
121
+
122
+ **DECISIONS.md format:**
123
+
124
+ ```markdown
125
+ # Decisions: <Feature Name>
126
+
127
+ ## Module
128
+ <primary module> (+ secondary modules if cross-module)
129
+
130
+ ## Locked
131
+ - [Decision 1 — specific, actionable]
132
+ - [Decision 2]
133
+ - [Decision 3]
134
+
135
+ ## Claude's Discretion
136
+ - [Things the agent can decide — naming, file organization, minor implementation details]
137
+
138
+ ## Deferred
139
+ - [Related work explicitly not part of this feature]
140
+
141
+ ## References
142
+ - [Doc page read: docs/src/content/<module>/index.mdx]
143
+ - [Doc page read: docs/src/content/<module>/<sub>.mdx]
144
+ - [Code read: packages/<module>/src/<file>.ts]
145
+ ```
146
+
147
+ ## Phase 5: Create the Plan
148
+
149
+ Write an execution plan with goal-backward success criteria.
150
+
151
+ Create:
152
+ ```
153
+ .context/<feature-id>/PLAN.md
154
+ ```
155
+
156
+ **PLAN.md format:**
157
+
158
+ ```markdown
159
+ # Plan: <Feature Name>
160
+
161
+ ## Success Criteria
162
+
163
+ What must be TRUE in the codebase when this feature is done. Each criterion is independently verifiable — a grep, a typecheck, a file existence check, or a test run.
164
+
165
+ - [ ] [Criterion 1 — specific and checkable, e.g., "`refundReason` column exists on `transactions` table"]
166
+ - [ ] [Criterion 2 — e.g., "POST /api/payments/refund accepts `reason` field and validates with Zod"]
167
+ - [ ] [Criterion 3 — e.g., "Admin transaction detail page renders `RefundReasonBadge` component"]
168
+ - [ ] [Criterion 4 — e.g., "Types exported from `@acme/shared`"]
169
+
170
+ ## Tasks
171
+
172
+ ### task-1: <Short description>
173
+ **Files:** [list of files to read and modify]
174
+ **Do:** [What to implement — specific enough that a fresh agent with no prior context can do it]
175
+ **Verify:** [How to check this task is done — e.g., "pnpm typecheck passes", "column exists in schema"]
176
+
177
+ ### task-2: <Short description>
178
+ **Files:** [list of files]
179
+ **Do:** [What to implement]
180
+ **Verify:** [How to check]
181
+ **Depends on:** task-1
182
+
183
+ ### task-3: <Short description>
184
+ **Files:** [list of files]
185
+ **Do:** [What to implement]
186
+ **Verify:** [How to check]
187
+ **Depends on:** task-1, task-2
188
+ ```
189
+
190
+ **Rules for plans:**
191
+
192
+ 1. **2-4 tasks.** If you need more, the feature should be split. Each task must fit in a fresh agent context.
193
+
194
+ 2. **File targets are explicit.** Every task lists exactly which files to read and modify. A fresh agent with no prior context should know exactly where to look.
195
+
196
+ 3. **Verification is concrete.** Not "verify it works" — rather "run `pnpm typecheck` and confirm no errors" or "grep for `refundReason` in `schema.ts`".
197
+
198
+ 4. **Dependencies are explicit.** If task-3 needs types from task-1, say so. Tasks without dependencies can run in parallel.
199
+
200
+ 5. **No scope reduction.** Every locked decision from DECISIONS.md must be covered by at least one task. If a decision can't be delivered, STOP and tell the user — don't silently simplify.
201
+
202
+ 6. **Each task produces a commit.** The task description should correspond to a single atomic commit. "Add column and update 3 API endpoints and redesign the UI" is too big.
203
+
204
+ 7. **Reference the docs.** If a task implements something described in the docs (a contract, a data model, an API shape), reference the doc page so the executor can read it.
205
+
206
+ ## Phase 6: Plan Check
207
+
208
+ Before presenting the plan to the user, self-check:
209
+
210
+ 1. **Coverage check:** Read DECISIONS.md. For each locked decision, confirm at least one task delivers it. If any decision is uncovered, add a task or flag the gap.
211
+
212
+ 2. **Scope reduction check:** Re-read your plan. Are you delivering exactly what was decided, or a simplified version? Look for red flags:
213
+ - "Simplified version" / "basic implementation" / "v1" / "placeholder"
214
+ - Missing a decision from the locked list
215
+ - A task that says "will be wired later" or "can be added in a follow-up"
216
+ If any of these appear, revise the plan or split into phases.
217
+
218
+ 3. **Size check:** Each task should touch 1-5 files. If a task lists more than 5 files, split it.
219
+
220
+ 4. **Fresh agent test:** For each task, ask: "Could a fresh agent with no conversation history execute this task from the description alone?" If not, add more detail to the task description.
221
+
222
+ ## Phase 7: Present the Plan
223
+
224
+ Show the user:
225
+
226
+ 1. The success criteria (what will be TRUE when done)
227
+ 2. The task breakdown (what each task does, in what order)
228
+ 3. Total number of tasks and estimated commits
229
+
230
+ Ask:
231
+ > Plan ready. Review the success criteria and tasks above. Confirm to proceed, or let me know what to adjust.
232
+
233
+ **Small task detection:** If the plan has only 1 task touching 3 or fewer files, offer:
234
+ > This is a small change. Want me to just do it now? (Skips /go, executes inline.)
235
+
236
+ If the user confirms inline execution, execute the single task directly — make the changes, run the verification step, and commit. No need for `/go`.
237
+
238
+ ---
239
+
240
+ ## What This Skill Does NOT Do
241
+
242
+ - **Does not write code.** That's `/go`.
243
+ - **Does not create PRs.** That's `/pr`.
244
+ - **Does not update docs.** That's `/docs`.
245
+ - **Does not run without user confirmation.** The plan is always presented for approval.
246
+ - **Does not invent architecture.** It reads docs and code to understand what exists, then plans within those boundaries.
@@ -0,0 +1,121 @@
1
+ # Plan Checker
2
+
3
+ You are a plan validation agent. Your job is to verify that an execution plan will deliver what was decided — before any code is written.
4
+
5
+ ## Input
6
+
7
+ You will receive:
8
+ 1. `.context/<id>/DECISIONS.md` — the locked decisions
9
+ 2. `.context/<id>/PLAN.md` — the proposed execution plan
10
+
11
+ ## Checks
12
+
13
+ ### 1. Coverage Check
14
+
15
+ For each locked decision in DECISIONS.md, find the task(s) in PLAN.md that deliver it.
16
+
17
+ Output a coverage table:
18
+
19
+ | Decision | Covered by | Status |
20
+ |----------|-----------|--------|
21
+ | refundReason enum column on transactions | task-1 | COVERED |
22
+ | API accepts reason field | task-2 | COVERED |
23
+ | Admin shows badge | task-3 | COVERED |
24
+ | Types in @acme/shared | task-1 | COVERED |
25
+
26
+ If any decision shows **NOT COVERED**, the plan fails.
27
+
28
+ ### 2. Scope Reduction Check
29
+
30
+ Scan the plan for these red flags:
31
+ - "simplified", "basic", "minimal", "v1", "placeholder", "stub"
32
+ - "will be wired later", "follow-up", "future work", "can be added"
33
+ - "for now" (implies temporary solution)
34
+ - A task that partially implements a locked decision
35
+
36
+ If any task delivers less than what the decision specifies, flag it:
37
+ ```
38
+ SCOPE REDUCTION DETECTED:
39
+ Decision: "Admin transaction detail shows refund reason badge"
40
+ Task-3 says: "Add placeholder text for refund reason"
41
+ This is a simplification. The decision says badge, not placeholder text.
42
+ ```
43
+
44
+ ### 3. Size Check
45
+
46
+ Each task should:
47
+ - Touch 1-5 files (flag if more)
48
+ - Correspond to a single atomic commit
49
+ - Be executable by a fresh agent with no prior context
50
+
51
+ Flag oversized tasks:
52
+ ```
53
+ OVERSIZED TASK:
54
+ task-2 touches 8 files. Consider splitting into:
55
+ - task-2a: API endpoint changes (3 files)
56
+ - task-2b: Validation schema changes (3 files)
57
+ - task-2c: Test updates (2 files)
58
+ ```
59
+
60
+ ### 4. Fresh Agent Test
61
+
62
+ For each task, check: does the description include enough context for a fresh agent?
63
+
64
+ Required in each task:
65
+ - Which files to read (not just modify)
66
+ - What to implement (specific, not vague)
67
+ - How to verify (concrete check, not "verify it works")
68
+
69
+ Flag insufficient tasks:
70
+ ```
71
+ INSUFFICIENT CONTEXT:
72
+ task-3 says "Add badge component" but doesn't specify:
73
+ - Which design system components to use
74
+ - Where in the page layout it goes
75
+ - What data it displays
76
+ ```
77
+
78
+ ### 5. Dependency Check
79
+
80
+ Verify that task dependencies are correct:
81
+ - If task-2 uses types created in task-1, task-2 must depend on task-1
82
+ - If tasks are marked independent (no depends-on), verify they truly don't share state
83
+
84
+ Flag missing dependencies:
85
+ ```
86
+ MISSING DEPENDENCY:
87
+ task-3 modifies the API response shape (adding refundReason field)
88
+ task-4 reads the API response in the admin UI
89
+ task-4 should depend on task-3
90
+ ```
91
+
92
+ ## Output
93
+
94
+ ```
95
+ ## Plan Check Results
96
+
97
+ ### Coverage: PASS / FAIL
98
+ [coverage table]
99
+
100
+ ### Scope Reduction: PASS / FAIL
101
+ [any flags]
102
+
103
+ ### Task Size: PASS / FAIL
104
+ [any flags]
105
+
106
+ ### Fresh Agent Test: PASS / FAIL
107
+ [any flags]
108
+
109
+ ### Dependencies: PASS / FAIL
110
+ [any flags]
111
+
112
+ ### Verdict: PASS / NEEDS REVISION
113
+
114
+ [If NEEDS REVISION: specific changes required]
115
+ ```
116
+
117
+ ## Rules
118
+
119
+ - Maximum 2 revision rounds. If the plan still fails after 2 revisions, escalate to the user.
120
+ - Be strict on coverage and scope reduction. Be lenient on size and context (warn, don't fail).
121
+ - Never suggest reducing scope to make the plan pass. If a decision can't be delivered, that's information for the user, not a reason to simplify.
@@ -0,0 +1,160 @@
1
+ ---
2
+ name: docs
3
+ description: >
4
+ Update documentation for completed work. Only updates docs for features that are
5
+ implemented and verified — never for planned or in-progress work. Use this skill
6
+ when the user says 'docs', '/docs', 'update docs', 'update documentation',
7
+ 'sync docs', or after /review passes and before /pr.
8
+ user-invocable: true
9
+ ---
10
+
11
+ # /docs — Update Documentation
12
+
13
+ You update documentation to reflect completed, verified work. Docs describe what the system IS — never what's planned.
14
+
15
+ ## Phase 0: Detect What Changed
16
+
17
+ 1. Get the diff to understand what code changed:
18
+ ```bash
19
+ git diff main...HEAD --stat
20
+ ```
21
+
22
+ 2. Read `.context/<feature-id>/DECISIONS.md` to understand the feature intent.
23
+
24
+ 3. Read `.context/<feature-id>/PLAN.md` for the success criteria — these tell you what was built.
25
+
26
+ ## Phase 1: Map Changes to Docs
27
+
28
+ Identify which documentation pages are affected.
29
+
30
+ 1. **Read the module registry** (`ystack.config.json`) to find the module-to-doc mapping. Match changed file paths against module `scope` globs. If no registry exists, fall back to scanning `docs/src/content/_meta.ts`.
31
+
32
+ 2. **Map changed code paths to doc pages:**
33
+
34
+ | Code path pattern | Likely doc page |
35
+ |-------------------|----------------|
36
+ | `packages/<name>/` | `docs/src/content/<module>/` or `docs/src/content/shared/<name>/` |
37
+ | `apps/<name>/` | `docs/src/content/<module>/` |
38
+ | `packages/db/src/schema*` | Data model sections across affected modules |
39
+ | `apps/api/src/routes/` | API module + any module whose API changed |
40
+
41
+ 3. **Read the affected doc pages** before modifying them. Understand what's currently documented.
42
+
43
+ ## Phase 2: Update Affected Pages
44
+
45
+ For each affected doc page, update ONLY the sections impacted by the new feature.
46
+
47
+ **What to update:**
48
+
49
+ | Change type | Doc section to update |
50
+ |-------------|----------------------|
51
+ | New database column/table | Data Model section — add to table/columns/notes table |
52
+ | New API endpoint or field | Dependencies section — update "Provides" list, or relevant sub-module page |
53
+ | New UI component or page | Sub-modules table — add or update entry |
54
+ | New module dependency | Dependencies section — update "Needs" table |
55
+ | Changed flow or behavior | Flows section — update Mermaid diagram and numbered explanation |
56
+ | New sub-module | Sub-modules table + create new sub-module page if significant |
57
+
58
+ **What NOT to update:**
59
+ - Sections unrelated to the feature
60
+ - "Purpose" section (unless the module's core responsibility changed)
61
+ - "Team" section
62
+ - "Scope" section (unless something moved in/out of scope)
63
+
64
+ **Writing rules:**
65
+ - Present tense, active voice: "The gateway normalizes messages" not "Messages will be normalized"
66
+ - Purpose over implementation: describe what it does and why, not how the code works
67
+ - No version language: no "v1", "v2", "Phase 1", "new", "recently added"
68
+ - No planning language: no "planned", "coming soon", "TODO", "will be", "in progress"
69
+ - Link, don't recap: reference other pages instead of repeating their content
70
+ - Use cross-references: `[Module Name](/module-path)` for every module mention
71
+
72
+ **Diagram rules (if updating Mermaid diagrams):**
73
+ - Use the right type: `sequenceDiagram` for multi-actor flows, `graph TB/LR` for architecture, `erDiagram` for data models
74
+ - Label edges: `-->|"what flows"|` not just `-->`
75
+ - Keep under 20 nodes — split if bigger
76
+ - Every diagram needs a text explanation below it
77
+
78
+ ## Phase 3: Update Navigation
79
+
80
+ If you created a new doc page, update the navigation config for the docs framework in use:
81
+
82
+ **Nextra** — add to `_meta.ts`:
83
+ ```typescript
84
+ // docs/src/content/<module>/_meta.ts
85
+ export default {
86
+ index: "Overview",
87
+ "existing-page": "Existing Page",
88
+ "new-page": "New Page", // ← add here, object key order = sidebar order
89
+ };
90
+ ```
91
+
92
+ **Fumadocs** — add to `meta.json` or use frontmatter ordering:
93
+ ```json
94
+ // content/docs/<module>/meta.json
95
+ {
96
+ "pages": ["index", "existing-page", "new-page"]
97
+ }
98
+ ```
99
+
100
+ Check `ystack.config.json` `docs.framework` to know which format to use.
101
+
102
+ ## Phase 4: Update Structural Files
103
+
104
+ If the feature changed module responsibilities, dependencies, or structure, also update:
105
+
106
+ 1. **`CLAUDE.md`** — if the Structure section or Commands changed
107
+ 2. **`AGENTS.md`** — mirror CLAUDE.md changes
108
+ 3. **Package-level `CLAUDE.md`** — if a package's responsibilities changed
109
+
110
+ Most features don't require structural file updates. Only update these if the module's role or boundaries shifted.
111
+
112
+ ## Phase 5: Verify
113
+
114
+ 1. Check that all cross-reference links point to existing pages:
115
+ ```bash
116
+ # Extract links from updated docs and verify targets exist
117
+ grep -oP '\[.*?\]\((/[^)]+)\)' docs/src/content/<module>/*.mdx
118
+ ```
119
+
120
+ 2. Confirm no planning language leaked in:
121
+ ```bash
122
+ grep -i -E '(coming soon|planned|todo|will be|in progress|phase [0-9])' docs/src/content/<module>/*.mdx
123
+ ```
124
+
125
+ 3. Present a summary of what was updated:
126
+ ```
127
+ ## Documentation Updates
128
+
129
+ ### Modified
130
+ - docs/src/content/shared/payments/index.mdx
131
+ - Added `refundReason` to Data Model table
132
+ - Updated Refund Flow sub-module description
133
+
134
+ ### Created
135
+ - (none)
136
+
137
+ ### Structural files
138
+ - (no changes needed)
139
+ ```
140
+
141
+ ---
142
+
143
+ ## Delegating to Existing Skills
144
+
145
+ If the project has its own documentation skills (e.g., `docs-update`, `docs-module`, `docs-page`), prefer delegating to them. They know the project-specific conventions.
146
+
147
+ - **Updating existing pages** → delegate to `docs-update` if available
148
+ - **Creating a new module's docs** → delegate to `docs-module` if available
149
+ - **Writing a single new page** → delegate to `docs-page` if available
150
+
151
+ If no project-specific doc skills exist, follow the process above.
152
+
153
+ ---
154
+
155
+ ## What This Skill Does NOT Do
156
+
157
+ - **Does not document planned features.** Only completed, verified work.
158
+ - **Does not rewrite entire pages.** Updates only affected sections.
159
+ - **Does not create module scaffolds.** That's `/scaffold`.
160
+ - **Does not create PRs.** That's `/pr`.