@eskoubar95/spec 0.1.0 → 0.1.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.
Files changed (98) hide show
  1. package/dist/commands/help.d.ts +5 -0
  2. package/dist/commands/help.d.ts.map +1 -0
  3. package/dist/commands/help.js +23 -0
  4. package/dist/commands/help.js.map +1 -0
  5. package/dist/commands/init.d.ts.map +1 -1
  6. package/dist/commands/init.js +30 -14
  7. package/dist/commands/init.js.map +1 -1
  8. package/dist/commands/install.d.ts +5 -0
  9. package/dist/commands/install.d.ts.map +1 -0
  10. package/dist/commands/install.js +88 -0
  11. package/dist/commands/install.js.map +1 -0
  12. package/dist/commands/update.d.ts +5 -0
  13. package/dist/commands/update.d.ts.map +1 -0
  14. package/dist/commands/update.js +72 -0
  15. package/dist/commands/update.js.map +1 -0
  16. package/dist/commands/workspace.d.ts +5 -0
  17. package/dist/commands/workspace.d.ts.map +1 -0
  18. package/dist/commands/workspace.js +17 -0
  19. package/dist/commands/workspace.js.map +1 -0
  20. package/dist/index.js +42 -9
  21. package/dist/index.js.map +1 -1
  22. package/dist/lib/backup-cursor.d.ts +16 -0
  23. package/dist/lib/backup-cursor.d.ts.map +1 -0
  24. package/dist/lib/backup-cursor.js +50 -0
  25. package/dist/lib/backup-cursor.js.map +1 -0
  26. package/dist/lib/copy-template.d.ts +9 -1
  27. package/dist/lib/copy-template.d.ts.map +1 -1
  28. package/dist/lib/copy-template.js +94 -3
  29. package/dist/lib/copy-template.js.map +1 -1
  30. package/dist/lib/cursor-detection.d.ts +6 -0
  31. package/dist/lib/cursor-detection.d.ts.map +1 -0
  32. package/dist/lib/cursor-detection.js +31 -0
  33. package/dist/lib/cursor-detection.js.map +1 -0
  34. package/dist/lib/detection.d.ts +25 -0
  35. package/dist/lib/detection.d.ts.map +1 -0
  36. package/dist/lib/detection.js +186 -0
  37. package/dist/lib/detection.js.map +1 -0
  38. package/dist/lib/install-existing.d.ts +6 -0
  39. package/dist/lib/install-existing.d.ts.map +1 -0
  40. package/dist/lib/install-existing.js +63 -0
  41. package/dist/lib/install-existing.js.map +1 -0
  42. package/dist/lib/project-name.d.ts +7 -0
  43. package/dist/lib/project-name.d.ts.map +1 -0
  44. package/dist/lib/project-name.js +13 -0
  45. package/dist/lib/project-name.js.map +1 -0
  46. package/dist/lib/prompts.d.ts +6 -5
  47. package/dist/lib/prompts.d.ts.map +1 -1
  48. package/dist/lib/prompts.js +114 -0
  49. package/dist/lib/prompts.js.map +1 -1
  50. package/dist/lib/version-check.d.ts +21 -0
  51. package/dist/lib/version-check.d.ts.map +1 -0
  52. package/dist/lib/version-check.js +49 -0
  53. package/dist/lib/version-check.js.map +1 -0
  54. package/dist/lib/workspace.d.ts +7 -0
  55. package/dist/lib/workspace.d.ts.map +1 -0
  56. package/dist/lib/workspace.js +38 -0
  57. package/dist/lib/workspace.js.map +1 -0
  58. package/dist/types.d.ts +32 -0
  59. package/dist/types.d.ts.map +1 -0
  60. package/dist/types.js +2 -0
  61. package/dist/types.js.map +1 -0
  62. package/package.json +2 -2
  63. package/template/.cursor/commands/_shared/activation.md +220 -0
  64. package/template/.cursor/commands/_shared/coderabbit-integration.md +278 -0
  65. package/template/.cursor/commands/_shared/command-stacks.md +124 -0
  66. package/template/.cursor/commands/_shared/deployment-detection.md +294 -0
  67. package/template/.cursor/commands/_shared/detection.md +277 -0
  68. package/template/.cursor/commands/_shared/documentation-lookup.md +321 -0
  69. package/template/.cursor/commands/_shared/git-workflow.md +288 -0
  70. package/template/.cursor/commands/_shared/github-helpers.md +337 -0
  71. package/template/.cursor/commands/_shared/github-workflows.md +351 -0
  72. package/template/.cursor/commands/_shared/helper-metadata.md +481 -0
  73. package/template/.cursor/commands/_shared/linear-automation.md +388 -0
  74. package/template/.cursor/commands/_shared/linear-helpers.md +254 -0
  75. package/template/.cursor/commands/_shared/performance-monitoring.md +369 -0
  76. package/template/.cursor/commands/_shared/pr-description.md +279 -0
  77. package/template/.cursor/commands/_shared/retrospective-spec-creation.md +977 -0
  78. package/template/.cursor/commands/_shared/scaling.md +264 -0
  79. package/template/.cursor/commands/_shared/state-assertions.md +174 -0
  80. package/template/.cursor/commands/_shared/test-automation.md +388 -0
  81. package/template/.cursor/commands/_shared/verification-checkpoints.md +145 -0
  82. package/template/.cursor/commands/spec/audit.md +240 -0
  83. package/template/.cursor/commands/spec/evolve.md +163 -0
  84. package/template/.cursor/commands/spec/sync.md +196 -0
  85. package/template/.cursor/commands/tools/refactor.md +555 -0
  86. package/template/.cursor/rules/10-engineering.mdc +149 -0
  87. package/template/.cursor/rules/11-design.mdc +129 -0
  88. package/template/.cursor/rules/12-business.mdc +132 -0
  89. package/template/.cursor/rules/20-nextjs.mdc +146 -0
  90. package/template/.cursor/rules/21-api-design.mdc +176 -0
  91. package/template/.cursor/rules/30-database.mdc +183 -0
  92. package/template/.cursor/rules/31-testing.mdc +191 -0
  93. package/template/.cursor/scripts/validate-helpers.js +254 -0
  94. package/template/.sdd/detection-cache.json +1 -0
  95. package/template/.sdd/install-info.json +1 -0
  96. package/template/.sdd/version +1 -0
  97. package/template/spec/00-root-spec.md +8 -1
  98. package/template/work/backlog/tasks.local.md +92 -0
