@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,259 @@
1
+ # RaftStack: Index Standards Registry
2
+
3
+ Scan for standards files and maintain a registry. Works with any directory structure.
4
+
5
+ ## Purpose
6
+
7
+ Keep track of all standards and context files in the project, regardless of where they're stored.
8
+
9
+ ## Tool Usage
10
+
11
+ **IMPORTANT:** Always use the `AskUserQuestion` tool for:
12
+ - Location negotiation
13
+ - Drift resolution decisions
14
+ - Follow-up options
15
+
16
+ Never use plain text questions - always use the structured `AskUserQuestion` tool.
17
+
18
+ ## Phase 1: Scan for Standards
19
+
20
+ Search common locations for standards files:
21
+
22
+ 1. **Standard locations:**
23
+ - `.claude/standards/**/*.md`
24
+ - `.claude/context/**/*.md`
25
+ - `docs/standards/**/*.md`
26
+ - `standards/**/*.md`
27
+ - `*.standard.md` (root level)
28
+
29
+ 2. **Context files:**
30
+ - `CONSTITUTION.md`
31
+ - `.claude/context/constitution.md`
32
+ - `docs/constitution.md`
33
+
34
+ 3. **Skills (RaftStack-provided):**
35
+ - `.claude/skills/*/SKILL.md`
36
+
37
+ ## Phase 2: Analyze Each File
38
+
39
+ For each discovered file, extract:
40
+
41
+ - **Path:** Full path from project root
42
+ - **Title:** First H1 heading
43
+ - **Domain:** Inferred from path or content (API, React, Database, etc.)
44
+ - **Last Modified:** File modification date
45
+ - **Summary:** First paragraph or purpose section
46
+
47
+ ## Phase 3: Generate Registry
48
+
49
+ Create or update a registry file:
50
+
51
+ ```markdown
52
+ # Standards Registry
53
+
54
+ > Auto-generated by `/raftstack/index`
55
+ > Last updated: [timestamp]
56
+
57
+ ## Project Context
58
+
59
+ | File | Description | Last Modified |
60
+ |------|-------------|---------------|
61
+ | [path] | [title/summary] | [date] |
62
+
63
+ ## Standards by Domain
64
+
65
+ ### API/Backend
66
+ | Standard | Path | Last Modified |
67
+ |----------|------|---------------|
68
+ | [name] | [path] | [date] |
69
+
70
+ ### React/Frontend
71
+ | Standard | Path | Last Modified |
72
+ |----------|------|---------------|
73
+ | [name] | [path] | [date] |
74
+
75
+ ### Database
76
+ | Standard | Path | Last Modified |
77
+ |----------|------|---------------|
78
+ | [name] | [path] | [date] |
79
+
80
+ ### Other
81
+ | Standard | Path | Last Modified |
82
+ |----------|------|---------------|
83
+ | [name] | [path] | [date] |
84
+
85
+ ## RaftStack Skills
86
+
87
+ | Skill | Path | Description |
88
+ |-------|------|-------------|
89
+ | React | `.claude/skills/react/SKILL.md` | React 19+ patterns |
90
+ | Backend | `.claude/skills/backend/SKILL.md` | Clean architecture |
91
+ | Database | `.claude/skills/database/SKILL.md` | PostgreSQL/Drizzle |
92
+ | SEO | `.claude/skills/seo/SKILL.md` | Technical SEO |
93
+ | Code Quality | `.claude/skills/code-quality/SKILL.md` | General patterns |
94
+
95
+ ## Usage
96
+
97
+ Reference standards in conversation:
98
+ - `@path/to/standard.md` - Load full standard
99
+ - `/raftstack/inject [domain]` - Get relevant standards for a task
100
+ ```
101
+
102
+ ## Phase 4: Location Negotiation
103
+
104
+ Use `AskUserQuestion` with these options:
105
+ - Option A: `.claude/standards/REGISTRY.md` - With standards (Recommended)
106
+ - Option B: `.claude/REGISTRY.md` - In Claude folder
107
+ - Option C: `docs/REGISTRY.md` - With documentation
108
+ - Option D: Other (let user specify)
109
+
110
+ If a registry already exists, update it in place.
111
+
112
+ ## Phase 5: Drift Detection
113
+
114
+ Compare current codebase against documented standards:
115
+
116
+ 1. **Check for orphaned standards:**
117
+ - Standards that reference files/patterns no longer in codebase
118
+ - Flag for review
119
+
120
+ 2. **Check for undocumented patterns:**
121
+ - Significant code areas without corresponding standards
122
+ - Suggest running `/raftstack/discover` for those areas
123
+
124
+ 3. **Check for inconsistencies:**
125
+ - Code that violates documented standards
126
+ - Flag specific files for review
127
+
128
+ ## Phase 6: Indexing Summary
129
+
130
+ After scanning and creating the registry, present:
131
+
132
+ ```markdown
133
+ ## ✅ Standards Indexing Completed
134
+
135
+ ### 🎯 Registry Overview
136
+ - **Total Standards:** [N] documents
137
+ - **Domains Covered:** [list domains]
138
+ - **Skills Available:** [N] RaftStack skills
139
+ - **Registry Location:** `[path]`
140
+
141
+ ### 📋 What Was Found
142
+ | Domain | Standards | Last Updated |
143
+ |--------|-----------|--------------|
144
+ | API/Backend | [N] | [most recent date] |
145
+ | React/Frontend | [N] | [most recent date] |
146
+ | Database | [N] | [most recent date] |
147
+ | Other | [N] | [most recent date] |
148
+
149
+ ### 🔍 Drift Report
150
+
151
+ #### Orphaned Standards
152
+ | Standard | Issue | Recommendation |
153
+ |----------|-------|----------------|
154
+ | [path] | [References deleted file] | [Remove or update] |
155
+
156
+ #### Undocumented Areas
157
+ | Area | Files | Recommendation |
158
+ |------|-------|----------------|
159
+ | `src/auth/` | [N files] | Run `/raftstack/discover auth` |
160
+ | `src/utils/` | [N files] | Run `/raftstack/discover utils` |
161
+
162
+ #### Potential Violations
163
+ | File | Standard | Issue |
164
+ |------|----------|-------|
165
+ | `src/api/users.ts:45` | Error Handling | [Description] |
166
+
167
+ ### ⚠️ Action Items
168
+ 1. **[High Priority]** [Action needed] - [Why]
169
+ 2. **[Medium Priority]** [Action needed] - [Why]
170
+ 3. **[Low Priority]** [Action needed] - [Why]
171
+
172
+ ### 🔄 What's Next
173
+ - **Option A:** Fix orphaned standards - Update or remove stale references
174
+ - **Option B:** Document undocumented areas - Run discover for flagged areas
175
+ - **Option C:** Review violations - Check flagged files for compliance
176
+ - **Option D:** Done for now
177
+
178
+ **Your options:** [A] Fix orphaned [B] Document areas [C] Review violations [D] Done
179
+ ```
180
+
181
+ Use `AskUserQuestion` for options.
182
+
183
+ ## Phase 7: Drift Resolution
184
+
185
+ If user chooses to address drift:
186
+
187
+ ### Orphaned Standards
188
+ ```markdown
189
+ ## Resolving Orphaned Standard: [Standard Name]
190
+
191
+ **Issue:** References `[old-path]` which no longer exists.
192
+
193
+ **Options:**
194
+ - [A] Update standard to reference new location (if moved)
195
+ - [B] Remove the outdated reference
196
+ - [C] Delete the standard entirely
197
+ - [D] Skip for now
198
+ ```
199
+
200
+ Use `AskUserQuestion` for each orphaned standard.
201
+
202
+ ### Undocumented Areas
203
+ For each undocumented area, suggest:
204
+ - Run `/raftstack/discover [area]` to document patterns
205
+
206
+ ### Violations
207
+ For each violation, present:
208
+ - The standard that's being violated
209
+ - The specific code that violates it
210
+ - Options to fix or mark as acceptable deviation
211
+
212
+ ## Automation Suggestions
213
+
214
+ After indexing, suggest based on findings:
215
+
216
+ 1. **If many undocumented areas:** "Run `/raftstack/discover` for key areas"
217
+
218
+ 2. **If standards are old:** "Some standards haven't been updated in 90+ days. Review for accuracy."
219
+
220
+ 3. **If violations found:** "Review flagged files for standard compliance"
221
+
222
+ ## Example Output
223
+
224
+ ```markdown
225
+ ## ✅ Standards Indexing Completed
226
+
227
+ ### 🎯 Registry Overview
228
+ - **Total Standards:** 5 documents
229
+ - **Domains Covered:** API, React, Database
230
+ - **Skills Available:** 5 RaftStack skills
231
+ - **Registry Location:** `.claude/standards/REGISTRY.md`
232
+
233
+ ### 📋 What Was Found
234
+ | Domain | Standards | Last Updated |
235
+ |--------|-----------|--------------|
236
+ | API/Backend | 2 | 2024-01-20 |
237
+ | React/Frontend | 1 | 2024-01-18 |
238
+ | Database | 1 | 2024-01-15 |
239
+ | Other | 1 | 2024-01-10 |
240
+
241
+ ### 🔍 Drift Report
242
+
243
+ #### Undocumented Areas
244
+ | Area | Files | Recommendation |
245
+ |------|-------|----------------|
246
+ | `src/auth/` | 8 files | Run `/raftstack/discover auth` |
247
+ | `src/middleware/` | 3 files | Run `/raftstack/discover middleware` |
248
+
249
+ #### Potential Violations
250
+ | File | Standard | Issue |
251
+ |------|----------|-------|
252
+ | `src/api/users.ts:45` | Error Handling | Missing correlation ID |
253
+
254
+ ### ⚠️ Action Items
255
+ 1. **[Medium Priority]** Document auth patterns - 8 files without standards
256
+ 2. **[Low Priority]** Review error handling - 1 potential violation
257
+
258
+ **Your options:** [A] Document auth area [B] Review violations [C] Update old standards [D] Done
259
+ ```
@@ -0,0 +1,221 @@
1
+ # RaftStack: Initialize Project Context
2
+
3
+ Analyze this codebase and generate a constitution document that captures how this project works.
4
+
5
+ ## Tool Usage
6
+
7
+ **IMPORTANT:** Always use the `AskUserQuestion` tool for:
8
+ - Location negotiation (where to save files)
9
+ - Confirmation requests
10
+ - Clarification questions
11
+
12
+ Never use plain text questions - always use the structured `AskUserQuestion` tool.
13
+
14
+ ## Phase 1: Structure Discovery
15
+
16
+ First, analyze the project structure:
17
+
18
+ 1. **Detect project type:**
19
+ - Check for `nx.json` → NX Monorepo
20
+ - Check for `turbo.json` → Turborepo
21
+ - Check for `pnpm-workspace.yaml` → pnpm Workspace
22
+ - Check for `apps/` or `packages/` directories → Monorepo pattern
23
+ - Otherwise → Single package
24
+
25
+ 2. **Scan key configuration files:**
26
+ - `package.json` - dependencies, scripts, name
27
+ - `tsconfig.json` - TypeScript settings
28
+ - Framework configs (next.config.*, vite.config.*, etc.)
29
+ - `.env.example` or `.env.local` - environment patterns
30
+ - Database configs (drizzle.config.ts, prisma/schema.prisma)
31
+
32
+ 3. **Map directory structure:**
33
+ - Source locations (`src/`, `app/`, `pages/`, `lib/`)
34
+ - Test locations (`__tests__/`, `*.test.ts`, `*.spec.ts`)
35
+ - Config locations (`.github/`, `.husky/`, etc.)
36
+
37
+ ### Phase 1 Summary
38
+
39
+ After completing structure discovery, present:
40
+
41
+ ```markdown
42
+ ## ✅ Structure Discovery Completed
43
+
44
+ ### 🎯 Key Discoveries (Top 3)
45
+ 1. [Discovery] - **Significance:** [Why this matters]
46
+ 2. [Discovery] - **Significance:** [Why this matters]
47
+ 3. [Discovery] - **Significance:** [Why this matters]
48
+
49
+ ### 📋 What Was Found
50
+ - **Project Type:** [Detected type]
51
+ - **Framework:** [Detected framework]
52
+ - **Key Directories:** [List main directories]
53
+
54
+ ### 🔍 Important Configuration Files
55
+ 1. [File and what it configures]
56
+ 2. [File and what it configures]
57
+ 3. [File and what it configures]
58
+
59
+ ### ⚠️ Watch Out For
60
+ - [Potential issue or unusual pattern] - **Note:** [Guidance]
61
+ - [Missing expected config] - **Note:** [Guidance]
62
+
63
+ ### 🔄 Ready for Next Phase
64
+ Pattern extraction will analyze code style and architecture.
65
+
66
+ **Your options:** [A] Proceed to Pattern Extraction [B] Re-analyze structure [C] Explain findings [D] Skip to constitution
67
+ ```
68
+
69
+ Use `AskUserQuestion` to present options A/B/C/D.
70
+
71
+ ## Phase 2: Pattern Extraction
72
+
73
+ Analyze the code to discover existing patterns:
74
+
75
+ 1. **Component/Module patterns:**
76
+ - How are React components structured? (file naming, export style)
77
+ - How are API routes organized?
78
+ - What's the state management approach?
79
+
80
+ 2. **Code style patterns:**
81
+ - Import ordering conventions
82
+ - Error handling approach
83
+ - Logging patterns
84
+ - Naming conventions (camelCase, kebab-case for files, etc.)
85
+
86
+ 3. **Architecture patterns:**
87
+ - Data flow (client → API → database)
88
+ - Authentication approach
89
+ - Shared utilities location
90
+
91
+ ### Phase 2 Summary
92
+
93
+ After completing pattern extraction, present:
94
+
95
+ ```markdown
96
+ ## ✅ Pattern Extraction Completed
97
+
98
+ ### 🎯 Key Patterns Found (Top 3)
99
+ 1. [Pattern] - **Significance:** [How it shapes development]
100
+ 2. [Pattern] - **Significance:** [How it shapes development]
101
+ 3. [Pattern] - **Significance:** [How it shapes development]
102
+
103
+ ### 📋 What Was Analyzed
104
+ - **Components:** [Summary of component patterns]
105
+ - **API/Backend:** [Summary of backend patterns]
106
+ - **Code Style:** [Summary of style conventions]
107
+
108
+ ### 🔍 Conventions Detected
109
+ 1. [Naming convention with example]
110
+ 2. [Import convention with example]
111
+ 3. [Error handling approach]
112
+
113
+ ### ⚠️ Inconsistencies Noted
114
+ - [Inconsistency] - **Impact:** [Why it matters]
115
+ - [Inconsistency] - **Impact:** [Why it matters]
116
+
117
+ ### 🔄 Ready for Constitution Generation
118
+ The constitution will capture all discovered patterns and structure.
119
+
120
+ **Your options:** [A] Generate constitution [B] Analyze more patterns [C] Explain a pattern [D] Start over
121
+ ```
122
+
123
+ Use `AskUserQuestion` to present options A/B/C/D.
124
+
125
+ ## Phase 3: Generate Constitution
126
+
127
+ Create a constitution document with these sections:
128
+
129
+ ```markdown
130
+ # [Project Name] Constitution
131
+
132
+ ## Overview
133
+ [One paragraph describing what this project does]
134
+
135
+ ## Project Structure
136
+ [Detected structure - monorepo type, key directories]
137
+
138
+ ## Tech Stack
139
+ | Layer | Technology | Config File |
140
+ |-------|------------|-------------|
141
+ | Framework | [detected] | [config path] |
142
+ | Database | [detected] | [config path] |
143
+ | Styling | [detected] | [config path] |
144
+ | Testing | [detected] | [config path] |
145
+
146
+ ## Patterns
147
+ ### Component Structure
148
+ [Detected patterns]
149
+
150
+ ### API/Backend Structure
151
+ [Detected patterns]
152
+
153
+ ### Error Handling
154
+ [Detected patterns]
155
+
156
+ ## Conventions
157
+ ### Naming
158
+ - Files: [detected]
159
+ - Functions: [detected]
160
+ - Components: [detected]
161
+
162
+ ### Imports
163
+ [Detected ordering/aliasing patterns]
164
+
165
+ ## Future Direction
166
+ [User provides this - project goals, planned features]
167
+ ```
168
+
169
+ ## Phase 4: Location Negotiation
170
+
171
+ After generating the constitution, use `AskUserQuestion` to ask where to save it:
172
+
173
+ **Use AskUserQuestion with these options:**
174
+ - Option A: `.claude/context/constitution.md` - Claude-specific context folder (Recommended)
175
+ - Option B: `docs/constitution.md` - With project documentation
176
+ - Option C: `CONSTITUTION.md` - At project root
177
+ - Option D: Other (let user specify)
178
+
179
+ ## Phase 5: Final Summary
180
+
181
+ After saving the constitution, present:
182
+
183
+ ```markdown
184
+ ## ✅ Context Initialization Completed
185
+
186
+ ### 🎯 What Was Created
187
+ 1. **Constitution Document** - **Location:** [path]
188
+ - Captures project structure and patterns
189
+ 2. **[N] Patterns Documented** - **Coverage:** [areas covered]
190
+ 3. **Tech Stack Mapped** - **Frameworks:** [list]
191
+
192
+ ### 📋 Constitution Highlights
193
+ - [Key insight about the project]
194
+ - [Key insight about the project]
195
+ - [Key insight about the project]
196
+
197
+ ### 🔍 Important Items to Review
198
+ 1. [Section that may need user refinement]
199
+ 2. [Area with incomplete detection]
200
+ 3. [Future Direction section - needs user input]
201
+
202
+ ### ⚠️ Follow-up Recommendations
203
+ - **Run `/raftstack/discover`** - Extract specific patterns as reusable standards
204
+ - **Review Future Direction** - Add your project goals and planned features
205
+
206
+ ### 🔄 What This Enables
207
+ - **Option A:** Run `/raftstack/discover [area]` - Document specific patterns as standards
208
+ - **Option B:** Run `/raftstack/shape [feature]` - Plan a feature using this context
209
+ - **Option C:** Edit constitution manually - Refine detected patterns
210
+
211
+ **Your options:** [A] Discover patterns [B] Shape a feature [C] Edit constitution [D] Done for now
212
+ ```
213
+
214
+ Use `AskUserQuestion` to present final options.
215
+
216
+ ## Output
217
+
218
+ Once location is confirmed:
219
+ 1. Create the constitution file at the chosen location
220
+ 2. Present the final summary with discoveries
221
+ 3. Offer next step options via `AskUserQuestion`