cfsa-antigravity 2.19.0 → 2.19.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 (200) hide show
  1. package/package.json +1 -1
  2. package/template/.agent/kit-sync.md +3 -3
  3. package/template/.claude/commands/audit-ambiguity-execute.md +6 -0
  4. package/template/.claude/commands/audit-ambiguity-rubrics.md +6 -0
  5. package/template/.claude/commands/audit-ambiguity.md +6 -0
  6. package/template/.claude/commands/bootstrap-agents-fill.md +6 -0
  7. package/template/.claude/commands/bootstrap-agents-provision.md +6 -0
  8. package/template/.claude/commands/bootstrap-agents.md +6 -0
  9. package/template/.claude/commands/create-prd-architecture.md +6 -0
  10. package/template/.claude/commands/create-prd-compile.md +6 -0
  11. package/template/.claude/commands/create-prd-design-system.md +6 -0
  12. package/template/.claude/commands/create-prd-security.md +6 -0
  13. package/template/.claude/commands/create-prd-stack.md +6 -0
  14. package/template/.claude/commands/decompose-architecture-structure.md +6 -0
  15. package/template/.claude/commands/decompose-architecture-validate.md +6 -0
  16. package/template/.claude/commands/evolve-contract.md +6 -0
  17. package/template/.claude/commands/evolve-feature-cascade.md +6 -0
  18. package/template/.claude/commands/evolve-feature-classify.md +6 -0
  19. package/template/.claude/commands/evolve-feature.md +6 -0
  20. package/template/.claude/commands/ideate-discover.md +6 -0
  21. package/template/.claude/commands/ideate-extract.md +6 -0
  22. package/template/.claude/commands/ideate-validate.md +6 -0
  23. package/template/.claude/commands/implement-slice-setup.md +6 -0
  24. package/template/.claude/commands/implement-slice-tdd.md +6 -0
  25. package/template/.claude/commands/plan-phase-preflight.md +6 -0
  26. package/template/.claude/commands/plan-phase-write.md +6 -0
  27. package/template/.claude/commands/propagate-decision-apply.md +6 -0
  28. package/template/.claude/commands/propagate-decision-scan.md +6 -0
  29. package/template/.claude/commands/propagate-decision.md +6 -0
  30. package/template/.claude/commands/remediate-pipeline-assess.md +6 -0
  31. package/template/.claude/commands/remediate-pipeline-execute.md +6 -0
  32. package/template/.claude/commands/remediate-pipeline.md +6 -0
  33. package/template/.claude/commands/remediate-shard-split.md +6 -0
  34. package/template/.claude/commands/resolve-ambiguity.md +6 -0
  35. package/template/.claude/commands/setup-workspace-cicd.md +6 -0
  36. package/template/.claude/commands/setup-workspace-data.md +6 -0
  37. package/template/.claude/commands/setup-workspace-hosting.md +6 -0
  38. package/template/.claude/commands/setup-workspace-scaffold.md +6 -0
  39. package/template/.claude/commands/sync-kit.md +6 -0
  40. package/template/.claude/commands/update-architecture-map.md +6 -0
  41. package/template/.claude/commands/validate-phase-quality.md +6 -0
  42. package/template/.claude/commands/validate-phase-readiness.md +6 -0
  43. package/template/.claude/commands/verify-infrastructure.md +6 -0
  44. package/template/.claude/commands/write-architecture-spec-deepen.md +6 -0
  45. package/template/.claude/commands/write-architecture-spec-design.md +6 -0
  46. package/template/.claude/commands/write-be-spec-classify.md +6 -0
  47. package/template/.claude/commands/write-be-spec-write.md +6 -0
  48. package/template/.claude/commands/write-fe-spec-classify.md +6 -0
  49. package/template/.claude/commands/write-fe-spec-write.md +6 -0
  50. package/template/.claude/skills/accessibility/SKILL.md +522 -0
  51. package/template/.claude/skills/accessibility/references/WCAG.md +162 -0
  52. package/template/.claude/skills/accessibility/references/ia-spec-checklist.md +35 -0
  53. package/template/.claude/skills/adversarial-review/SKILL.md +90 -0
  54. package/template/.claude/skills/antigravity-workflows/SKILL.md +81 -0
  55. package/template/.claude/skills/antigravity-workflows/resources/implementation-playbook.md +36 -0
  56. package/template/.claude/skills/api-design-principles/SKILL.md +169 -0
  57. package/template/.claude/skills/api-design-principles/assets/api-design-checklist.md +155 -0
  58. package/template/.claude/skills/api-design-principles/assets/rest-api-template.py +182 -0
  59. package/template/.claude/skills/api-design-principles/references/graphql-schema-design.md +583 -0
  60. package/template/.claude/skills/api-design-principles/references/rest-best-practices.md +408 -0
  61. package/template/.claude/skills/api-design-principles/resources/implementation-playbook.md +513 -0
  62. package/template/.claude/skills/api-versioning/SKILL.md +166 -0
  63. package/template/.claude/skills/api-versioning/references/typescript.md +157 -0
  64. package/template/.claude/skills/architecture-mapping/SKILL.md +219 -0
  65. package/template/.claude/skills/bootstrap-agents/SKILL.md +258 -0
  66. package/template/.claude/skills/brainstorming/SKILL.md +177 -0
  67. package/template/.claude/skills/brand-guidelines/SKILL.md +44 -0
  68. package/template/.claude/skills/clean-code/SKILL.md +196 -0
  69. package/template/.claude/skills/clean-code/references/typescript.md +126 -0
  70. package/template/.claude/skills/code-review-pro/SKILL.md +152 -0
  71. package/template/.claude/skills/concise-planning/SKILL.md +107 -0
  72. package/template/.claude/skills/cross-layer-consistency/SKILL.md +117 -0
  73. package/template/.claude/skills/database-schema-design/SKILL.md +205 -0
  74. package/template/.claude/skills/database-schema-design/references/relational.md +228 -0
  75. package/template/.claude/skills/deployment-procedures/SKILL.md +241 -0
  76. package/template/.claude/skills/design-anti-cliche/SKILL.md +159 -0
  77. package/template/.claude/skills/design-direction/SKILL.md +45 -0
  78. package/template/.claude/skills/error-handling-patterns/SKILL.md +226 -0
  79. package/template/.claude/skills/error-handling-patterns/references/go.md +162 -0
  80. package/template/.claude/skills/error-handling-patterns/references/python.md +262 -0
  81. package/template/.claude/skills/error-handling-patterns/references/rust.md +112 -0
  82. package/template/.claude/skills/error-handling-patterns/references/typescript.md +178 -0
  83. package/template/.claude/skills/find-skills/SKILL.md +145 -0
  84. package/template/.claude/skills/git-advanced/SKILL.md +972 -0
  85. package/template/.claude/skills/git-workflow/SKILL.md +420 -0
  86. package/template/.claude/skills/idea-extraction/SKILL.md +644 -0
  87. package/template/.claude/skills/logging-best-practices/SKILL.md +192 -0
  88. package/template/.claude/skills/logging-best-practices/references/go.md +49 -0
  89. package/template/.claude/skills/logging-best-practices/references/python.md +52 -0
  90. package/template/.claude/skills/logging-best-practices/references/typescript.md +215 -0
  91. package/template/.claude/skills/migration-management/SKILL.md +200 -0
  92. package/template/.claude/skills/migration-management/references/relational.md +214 -0
  93. package/template/.claude/skills/minimalist-surgical-development/SKILL.md +135 -0
  94. package/template/.claude/skills/parallel-agents/SKILL.md +165 -0
  95. package/template/.claude/skills/parallel-debugging/SKILL.md +135 -0
  96. package/template/.claude/skills/parallel-feature-development/SKILL.md +157 -0
  97. package/template/.claude/skills/performance-budgeting/SKILL.md +144 -0
  98. package/template/.claude/skills/pipeline-rubrics/SKILL.md +51 -0
  99. package/template/.claude/skills/pipeline-rubrics/references/architecture-rubric.md +19 -0
  100. package/template/.claude/skills/pipeline-rubrics/references/be-rubric.md +21 -0
  101. package/template/.claude/skills/pipeline-rubrics/references/fe-rubric.md +20 -0
  102. package/template/.claude/skills/pipeline-rubrics/references/ia-rubric.md +19 -0
  103. package/template/.claude/skills/pipeline-rubrics/references/scoring.md +32 -0
  104. package/template/.claude/skills/pipeline-rubrics/references/vision-rubric.md +12 -0
  105. package/template/.claude/skills/prd-templates/SKILL.md +107 -0
  106. package/template/.claude/skills/prd-templates/references/architecture-completeness-checklist.md +28 -0
  107. package/template/.claude/skills/prd-templates/references/architecture-design-template.md +88 -0
  108. package/template/.claude/skills/prd-templates/references/be-spec-classification.md +41 -0
  109. package/template/.claude/skills/prd-templates/references/be-spec-template.md +107 -0
  110. package/template/.claude/skills/prd-templates/references/bootstrap-verification-protocol.md +50 -0
  111. package/template/.claude/skills/prd-templates/references/constraint-exploration.md +41 -0
  112. package/template/.claude/skills/prd-templates/references/data-placement-template.md +74 -0
  113. package/template/.claude/skills/prd-templates/references/decision-confirmation-protocol.md +68 -0
  114. package/template/.claude/skills/prd-templates/references/decision-propagation.md +121 -0
  115. package/template/.claude/skills/prd-templates/references/decomposition-templates.md +226 -0
  116. package/template/.claude/skills/prd-templates/references/deep-ideation-loading-protocol.md +114 -0
  117. package/template/.claude/skills/prd-templates/references/design-system-decisions.md +198 -0
  118. package/template/.claude/skills/prd-templates/references/design-system-prerequisite-check.md +18 -0
  119. package/template/.claude/skills/prd-templates/references/domain-exhaustion-criteria.md +37 -0
  120. package/template/.claude/skills/prd-templates/references/engagement-tier-protocol.md +58 -0
  121. package/template/.claude/skills/prd-templates/references/engineering-standards-template.md +126 -0
  122. package/template/.claude/skills/prd-templates/references/evolution-layer-guidance.md +91 -0
  123. package/template/.claude/skills/prd-templates/references/expansion-modes.md +27 -0
  124. package/template/.claude/skills/prd-templates/references/fe-classification-procedures.md +47 -0
  125. package/template/.claude/skills/prd-templates/references/fe-spec-template.md +90 -0
  126. package/template/.claude/skills/prd-templates/references/feature-ledger-protocol.md +149 -0
  127. package/template/.claude/skills/prd-templates/references/folder-seeding-protocol.md +77 -0
  128. package/template/.claude/skills/prd-templates/references/fractal-cx-template.md +58 -0
  129. package/template/.claude/skills/prd-templates/references/fractal-feature-template.md +93 -0
  130. package/template/.claude/skills/prd-templates/references/fractal-node-index-template.md +55 -0
  131. package/template/.claude/skills/prd-templates/references/gate-applicability.md +92 -0
  132. package/template/.claude/skills/prd-templates/references/ideation-crosscut-template.md +36 -0
  133. package/template/.claude/skills/prd-templates/references/ideation-index-template.md +111 -0
  134. package/template/.claude/skills/prd-templates/references/ideation-meta-template.md +126 -0
  135. package/template/.claude/skills/prd-templates/references/infrastructure-report-template.md +71 -0
  136. package/template/.claude/skills/prd-templates/references/input-classification.md +23 -0
  137. package/template/.claude/skills/prd-templates/references/map-guard-protocol.md +65 -0
  138. package/template/.claude/skills/prd-templates/references/operational-templates.md +116 -0
  139. package/template/.claude/skills/prd-templates/references/persona-completeness-gate.md +20 -0
  140. package/template/.claude/skills/prd-templates/references/placeholder-guard-template.md +21 -0
  141. package/template/.claude/skills/prd-templates/references/placeholder-workflow-mapping.md +50 -0
  142. package/template/.claude/skills/prd-templates/references/shard-boundary-analysis.md +103 -0
  143. package/template/.claude/skills/prd-templates/references/shard-split-remediation.md +157 -0
  144. package/template/.claude/skills/prd-templates/references/skill-loading-protocol.md +36 -0
  145. package/template/.claude/skills/prd-templates/references/slice-completion-gates.md +29 -0
  146. package/template/.claude/skills/prd-templates/references/spec-coverage-sweep.md +44 -0
  147. package/template/.claude/skills/prd-templates/references/surface-model.md +61 -0
  148. package/template/.claude/skills/prd-templates/references/tdd-testing-policy.md +39 -0
  149. package/template/.claude/skills/prd-templates/references/vision-template.md +57 -0
  150. package/template/.claude/skills/prd-templates/references/workflow-checkpoint-protocol.md +112 -0
  151. package/template/.claude/skills/prd-templates/references/write-verification-protocol.md +57 -0
  152. package/template/.claude/skills/prompt-engineer/SKILL.md +203 -0
  153. package/template/.claude/skills/regex-patterns/SKILL.md +333 -0
  154. package/template/.claude/skills/regex-patterns/references/go.md +44 -0
  155. package/template/.claude/skills/regex-patterns/references/javascript.md +63 -0
  156. package/template/.claude/skills/regex-patterns/references/python.md +77 -0
  157. package/template/.claude/skills/regex-patterns/references/rust.md +43 -0
  158. package/template/.claude/skills/resolve-ambiguity/SKILL.md +278 -0
  159. package/template/.claude/skills/security-scanning-security-hardening/SKILL.md +231 -0
  160. package/template/.claude/skills/session-continuity/SKILL.md +732 -0
  161. package/template/.claude/skills/session-continuity/protocols/01-session-resumption.md +38 -0
  162. package/template/.claude/skills/session-continuity/protocols/02-progress-generation.md +85 -0
  163. package/template/.claude/skills/session-continuity/protocols/03-progress-update.md +70 -0
  164. package/template/.claude/skills/session-continuity/protocols/04-pattern-extraction.md +60 -0
  165. package/template/.claude/skills/session-continuity/protocols/05-session-close.md +37 -0
  166. package/template/.claude/skills/session-continuity/protocols/06-decision-analysis.md +84 -0
  167. package/template/.claude/skills/session-continuity/protocols/07-spec-pipeline-generation.md +48 -0
  168. package/template/.claude/skills/session-continuity/protocols/08-spec-pipeline-update.md +55 -0
  169. package/template/.claude/skills/session-continuity/protocols/09-parallel-claim.md +122 -0
  170. package/template/.claude/skills/session-continuity/protocols/10-placeholder-verification-gate.md +83 -0
  171. package/template/.claude/skills/session-continuity/protocols/11-parallel-synthesis.md +21 -0
  172. package/template/.claude/skills/session-continuity/protocols/ambiguity-gates.md +48 -0
  173. package/template/.claude/skills/skill-creator/SKILL.md +203 -0
  174. package/template/.claude/skills/skill-creator/references/.gitkeep +0 -0
  175. package/template/.claude/skills/skill-creator/scripts/.gitkeep +0 -0
  176. package/template/.claude/skills/spec-writing/SKILL.md +110 -0
  177. package/template/.claude/skills/systematic-debugging/CREATION-LOG.md +119 -0
  178. package/template/.claude/skills/systematic-debugging/SKILL.md +297 -0
  179. package/template/.claude/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
  180. package/template/.claude/skills/systematic-debugging/condition-based-waiting.md +115 -0
  181. package/template/.claude/skills/systematic-debugging/defense-in-depth.md +122 -0
  182. package/template/.claude/skills/systematic-debugging/find-polluter.sh +63 -0
  183. package/template/.claude/skills/systematic-debugging/root-cause-tracing.md +169 -0
  184. package/template/.claude/skills/systematic-debugging/test-academic.md +14 -0
  185. package/template/.claude/skills/systematic-debugging/test-pressure-1.md +58 -0
  186. package/template/.claude/skills/systematic-debugging/test-pressure-2.md +68 -0
  187. package/template/.claude/skills/systematic-debugging/test-pressure-3.md +69 -0
  188. package/template/.claude/skills/tdd-workflow/SKILL.md +186 -0
  189. package/template/.claude/skills/tdd-workflow/references/typescript.md +231 -0
  190. package/template/.claude/skills/tech-stack-catalog/SKILL.md +49 -0
  191. package/template/.claude/skills/tech-stack-catalog/references/constraint-questions.md +237 -0
  192. package/template/.claude/skills/tech-stack-catalog/references/dev-tooling-decisions.md +37 -0
  193. package/template/.claude/skills/tech-stack-catalog/references/surface-decision-tables.md +69 -0
  194. package/template/.claude/skills/technical-writer/SKILL.md +242 -0
  195. package/template/.claude/skills/testing-strategist/SKILL.md +319 -0
  196. package/template/.claude/skills/testing-strategist/references/typescript.md +328 -0
  197. package/template/.claude/skills/verification-before-completion/SKILL.md +97 -0
  198. package/template/.claude/skills/workflow-automation/SKILL.md +166 -0
  199. package/template/.claude/skills/workflow-automation/references/inngest.md +88 -0
  200. package/template/.claude/skills/workflow-automation/references/temporal.md +64 -0
