@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,977 @@
1
+ ---
2
+ helper_id: retrospective-spec-creation
3
+ load_when:
4
+ - legacy_project_detected
5
+ - retrospective_mode_requested
6
+ - spec_audit
7
+ - spec_sync
8
+ sections:
9
+ overview:
10
+ title: "Retrospective Spec Creation Overview"
11
+ lines: [1, 50]
12
+ audit_strategy:
13
+ title: "Audit Strategy"
14
+ lines: [51, 120]
15
+ sync_process:
16
+ title: "Sync Process"
17
+ lines: [121, 200]
18
+ documentation_patterns:
19
+ title: "Documentation Patterns"
20
+ lines: [201, 300]
21
+ enterprise_patterns:
22
+ title: "Enterprise-Specific Patterns"
23
+ lines: [301, 400]
24
+ always_load: false
25
+ ---
26
+
27
+ # Retrospective Spec Creation
28
+
29
+ This helper provides guidance for creating specifications from existing codebases, enabling SDD adoption in legacy and enterprise projects.
30
+
31
+ ## Purpose
32
+
33
+ Create comprehensive specifications that document what already exists in an existing codebase, serving as:
34
+ - Foundation for future development work
35
+ - Knowledge preservation and transfer
36
+ - Alignment baseline for refactoring and migration
37
+ - Source of truth for undocumented features
38
+
39
+ ## When to Use
40
+
41
+ Use retrospective spec creation when:
42
+ - Working with existing projects older than 6 months
43
+ - Codebase lacks comprehensive documentation
44
+ - Team needs to understand current state before changes
45
+ - Adopting SDD in an established project
46
+ - Planning major refactoring or migration
47
+
48
+ ## Difference from New Project Specs
49
+
50
+ **New Project Specs (Prospective):**
51
+ - Define what will be built
52
+ - Start from business requirements
53
+ - Evolve as implementation progresses
54
+
55
+ **Retrospective Specs:**
56
+ - Document what already exists
57
+ - Derived from codebase analysis
58
+ - Reflect current state and discovered decisions
59
+ - Serve as baseline for future changes
60
+
61
+ ## Section: Retrospective Spec Creation Overview (Lines 1-50)
62
+
63
+ ### Benefits
64
+
65
+ 1. **Knowledge Preservation**
66
+ - Capture tribal knowledge embedded in code
67
+ - Document implicit decisions and patterns
68
+ - Create living documentation
69
+
70
+ 2. **Foundation for Future Work**
71
+ - Understand current architecture before changes
72
+ - Identify technical debt and improvement opportunities
73
+ - Plan migrations and refactorings with full context
74
+
75
+ 3. **Team Onboarding**
76
+ - Accelerate new team member onboarding
77
+ - Provide structured learning path
78
+ - Reduce knowledge silos
79
+
80
+ 4. **Quality Improvement**
81
+ - Identify undocumented features
82
+ - Surface architectural inconsistencies
83
+ - Document known issues and workarounds
84
+
85
+ ## Section: Audit Strategy (Lines 51-120)
86
+
87
+ ### Comprehensive Audit Approach
88
+
89
+ Reference: `/spec/audit` command provides the audit execution logic. This section focuses on strategy and prioritization.
90
+
91
+ ### What to Analyze
92
+
93
+ #### 1. File Structure and Organization
94
+
95
+ **Analysis Points:**
96
+ - Directory structure patterns
97
+ - File naming conventions
98
+ - Module boundaries
99
+ - Import/export patterns
100
+
101
+ **Questions to Answer:**
102
+ - How is code organized?
103
+ - What patterns emerge from structure?
104
+ - Are there clear module boundaries?
105
+ - Does structure align with architecture?
106
+
107
+ **Documentation:**
108
+ - Map structure in `spec/02-architecture.md`
109
+ - Document patterns in `spec/05-decisions.md`
110
+ - Note inconsistencies and technical debt
111
+
112
+ #### 2. Features and Functionality
113
+
114
+ **Analysis Points:**
115
+ - User-facing features
116
+ - API endpoints
117
+ - Background jobs and processes
118
+ - Admin/management interfaces
119
+
120
+ **Questions to Answer:**
121
+ - What does this application actually do?
122
+ - What features exist that aren't documented?
123
+ - How do features interact?
124
+ - What are the critical user flows?
125
+
126
+ **Documentation:**
127
+ - Feature inventory in `spec/00-root-spec.md`
128
+ - Feature descriptions with code references
129
+ - User flows and interactions
130
+
131
+ #### 3. Architecture Patterns
132
+
133
+ **Analysis Points:**
134
+ - Design patterns in use
135
+ - Architectural patterns (MVC, Clean Architecture, etc.)
136
+ - Data flow patterns
137
+ - State management approaches
138
+
139
+ **Questions to Answer:**
140
+ - What architectural patterns are used?
141
+ - How is separation of concerns handled?
142
+ - What design patterns are common?
143
+ - Are patterns consistent across codebase?
144
+
145
+ **Documentation:**
146
+ - Architecture overview in `spec/02-architecture.md`
147
+ - Pattern catalog in `spec/05-decisions.md`
148
+ - Code examples illustrating patterns
149
+
150
+ #### 4. Technology Stack
151
+
152
+ **Analysis Points:**
153
+ - Frameworks and libraries
154
+ - Database and data storage
155
+ - Authentication and authorization
156
+ - External services and integrations
157
+ - Build and deployment tools
158
+
159
+ **Questions to Answer:**
160
+ - What is the actual tech stack in use?
161
+ - What versions are deployed?
162
+ - What dependencies are critical?
163
+ - What integrations exist?
164
+
165
+ **Documentation:**
166
+ - Technology inventory in `spec/08-infrastructure.md`
167
+ - Dependency analysis
168
+ - Version information and upgrade paths
169
+
170
+ #### 5. Dependencies and Integrations
171
+
172
+ **Analysis Points:**
173
+ - External API integrations
174
+ - Third-party services
175
+ - Internal service dependencies
176
+ - Database dependencies
177
+
178
+ **Questions to Answer:**
179
+ - What external systems does this depend on?
180
+ - What are the integration points?
181
+ - What are the failure modes?
182
+ - How is error handling done?
183
+
184
+ **Documentation:**
185
+ - Integration map in `spec/08-infrastructure.md`
186
+ - API contracts and interfaces
187
+ - Failure handling strategies
188
+
189
+ #### 6. Code Quality and Technical Debt
190
+
191
+ **Analysis Points:**
192
+ - Code duplication
193
+ - Complexity hotspots
194
+ - Test coverage gaps
195
+ - Known issues and workarounds
196
+ - Deprecated patterns
197
+
198
+ **Questions to Answer:**
199
+ - What technical debt exists?
200
+ - What are the highest-risk areas?
201
+ - What needs immediate attention?
202
+ - What can wait?
203
+
204
+ **Documentation:**
205
+ - Technical debt inventory in `spec/03-risks.md`
206
+ - Prioritized improvement opportunities
207
+ - Known issues and workarounds
208
+
209
+ ### How to Organize Findings
210
+
211
+ **Phase 1: Discovery**
212
+ - Create audit checklist
213
+ - Identify key areas to analyze
214
+ - Set scope boundaries
215
+
216
+ **Phase 2: Analysis**
217
+ - Systematically analyze each area
218
+ - Document findings as you go
219
+ - Take code samples for reference
220
+
221
+ **Phase 3: Synthesis**
222
+ - Organize findings by category
223
+ - Identify patterns and themes
224
+ - Prioritize findings by importance
225
+
226
+ **Phase 4: Documentation**
227
+ - Structure findings into spec format
228
+ - Cross-reference code locations
229
+ - Create diagrams where helpful
230
+
231
+ ### Prioritization Strategies
232
+
233
+ **High Priority:**
234
+ - Core user-facing features
235
+ - Critical integration points
236
+ - Architecture and patterns
237
+ - Security-sensitive areas
238
+
239
+ **Medium Priority:**
240
+ - Supporting features
241
+ - Internal utilities
242
+ - Configuration patterns
243
+ - Development workflows
244
+
245
+ **Low Priority:**
246
+ - Edge cases
247
+ - Deprecated code paths
248
+ - Unused features
249
+ - Historical context
250
+
251
+ **Time-Constrained Approach:**
252
+ - Start with critical paths
253
+ - Document enough for future work
254
+ - Leave detailed documentation for later
255
+ - Focus on "what" over "why" initially
256
+
257
+ ## Section: Sync Process (Lines 121-200)
258
+
259
+ ### Creating Specs from Audit Findings
260
+
261
+ Reference: `/spec/sync` command provides the sync execution logic. This section focuses on the process of transforming audit findings into specification documents.
262
+
263
+ ### Organizing Information into Spec Structure
264
+
265
+ #### Step 1: Map Findings to Spec Files
266
+
267
+ **`spec/00-root-spec.md` (Current State)**
268
+ - What exists: Feature inventory
269
+ - Current state: System capabilities
270
+ - Scope: What's actually implemented
271
+ - Structure: Similar to new project spec but documenting existing state
272
+
273
+ **`spec/02-architecture.md` (Discovered Architecture)**
274
+ - Architecture overview from code analysis
275
+ - Patterns discovered in codebase
276
+ - Data flow and component interactions
277
+ - Technology choices and their implications
278
+
279
+ **`spec/05-decisions.md` (Inferred Decisions)**
280
+ - Decisions inferred from code patterns
281
+ - Trade-offs visible in implementation
282
+ - Historical context where available
283
+ - Rationale for current approach
284
+
285
+ **`spec/08-infrastructure.md` (Actual Tech Stack)**
286
+ - Actual technologies in use
287
+ - Dependencies and their purposes
288
+ - Infrastructure setup and configuration
289
+ - Deployment and operational patterns
290
+
291
+ #### Step 2: Document Current State
292
+
293
+ **For Each Feature:**
294
+ - What it does (functionality)
295
+ - How it works (implementation approach)
296
+ - Where it lives (file locations)
297
+ - Dependencies (what it depends on, what depends on it)
298
+
299
+ **Example Structure:**
300
+ ```markdown
301
+ ## Feature: User Authentication
302
+
303
+ **Current State:**
304
+ - Implements OAuth2 with Google and GitHub providers
305
+ - Uses JWT tokens for session management
306
+ - Token refresh logic in `/app/auth/refresh`
307
+ - Session storage: Redis (expires after 7 days)
308
+
309
+ **Code Locations:**
310
+ - `/app/auth/login.tsx` - Login UI
311
+ - `/app/api/auth/callback/route.ts` - OAuth callback
312
+ - `/lib/auth/session.ts` - Session management
313
+ - `/lib/auth/token.ts` - JWT handling
314
+
315
+ **Dependencies:**
316
+ - NextAuth.js v4.24
317
+ - Redis client for session storage
318
+ - External: Google OAuth, GitHub OAuth
319
+
320
+ **Known Issues:**
321
+ - Token refresh sometimes fails silently
322
+ - Session timeout not communicated to user
323
+ ```
324
+
325
+ #### Step 3: Handle Undocumented Features
326
+
327
+ **When Feature Has No Documentation:**
328
+ 1. Analyze code to understand functionality
329
+ 2. Document what it does (not what it should do)
330
+ 3. Mark as "undocumented" for future clarification
331
+ 4. Add to open questions if behavior is unclear
332
+
333
+ **Questions to Ask:**
334
+ - What is the intended behavior?
335
+ - Is this feature actively used?
336
+ - Should it be documented or removed?
337
+ - Are there tests that clarify intent?
338
+
339
+ #### Step 4: Identify Decisions from Code Patterns
340
+
341
+ **Pattern Analysis:**
342
+ - Repeated patterns → deliberate decisions
343
+ - Consistent approaches → architectural choices
344
+ - Inconsistencies → areas needing clarification
345
+
346
+ **Inferring Decisions:**
347
+ - Why this pattern? (performance, simplicity, constraints)
348
+ - What trade-offs were made?
349
+ - What alternatives exist?
350
+ - Is this still the right choice?
351
+
352
+ **Documentation Format:**
353
+ ```markdown
354
+ ## Decision: State Management Pattern
355
+
356
+ **Current Approach:** React Context API for global state
357
+
358
+ **Evidence:**
359
+ - Consistent use across 12+ components
360
+ - Custom hooks for state access (`useAppState`)
361
+ - No Redux or Zustand found in codebase
362
+
363
+ **Inferred Rationale:**
364
+ - Simplicity over scalability
365
+ - Built-in React solution
366
+ - Smaller bundle size
367
+
368
+ **Context:**
369
+ - Project started 2020, before state management libraries were standardized
370
+ - Team prefers minimal dependencies
371
+
372
+ **Status:** Active, but may need reconsideration for scale
373
+ ```
374
+
375
+ #### Step 5: Document "Why" Through Code Analysis
376
+
377
+ **Code Analysis Techniques:**
378
+ - Comment analysis (capture rationale in comments)
379
+ - Git history (check commit messages for context)
380
+ - Related code (patterns suggest intent)
381
+ - Test files (tests often document expected behavior)
382
+
383
+ **When "Why" is Unclear:**
384
+ - Mark as open question in `spec/04-open-questions.md`
385
+ - Note speculation separately from facts
386
+ - Identify who might know (team members, original authors)
387
+ - Plan follow-up investigation
388
+
389
+ ### Handling Discrepancies
390
+
391
+ **Spec vs Implementation Divergence:**
392
+ - If spec exists but differs from code → Document both, note discrepancy
393
+ - If no spec exists → Create retrospective spec from code
394
+ - Prioritize code as source of truth for current state
395
+ - Document desired state separately if known
396
+
397
+ **Multiple Versions of Truth:**
398
+ - Code is authoritative for "what is"
399
+ - Comments may be outdated
400
+ - Git history provides timeline
401
+ - Documentation may be aspirational
402
+
403
+ ## Section: Documentation Patterns (Lines 201-300)
404
+
405
+ ### Spec Structure for Existing Projects
406
+
407
+ #### `spec/00-root-spec.md` - What Exists, Current State
408
+
409
+ **Structure:**
410
+ ```markdown
411
+ # Project Root Specification (Retrospective)
412
+
413
+ **Created:** [Date of retrospective]
414
+ **Last Updated:** [Date]
415
+ **Status:** Retrospective documentation of existing system
416
+
417
+ ## Overview
418
+
419
+ [What the system currently does, derived from codebase analysis]
420
+
421
+ ## Current Features
422
+
423
+ [Feature inventory with code references]
424
+
425
+ ## Current State
426
+
427
+ [Architectural state, technical debt, known issues]
428
+
429
+ ## Target State (Optional)
430
+
431
+ [If known, document where the system should evolve]
432
+ ```
433
+
434
+ **Key Differences from New Project Spec:**
435
+ - Focus on "is" not "will be"
436
+ - Include code references
437
+ - Document technical debt
438
+ - Note discrepancies with desired state
439
+
440
+ #### `spec/02-architecture.md` - Discovered Architecture Patterns
441
+
442
+ **Structure:**
443
+ ```markdown
444
+ # Architecture (Discovered)
445
+
446
+ **Analysis Date:** [Date]
447
+ **Analysis Scope:** [What was analyzed]
448
+
449
+ ## Architecture Overview
450
+
451
+ [High-level architecture derived from codebase]
452
+
453
+ ## Patterns in Use
454
+
455
+ [Design patterns, architectural patterns found in code]
456
+
457
+ ## Component Structure
458
+
459
+ [How components/modules are organized]
460
+
461
+ ## Data Flow
462
+
463
+ [How data flows through the system]
464
+
465
+ ## Technology Stack
466
+
467
+ [Reference to spec/08-infrastructure.md for details]
468
+ ```
469
+
470
+ **Include:**
471
+ - Architecture diagrams (generated from code structure)
472
+ - Pattern examples with code snippets
473
+ - Evolution over time (if visible in git history)
474
+ - Architectural debt and inconsistencies
475
+
476
+ #### `spec/05-decisions.md` - Inferred Decisions from Code
477
+
478
+ **Structure:**
479
+ ```markdown
480
+ # Decisions (Inferred)
481
+
482
+ **Note:** These decisions are inferred from code patterns and may not reflect explicit choices.
483
+
484
+ ## Architectural Decisions
485
+
486
+ [Major architectural choices visible in code]
487
+
488
+ ## Technology Decisions
489
+
490
+ [Technology choices and their rationale (inferred)]
491
+
492
+ ## Pattern Decisions
493
+
494
+ [Design patterns and why they were chosen (inferred)]
495
+
496
+ ## Historical Context
497
+
498
+ [What can be determined from git history, comments, etc.]
499
+ ```
500
+
501
+ **Documentation Format:**
502
+ - Decision statement
503
+ - Evidence (code patterns, git history)
504
+ - Inferred rationale
505
+ - Context (when, constraints)
506
+ - Status (still valid, needs review, deprecated)
507
+
508
+ #### `spec/08-infrastructure.md` - Actual Tech Stack in Use
509
+
510
+ **Structure:**
511
+ ```markdown
512
+ # Infrastructure (Current State)
513
+
514
+ **As of:** [Date of analysis]
515
+
516
+ ## Technology Stack
517
+
518
+ [Actual technologies in use, versions]
519
+
520
+ ## Dependencies
521
+
522
+ [Dependencies and their purposes]
523
+
524
+ ## Infrastructure Setup
525
+
526
+ [How infrastructure is configured]
527
+
528
+ ## Deployment
529
+
530
+ [How the system is deployed]
531
+ ```
532
+
533
+ **Include:**
534
+ - Exact versions (from package.json, requirements.txt, etc.)
535
+ - Configuration patterns
536
+ - Environment setup
537
+ - Operational procedures (if documented)
538
+
539
+ ### How to Document
540
+
541
+ #### Current State vs Desired State
542
+
543
+ **Current State Section:**
544
+ - What exists now
545
+ - Derived from code analysis
546
+ - Code references for verification
547
+ - Known limitations
548
+
549
+ **Desired State Section (Optional):**
550
+ - Where the system should evolve
551
+ - If planning refactoring/migration
552
+ - Separate clearly from current state
553
+ - Document rationale for changes
554
+
555
+ #### Technical Debt Sections
556
+
557
+ **Document in `spec/03-risks.md`:**
558
+ ```markdown
559
+ ## Technical Debt
560
+
561
+ ### High Priority
562
+ - [Issue description]
563
+ - Impact: [What's at risk]
564
+ - Location: [Code references]
565
+ - Suggested Fix: [If known]
566
+
567
+ ### Medium Priority
568
+ [Similar format]
569
+
570
+ ### Low Priority
571
+ [Similar format]
572
+ ```
573
+
574
+ **Categories:**
575
+ - Code quality issues
576
+ - Architecture inconsistencies
577
+ - Outdated dependencies
578
+ - Performance bottlenecks
579
+ - Security concerns
580
+
581
+ #### Migration Opportunities
582
+
583
+ **Document Potential Improvements:**
584
+ - Framework upgrades
585
+ - Architecture improvements
586
+ - Dependency modernization
587
+ - Performance optimizations
588
+
589
+ **Format:**
590
+ ```markdown
591
+ ## Migration Opportunities
592
+
593
+ ### Framework Upgrade: Next.js 12 → 15
594
+ **Current State:** Next.js 12.3.4
595
+ **Target State:** Next.js 15.1.3
596
+ **Effort:** High
597
+ **Benefits:** App Router, React 19, better performance
598
+ **Risks:** Breaking changes, large codebase
599
+ **Recommendation:** Plan for Q2 2025
600
+ ```
601
+
602
+ #### Known Issues and Workarounds
603
+
604
+ **Document Operational Knowledge:**
605
+ - Known bugs and workarounds
606
+ - Configuration quirks
607
+ - Deployment gotchas
608
+ - Performance workarounds
609
+
610
+ **Format:**
611
+ ```markdown
612
+ ## Known Issues and Workarounds
613
+
614
+ ### Issue: Memory Leak in Background Jobs
615
+ **Symptom:** Server memory increases over time
616
+ **Location:** `/app/jobs/process-queue.ts`
617
+ **Workaround:** Restart service daily via cron
618
+ **Permanent Fix:** Not yet identified
619
+ **Status:** Monitoring, needs investigation
620
+ ```
621
+
622
+ ## Section: Enterprise-Specific Patterns (Lines 301-400)
623
+
624
+ ### Large Codebase Strategies
625
+
626
+ #### Module-by-Module Documentation
627
+
628
+ **For Very Large Projects:**
629
+ - Don't try to document everything at once
630
+ - Prioritize modules by importance
631
+ - Document critical paths first
632
+ - Create module-level specs if needed
633
+
634
+ **Approach:**
635
+ 1. Identify modules/services (monolith) or services (microservices)
636
+ 2. Prioritize: Core business logic → Supporting features → Utilities
637
+ 3. Document one module at a time
638
+ 4. Create module overview linking to detailed docs
639
+
640
+ **Structure:**
641
+ ```
642
+ spec/
643
+ ├── 00-root-spec.md (overview)
644
+ ├── modules/
645
+ │ ├── 01-auth.md
646
+ │ ├── 02-payments.md
647
+ │ ├── 03-notifications.md
648
+ │ └── ...
649
+ ```
650
+
651
+ #### Prioritizing Critical Paths
652
+
653
+ **Critical Path Definition:**
654
+ - User-facing features
655
+ - Revenue-generating features
656
+ - Security-sensitive areas
657
+ - Infrastructure dependencies
658
+
659
+ **Documentation Order:**
660
+ 1. Core business logic
661
+ 2. Authentication and authorization
662
+ 3. Payment/transaction processing
663
+ 4. Data storage and retrieval
664
+ 5. Supporting features
665
+ 6. Admin/management interfaces
666
+ 7. Utilities and helpers
667
+
668
+ #### Handling Microservices
669
+
670
+ **For Microservices Architecture:**
671
+ - Document each service separately
672
+ - Create service-level specs
673
+ - Document inter-service communication
674
+ - Map dependencies between services
675
+
676
+ **Structure:**
677
+ ```
678
+ spec/
679
+ ├── 00-root-spec.md (system overview)
680
+ ├── services/
681
+ │ ├── auth-service.md
682
+ │ ├── payment-service.md
683
+ │ ├── notification-service.md
684
+ │ └── ...
685
+ ├── 02-architecture.md (service interactions)
686
+ ├── 08-infrastructure.md (service infrastructure)
687
+ ```
688
+
689
+ **Document for Each Service:**
690
+ - Purpose and responsibilities
691
+ - API contracts
692
+ - Dependencies (other services, databases)
693
+ - Data models
694
+ - Deployment and scaling
695
+
696
+ #### Database Schema Documentation
697
+
698
+ **For Complex Databases:**
699
+ - Document schema structure
700
+ - Document relationships
701
+ - Document indexes and constraints
702
+ - Document data migration history
703
+
704
+ **Include:**
705
+ - ER diagrams (if applicable)
706
+ - Table structures
707
+ - Key relationships
708
+ - Index strategies
709
+ - Data constraints and validations
710
+
711
+ **Format:**
712
+ ```markdown
713
+ ## Database Schema
714
+
715
+ ### Tables
716
+
717
+ #### users
718
+ **Purpose:** User accounts and profiles
719
+ **Relationships:**
720
+ - One-to-many: orders, sessions
721
+ - Many-to-many: roles (via user_roles)
722
+ **Indexes:** email (unique), username (unique)
723
+ **Constraints:** email required, created_at auto-set
724
+ ```
725
+
726
+ ### Team Considerations
727
+
728
+ #### Involving Subject Matter Experts
729
+
730
+ **Who to Involve:**
731
+ - Original developers (if available)
732
+ - Long-term team members
733
+ - Domain experts
734
+ - Product owners
735
+
736
+ **How to Involve:**
737
+ - Interviews for context on decisions
738
+ - Code walkthroughs for complex areas
739
+ - Review sessions for spec accuracy
740
+ - Feedback on inferred decisions
741
+
742
+ **Documentation:**
743
+ - Capture SME input in spec
744
+ - Note uncertainty where consensus is lacking
745
+ - Document different perspectives if relevant
746
+ - Include attribution for insights
747
+
748
+ #### Knowledge Transfer Sessions
749
+
750
+ **Format:**
751
+ - Pair programming for code review
752
+ - Architecture walkthroughs
753
+ - Feature deep-dives
754
+ - Q&A sessions
755
+
756
+ **Documentation:**
757
+ - Capture key insights in specs
758
+ - Record questions and answers
759
+ - Document assumptions validated
760
+ - Note areas needing further investigation
761
+
762
+ #### Documentation Reviews
763
+
764
+ **Review Process:**
765
+ - Have team review retrospective specs
766
+ - Validate accuracy against code
767
+ - Fill in missing context
768
+ - Identify areas needing more detail
769
+
770
+ **Review Checklist:**
771
+ - [ ] Specs match actual code
772
+ - [ ] Decisions documented accurately
773
+ - [ ] All critical features covered
774
+ - [ ] Technical debt identified
775
+ - [ ] Open questions surfaced
776
+
777
+ ### Integration with Existing Tools
778
+
779
+ #### Confluence/Wiki Integration
780
+
781
+ **Export Strategy:**
782
+ - Generate markdown specs
783
+ - Convert to Confluence format if needed
784
+ - Link to code repositories
785
+ - Keep specs as source of truth
786
+
787
+ **Update Process:**
788
+ - Maintain specs in SDD format
789
+ - Sync to Confluence periodically
790
+ - Use Confluence for team discussion
791
+ - Keep spec files authoritative
792
+
793
+ #### Jira/Linear Synchronization
794
+
795
+ **Task Management Integration:**
796
+ - Link retrospective audit tasks to issues
797
+ - Create issues for technical debt items
798
+ - Track spec updates as tasks
799
+ - Use Linear documents for detailed sections
800
+
801
+ **Using Linear MCP:**
802
+ - Create Linear document for each spec file
803
+ - Sync updates automatically
804
+ - Link documents to issues
805
+ - Use Linear for team collaboration
806
+
807
+ **Format:**
808
+ - Linear document: Spec content
809
+ - Linear issue: Tasks for addressing findings
810
+ - Linear project: Retrospective spec creation project
811
+
812
+ #### Code Review Integration
813
+
814
+ **During Code Review:**
815
+ - Reference specs when reviewing code
816
+ - Update specs when code changes
817
+ - Document new patterns discovered
818
+ - Identify spec-code divergence
819
+
820
+ **Process:**
821
+ - Reviewer checks spec compliance
822
+ - Reviewer notes new patterns
823
+ - Spec updated after review approval
824
+ - Maintain spec as living document
825
+
826
+ ## Best Practices
827
+
828
+ ### Don't Try to Document Everything at Once
829
+
830
+ **Risk:** Overwhelm, analysis paralysis, burnout
831
+
832
+ **Approach:**
833
+ - Start with critical paths
834
+ - Document enough for immediate needs
835
+ - Iterate and expand over time
836
+ - Focus on what enables future work
837
+
838
+ **Strategy:**
839
+ - Phase 1: Core features and architecture
840
+ - Phase 2: Supporting features and integrations
841
+ - Phase 3: Utilities and edge cases
842
+ - Ongoing: Update as you learn more
843
+
844
+ ### Focus on What Matters for Future Work
845
+
846
+ **Priority Framework:**
847
+ 1. What will change soon? (document well)
848
+ 2. What is complex? (document clearly)
849
+ 3. What is critical? (document thoroughly)
850
+ 4. What is obvious? (document briefly)
851
+
852
+ **Documentation Depth:**
853
+ - High: Features being refactored
854
+ - Medium: Features being extended
855
+ - Low: Stable, well-understood features
856
+ - None: Deprecated, unused code
857
+
858
+ ### Document "Why" Not Just "What"
859
+
860
+ **Include:**
861
+ - Rationale for architectural choices
862
+ - Trade-offs made
863
+ - Constraints that influenced decisions
864
+ - Historical context
865
+
866
+ **Avoid:**
867
+ - Just describing what code does
868
+ - Missing the reasoning
869
+ - Ignoring context
870
+ - Pure speculation without evidence
871
+
872
+ ### Include Code Examples in Specs
873
+
874
+ **Benefits:**
875
+ - Concrete illustrations of patterns
876
+ - Easy verification
877
+ - Learning resource for team
878
+ - Reference for future changes
879
+
880
+ **Format:**
881
+ - Brief code snippets
882
+ - File references for full context
883
+ - Explanations alongside code
884
+ - Updated when code changes
885
+
886
+ ### Keep Specs Living Documents
887
+
888
+ **Maintenance:**
889
+ - Update specs when code changes
890
+ - Review specs periodically
891
+ - Remove outdated information
892
+ - Add new discoveries
893
+
894
+ **Process:**
895
+ - Update specs during code reviews
896
+ - Review specs during planning
897
+ - Validate specs during audits
898
+ - Evolve specs with the codebase
899
+
900
+ ## Common Pitfalls
901
+
902
+ ### Over-Documentation
903
+
904
+ **Symptom:** Spending too much time documenting, not enough developing
905
+
906
+ **Solution:**
907
+ - Focus on what enables work
908
+ - Document iteratively
909
+ - Set time limits
910
+ - Prioritize ruthlessly
911
+
912
+ ### Under-Documentation
913
+
914
+ **Symptom:** Specs too high-level, missing critical details
915
+
916
+ **Solution:**
917
+ - Include code references
918
+ - Document complex areas thoroughly
919
+ - Capture rationale and context
920
+ - Review with team
921
+
922
+ ### Spec-Impl Divergence (Already Exists)
923
+
924
+ **Symptom:** Specs describe desired state, code shows different reality
925
+
926
+ **Solution:**
927
+ - Document current state first
928
+ - Separate current vs desired
929
+ - Update specs when code changes
930
+ - Regular audits to catch divergence
931
+
932
+ ### Outdated Information
933
+
934
+ **Symptom:** Specs become stale as code evolves
935
+
936
+ **Solution:**
937
+ - Update specs with code changes
938
+ - Review during code reviews
939
+ - Audit periodically
940
+ - Treat as living documents
941
+
942
+ ### Pure Speculation
943
+
944
+ **Symptom:** Inferring too much from code without validation
945
+
946
+ **Solution:**
947
+ - Distinguish facts from inference
948
+ - Mark speculation clearly
949
+ - Validate with team members
950
+ - Document uncertainty
951
+
952
+ ## Integration Points
953
+
954
+ ### Reference `detection.md` for Legacy Phase Detection
955
+
956
+ - Use detection engine to identify legacy projects
957
+ - Leverage phase detection (legacy/migration)
958
+ - Activate appropriate workflow
959
+
960
+ ### Reference `spec/audit.md` Command for Audit Process
961
+
962
+ - Use `/spec/audit` for comprehensive audit
963
+ - Follow audit command workflow
964
+ - Leverage audit findings for spec creation
965
+
966
+ ### Reference `spec/sync.md` Command for Sync Process
967
+
968
+ - Use `/spec/sync` to create specs from audit
969
+ - Follow sync command workflow
970
+ - Maintain spec-code alignment
971
+
972
+ ### Reference `command-stacks.md` for Legacy Onboarding Stack
973
+
974
+ - Use command stack: `/spec/audit → /spec/sync → /spec/refine`
975
+ - Execute stack for complete retrospective
976
+ - Leverage automated workflow
977
+