@raftlabs/raftstack 1.8.0 → 1.9.2

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,205 @@
1
+ # RaftStack: Discover and Extract Patterns
2
+
3
+ Analyze a specific area of the codebase and extract patterns into reusable standards.
4
+
5
+ ## Arguments
6
+
7
+ - `$ARGUMENTS` - (Optional) Focus area to analyze (e.g., "API", "components", "database", "error handling")
8
+
9
+ ## Tool Usage
10
+
11
+ **IMPORTANT:** Always use the `AskUserQuestion` tool for:
12
+ - Focus area selection
13
+ - Standard creation decisions
14
+ - Location negotiation
15
+ - Option selection
16
+
17
+ Never use plain text questions - always use the structured `AskUserQuestion` tool.
18
+
19
+ ## Phase 1: Focus Selection
20
+
21
+ If no focus area provided, use `AskUserQuestion` with these options:
22
+ - Option A: API/Backend - Route structure, error handling, validation
23
+ - Option B: Components - File structure, prop patterns, styling
24
+ - Option C: Database - Schema conventions, query patterns
25
+ - Option D: Other (let user specify)
26
+
27
+ **Common areas:**
28
+ - **API/Backend** - Route structure, error handling, validation, response formats
29
+ - **Components** - File structure, prop patterns, state management, styling
30
+ - **Database** - Schema conventions, query patterns, migrations
31
+ - **Error Handling** - Error types, logging, user-facing messages
32
+ - **Testing** - Test structure, mocking patterns, coverage approach
33
+ - **Authentication** - Auth flow, session management, permissions
34
+ - **Utilities** - Helper function patterns, shared logic
35
+
36
+ ## Phase 2: Deep Pattern Analysis
37
+
38
+ For the selected area, analyze:
39
+
40
+ 1. **Find representative files:**
41
+ - Locate 3-5 files that implement this pattern well
42
+ - Note file paths for reference
43
+
44
+ 2. **Extract structural patterns:**
45
+ - File naming convention
46
+ - Directory organization
47
+ - Export patterns
48
+
49
+ 3. **Extract code patterns:**
50
+ - Common function signatures
51
+ - Type definitions
52
+ - Error handling approach
53
+ - Import structure
54
+
55
+ 4. **Identify conventions:**
56
+ - Naming (variables, functions, types)
57
+ - Formatting preferences
58
+ - Comment style
59
+
60
+ ## Phase 3: Pattern Analysis Summary
61
+
62
+ After analyzing patterns, present:
63
+
64
+ ```markdown
65
+ ## ✅ Pattern Discovery Completed
66
+
67
+ ### 🎯 Key Patterns Found (Top 3)
68
+ 1. **[Pattern Name]** - Location: `path/to/files/`
69
+ - [Brief description of pattern]
70
+ 2. **[Pattern Name]** - Location: `path/to/files/`
71
+ - [Brief description of pattern]
72
+ 3. **[Pattern Name]** - Location: `path/to/files/`
73
+ - [Brief description of pattern]
74
+
75
+ ### 📋 Files Analyzed
76
+ - `path/to/file1.ts` - [what it demonstrates]
77
+ - `path/to/file2.ts` - [what it demonstrates]
78
+ - `path/to/file3.ts` - [what it demonstrates]
79
+
80
+ ### 🔍 Consistency Assessment
81
+ - ✅ **Consistent:** [list consistent patterns]
82
+ - ⚠️ **Inconsistent:** [list inconsistencies with file references]
83
+
84
+ ### ⚠️ Technical Debt Noted
85
+ - [Debt item] - **Impact:** [why it matters] - **Files:** [affected files]
86
+ - [Debt item] - **Impact:** [why it matters] - **Files:** [affected files]
87
+
88
+ ### 🔄 Recommended Standards to Create
89
+ 1. **[Standard Name]** - Captures: [what pattern]
90
+ 2. **[Standard Name]** - Captures: [what pattern]
91
+ 3. **[Standard Name]** - Captures: [what pattern]
92
+
93
+ **Your options:** [A] Create all standards [B] Select specific standards [C] Analyze another area [D] Skip standardization
94
+ ```
95
+
96
+ Use `AskUserQuestion` for options.
97
+
98
+ ## Phase 4: Standard Creation
99
+
100
+ For each selected pattern, create a standard document:
101
+
102
+ ```markdown
103
+ # [Pattern Name] Standard
104
+
105
+ ## Purpose
106
+ [Why this pattern exists]
107
+
108
+ ## When to Use
109
+ [Situations where this applies]
110
+
111
+ ## Pattern
112
+
113
+ ### Structure
114
+ [File/directory structure]
115
+
116
+ ### Code Template
117
+ ```typescript
118
+ // Template with placeholders
119
+ [code template]
120
+ ```
121
+
122
+ ### Examples
123
+ [Real examples from codebase with file paths]
124
+
125
+ ## Anti-patterns
126
+ [What NOT to do]
127
+
128
+ ## References
129
+ - [Link to related file in codebase]
130
+ - [Link to related skill if applicable]
131
+ ```
132
+
133
+ ## Phase 5: Location Negotiation
134
+
135
+ Use `AskUserQuestion` with these options:
136
+ - Option A: `.claude/standards/[area]/` - Claude-specific standards folder (Recommended)
137
+ - Option B: `docs/standards/[area]/` - With project documentation
138
+ - Option C: `standards/[area]/` - At project root
139
+ - Option D: Other (let user specify)
140
+
141
+ ## Phase 6: Completion Summary
142
+
143
+ After creating standards, present:
144
+
145
+ ```markdown
146
+ ## ✅ Standards Created
147
+
148
+ ### 🎯 What Was Created
149
+ 1. **[Standard Name]** - **Location:** `path/to/standard.md`
150
+ - Captures: [what pattern]
151
+ 2. **[Standard Name]** - **Location:** `path/to/standard.md`
152
+ - Captures: [what pattern]
153
+
154
+ ### 📋 Standards Contents
155
+ | Standard | Patterns Captured | Examples Included |
156
+ |----------|-------------------|-------------------|
157
+ | [Name] | [List] | [Count] |
158
+
159
+ ### 🔍 Coverage Assessment
160
+ - **Fully Covered:** [list of patterns now documented]
161
+ - **Partially Covered:** [patterns that could use more detail]
162
+ - **Not Covered:** [patterns skipped for now]
163
+
164
+ ### ⚠️ Follow-up Recommendations
165
+ - **Run `/raftstack/index`** - Update the standards registry
166
+ - **Run `/raftstack/inject [area]`** - Use these standards when working on related code
167
+
168
+ ### 🔄 What This Enables
169
+ - **Option A:** Run `/raftstack/index` - Update standards registry
170
+ - **Option B:** Run `/raftstack/discover [other-area]` - Analyze another area
171
+ - **Option C:** Run `/raftstack/inject [area]` - Test the new standards
172
+ - **Option D:** Done for now
173
+
174
+ **Your options:** [A] Index standards [B] Discover more [C] Test with inject [D] Done
175
+ ```
176
+
177
+ Use `AskUserQuestion` for final options.
178
+
179
+ ## Example Session
180
+
181
+ **User:** `/raftstack/discover API`
182
+
183
+ **AI analyzes API routes, finds patterns:**
184
+ - RESTful structure with `/api/[resource]/route.ts`
185
+ - Zod validation on all inputs
186
+ - Consistent error response format
187
+ - Auth middleware pattern
188
+
189
+ **AI presents Pattern Analysis Summary**
190
+
191
+ **User selects:** [B] Select specific standards
192
+
193
+ **AI uses AskUserQuestion:** Which patterns to document?
194
+ - [A] Error handling
195
+ - [B] Validation
196
+ - [C] Auth middleware
197
+ - [D] All of the above
198
+
199
+ **User selects:** Error handling and Validation
200
+
201
+ **AI creates:**
202
+ - `.claude/standards/api/error-handling.md`
203
+ - `.claude/standards/api/validation.md`
204
+
205
+ **AI presents Completion Summary with next steps**
@@ -0,0 +1,309 @@
1
+ # RaftStack: Help & Guidance
2
+
3
+ Guide the user on what to do next based on their current project state.
4
+
5
+ ## Tool Usage
6
+
7
+ **IMPORTANT:** Always use the `AskUserQuestion` tool for:
8
+ - Presenting recommendations
9
+ - Showing command options
10
+ - Getting user preferences
11
+
12
+ Never use plain text questions - always use the structured `AskUserQuestion` tool.
13
+
14
+ ## Phase 1: Detect Current State
15
+
16
+ Check for existing RaftStack artifacts:
17
+
18
+ ### Constitution/Context
19
+ - `.claude/context/constitution.md` → Has project context
20
+ - `CONSTITUTION.md` → Has project context
21
+ - `docs/constitution.md` → Has project context
22
+
23
+ ### Standards
24
+ - `.claude/standards/**/*.md` → Has standards
25
+ - `docs/standards/**/*.md` → Has standards
26
+ - `standards/**/*.md` → Has standards
27
+ - `*.standard.md` → Has standards
28
+
29
+ ### Specs
30
+ - `.claude/specs/**/*` → Has feature specs
31
+ - `docs/specs/**/*` → Has feature specs
32
+ - `specs/**/*` → Has feature specs
33
+
34
+ ### Skills
35
+ - `.claude/skills/*/SKILL.md` → Has RaftStack skills installed
36
+
37
+ ### Registry
38
+ - `.claude/standards/REGISTRY.md` → Has standards registry
39
+ - `.claude/REGISTRY.md` → Has standards registry
40
+ - `docs/REGISTRY.md` → Has standards registry
41
+
42
+ ## Phase 2: Assess Project State
43
+
44
+ Categorize the project state:
45
+
46
+ ### New to RaftStack (No artifacts found)
47
+ - No constitution
48
+ - No standards
49
+ - No skills
50
+
51
+ ### Partially Set Up
52
+ - Has constitution but no standards
53
+ - Has standards but no registry
54
+ - Has skills but no project-specific standards
55
+
56
+ ### Fully Set Up
57
+ - Has constitution
58
+ - Has standards
59
+ - Has registry (recently updated)
60
+ - Has skills
61
+
62
+ ### Needs Maintenance
63
+ - Has artifacts but registry is outdated (>30 days)
64
+ - Has standards that may have drifted
65
+
66
+ ## Phase 3: Present State Summary
67
+
68
+ Show the user their current state:
69
+
70
+ ```markdown
71
+ ## 📊 RaftStack Project Status
72
+
73
+ ### Artifacts Found
74
+ | Artifact | Status | Location |
75
+ |----------|--------|----------|
76
+ | Constitution | [✅ Found / ❌ Missing] | [path or -] |
77
+ | Standards | [[N] found / ❌ None] | [path or -] |
78
+ | Registry | [✅ Found / ❌ Missing] | [path or -] |
79
+ | Specs | [[N] found / ❌ None] | [path or -] |
80
+ | Skills | [✅ Installed / ❌ Missing] | [path or -] |
81
+
82
+ ### Health Assessment
83
+ - **Overall:** [New / Partially Set Up / Ready / Needs Maintenance]
84
+ - **Last Registry Update:** [date or Never]
85
+ - **Standards Coverage:** [list of domains covered]
86
+ ```
87
+
88
+ ## Phase 4: Determine Recommendation
89
+
90
+ Based on state, recommend next action:
91
+
92
+ ### If no constitution:
93
+ **Recommended:** `/raftstack/init-context`
94
+ > "Start by analyzing your codebase and generating a constitution. This captures your project's structure, patterns, and conventions."
95
+
96
+ ### If constitution but no standards:
97
+ **Recommended:** `/raftstack/discover`
98
+ > "You have project context. Consider extracting patterns from your code as reusable standards."
99
+
100
+ ### If standards but no registry:
101
+ **Recommended:** `/raftstack/index`
102
+ > "You have standards but no registry. Index them to enable easy discovery and drift detection."
103
+
104
+ ### If starting new work:
105
+ **Recommended:** `/raftstack/shape`
106
+ > "Use shape to plan your feature with the right level of detail - from quick fixes to full specs."
107
+
108
+ ### If working on code:
109
+ **Recommended:** `/raftstack/inject`
110
+ > "Surface relevant standards and skills for your current task to ensure consistency."
111
+
112
+ ### If registry is outdated (>30 days):
113
+ **Recommended:** `/raftstack/index`
114
+ > "Your standards registry hasn't been updated recently. Re-index to check for drift and updates."
115
+
116
+ ### If fully set up and current:
117
+ **Recommended:** Based on what user wants to do
118
+ > "Your RaftStack setup is complete and current. What would you like to work on?"
119
+
120
+ ## Phase 5: Present Options
121
+
122
+ Use `AskUserQuestion` with context-appropriate options:
123
+
124
+ ### For New Projects
125
+ ```markdown
126
+ **Recommended next step:** `/raftstack/init-context`
127
+ Start by generating a constitution that captures how your project works.
128
+
129
+ **Your options:**
130
+ - [A] Initialize project context (Recommended) - Generate a constitution
131
+ - [B] Skip to discover patterns - Extract standards from existing code
132
+ - [C] Show all commands - See everything RaftStack can do
133
+ - [D] Not now - Exit help
134
+ ```
135
+
136
+ ### For Partially Set Up Projects
137
+ ```markdown
138
+ **Recommended next step:** [Based on what's missing]
139
+ [Explanation of why this is recommended]
140
+
141
+ **Your options:**
142
+ - [A] [Recommended action] (Recommended)
143
+ - [B] [Alternative action]
144
+ - [C] Show all commands
145
+ - [D] Not now
146
+ ```
147
+
148
+ ### For Ready Projects
149
+ ```markdown
150
+ **Your RaftStack setup is complete!**
151
+
152
+ **What would you like to do?**
153
+ - [A] Shape a new feature - Plan work with /raftstack/shape
154
+ - [B] Inject context - Surface standards for current work
155
+ - [C] Check for drift - Re-index and detect changes
156
+ - [D] Show all commands
157
+ ```
158
+
159
+ ## Phase 6: All Commands Reference
160
+
161
+ If user requests to see all commands:
162
+
163
+ ```markdown
164
+ ## RaftStack Commands Reference
165
+
166
+ ### Setup & Context
167
+ | Command | Purpose | When to Use |
168
+ |---------|---------|-------------|
169
+ | `/raftstack/init-context` | Generate constitution | New project or first setup |
170
+ | `/raftstack/index` | Update standards registry | Standards changed, check drift |
171
+
172
+ ### Planning & Discovery
173
+ | Command | Purpose | When to Use |
174
+ |---------|---------|-------------|
175
+ | `/raftstack/shape [task]` | Plan feature/task | Starting any new work |
176
+ | `/raftstack/discover [area]` | Extract patterns | Document existing code patterns |
177
+
178
+ ### Working with Code
179
+ | Command | Purpose | When to Use |
180
+ |---------|---------|-------------|
181
+ | `/raftstack/inject [domain]` | Surface context | Before coding, need guidance |
182
+
183
+ ### Help
184
+ | Command | Purpose | When to Use |
185
+ |---------|---------|-------------|
186
+ | `/raftstack/help` | Get guidance | Unsure what to do next |
187
+
188
+ ---
189
+
190
+ ### Quick Start Guide
191
+
192
+ 1. **First time?** Run `/raftstack/init-context` to analyze your project
193
+ 2. **Have patterns?** Run `/raftstack/discover` to document them as standards
194
+ 3. **Starting work?** Run `/raftstack/shape [task]` to plan your approach
195
+ 4. **Need guidance?** Run `/raftstack/inject [domain]` to surface relevant standards
196
+
197
+ **Your options:** [A] Run a command [B] Back to recommendations [C] Exit help
198
+ ```
199
+
200
+ Use `AskUserQuestion` for navigation.
201
+
202
+ ## Example Sessions
203
+
204
+ ### Example 1: New Project
205
+
206
+ **User:** `/raftstack/help`
207
+
208
+ **AI detects:** No RaftStack artifacts found
209
+
210
+ **AI responds:**
211
+ ```markdown
212
+ ## 📊 RaftStack Project Status
213
+
214
+ ### Artifacts Found
215
+ | Artifact | Status | Location |
216
+ |----------|--------|----------|
217
+ | Constitution | ❌ Missing | - |
218
+ | Standards | ❌ None | - |
219
+ | Registry | ❌ Missing | - |
220
+ | Specs | ❌ None | - |
221
+ | Skills | ✅ Installed | `.claude/skills/` |
222
+
223
+ ### Health Assessment
224
+ - **Overall:** New to RaftStack
225
+ - **Last Registry Update:** Never
226
+ - **Standards Coverage:** None
227
+
228
+ ---
229
+
230
+ **Recommended next step:** `/raftstack/init-context`
231
+ Start by generating a constitution that captures how your project works. This analyzes your codebase structure, patterns, and conventions.
232
+ ```
233
+
234
+ **Uses AskUserQuestion:**
235
+ - [A] Initialize project context (Recommended)
236
+ - [B] Skip to discover patterns
237
+ - [C] Show all commands
238
+ - [D] Not now
239
+
240
+ ### Example 2: Ready Project
241
+
242
+ **User:** `/raftstack/help`
243
+
244
+ **AI detects:** Constitution, 5 standards, registry (3 days old), skills
245
+
246
+ **AI responds:**
247
+ ```markdown
248
+ ## 📊 RaftStack Project Status
249
+
250
+ ### Artifacts Found
251
+ | Artifact | Status | Location |
252
+ |----------|--------|----------|
253
+ | Constitution | ✅ Found | `.claude/context/constitution.md` |
254
+ | Standards | 5 found | `.claude/standards/` |
255
+ | Registry | ✅ Found | `.claude/standards/REGISTRY.md` |
256
+ | Specs | 2 found | `.claude/specs/` |
257
+ | Skills | ✅ Installed | `.claude/skills/` |
258
+
259
+ ### Health Assessment
260
+ - **Overall:** Ready
261
+ - **Last Registry Update:** 3 days ago
262
+ - **Standards Coverage:** API, React, Database
263
+
264
+ ---
265
+
266
+ **Your RaftStack setup is complete and current!**
267
+ ```
268
+
269
+ **Uses AskUserQuestion:**
270
+ - [A] Shape a new feature - Plan work with scale-adaptive depth
271
+ - [B] Inject context - Surface standards for current task
272
+ - [C] Check for drift - Re-index and detect changes
273
+ - [D] Show all commands
274
+
275
+ ### Example 3: Needs Maintenance
276
+
277
+ **User:** `/raftstack/help`
278
+
279
+ **AI detects:** Constitution, standards, but registry is 45 days old
280
+
281
+ **AI responds:**
282
+ ```markdown
283
+ ## 📊 RaftStack Project Status
284
+
285
+ ### Artifacts Found
286
+ | Artifact | Status | Location |
287
+ |----------|--------|----------|
288
+ | Constitution | ✅ Found | `.claude/context/constitution.md` |
289
+ | Standards | 3 found | `.claude/standards/` |
290
+ | Registry | ⚠️ Outdated | `.claude/standards/REGISTRY.md` |
291
+ | Specs | ❌ None | - |
292
+ | Skills | ✅ Installed | `.claude/skills/` |
293
+
294
+ ### Health Assessment
295
+ - **Overall:** Needs Maintenance
296
+ - **Last Registry Update:** 45 days ago ⚠️
297
+ - **Standards Coverage:** API, React
298
+
299
+ ---
300
+
301
+ **Recommended next step:** `/raftstack/index`
302
+ Your standards registry is over 30 days old. Re-index to check for drift and ensure standards are still accurate.
303
+ ```
304
+
305
+ **Uses AskUserQuestion:**
306
+ - [A] Re-index standards (Recommended) - Check for drift
307
+ - [B] Shape a new feature - Plan work
308
+ - [C] Show all commands
309
+ - [D] Not now