@@ -0,0 +1,408 @@
1
+ # REST API Best Practices
2
+
3
+ ## URL Structure
4
+
5
+ ### Resource Naming
6
+
7
+ ```
8
+ # Good - Plural nouns
9
+ GET /api/users
10
+ GET /api/orders
11
+ GET /api/products
12
+
13
+ # Bad - Verbs or mixed conventions
14
+ GET /api/getUser
15
+ GET /api/user (inconsistent singular)
16
+ POST /api/createOrder
17
+ ```
18
+
19
+ ### Nested Resources
20
+
21
+ ```
22
+ # Shallow nesting (preferred)
23
+ GET /api/users/{id}/orders
24
+ GET /api/orders/{id}
25
+
26
+ # Deep nesting (avoid)
27
+ GET /api/users/{id}/orders/{orderId}/items/{itemId}/reviews
28
+ # Better:
29
+ GET /api/order-items/{id}/reviews
30
+ ```
31
+
32
+ ## HTTP Methods and Status Codes
33
+
34
+ ### GET - Retrieve Resources
35
+
36
+ ```
37
+ GET /api/users → 200 OK (with list)
38
+ GET /api/users/{id} → 200 OK or 404 Not Found
39
+ GET /api/users?page=2 → 200 OK (paginated)
40
+ ```
41
+
42
+ ### POST - Create Resources
43
+
44
+ ```
45
+ POST /api/users
46
+ Body: {"name": "John", "email": "john@example.com"}
47
+ → 201 Created
48
+ Location: /api/users/123
49
+ Body: {"id": "123", "name": "John", ...}
50
+
51
+ POST /api/users (validation error)
52
+ → 422 Unprocessable Entity
53
+ Body: {"errors": [...]}
54
+ ```
55
+
56
+ ### PUT - Replace Resources
57
+
58
+ ```
59
+ PUT /api/users/{id}
60
+ Body: {complete user object}
61
+ → 200 OK (updated)
62
+ → 404 Not Found (doesn't exist)
63
+
64
+ # Must include ALL fields
65
+ ```
66
+
67
+ ### PATCH - Partial Update
68
+
69
+ ```
70
+ PATCH /api/users/{id}
71
+ Body: {"name": "Jane"} (only changed fields)
72
+ → 200 OK
73
+ → 404 Not Found
74
+ ```
75
+
76
+ ### DELETE - Remove Resources
77
+
78
+ ```
79
+ DELETE /api/users/{id}
80
+ → 204 No Content (deleted)
81
+ → 404 Not Found
82
+ → 409 Conflict (can't delete due to references)
83
+ ```
84
+
85
+ ## Filtering, Sorting, and Searching
86
+
87
+ ### Query Parameters
88
+
89
+ ```
90
+ # Filtering
91
+ GET /api/users?status=active
92
+ GET /api/users?role=admin&status=active
93
+
94
+ # Sorting
95
+ GET /api/users?sort=created_at
96
+ GET /api/users?sort=-created_at (descending)
97
+ GET /api/users?sort=name,created_at
98
+
99
+ # Searching
100
+ GET /api/users?search=john
101
+ GET /api/users?q=john
102
+
103
+ # Field selection (sparse fieldsets)
104
+ GET /api/users?fields=id,name,email
105
+ ```
106
+
107
+ ## Pagination Patterns
108
+
109
+ ### Offset-Based Pagination
110
+
111
+ ```python
112
+ GET /api/users?page=2&page_size=20
113
+
114
+ Response:
115
+ {
116
+ "items": [...],
117
+ "page": 2,
118
+ "page_size": 20,
119
+ "total": 150,
120
+ "pages": 8
121
+ }
122
+ ```
123
+
124
+ ### Cursor-Based Pagination (for large datasets)
125
+
126
+ ```python
127
+ GET /api/users?limit=20&cursor=eyJpZCI6MTIzfQ
128
+
129
+ Response:
130
+ {
131
+ "items": [...],
132
+ "next_cursor": "eyJpZCI6MTQzfQ",
133
+ "has_more": true
134
+ }
135
+ ```
136
+
137
+ ### Link Header Pagination (RESTful)
138
+
139
+ ```
140
+ GET /api/users?page=2
141
+
142
+ Response Headers:
143
+ Link: <https://api.example.com/users?page=3>; rel="next",
144
+ <https://api.example.com/users?page=1>; rel="prev",
145
+ <https://api.example.com/users?page=1>; rel="first",
146
+ <https://api.example.com/users?page=8>; rel="last"
147
+ ```
148
+
149
+ ## Versioning Strategies
150
+
151
+ ### URL Versioning (Recommended)
152
+
153
+ ```
154
+ /api/v1/users
155
+ /api/v2/users
156
+
157
+ Pros: Clear, easy to route
158
+ Cons: Multiple URLs for same resource
159
+ ```
160
+
161
+ ### Header Versioning
162
+
163
+ ```
164
+ GET /api/users
165
+ Accept: application/vnd.api+json; version=2
166
+
167
+ Pros: Clean URLs
168
+ Cons: Less visible, harder to test
169
+ ```
170
+
171
+ ### Query Parameter
172
+
173
+ ```
174
+ GET /api/users?version=2
175
+
176
+ Pros: Easy to test
177
+ Cons: Optional parameter can be forgotten
178
+ ```
179
+
180
+ ## Rate Limiting
181
+
182
+ ### Headers
183
+
184
+ ```
185
+ X-RateLimit-Limit: 1000
186
+ X-RateLimit-Remaining: 742
187
+ X-RateLimit-Reset: 1640000000
188
+
189
+ Response when limited:
190
+ 429 Too Many Requests
191
+ Retry-After: 3600
192
+ ```
193
+
194
+ ### Implementation Pattern
195
+
196
+ ```python
197
+ from fastapi import HTTPException, Request
198
+ from datetime import datetime, timedelta
199
+
200
+ class RateLimiter:
201
+ def __init__(self, calls: int, period: int):
202
+ self.calls = calls
203
+ self.period = period
204
+ self.cache = {}
205
+
206
+ def check(self, key: str) -> bool:
207
+ now = datetime.now()
208
+ if key not in self.cache:
209
+ self.cache[key] = []
210
+
211
+ # Remove old requests
212
+ self.cache[key] = [
213
+ ts for ts in self.cache[key]
214
+ if now - ts < timedelta(seconds=self.period)
215
+ ]
216
+
217
+ if len(self.cache[key]) >= self.calls:
218
+ return False
219
+
220
+ self.cache[key].append(now)
221
+ return True
222
+
223
+ limiter = RateLimiter(calls=100, period=60)
224
+
225
+ @app.get("/api/users")
226
+ async def get_users(request: Request):
227
+ if not limiter.check(request.client.host):
228
+ raise HTTPException(
229
+ status_code=429,
230
+ headers={"Retry-After": "60"}
231
+ )
232
+ return {"users": [...]}
233
+ ```
234
+
235
+ ## Authentication and Authorization
236
+
237
+ ### Bearer Token
238
+
239
+ ```
240
+ Authorization: Bearer eyJhbGciOiJIUzI1NiIs...
241
+
242
+ 401 Unauthorized - Missing/invalid token
243
+ 403 Forbidden - Valid token, insufficient permissions
244
+ ```
245
+
246
+ ### API Keys
247
+
248
+ ```
249
+ X-API-Key: your-api-key-here
250
+ ```
251
+
252
+ ## Error Response Format
253
+
254
+ ### Consistent Structure
255
+
256
+ ```json
257
+ {
258
+ "error": {
259
+ "code": "VALIDATION_ERROR",
260
+ "message": "Request validation failed",
261
+ "details": [
262
+ {
263
+ "field": "email",
264
+ "message": "Invalid email format",
265
+ "value": "not-an-email"
266
+ }
267
+ ],
268
+ "timestamp": "2025-10-16T12:00:00Z",
269
+ "path": "/api/users"
270
+ }
271
+ }
272
+ ```
273
+
274
+ ### Status Code Guidelines
275
+
276
+ - `200 OK`: Successful GET, PATCH, PUT
277
+ - `201 Created`: Successful POST
278
+ - `204 No Content`: Successful DELETE
279
+ - `400 Bad Request`: Malformed request
280
+ - `401 Unauthorized`: Authentication required
281
+ - `403 Forbidden`: Authenticated but not authorized
282
+ - `404 Not Found`: Resource doesn't exist
283
+ - `409 Conflict`: State conflict (duplicate email, etc.)
284
+ - `422 Unprocessable Entity`: Validation errors
285
+ - `429 Too Many Requests`: Rate limited
286
+ - `500 Internal Server Error`: Server error
287
+ - `503 Service Unavailable`: Temporary downtime
288
+
289
+ ## Caching
290
+
291
+ ### Cache Headers
292
+
293
+ ```
294
+ # Client caching
295
+ Cache-Control: public, max-age=3600
296
+
297
+ # No caching
298
+ Cache-Control: no-cache, no-store, must-revalidate
299
+
300
+ # Conditional requests
301
+ ETag: "33a64df551425fcc55e4d42a148795d9f25f89d4"
302
+ If-None-Match: "33a64df551425fcc55e4d42a148795d9f25f89d4"
303
+ → 304 Not Modified
304
+ ```
305
+
306
+ ## Bulk Operations
307
+
308
+ ### Batch Endpoints
309
+
310
+ ```python
311
+ POST /api/users/batch
312
+ {
313
+ "items": [
314
+ {"name": "User1", "email": "user1@example.com"},
315
+ {"name": "User2", "email": "user2@example.com"}
316
+ ]
317
+ }
318
+
319
+ Response:
320
+ {
321
+ "results": [
322
+ {"id": "1", "status": "created"},
323
+ {"id": null, "status": "failed", "error": "Email already exists"}
324
+ ]
325
+ }
326
+ ```
327
+
328
+ ## Idempotency
329
+
330
+ ### Idempotency Keys
331
+
332
+ ```
333
+ POST /api/orders
334
+ Idempotency-Key: unique-key-123
335
+
336
+ If duplicate request:
337
+ → 200 OK (return cached response)
338
+ ```
339
+
340
+ ## CORS Configuration
341
+
342
+ ```python
343
+ from fastapi.middleware.cors import CORSMiddleware
344
+
345
+ app.add_middleware(
346
+ CORSMiddleware,
347
+ allow_origins=["https://example.com"],
348
+ allow_credentials=True,
349
+ allow_methods=["*"],
350
+ allow_headers=["*"],
351
+ )
352
+ ```
353
+
354
+ ## Documentation with OpenAPI
355
+
356
+ ```python
357
+ from fastapi import FastAPI
358
+
359
+ app = FastAPI(
360
+ title="My API",
361
+ description="API for managing users",
362
+ version="1.0.0",
363
+ docs_url="/docs",
364
+ redoc_url="/redoc"
365
+ )
366
+
367
+ @app.get(
368
+ "/api/users/{user_id}",
369
+ summary="Get user by ID",
370
+ response_description="User details",
371
+ tags=["Users"]
372
+ )
373
+ async def get_user(
374
+ user_id: str = Path(..., description="The user ID")
375
+ ):
376
+ """
377
+ Retrieve user by ID.
378
+
379
+ Returns full user profile including:
380
+ - Basic information
381
+ - Contact details
382
+ - Account status
383
+ """
384
+ pass
385
+ ```
386
+
387
+ ## Health and Monitoring Endpoints
388
+
389
+ ```python
390
+ @app.get("/health")
391
+ async def health_check():
392
+ return {
393
+ "status": "healthy",
394
+ "version": "1.0.0",
395
+ "timestamp": datetime.now().isoformat()
396
+ }
397
+
398
+ @app.get("/health/detailed")
399
+ async def detailed_health():
400
+ return {
401
+ "status": "healthy",
402
+ "checks": {
403
+ "database": await check_database(),
404
+ "redis": await check_redis(),
405
+ "external_api": await check_external_api()
406
+ }
407
+ }
408
+ ```