@catchdrift/cli 0.1.17 → 0.1.19

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,208 @@
1
+ ---
2
+ description: "Show a full DS snapshot — registry, static coverage, recent gaps, and prioritized next actions. Run this first to orient before any session involving the design system."
3
+ allowed-tools: Read, Glob, Grep, Bash
4
+ argument-hint: "[quick | file <path> | --export]"
5
+ ---
6
+
7
+ # /drift-context — Instant DS snapshot for your current session
8
+
9
+ Gives you a complete picture of the design system state in one shot — no grepping,
10
+ no file hunting. Run this at the start of any session to orient yourself before
11
+ building, reviewing, or planning.
12
+
13
+ Designed for every persona:
14
+ - **PdMs/Designers** — "what components exist right now?"
15
+ - **Developers joining a project** — "what's the DS state before I touch anything?"
16
+ - **Code reviewers** — "what does drift look like for this file/feature?"
17
+ - **AI tools** — load this context before scaffolding or fixing
18
+
19
+ ## Arguments: `$ARGUMENTS`
20
+ - *(no args)* — full snapshot: registry + coverage + gaps + recent drift
21
+ - `quick` — registry only (component list, no coverage scan)
22
+ - `file <path>` — DS coverage for a specific file only
23
+ - `--export` — output as markdown block suitable for pasting into a PRD, Jira ticket, or AI prompt
24
+
25
+ ---
26
+
27
+ ## Step 1 — Find the config
28
+
29
+ Look for config in this order:
30
+ 1. `drift.config.ts` at project root
31
+ 2. `src/ds-coverage/config.ts`
32
+ 3. If neither exists, stop:
33
+ ```
34
+ No drift config found. Run /drift-setup to get started.
35
+ ```
36
+
37
+ Read the config and extract:
38
+ - Component registry (names, storyPaths, figmaLinks)
39
+ - `storybookUrl` / `chromaticUrl`
40
+ - `figmaFileKey`
41
+ - `threshold`
42
+ - `approvedGaps` (if any)
43
+
44
+ ---
45
+
46
+ ## Step 2 — Dispatch
47
+
48
+ ### No args → Full snapshot
49
+
50
+ **A. Registry summary** (read from config — no network call needed)
51
+
52
+ ```
53
+ ## DS Context — <project name from package.json> — <date>
54
+
55
+ ### Component Registry (<N> components)
56
+ | Component | Story | Figma | Status |
57
+ |--------------------|-------|-------|---------------|
58
+ | Button | ✅ | ✅ | stable |
59
+ | Input | ✅ | — | needs figma |
60
+ | TenantsTable | ✅ | ✅ | stable |
61
+ | ... | | | |
62
+
63
+ Missing storyPaths: N → run /drift-sync storybook to fill
64
+ Missing figmaLinks: N → run /drift-push gaps to fill
65
+
66
+ Approved exceptions: N
67
+ • <ComponentName> — "<rationale>" (approved by <name>)
68
+ ```
69
+
70
+ **B. Static coverage scan** (grep src/ — fast, no build needed)
71
+
72
+ Glob all `.tsx` files in `src/` (excluding stories, tests, tokens, node_modules).
73
+ For each file, count DS vs custom component usage.
74
+
75
+ ```
76
+ ### Coverage (static scan)
77
+ Overall: XX% DS (threshold: XX%)
78
+ Status: ✅ PASS / 🔴 FAIL
79
+
80
+ Top 5 files by custom usage:
81
+ src/features/dashboard/KPIRow.tsx — 3 custom, 2 DS (40%)
82
+ src/features/tenants/BulkActions.tsx — 2 custom, 5 DS (71%)
83
+ ...
84
+
85
+ Top gaps (custom components not in DS):
86
+ CustomCard — 8× → no DS equivalent (promote candidate)
87
+ IconBtn — 5× → use Button variant="ghost"
88
+ StatusPill — 4× → use Badge variant="status"
89
+ ```
90
+
91
+ **C. Recent drift summary** (from git log — no build needed)
92
+
93
+ ```bash
94
+ git log --oneline --since="7 days ago" -- "src/**/*.tsx"
95
+ ```
96
+
97
+ Show files changed in the last 7 days, and for each, show whether DS coverage
98
+ went up or down based on static diff (add/remove DS vs custom components).
99
+
100
+ ```
101
+ ### Recent changes (last 7 days)
102
+ src/features/payments/PaymentForm.tsx — modified — DS coverage: stable
103
+ src/features/dashboard/NewWidget.tsx — added — 2 custom components (⚠️ check drift)
104
+ ```
105
+
106
+ **D. Session recommendations**
107
+
108
+ Based on the snapshot, output 1-3 prioritized actions:
109
+ ```
110
+ ### What to do next
111
+ 1. 🔴 CustomCard used 8× — biggest coverage win: /drift fix CustomCard
112
+ 2. ⚠️ src/features/dashboard/NewWidget.tsx added recently — run /drift file src/features/dashboard/NewWidget.tsx
113
+ 3. 📎 6 components missing figmaLinks — run /drift-push gaps
114
+ ```
115
+
116
+ ---
117
+
118
+ ### `quick` → Registry only
119
+
120
+ Skip the coverage scan and git log. Just output the component table and approved gaps.
121
+ Fast — reads only config.ts. Use this when you just need to know what's available.
122
+
123
+ ```
124
+ ## DS Components — <N> registered
125
+
126
+ Primitives: Button, Input, Badge, Modal, Toast, Dropdown, Tabs, Icon
127
+ Navigation: Navbar, Sidebar, Breadcrumb
128
+ Patterns: TenantsTable, UnitDetailsCard, PaymentBanner, CommunicationsPanel, PinnedNotes
129
+
130
+ Approved gaps (N): <list>
131
+ Missing stories (N): <list>
132
+
133
+ Storybook: <storybookUrl>
134
+ Figma: https://figma.com/design/<figmaFileKey>
135
+ ```
136
+
137
+ ---
138
+
139
+ ### `file <path>` → Single-file coverage
140
+
141
+ Read the specified file and classify every JSX component:
142
+
143
+ ```
144
+ ## Coverage: src/features/dashboard/NewWidget.tsx
145
+
146
+ DS components (4): Button, Badge, Tabs, Input
147
+ Custom components (2): KPICard, TrendArrow
148
+
149
+ Coverage: 67% (threshold: 80%) — 🔴 below threshold
150
+
151
+ Gaps:
152
+ KPICard — used 1× — no DS equivalent → /drift promote KPICard
153
+ TrendArrow — used 1× — check Badge for icon variant → /drift fix TrendArrow
154
+
155
+ Token violations:
156
+ Line 34: color: '#3b82f6' → use var(--ds-color-brand-500)
157
+ ```
158
+
159
+ ---
160
+
161
+ ### `--export` → Paste-ready block
162
+
163
+ Formats the full snapshot as a clean markdown block for:
164
+ - Pasting into a PRD / Linear issue (`/drift-prd` uses this internally)
165
+ - Adding to a Jira ticket
166
+ - Loading into an AI prompt as system context
167
+
168
+ ```markdown
169
+ ---
170
+ drift-context: <project> — <date>
171
+ threshold: XX%
172
+ coverage: XX% (static)
173
+ ---
174
+
175
+ ## Design System: <N> components
176
+ [component table]
177
+
178
+ ## Coverage snapshot
179
+ [coverage summary]
180
+
181
+ ## Active gaps
182
+ [gap list]
183
+
184
+ ## Approved exceptions
185
+ [approved list]
186
+ ---
187
+ ```
188
+
189
+ ---
190
+
191
+ ## Performance notes
192
+
193
+ - **No build required** — reads config and source files directly
194
+ - **No network calls** in `quick` mode — instant
195
+ - **Static scan only** — grep-based, not fiber-tree (for fiber-tree accuracy, run `/drift check`)
196
+ - For large codebases (500+ files), the static scan may take a few seconds — this is expected
197
+ - The `file <path>` mode is always instant regardless of codebase size
198
+
199
+ ## Why this exists
200
+
201
+ Without this command, getting oriented in a new session requires:
202
+ - Reading drift.config.ts manually
203
+ - Grepping src/ for component usage
204
+ - Running git log to see what changed
205
+ - Cross-referencing all of it mentally
206
+
207
+ `/drift-context` does all of that in one pass and surfaces the most important next action.
208
+ It is designed to be the **first command you run** in any session involving the design system.
@@ -0,0 +1,250 @@
1
+ ---
2
+ description: "Generate a DS component inventory for a feature spec — which components exist, which are gaps, with Storybook/Figma links. Outputs a .drift-spec.md file for CI enforcement. Paste into Linear, Notion, Confluence, or GitHub Issues."
3
+ allowed-tools: Read, Glob, Grep, Edit, Write
4
+ argument-hint: "[\"<feature description>\"] [--format linear|notion|confluence|github] [--update <file>] [--spec-only]"
5
+ disable-model-invocation: true
6
+ ---
7
+
8
+ # /drift-prd — Generate a DS-aware component inventory + enforcement spec
9
+
10
+ Takes a feature description or existing PRD draft and outputs:
11
+ 1. A structured component inventory (which DS components, which gaps, Figma/Storybook links)
12
+ 2. A `.drift-spec.md` file that CI can validate against the implementation
13
+
14
+ Designed for PdMs and designers — no code knowledge required. The spec file is version-controlled
15
+ and automatically checked in every PR. If a developer uses a custom component that wasn't declared,
16
+ the PR gets a warning before merge.
17
+
18
+ Output is formatted to paste directly into Linear, Notion, Confluence, or GitHub Issues.
19
+
20
+ ## Arguments: `$ARGUMENTS`
21
+ - *(no args)* — interactive mode: asks for feature description, then generates inventory + spec
22
+ - `"<feature description>"` — generate inventory + spec from inline description
23
+ - `--format linear` — output optimized for Linear (default)
24
+ - `--format notion` — output as Notion-pasteable table
25
+ - `--format confluence` — output as Confluence wiki markup
26
+ - `--format github` — output as GitHub-flavored markdown
27
+ - `--update <file>` — read an existing PRD file and inject the component inventory section into it
28
+ - `--spec-only` — only write the .drift-spec.md file, skip the human-readable inventory
29
+
30
+ ---
31
+
32
+ ## Step 1 — Read the DS registry
33
+
34
+ Read `drift.config.ts` (or `src/ds-coverage/config.ts`) to get:
35
+ - Every registered DS component, its story path, and Figma link
36
+ - `storybookUrl` and `chromaticUrl` (for building story links)
37
+ - `figmaFileKey` (for building Figma links)
38
+ - Any `approvedGaps` with rationale (these count as available, with a note)
39
+
40
+ If no config is found:
41
+ ```
42
+ No drift.config.ts found. Run /drift-setup first to register your DS components.
43
+ ```
44
+
45
+ ---
46
+
47
+ ## Step 2 — Get the feature description
48
+
49
+ ### No args — interactive mode
50
+
51
+ Ask in a single prompt (don't ping-pong):
52
+ ```
53
+ Describe the feature or screen you're planning. Include:
54
+
55
+ 1. What is this screen/feature? (1-2 sentences)
56
+ 2. What are the main user actions? (e.g. "user can filter, sort, view details")
57
+ 3. What data is displayed? (e.g. "list of tenants, unit number, balance")
58
+ 4. Are there any modals, drawers, or overlays?
59
+ 5. Any existing screen in the app this is similar to?
60
+
61
+ You can answer in plain English — no need to list components.
62
+ ```
63
+
64
+ ### With description argument — proceed immediately
65
+
66
+ Use the provided description as input.
67
+
68
+ ---
69
+
70
+ ## Step 3 — Analyze and classify components
71
+
72
+ Based on the feature description, identify the UI components needed:
73
+
74
+ 1. **Infer the component list** from the description using product + UI knowledge:
75
+ - Navigation elements (tabs, breadcrumbs, nav bars)
76
+ - Data display (tables, cards, lists, badges, charts)
77
+ - Actions (buttons, dropdowns, menus)
78
+ - Forms (inputs, selects, checkboxes, date pickers)
79
+ - Feedback (toasts, banners, modals, loading states)
80
+ - Layout (headers, sidebars, panels)
81
+
82
+ 2. **Classify each component** against the DS registry:
83
+ - **✅ In DS** — exact match in `config.components`
84
+ - **🔁 Partial match** — a DS component covers this with a variant (e.g., `Button` covers "icon button" via `variant="ghost"`)
85
+ - **⚠️ Gap** — no DS component covers this need
86
+ - **✅ Approved exception** — in `approvedGaps` with documented rationale
87
+
88
+ 3. **For gaps**, check if a DS component could be extended:
89
+ - If yes: flag as "extension candidate" with the base component name
90
+ - If no: flag as "new component needed" with suggested design request
91
+
92
+ ---
93
+
94
+ ## Step 4 — Generate the PRD component inventory
95
+
96
+ Output in the requested format. Default (Linear):
97
+
98
+ ```markdown
99
+ ## Component Inventory
100
+
101
+ > Auto-generated by Drift on <date>. Run `/drift-prd` to regenerate.
102
+
103
+ ### DS Components (ready to use)
104
+ | Component | Variant/Usage | Storybook | Figma |
105
+ |-----------|--------------|-----------|-------|
106
+ | Button | Primary — "Save", "Cancel" actions | [Story](<url>) | [Figma](<url>) |
107
+ | Input | Text — search bar, form fields | [Story](<url>) | [Figma](<url>) |
108
+ | Modal | Confirmation dialog | [Story](<url>) | [Figma](<url>) |
109
+ | TenantsTable | Main data table | [Story](<url>) | — |
110
+ | Badge | Status indicators | [Story](<url>) | [Figma](<url>) |
111
+
112
+ ### Partial Matches (DS component covers this with a variant)
113
+ | Component Needed | Use Instead | Notes |
114
+ |-----------------|-------------|-------|
115
+ | Icon button | `Button` variant="ghost" | Add icon prop — story: primitives-button--ghost |
116
+ | Danger confirm | `Button` variant="danger" | Already in DS |
117
+
118
+ ### Design Gaps (need Figma spec before engineering starts)
119
+ | Component Needed | Priority | Suggested Owner | Next Step |
120
+ |-----------------|----------|-----------------|-----------|
121
+ | DateRangePicker | High | Design team | Run `/drift-push request DateRangePicker "date range selector for filter panel"` |
122
+ | StatusTimeline | Medium | Design team | Run `/drift-push request StatusTimeline "chronological status history"` |
123
+
124
+ ### DS Coverage Estimate
125
+ - Components in DS: N / N total (~XX%)
126
+ - Gaps requiring design: N
127
+ - Estimated dev-ready after design: <date estimate not provided — ask design team>
128
+
129
+ ### Engineering Notes
130
+ - All DS components are in Storybook at: <storybookUrl>
131
+ - Token reference: src/tokens/variables.css
132
+ - To scaffold this screen: run `/drift-scaffold "<feature name>"`
133
+ - To check DS coverage after building: run `/drift check`
134
+ ```
135
+
136
+ ---
137
+
138
+ ## Step 5 — Handle gaps
139
+
140
+ For each gap component, offer to create a design request:
141
+
142
+ ```
143
+ Found N gap components that need Figma specs:
144
+ 1. DateRangePicker — no DS equivalent
145
+ 2. StatusTimeline — no DS equivalent
146
+
147
+ Create design requests in Figma for these? (yes/no/select)
148
+ This will run /drift-push request for each gap and post briefs to your Figma proposals page.
149
+ ```
150
+
151
+ If yes, run the `/drift-push request` flow for each gap component.
152
+
153
+ ---
154
+
155
+ ## Step 6 — Update an existing PRD file (`--update <file>`)
156
+
157
+ If `--update` was passed with a file path:
158
+
159
+ 1. Read the file
160
+ 2. Look for an existing component inventory section (search for "Component Inventory" heading)
161
+ 3. If found: replace the section between `<!-- drift:prd-start -->` and `<!-- drift:prd-end -->` markers
162
+ 4. If not found: append the inventory at the end of the file
163
+ 5. Write the updated file
164
+ 6. Report: "Updated <file> — added component inventory with N components (N gaps)"
165
+
166
+ ---
167
+
168
+ ---
169
+
170
+ ## Step 7 — Write the .drift-spec.md file
171
+
172
+ After generating the human-readable inventory, write a machine-readable spec file that CI
173
+ can validate against the implementation.
174
+
175
+ ### File location
176
+ Create `specs/<feature-slug>.drift-spec.md` in the project root's `specs/` directory.
177
+ If `specs/` doesn't exist, create it.
178
+
179
+ ### Spec format
180
+
181
+ ```markdown
182
+ ---
183
+ drift-spec: "1.0"
184
+ screen: <ScreenName>
185
+ feature: <feature-slug>
186
+ owner: <ask or infer from git config>
187
+ created: <today ISO date>
188
+ updated: <today ISO date>
189
+ intent: |
190
+ <1-2 sentence description of what the screen does>
191
+ components:
192
+ required: [<comma-separated DS component names from inventory>]
193
+ optional: [<components that may or may not appear>]
194
+ gaps:
195
+ - name: <GapComponentName>
196
+ description: "<what it does>"
197
+ priority: high|normal|low
198
+ approved: false
199
+ figma-request: pending
200
+ tokens-required:
201
+ - "--ds-color-danger-*"
202
+ threshold: <from drift.config.ts — default 80>
203
+ status: draft
204
+ ---
205
+
206
+ ## Feature: <ScreenName>
207
+
208
+ <intent text>
209
+
210
+ ### User actions
211
+ - <describe key user actions>
212
+
213
+ ### Screens in scope
214
+ - <list screens this spec covers>
215
+ ```
216
+
217
+ ### Rules for the spec file
218
+ - `required` = DS components the implementation MUST use. Missing any → CI warning.
219
+ - `optional` = DS components that may appear depending on state/data. Not enforced.
220
+ - `gaps[].approved: false` = unapproved custom component. CI flags this until approved.
221
+ - `gaps[].approved: true` = explicitly approved exception with documented rationale.
222
+ - `threshold` = minimum DS coverage %. Pulled from `drift.config.ts` if set.
223
+ - `status` starts as `draft`. Designer/TL changes to `approved` before engineering starts.
224
+
225
+ ### After writing the spec
226
+
227
+ Tell the user:
228
+ ```
229
+ ✅ Spec written: specs/<feature-slug>.drift-spec.md
230
+
231
+ This file is now version-controlled. In every PR:
232
+ • catchdrift spec validate checks that required components are actually used
233
+ • Unapproved gaps trigger a warning in the PR comment
234
+ • Designers can approve gaps by changing approved: true in this file
235
+
236
+ To validate now: catchdrift spec validate specs/<feature-slug>.drift-spec.md
237
+ To approve a gap: change approved: false → approved: true + add rationale comment
238
+ ```
239
+
240
+ ---
241
+
242
+ ## Style notes
243
+
244
+ - Always lead with DS components the team can use immediately — show the good news first
245
+ - Frame gaps as "design requests" not "missing components" — it's a workflow step, not a failure
246
+ - Include direct story links when `chromaticUrl` or `storybookUrl` is set — PdMs will use these to preview components
247
+ - Never invent component names. If unsure whether a DS component covers a need, classify as a gap
248
+ - Keep the table concise — this is a spec document, not a technical breakdown
249
+ - If the feature description is vague, generate a best-effort inventory and note what was assumed
250
+ - The spec file is the contract. The inventory table is the human-readable explanation of that contract.