@@ -0,0 +1,277 @@
1
+ ---
2
+ helper_id: detection
3
+ load_when:
4
+ - always
5
+ sections:
6
+ project_type:
7
+ title: "Project Type Detection"
8
+ lines: [1, 50]
9
+ project_size:
10
+ title: "Project Size Detection"
11
+ lines: [51, 100]
12
+ technologies:
13
+ title: "Technology Detection"
14
+ lines: [101, 200]
15
+ always_load: true
16
+ ---
17
+
18
+ # Project Detection Engine
19
+
20
+ This detection engine automatically identifies project characteristics to enable dynamic rule activation and workflow adaptation.
21
+
22
+ ## Purpose
23
+
24
+ Before any SDD command executes, this engine detects:
25
+ - Project type (web-app, cli-tool, library, api-service, mobile-app, monorepo)
26
+ - Project size (small, medium, large, enterprise)
27
+ - Project phase (initialization, expansion, maintenance, migration, legacy)
28
+ - Technologies (frameworks, databases, auth, styling, testing)
29
+ - Team size (if available from git)
30
+
31
+ ## Detection Process
32
+
33
+ **Step 1: Read project structure**
34
+ - Check for `package.json` (Node.js projects)
35
+ - Check for `pyproject.toml`, `requirements.txt` (Python projects)
36
+ - Check for `Cargo.toml` (Rust projects)
37
+ - Check for `go.mod` (Go projects)
38
+ - Check file structure (app/, src/, lib/, etc.)
39
+ - Check config files (next.config.js, vite.config.js, etc.)
40
+
41
+ **Step 2: Detect project type**
42
+
43
+ ```markdown
44
+ ## Project Type Detection Rules
45
+
46
+ **web-app:**
47
+ - Has: next.config.js, vite.config.js, nuxt.config.js, remix.config.js
48
+ - OR: app/ directory (Next.js App Router)
49
+ - OR: src/app/ directory
50
+ - OR: pages/ directory (Next.js Pages Router)
51
+ - OR: React, Vue, Angular, Svelte in dependencies
52
+
53
+ **cli-tool:**
54
+ - Has: bin/ directory
55
+ - OR: commander, yargs, meow, oclif in dependencies
56
+ - OR: package.json has "bin" field
57
+
58
+ **library:**
59
+ - Has: package.json with "exports" field
60
+ - OR: package.json with "types" field
61
+ - OR: src/ with index.ts/js (main entry point)
62
+ - AND: No app/, pages/, or bin/ directories
63
+
64
+ **api-service:**
65
+ - Has: Express, FastAPI, Flask, Koa in dependencies
66
+ - OR: app/api/ directory (Next.js API routes)
67
+ - OR: routes/ directory
68
+ - OR: server.ts/js file
69
+ - AND: No app/ or pages/ directories (unless Next.js API routes)
70
+
71
+ **mobile-app:**
72
+ - Has: react-native, flutter, expo in dependencies
73
+ - OR: ios/ directory
74
+ - OR: android/ directory
75
+ - OR: app.json (Expo)
76
+
77
+ **monorepo:**
78
+ - Has: package.json with "workspaces" field
79
+ - OR: packages/ directory
80
+ - OR: apps/ directory
81
+ - OR: pnpm-workspace.yaml, lerna.json, nx.json
82
+ ```
83
+
84
+ **Step 3: Detect project size**
85
+
86
+ ```markdown
87
+ ## Project Size Detection Rules
88
+
89
+ Count files (excluding node_modules, .git, dist, build):
90
+ - **Small:** < 50 files, < 10 dependencies, simple spec structure
91
+ - **Medium:** 50-200 files, 10-50 dependencies, moderate spec structure
92
+ - **Large:** 200-1000 files, 50-200 dependencies, complex spec structure
93
+ - **Enterprise:** > 1000 files, > 200 dependencies, very complex spec structure
94
+
95
+ **Complexity indicators:**
96
+ - Number of spec files
97
+ - Number of work/backlog tasks
98
+ - Number of milestones
99
+ - Depth of directory structure
100
+ ```
101
+
102
+ **Step 4: Detect project phase**
103
+
104
+ ```markdown
105
+ ## Project Phase Detection Rules
106
+
107
+ **initialization:**
108
+ - New git repo (few or no commits)
109
+ - Empty or initial spec files
110
+ - No or minimal work/backlog content
111
+ - Recent first commit (< 1 week old)
112
+
113
+ **expansion:**
114
+ - Active development (regular commits)
115
+ - Growing spec (multiple spec files, evolving content)
116
+ - Active work/backlog (tasks being added/completed)
117
+ - Recent commits (< 1 month old)
118
+
119
+ **maintenance:**
120
+ - Stable codebase (infrequent commits)
121
+ - Stable spec (minimal changes)
122
+ - Bugfix/refactor commits dominate
123
+ - Long history (> 3 months old)
124
+
125
+ **migration:**
126
+ - Framework upgrade commits
127
+ - Architecture change commits
128
+ - Spec updates related to migration
129
+ - Breaking changes in git history
130
+
131
+ **legacy:**
132
+ - Existing codebase (long history > 6 months)
133
+ - Old spec (not updated recently)
134
+ - Minimal changes (few commits)
135
+ - Outdated dependencies
136
+ ```
137
+
138
+ **Step 5: Detect technologies**
139
+
140
+ **Priority 1: Read tech stack from spec (if available)**
141
+
142
+ 1. **Check for tech stack in spec:**
143
+ - Read `spec/08-infrastructure.md` for "Technology Stack" section
144
+ - Read `spec/02-architecture.md` for "Technology Stack" section (if architecture exists)
145
+ - Parse tech stack format: "Frontend Framework: [name], CMS: [name], Database: [name], etc."
146
+
147
+ 2. **Extract frameworks/tools from tech stack:**
148
+ - Parse each line in Technology Stack section
149
+ - Extract framework/tool names
150
+ - Normalize names (e.g., "Next.js" → "nextjs", "Payload CMS" → "payload-cms")
151
+
152
+ 3. **If tech stack found in spec:**
153
+ - Use tech stack from spec as primary source
154
+ - This is the authoritative source of truth for frameworks/tools
155
+ - Supplement with package.json detection if needed
156
+
157
+ **Priority 2: Detect from package.json (if tech stack not in spec)**
158
+
159
+ ```markdown
160
+ ## Technology Detection Rules
161
+
162
+ **Frameworks:**
163
+ - next → Next.js
164
+ - react → React
165
+ - vue → Vue.js
166
+ - angular → Angular
167
+ - svelte → Svelte
168
+ - express → Express.js
169
+ - fastapi → FastAPI
170
+ - flask → Flask
171
+
172
+ **Databases:**
173
+ - postgres, pg → PostgreSQL
174
+ - mysql, mysql2 → MySQL
175
+ - mongodb → MongoDB
176
+ - supabase → Supabase
177
+ - prisma → Prisma (ORM)
178
+
179
+ **Auth:**
180
+ - clerk → Clerk
181
+ - auth0 → Auth0
182
+ - next-auth → NextAuth.js
183
+ - supabase-auth → Supabase Auth
184
+
185
+ **Styling:**
186
+ - tailwindcss → Tailwind CSS
187
+ - styled-components → Styled Components
188
+ - emotion → Emotion
189
+ - css-modules → CSS Modules
190
+
191
+ **Testing:**
192
+ - jest → Jest
193
+ - vitest → Vitest
194
+ - playwright → Playwright
195
+ - cypress → Cypress
196
+ - testing-library → Testing Library
197
+ ```
198
+
199
+ **Tech Stack Parsing Logic:**
200
+
201
+ When reading tech stack from spec:
202
+ 1. Look for "Technology Stack" section in `spec/08-infrastructure.md` or `spec/02-architecture.md`
203
+ 2. Parse lines like:
204
+ - "Frontend Framework: Next.js" → extract "Next.js" → normalize to "nextjs"
205
+ - "CMS: Payload CMS" → extract "Payload CMS" → normalize to "payload-cms"
206
+ - "Database: PostgreSQL" → extract "PostgreSQL" → normalize to "postgres"
207
+ 3. Create list of detected frameworks/tools from spec
208
+ 4. Use this list for rule activation and documentation lookup
209
+
210
+ **Step 6: Detect team size (optional)**
211
+
212
+ ```markdown
213
+ ## Team Size Detection Rules
214
+
215
+ From git contributors (if available):
216
+ - **Solo:** 1 contributor
217
+ - **Small team:** 2-5 contributors
218
+ - **Medium team:** 5-15 contributors
219
+ - **Large team:** 15+ contributors
220
+ ```
221
+
222
+ ## Detection Output Format
223
+
224
+ ```json
225
+ {
226
+ "projectType": "web-app",
227
+ "projectSize": "medium",
228
+ "projectPhase": "expansion",
229
+ "technologies": {
230
+ "framework": "nextjs",
231
+ "database": "postgres",
232
+ "auth": "clerk",
233
+ "styling": "tailwindcss",
234
+ "testing": "jest"
235
+ },
236
+ "teamSize": "small",
237
+ "confidence": {
238
+ "projectType": 0.95,
239
+ "projectSize": 0.85,
240
+ "projectPhase": 0.90,
241
+ "technologies": 0.95
242
+ },
243
+ "sources": {
244
+ "projectType": ["next.config.js", "app/ directory"],
245
+ "projectSize": ["file count: 127", "dependencies: 23"],
246
+ "projectPhase": ["git history", "spec age"],
247
+ "technologies": ["package.json dependencies"]
248
+ },
249
+ "timestamp": "2026-01-07T12:00:00Z"
250
+ }
251
+ ```
252
+
253
+ ## Cache Management
254
+
255
+ Detection results are cached in `.sdd/detection-cache.json` for performance.
256
+
257
+ **Cache invalidation triggers:**
258
+ - package.json changes
259
+ - New config files added
260
+ - Significant file structure changes
261
+ - Spec files added/removed
262
+ - Git history changes (new commits)
263
+
264
+ **Cache structure:**
265
+ - Store detection results with timestamp
266
+ - Include confidence scores
267
+ - Include sources for each detection
268
+ - Allow manual cache invalidation
269
+
270
+ ## Usage in Commands
271
+
272
+ All SDD commands should:
273
+ 1. Run detection (or read from cache if valid)
274
+ 2. Use detection results for rule activation
275
+ 3. Include detection context in state assertions
276
+ 4. Adapt workflow based on detected characteristics
277
+
@@ -0,0 +1,321 @@
1
+ ---
2
+ helper_id: documentation-lookup
3
+ load_when:
4
+ - framework_detected
5
+ - tool_detected
6
+ - documentation_needed
7
+ - task_start
8
+ - task_validate
9
+ sections:
10
+ context7:
11
+ title: "Context7 Integration"
12
+ lines: [10, 80]
13
+ lookup_logic:
14
+ title: "Documentation Lookup Logic"
15
+ lines: [17, 150]
16
+ fallback:
17
+ title: "Fallback Strategies"
18
+ lines: [151, 220]
19
+ always_load: false
20
+ ---
21
+
22
+ # Documentation Lookup Helper
23
+
24
+ This document provides guidance for fetching up-to-date documentation for frameworks, tools, and libraries using Context7 MCP.
25
+
26
+ ## Purpose
27
+
28
+ Enable dynamic documentation lookup for any framework/tool/library without requiring library ID mapping. Context7 MCP can automatically resolve library IDs based on queries.
29
+
30
+ ## Context7 Integration
31
+
32
+ **Context7 MCP Functions:**
33
+ - `mcp_context7_resolve-library-id`: Resolves library name to Context7 library ID (optional, Context7 can find it automatically)
34
+ - `mcp_context7_query-docs`: Queries documentation directly using library name or ID
35
+
36
+ **Key Insight:** Context7 can automatically resolve library IDs from queries, so library ID mapping is not necessary.
37
+
38
+ ## Documentation Lookup Logic
39
+
40
+ ### Step 1: Check Context7 MCP Availability
41
+
42
+ **Before fetching documentation:**
43
+ 1. Check if Context7 MCP is available
44
+ 2. If available → proceed with Context7 lookup
45
+ 3. If unavailable → use cached documentation or continue without documentation
46
+
47
+ ### Step 2: Query Context7 (If Available)
48
+
49
+ **Query Format:**
50
+ - Use framework/tool name directly in query
51
+ - Format: "[Framework/Tool Name] [specific topic]"
52
+ - Context7 automatically resolves library ID based on query
53
+
54
+ **Example Queries:**
55
+ - "Next.js Server Components patterns"
56
+ - "Payload CMS collection setup"
57
+ - "Vite build configuration"
58
+ - "FastAPI endpoint implementation"
59
+ - "PostgreSQL connection pooling"
60
+ - "React hooks best practices"
61
+
62
+ **Query Strategy:**
63
+ 1. **Direct Query (Recommended):**
64
+ - Use `mcp_context7_query-docs` directly with framework/tool name in query
65
+ - Example: `mcp_context7_query-docs(libraryId: null, query: "Next.js Server Components patterns")`
66
+ - Context7 will automatically resolve the library ID from the query
67
+
68
+ 2. **Resolve First (If Needed):**
69
+ - If you need the library ID explicitly, use `mcp_context7_resolve-library-id` first
70
+ - Example: `mcp_context7_resolve-library-id(libraryName: "next.js", query: "Server Components")`
71
+ - Then use resolved library ID in `mcp_context7_query-docs`
72
+
73
+ **Best Practice:**
74
+ - Use direct query approach (Step 1) - it's simpler and Context7 handles resolution automatically
75
+ - Only use resolve-first approach if you need the library ID for other purposes
76
+
77
+ ### Step 3: Cache Management
78
+
79
+ **Cache File:** `.sdd/docs-cache.json`
80
+
81
+ **Cache Structure:**
82
+ ```json
83
+ {
84
+ "nextjs": {
85
+ "queries": {
86
+ "Server Components patterns": {
87
+ "content": "...",
88
+ "timestamp": "2024-01-01T00:00:00Z",
89
+ "ttl": 86400
90
+ }
91
+ }
92
+ },
93
+ "vite": {
94
+ "queries": {
95
+ "Build configuration": {
96
+ "content": "...",
97
+ "timestamp": "2024-01-01T00:00:00Z",
98
+ "ttl": 86400
99
+ }
100
+ }
101
+ }
102
+ }
103
+ ```
104
+
105
+ **Cache Strategy:**
106
+ 1. Before querying Context7, check cache:
107
+ - If query exists in cache and not expired (TTL: 24 hours) → use cached content
108
+ - If query doesn't exist or expired → fetch from Context7
109
+ 2. After fetching from Context7, update cache with new content and timestamp
110
+ 3. Cache key: framework/tool name + query topic
111
+
112
+ **Cache TTL:** 24 hours (documentation doesn't change frequently)
113
+
114
+ ### Step 4: Fallback Strategy (Multi-Source Documentation)
115
+
116
+ **If Context7 MCP Unavailable or insufficient:**
117
+
118
+ **Priority 1: Check Cache**
119
+ 1. Check cache for existing documentation (if available and not expired)
120
+ 2. If cached documentation available → use it
121
+
122
+ **Priority 2: Cursor Documentation Indexing**
123
+ 1. If Context7 unavailable or insufficient → use Cursor's built-in documentation indexing
124
+ 2. Cursor can index project documentation, README files, and code comments
125
+ 3. Search indexed documentation for framework/tool information
126
+ 4. Use indexed documentation to answer questions
127
+
128
+ **Priority 3: Web Search**
129
+ 1. If Context7 unavailable and cache/indexed docs insufficient → use web search
130
+ 2. Search for framework/tool documentation online
131
+ 3. Use web search results to answer questions
132
+ 4. Example queries: "[Framework] [topic] documentation", "[Framework] [topic] best practices"
133
+
134
+ **Priority 4: General Patterns**
135
+ 1. If all documentation sources unavailable → use general engineering patterns from `10-engineering.mdc`
136
+ 2. Continue workflow without blocking
137
+ 3. Report to user: "Documentation lookup limited. Using general patterns and available information."
138
+
139
+ **Smart Thinking Approach:**
140
+ - Be flexible and adaptive
141
+ - Use multiple sources when available
142
+ - Don't be rigid - if one source fails, try others
143
+ - Combine information from multiple sources when helpful
144
+ - Only ask user if all sources exhausted and information critical
145
+
146
+ ## When to Fetch Documentation
147
+
148
+ **Fetch documentation when:**
149
+ 1. Framework/tool detected from tech stack in spec
150
+ 2. Implementation question arises (how to implement X in framework Y)
151
+ 3. Debugging framework-specific issue
152
+ 4. Verifying framework patterns match best practices
153
+ 5. Refactoring framework-specific code
154
+
155
+ **Do NOT fetch documentation when:**
156
+ - General code quality issues (use general patterns)
157
+ - Framework-agnostic problems
158
+ - Documentation already cached and not expired
159
+
160
+ ## Query Examples by Use Case
161
+
162
+ ### Implementation Guidance
163
+
164
+ **When implementing a feature:**
165
+ - Query: "[Framework] [feature type] implementation"
166
+ - Example: "Next.js Server Actions implementation"
167
+ - Example: "Payload CMS collection setup"
168
+
169
+ ### Debugging
170
+
171
+ **When debugging an issue:**
172
+ - Query: "[Framework] [issue type] troubleshooting"
173
+ - Example: "Next.js hydration mismatch"
174
+ - Example: "Vite build errors"
175
+
176
+ ### Best Practices
177
+
178
+ **When verifying patterns:**
179
+ - Query: "[Framework] [pattern type] best practices"
180
+ - Example: "Next.js Server Components best practices"
181
+ - Example: "FastAPI endpoint patterns"
182
+
183
+ ### Common Patterns
184
+
185
+ **When checking common patterns:**
186
+ - Query: "[Framework] [pattern name]"
187
+ - Example: "Next.js API routes"
188
+ - Example: "React hooks patterns"
189
+
190
+ ## Integration in Commands
191
+
192
+ ### In `/task/start`:
193
+
194
+ **When framework/tool detected from tech stack:**
195
+ 1. Check if documentation needed for implementation
196
+ 2. If yes → try multiple sources (in order):
197
+ - Query Context7: "[Framework] [implementation topic]"
198
+ - If Context7 unavailable → use Cursor documentation indexing
199
+ - If insufficient → use web search: "[Framework] [implementation topic] documentation"
200
+ - Combine with general engineering patterns
201
+ 3. Use documentation from available sources to guide implementation
202
+ 4. Reference documentation source in suggestions
203
+
204
+ **Example:**
205
+ - Tech stack: "Next.js, Payload CMS"
206
+ - Task: "Implement blog post creation"
207
+ - Try: Context7 query "Next.js Server Actions form submission"
208
+ - If unavailable: Search Cursor indexed docs or web for "Next.js Server Actions form submission"
209
+ - Use: Information from available sources to guide implementation
210
+
211
+ ### In `/task/validate`:
212
+
213
+ **When debugging framework-specific issue:**
214
+ 1. Identify framework/tool from tech stack
215
+ 2. Try multiple sources (in order):
216
+ - Query Context7: "[Framework] [issue topic]"
217
+ - If Context7 unavailable → use Cursor documentation indexing
218
+ - If insufficient → use web search: "[Framework] [issue topic] troubleshooting"
219
+ - Combine with general engineering patterns
220
+ 3. Use documentation from available sources to verify correct usage
221
+ 4. Suggest fixes based on documentation from available sources
222
+
223
+ **Example:**
224
+ - Issue: "Server Component using hooks"
225
+ - Try: Context7 query "Next.js Server Components limitations"
226
+ - If unavailable: Search Cursor indexed docs or web for "Next.js Server Components limitations"
227
+ - Use: Information from available sources to explain issue and suggest fix
228
+
229
+ ### In `/tools/refactor`:
230
+
231
+ **When checking framework-specific patterns:**
232
+ 1. Identify framework/tool from tech stack
233
+ 2. Try multiple sources (in order):
234
+ - Query Context7: "[Framework] [pattern topic]"
235
+ - If Context7 unavailable → use Cursor documentation indexing
236
+ - If insufficient → use web search: "[Framework] [pattern topic] best practices"
237
+ - Combine with general engineering patterns
238
+ 3. Check code against documentation from available sources
239
+ 4. Reference documentation source in refactoring suggestions
240
+
241
+ **Example:**
242
+ - Framework: "Next.js"
243
+ - Pattern check: "Server Components vs Client Components"
244
+ - Try: Context7 query "Next.js Server Components vs Client Components"
245
+ - If unavailable: Search Cursor indexed docs or web for "Next.js Server Components vs Client Components"
246
+ - Use: Information from available sources to verify correct usage
247
+
248
+ ## Tech Stack Source
249
+
250
+ **Read tech stack from:**
251
+ 1. `spec/08-infrastructure.md` - Technology Stack section
252
+ 2. `spec/02-architecture.md` - Technology Stack section (if architecture exists)
253
+
254
+ **Tech Stack Format:**
255
+ ```markdown
256
+ ## Technology Stack
257
+ - Frontend Framework: Next.js
258
+ - CMS: Payload CMS
259
+ - Database: PostgreSQL
260
+ - Build Tool: Vite
261
+ - Language: TypeScript
262
+ ```
263
+
264
+ **Parse tech stack:**
265
+ - Extract framework/tool names from tech stack
266
+ - Use these names directly in Context7 queries
267
+ - No library ID mapping needed
268
+
269
+ ## Error Handling & Multi-Source Strategy
270
+
271
+ **If Context7 query fails:**
272
+ 1. Log error clearly
273
+ 2. Try alternative sources (in order):
274
+ - Check cache for alternative documentation
275
+ - Use Cursor's documentation indexing
276
+ - Use web search for framework documentation
277
+ - Use general engineering patterns
278
+ 3. Combine information from multiple sources if helpful
279
+ 4. Continue workflow (don't block)
280
+ 5. Report to user: "Context7 lookup failed for [framework]. Using alternative sources (cache/indexing/web search)."
281
+
282
+ **If Context7 MCP unavailable:**
283
+ 1. Try alternative sources (in order):
284
+ - Check cache first
285
+ - Use Cursor's documentation indexing
286
+ - Use web search for framework documentation
287
+ - Use general engineering patterns
288
+ 2. Combine information from multiple sources if helpful
289
+ 3. Continue workflow (don't block)
290
+ 4. Report to user: "Context7 unavailable. Using alternative sources (cache/indexing/web search)."
291
+
292
+ **Smart Thinking:**
293
+ - Don't be rigid - adapt to available resources
294
+ - Use multiple sources when helpful
295
+ - Combine information from different sources
296
+ - Only ask user if all sources exhausted and information is critical
297
+ - Be proactive in finding information, not passive
298
+
299
+ ## Best Practices
300
+
301
+ 1. **Use specific queries:** Be specific in queries to get relevant documentation
302
+ 2. **Cache results:** Always cache successful queries to reduce API calls
303
+ 3. **Don't block workflow:** Never block workflow if documentation unavailable
304
+ 4. **Use multiple sources:** Combine Context7, Cursor indexing, web search, and general patterns
305
+ 5. **Be adaptive:** If one source fails, try others - don't give up easily
306
+ 6. **Combine information:** Use information from multiple sources when helpful
307
+ 7. **Reference sources:** Always reference documentation source when suggesting implementation
308
+ 8. **Smart thinking:** Be proactive in finding information, not passive
309
+
310
+ ## Example Workflow
311
+
312
+ **Scenario: Implementing Next.js Server Component**
313
+
314
+ 1. **Tech stack detected:** "Next.js" from `spec/08-infrastructure.md`
315
+ 2. **Documentation needed:** Server Component implementation
316
+ 3. **Check cache:** Look for "nextjs" → "Server Components patterns" in cache
317
+ 4. **If not cached:** Query Context7: "Next.js Server Components patterns"
318
+ 5. **Cache result:** Store in `.sdd/docs-cache.json`
319
+ 6. **Use documentation:** Guide implementation based on documentation
320
+ 7. **Reference in suggestions:** "According to Next.js documentation, Server Components..."
321
+