@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,129 @@
1
+ ---
2
+ title: Design Foundations
3
+ description: Framework-agnostic design system and UI patterns - applies to design tasks
4
+ owner: sdd-system
5
+ severity: warn
6
+ globs: "**/*"
7
+ alwaysApply: false
8
+ activation:
9
+ projectTypes: [web-app, mobile-app]
10
+ projectSizes: [small, medium, large, enterprise]
11
+ projectPhases: [initialization, expansion, maintenance, migration, legacy]
12
+ technologies: []
13
+ requires: []
14
+ ---
15
+
16
+ # Design Foundations
17
+
18
+ ## Purpose
19
+
20
+ Framework-agnostic design system patterns, UI components, and visual consistency guidelines. These patterns apply to all design tasks regardless of styling framework.
21
+
22
+ ## Design System Reference
23
+
24
+ **Always reference project design system if it exists:**
25
+ - Check for `spec/07-design-system.md`
26
+ - Follow established color, typography, spacing systems
27
+ - Maintain visual consistency with existing design
28
+
29
+ ## Principles
30
+
31
+ - **Consistency**: Visual consistency across all UI
32
+ - **Accessibility First**: WCAG AA minimum, aim for AAA
33
+ - **Responsive by Default**: Mobile-first approach
34
+ - **Clear Visual Hierarchy**: Guide user attention effectively
35
+
36
+ ## Component Design
37
+
38
+ **Reusable, Composable UI Components:**
39
+ - Build components from primitives
40
+ - Components are self-contained
41
+ - Components are composable
42
+ - Components follow design system tokens
43
+
44
+ **Accessibility Requirements:**
45
+ - Semantic HTML elements
46
+ - Correct ARIA roles and labels
47
+ - Visible focus states
48
+ - Keyboard navigation support
49
+ - Screen reader support
50
+ - Color contrast (WCAG AA minimum)
51
+
52
+ **Responsive Design:**
53
+ - Mobile-first approach
54
+ - Breakpoints: mobile (320px+), tablet (768px+), desktop (1024px+)
55
+ - Fluid typography and spacing
56
+ - Flexible layouts (flexbox, grid)
57
+
58
+ ## Visual Consistency
59
+
60
+ **Color System:**
61
+ - Use design system color tokens
62
+ - Semantic colors (success, error, warning, info)
63
+ - Consistent color usage across components
64
+
65
+ **Typography:**
66
+ - Use design system typography scale
67
+ - Consistent font families, weights, sizes
68
+ - Proper line heights and spacing
69
+
70
+ **Spacing:**
71
+ - Use design system spacing scale
72
+ - Consistent margins and padding
73
+ - Visual rhythm and alignment
74
+
75
+ ## UI Patterns
76
+
77
+ **Card Layouts:**
78
+ - Consistent card styling
79
+ - Proper spacing and shadows
80
+ - Responsive card grids
81
+
82
+ **Button Styles:**
83
+ - Primary, secondary, outline variants
84
+ - Consistent sizing and spacing
85
+ - Proper disabled states
86
+ - Loading states
87
+
88
+ **Form Inputs:**
89
+ - Consistent input styling
90
+ - Proper labels and placeholders
91
+ - Error states and validation feedback
92
+ - Accessible form controls
93
+
94
+ **Navigation Patterns:**
95
+ - Consistent navigation structure
96
+ - Clear active states
97
+ - Mobile-friendly navigation
98
+ - Breadcrumbs where appropriate
99
+
100
+ ## Framework-Specific Extensions
101
+
102
+ This rule provides foundation patterns. For framework-specific patterns, see:
103
+ - Tailwind CSS: `[tailwind]-*.mdc` (if Tailwind detected)
104
+ - CSS Modules: `[css-modules]-*.mdc` (if CSS Modules detected)
105
+ - Styled Components: `[styled-components]-*.mdc` (if detected)
106
+ - Other styling: `[styling]-*.mdc` (if detected)
107
+
108
+ ## Accessibility Checklist
109
+
110
+ - [ ] Semantic HTML elements used
111
+ - [ ] ARIA roles and labels correct
112
+ - [ ] Visible focus states
113
+ - [ ] Keyboard navigation works
114
+ - [ ] Screen reader tested
115
+ - [ ] Color contrast meets WCAG AA
116
+ - [ ] Images have meaningful alt text
117
+ - [ ] Forms are accessible
118
+ - [ ] Interactive elements are keyboard accessible
119
+
120
+ ## Responsive Design Checklist
121
+
122
+ - [ ] Mobile layout tested (320px+)
123
+ - [ ] Tablet layout tested (768px+)
124
+ - [ ] Desktop layout tested (1024px+)
125
+ - [ ] No horizontal scrolling
126
+ - [ ] Touch targets are adequate size (44x44px minimum)
127
+ - [ ] Typography scales appropriately
128
+ - [ ] Images are responsive
129
+ - [ ] Navigation works on all screen sizes
@@ -0,0 +1,132 @@
1
+ ---
2
+ title: Business Analysis Foundations
3
+ description: Business analysis patterns - applies to business and requirements tasks
4
+ owner: sdd-system
5
+ severity: warn
6
+ globs: "**/*"
7
+ alwaysApply: false
8
+ activation:
9
+ projectTypes: [web-app, api-service, mobile-app]
10
+ projectSizes: [small, medium, large, enterprise]
11
+ projectPhases: [initialization, expansion]
12
+ technologies: []
13
+ requires: []
14
+ ---
15
+
16
+ # Business Analysis Foundations
17
+
18
+ ## Purpose
19
+
20
+ Business analysis patterns for requirements gathering, user stories, business logic, and domain models. These patterns apply to business-focused tasks and requirements definition.
21
+
22
+ ## Principles
23
+
24
+ - **User-Centric**: Focus on user value and outcomes
25
+ - **Clear Requirements**: Explicit, testable requirements
26
+ - **Domain-Driven**: Business logic reflects domain understanding
27
+ - **Value-Focused**: Prioritize features by business value
28
+
29
+ ## Requirements Gathering
30
+
31
+ **Ask the Right Questions:**
32
+ - What problem are we solving?
33
+ - Who is the user?
34
+ - What value does this deliver?
35
+ - What does success look like?
36
+ - What are the constraints?
37
+
38
+ **Document Requirements:**
39
+ - User stories with acceptance criteria
40
+ - Business rules and logic
41
+ - Success metrics
42
+ - Constraints and limitations
43
+
44
+ ## User Stories
45
+
46
+ **Format:**
47
+ - As a [user type]
48
+ - I want [goal]
49
+ - So that [benefit]
50
+
51
+ **Acceptance Criteria:**
52
+ - Given [context]
53
+ - When [action]
54
+ - Then [outcome]
55
+
56
+ **Example:**
57
+ ```
58
+ As a customer
59
+ I want to save items to my wishlist
60
+ So that I can purchase them later
61
+
62
+ Acceptance Criteria:
63
+ - Given I am logged in
64
+ - When I click "Save to Wishlist" on a product
65
+ - Then the product is added to my wishlist
66
+ - And I can view my wishlist later
67
+ - And I can remove items from my wishlist
68
+ ```
69
+
70
+ ## Business Logic
71
+
72
+ **Domain Models:**
73
+ - Represent business entities
74
+ - Contain business rules
75
+ - Are framework-agnostic
76
+ - Reflect real-world concepts
77
+
78
+ **Business Rules:**
79
+ - Explicit rules, not implicit
80
+ - Documented in spec or code
81
+ - Testable and verifiable
82
+ - Can be changed as business evolves
83
+
84
+ **Value Proposition:**
85
+ - Clear value to users
86
+ - Measurable outcomes
87
+ - Business impact
88
+ - Success metrics
89
+
90
+ ## Domain-Driven Design
91
+
92
+ **Domain Models:**
93
+ - Entities: Things with identity (User, Order, Product)
94
+ - Value Objects: Things without identity (Money, Address)
95
+ - Aggregates: Clusters of entities (Order with OrderItems)
96
+ - Services: Operations that don't fit entities
97
+
98
+ **Business Logic Location:**
99
+ - Domain models contain business rules
100
+ - Services orchestrate business operations
101
+ - Repositories handle data access
102
+ - Keep business logic out of UI/API layers
103
+
104
+ ## Success Metrics
105
+
106
+ **Define Measurable Outcomes:**
107
+ - User engagement metrics
108
+ - Business value metrics
109
+ - Performance metrics
110
+ - Quality metrics
111
+
112
+ **Track Progress:**
113
+ - Baseline measurements
114
+ - Target goals
115
+ - Current status
116
+ - Improvement over time
117
+
118
+ ## Requirements Traceability
119
+
120
+ **Link Requirements to Implementation:**
121
+ - Requirements → Spec → Plan → Tasks → Code
122
+ - Track which code implements which requirement
123
+ - Verify requirements are met
124
+ - Update requirements as needed
125
+
126
+ ## Business Rules Documentation
127
+
128
+ **Document Business Rules:**
129
+ - In spec files (spec/05-decisions.md)
130
+ - In code comments (for complex logic)
131
+ - In domain model documentation
132
+ - Keep rules explicit and testable
@@ -0,0 +1,146 @@
1
+ ---
2
+ title: Next.js Patterns
3
+ description: Next.js App Router patterns - applies when Next.js is detected
4
+ owner: sdd-system
5
+ severity: warn
6
+ globs: "app/**, src/app/**"
7
+ alwaysApply: false
8
+ activation:
9
+ projectTypes: [web-app]
10
+ projectSizes: [small, medium, large, enterprise]
11
+ projectPhases: [initialization, expansion, maintenance, migration, legacy]
12
+ technologies: [nextjs]
13
+ requires: [10-engineering]
14
+ ---
15
+
16
+ # Next.js Patterns
17
+
18
+ ## Purpose
19
+
20
+ Next.js App Router patterns for server components, Server Actions, API routes, file structure, routing, and data fetching. Only activates when Next.js is detected.
21
+
22
+ ## Component Types
23
+
24
+ **Server Components (Default):**
25
+ - Server components by default
26
+ - No "use client" directive needed
27
+ - Can use async/await for data fetching
28
+ - Cannot use browser APIs or hooks
29
+
30
+ **Client Components:**
31
+ - Use "use client" directive only when interactivity required
32
+ - Can use browser APIs, hooks, event handlers
33
+ - Keep business logic out of client components
34
+ - Prefer server components when possible
35
+
36
+ ## Data Fetching
37
+
38
+ **Server Components:**
39
+ - Use async/await for data fetching
40
+ - Fetch data in server components
41
+ - Pass data as props to client components
42
+ - Centralize API calls in `lib/services/*`
43
+
44
+ **Server Actions:**
45
+ - Handle mutations via Server Actions
46
+ - Return `{ ok: true, data? }` or `{ ok: false, error: { code, message } }`
47
+ - Validate input server-side
48
+ - Handle errors gracefully
49
+
50
+ **API Routes:**
51
+ - API routes in `app/api/v1/...`
52
+ - Use Next.js route handlers
53
+ - Return standard JSON responses
54
+ - Handle authentication server-side
55
+
56
+ ## Caching and Revalidation
57
+
58
+ **Cache Strategy:**
59
+ - `cache` for public, slow-changing data
60
+ - `revalidate` for ISR (Incremental Static Regeneration)
61
+ - `no-store` for user/checkout data
62
+ - Avoid double-fetch
63
+
64
+ **Revalidation:**
65
+ - Use `export const revalidate = <seconds>` for ISR
66
+ - Revalidate on-demand when needed
67
+ - Cache public data, don't cache user-specific data
68
+
69
+ ## Routing and Structure
70
+
71
+ **App Router Structure:**
72
+ - Organize by features/segments
73
+ - Keep nesting shallow
74
+ - Use `next/link` for internal navigation
75
+ - Route groups with `(groupName)` for organization
76
+
77
+ **API Routes:**
78
+ - `app/api/v1/jerseys/route.ts` for GET/POST
79
+ - `app/api/v1/jerseys/[id]/route.ts` for GET/PATCH/DELETE
80
+ - Use standard HTTP methods
81
+ - Follow RESTful conventions
82
+
83
+ ## File Structure
84
+
85
+ **Recommended Structure:**
86
+ ```
87
+ app/
88
+ (app)/ # Route group
89
+ page.tsx # Home page
90
+ layout.tsx # App layout
91
+ blog/
92
+ page.tsx # Blog listing
93
+ [slug]/
94
+ page.tsx # Blog post
95
+ api/
96
+ v1/
97
+ jerseys/
98
+ route.ts # API routes
99
+ lib/
100
+ services/ # Business logic
101
+ repositories/ # Data access
102
+ utils/ # Utilities
103
+ components/ # Shared components
104
+ ```
105
+
106
+ ## Performance
107
+
108
+ **Optimizations:**
109
+ - Prefer streamed SSR
110
+ - Lazy-load large components with `Suspense`
111
+ - Keep client bundle slim
112
+ - Use dynamic imports for heavy modules
113
+ - Optimize images with `next/image`
114
+
115
+ ## Integrations
116
+
117
+ **Supabase:**
118
+ - Server-side: `lib/supabase-server.ts` with service role
119
+ - Client-side: `lib/supabase-client.ts` with anon key
120
+ - Never expose service role key to client
121
+
122
+ **Auth (Clerk/NextAuth):**
123
+ - Use `@clerk/nextjs` for frontend auth
124
+ - Use `@clerk/backend` for API route verification
125
+ - Protect routes with middleware
126
+
127
+ ## State Management
128
+
129
+ **Server State:**
130
+ - TanStack Query for client-side data management
131
+ - Server components for initial data
132
+ - Server Actions for mutations
133
+
134
+ **Client State:**
135
+ - React Hook Form + Zod for forms
136
+ - Context API for minimal global UI state
137
+ - Avoid global state when possible
138
+
139
+ ## DoD (Definition of Done)
140
+
141
+ - No client-only secrets
142
+ - Server Actions/API routes for mutations
143
+ - No duplicate fetch
144
+ - LCP (Largest Contentful Paint) optimized
145
+ - Accessibility checks pass
146
+ - API routes follow RESTful patterns
@@ -0,0 +1,176 @@
1
+ ---
2
+ title: API Design Patterns
3
+ description: API design patterns - applies when API work is detected
4
+ owner: sdd-system
5
+ severity: warn
6
+ globs: "app/api/**, src/api/**, routes/**, api/**"
7
+ alwaysApply: false
8
+ activation:
9
+ projectTypes: [web-app, api-service]
10
+ projectSizes: [small, medium, large, enterprise]
11
+ projectPhases: [initialization, expansion, maintenance, migration, legacy]
12
+ technologies: [nextjs, express, fastapi, flask]
13
+ requires: [10-engineering]
14
+ ---
15
+
16
+ # API Design Patterns
17
+
18
+ ## Purpose
19
+
20
+ API design patterns for REST, GraphQL, RPC patterns, error handling, pagination, and versioning. Applies when API work is detected (API routes, Express, FastAPI, etc.).
21
+
22
+ ## Principles
23
+
24
+ - **Resource-First Design**: Design around resources, not actions
25
+ - **Stable IDs**: Use stable, predictable resource IDs
26
+ - **Explicit Versioning**: Version APIs explicitly (`/api/v1`)
27
+ - **Consistent Errors**: Standard error format across all endpoints
28
+ - **Idempotency**: Mutations should be idempotent where applicable
29
+
30
+ ## API Structure
31
+
32
+ **RESTful Endpoints:**
33
+ - `GET /api/v1/jerseys` - List resources
34
+ - `GET /api/v1/jerseys/:id` - Get single resource
35
+ - `POST /api/v1/jerseys` - Create resource
36
+ - `PATCH /api/v1/jerseys/:id` - Update resource
37
+ - `DELETE /api/v1/jerseys/:id` - Delete resource
38
+
39
+ **Route Organization:**
40
+ - Group by resource type
41
+ - Use nested routes for relationships
42
+ - Keep routes shallow (max 2-3 levels)
43
+
44
+ ## Error Handling
45
+
46
+ **Standard Error Format:**
47
+ ```json
48
+ {
49
+ "error": {
50
+ "code": "NOT_FOUND",
51
+ "message": "Jersey not found",
52
+ "details": null
53
+ }
54
+ }
55
+ ```
56
+
57
+ **Error Codes:**
58
+ - `NOT_FOUND` - Resource doesn't exist
59
+ - `VALIDATION_ERROR` - Input validation failed
60
+ - `UNAUTHORIZED` - Authentication required
61
+ - `FORBIDDEN` - Insufficient permissions
62
+ - `CONFLICT` - Resource conflict
63
+ - `INTERNAL_ERROR` - Server error
64
+
65
+ **Status Codes:**
66
+ - `200` - Success
67
+ - `201` - Created
68
+ - `204` - No Content
69
+ - `400` - Bad Request
70
+ - `401` - Unauthorized
71
+ - `403` - Forbidden
72
+ - `404` - Not Found
73
+ - `409` - Conflict
74
+ - `500` - Internal Server Error
75
+
76
+ ## Pagination
77
+
78
+ **Cursor-Based Pagination (Preferred):**
79
+ ```
80
+ GET /api/v1/jerseys?limit=20&cursor=abc123
81
+
82
+ Response:
83
+ {
84
+ "items": [...],
85
+ "nextCursor": "def456",
86
+ "hasMore": true
87
+ }
88
+ ```
89
+
90
+ **Offset Pagination (If Needed):**
91
+ ```
92
+ GET /api/v1/jerseys?limit=20&offset=40
93
+
94
+ Response:
95
+ {
96
+ "items": [...],
97
+ "total": 100,
98
+ "limit": 20,
99
+ "offset": 40
100
+ }
101
+ ```
102
+
103
+ **Why Cursor-Based:**
104
+ - Stable under concurrent writes
105
+ - Better performance
106
+ - No duplicate/missing items
107
+
108
+ ## Authentication
109
+
110
+ **Protected Routes:**
111
+ - Verify authentication in all protected routes
112
+ - Extract user ID from token
113
+ - Check permissions before operations
114
+ - Return 401 if unauthenticated, 403 if unauthorized
115
+
116
+ **Token Verification:**
117
+ - Verify JWT tokens server-side
118
+ - Never trust client-provided user IDs
119
+ - Check token expiration
120
+ - Validate token signature
121
+
122
+ ## Authorization
123
+
124
+ **Ownership Checks:**
125
+ - Verify user owns resource before operations
126
+ - Check `owner_id === currentUserId`
127
+ - Enforce at service layer, not just API layer
128
+
129
+ **Permission Checks:**
130
+ - Role-based access control (RBAC) if needed
131
+ - Permission-based access control (PBAC) if needed
132
+ - Document permission requirements
133
+
134
+ ## Response Formats
135
+
136
+ **Success Responses:**
137
+ - Direct JSON object (no envelope for simplicity)
138
+ - Include all relevant resource data
139
+ - Consistent field naming
140
+
141
+ **Error Responses:**
142
+ - Standard error format
143
+ - Never leak internal errors
144
+ - Include helpful error messages
145
+ - No stack traces in production
146
+
147
+ ## Versioning
148
+
149
+ **URL Versioning:**
150
+ - `/api/v1/...` for version 1
151
+ - `/api/v2/...` for version 2
152
+ - Maintain backward compatibility when possible
153
+ - Document breaking changes
154
+
155
+ ## Idempotency
156
+
157
+ **Idempotent Operations:**
158
+ - Use idempotency keys for mutations
159
+ - Return same result for duplicate requests
160
+ - Handle idempotency at service layer
161
+
162
+ ## Rate Limiting
163
+
164
+ **Implement Rate Limiting:**
165
+ - Per-user rate limits
166
+ - Per-IP rate limits
167
+ - Return 429 (Too Many Requests) when exceeded
168
+ - Include rate limit headers
169
+
170
+ ## Documentation
171
+
172
+ **API Documentation:**
173
+ - Document all endpoints
174
+ - Include request/response examples
175
+ - Document error codes
176
+ - Include authentication requirements