agentic-team-templates 0.3.0
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.
- package/README.md +280 -0
- package/bin/cli.js +5 -0
- package/package.json +47 -0
- package/src/index.js +521 -0
- package/templates/_shared/code-quality.md +162 -0
- package/templates/_shared/communication.md +114 -0
- package/templates/_shared/core-principles.md +62 -0
- package/templates/_shared/git-workflow.md +165 -0
- package/templates/_shared/security-fundamentals.md +173 -0
- package/templates/blockchain/.cursorrules/defi-patterns.md +520 -0
- package/templates/blockchain/.cursorrules/gas-optimization.md +339 -0
- package/templates/blockchain/.cursorrules/overview.md +130 -0
- package/templates/blockchain/.cursorrules/security.md +318 -0
- package/templates/blockchain/.cursorrules/smart-contracts.md +364 -0
- package/templates/blockchain/.cursorrules/testing.md +415 -0
- package/templates/blockchain/.cursorrules/web3-integration.md +538 -0
- package/templates/blockchain/CLAUDE.md +389 -0
- package/templates/cli-tools/.cursorrules/architecture.md +412 -0
- package/templates/cli-tools/.cursorrules/arguments.md +406 -0
- package/templates/cli-tools/.cursorrules/distribution.md +546 -0
- package/templates/cli-tools/.cursorrules/error-handling.md +455 -0
- package/templates/cli-tools/.cursorrules/overview.md +136 -0
- package/templates/cli-tools/.cursorrules/testing.md +537 -0
- package/templates/cli-tools/.cursorrules/user-experience.md +545 -0
- package/templates/cli-tools/CLAUDE.md +356 -0
- package/templates/data-engineering/.cursorrules/data-modeling.md +367 -0
- package/templates/data-engineering/.cursorrules/data-quality.md +455 -0
- package/templates/data-engineering/.cursorrules/overview.md +85 -0
- package/templates/data-engineering/.cursorrules/performance.md +339 -0
- package/templates/data-engineering/.cursorrules/pipeline-design.md +280 -0
- package/templates/data-engineering/.cursorrules/security.md +460 -0
- package/templates/data-engineering/.cursorrules/testing.md +452 -0
- package/templates/data-engineering/CLAUDE.md +974 -0
- package/templates/devops-sre/.cursorrules/capacity-planning.md +653 -0
- package/templates/devops-sre/.cursorrules/change-management.md +584 -0
- package/templates/devops-sre/.cursorrules/chaos-engineering.md +651 -0
- package/templates/devops-sre/.cursorrules/disaster-recovery.md +641 -0
- package/templates/devops-sre/.cursorrules/incident-management.md +565 -0
- package/templates/devops-sre/.cursorrules/observability.md +714 -0
- package/templates/devops-sre/.cursorrules/overview.md +230 -0
- package/templates/devops-sre/.cursorrules/postmortems.md +588 -0
- package/templates/devops-sre/.cursorrules/runbooks.md +760 -0
- package/templates/devops-sre/.cursorrules/slo-sli.md +617 -0
- package/templates/devops-sre/.cursorrules/toil-reduction.md +567 -0
- package/templates/devops-sre/CLAUDE.md +1007 -0
- package/templates/documentation/.cursorrules/adr.md +277 -0
- package/templates/documentation/.cursorrules/api-documentation.md +411 -0
- package/templates/documentation/.cursorrules/code-comments.md +253 -0
- package/templates/documentation/.cursorrules/maintenance.md +260 -0
- package/templates/documentation/.cursorrules/overview.md +82 -0
- package/templates/documentation/.cursorrules/readme-standards.md +306 -0
- package/templates/documentation/CLAUDE.md +120 -0
- package/templates/fullstack/.cursorrules/api-contracts.md +331 -0
- package/templates/fullstack/.cursorrules/architecture.md +298 -0
- package/templates/fullstack/.cursorrules/overview.md +109 -0
- package/templates/fullstack/.cursorrules/shared-types.md +348 -0
- package/templates/fullstack/.cursorrules/testing.md +386 -0
- package/templates/fullstack/CLAUDE.md +349 -0
- package/templates/ml-ai/.cursorrules/data-engineering.md +483 -0
- package/templates/ml-ai/.cursorrules/deployment.md +601 -0
- package/templates/ml-ai/.cursorrules/model-development.md +538 -0
- package/templates/ml-ai/.cursorrules/monitoring.md +658 -0
- package/templates/ml-ai/.cursorrules/overview.md +131 -0
- package/templates/ml-ai/.cursorrules/security.md +637 -0
- package/templates/ml-ai/.cursorrules/testing.md +678 -0
- package/templates/ml-ai/CLAUDE.md +1136 -0
- package/templates/mobile/.cursorrules/navigation.md +246 -0
- package/templates/mobile/.cursorrules/offline-first.md +302 -0
- package/templates/mobile/.cursorrules/overview.md +71 -0
- package/templates/mobile/.cursorrules/performance.md +345 -0
- package/templates/mobile/.cursorrules/testing.md +339 -0
- package/templates/mobile/CLAUDE.md +233 -0
- package/templates/platform-engineering/.cursorrules/ci-cd.md +778 -0
- package/templates/platform-engineering/.cursorrules/developer-experience.md +632 -0
- package/templates/platform-engineering/.cursorrules/infrastructure-as-code.md +600 -0
- package/templates/platform-engineering/.cursorrules/kubernetes.md +710 -0
- package/templates/platform-engineering/.cursorrules/observability.md +747 -0
- package/templates/platform-engineering/.cursorrules/overview.md +215 -0
- package/templates/platform-engineering/.cursorrules/security.md +855 -0
- package/templates/platform-engineering/.cursorrules/testing.md +878 -0
- package/templates/platform-engineering/CLAUDE.md +850 -0
- package/templates/utility-agent/.cursorrules/action-control.md +284 -0
- package/templates/utility-agent/.cursorrules/context-management.md +186 -0
- package/templates/utility-agent/.cursorrules/hallucination-prevention.md +253 -0
- package/templates/utility-agent/.cursorrules/overview.md +78 -0
- package/templates/utility-agent/.cursorrules/token-optimization.md +369 -0
- package/templates/utility-agent/CLAUDE.md +513 -0
- package/templates/web-backend/.cursorrules/api-design.md +255 -0
- package/templates/web-backend/.cursorrules/authentication.md +309 -0
- package/templates/web-backend/.cursorrules/database-patterns.md +298 -0
- package/templates/web-backend/.cursorrules/error-handling.md +366 -0
- package/templates/web-backend/.cursorrules/overview.md +69 -0
- package/templates/web-backend/.cursorrules/security.md +358 -0
- package/templates/web-backend/.cursorrules/testing.md +395 -0
- package/templates/web-backend/CLAUDE.md +366 -0
- package/templates/web-frontend/.cursorrules/accessibility.md +296 -0
- package/templates/web-frontend/.cursorrules/component-patterns.md +204 -0
- package/templates/web-frontend/.cursorrules/overview.md +72 -0
- package/templates/web-frontend/.cursorrules/performance.md +325 -0
- package/templates/web-frontend/.cursorrules/state-management.md +227 -0
- package/templates/web-frontend/.cursorrules/styling.md +271 -0
- package/templates/web-frontend/.cursorrules/testing.md +311 -0
- package/templates/web-frontend/CLAUDE.md +399 -0
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
# Architecture Decision Records (ADRs)
|
|
2
|
+
|
|
3
|
+
Guidelines for documenting architectural decisions and their rationale.
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
ADRs capture **architecturally significant decisions** — choices that affect:
|
|
8
|
+
- System structure and organization
|
|
9
|
+
- Non-functional characteristics (performance, security, scalability)
|
|
10
|
+
- External dependencies and integrations
|
|
11
|
+
- Development and deployment approaches
|
|
12
|
+
- Standards and conventions
|
|
13
|
+
|
|
14
|
+
## Why ADRs Matter
|
|
15
|
+
|
|
16
|
+
- **Future developers** understand why decisions were made
|
|
17
|
+
- **Prevents rehashing** the same debates
|
|
18
|
+
- **Documents tradeoffs** that aren't obvious from code
|
|
19
|
+
- **Creates accountability** for decisions
|
|
20
|
+
- **Enables learning** from past choices
|
|
21
|
+
|
|
22
|
+
## ADR Format (MADR Template)
|
|
23
|
+
|
|
24
|
+
Use the Markdown Architectural Decision Records (MADR) format:
|
|
25
|
+
|
|
26
|
+
```markdown
|
|
27
|
+
# ADR-001: Use PostgreSQL for Primary Database
|
|
28
|
+
|
|
29
|
+
## Status
|
|
30
|
+
|
|
31
|
+
Accepted
|
|
32
|
+
|
|
33
|
+
## Context
|
|
34
|
+
|
|
35
|
+
We need to choose a primary database for storing user data, transactions,
|
|
36
|
+
and application state. Key requirements:
|
|
37
|
+
|
|
38
|
+
- ACID compliance for financial transactions
|
|
39
|
+
- Support for complex queries and joins
|
|
40
|
+
- Horizontal read scaling
|
|
41
|
+
- Strong ecosystem and tooling
|
|
42
|
+
|
|
43
|
+
Currently evaluating:
|
|
44
|
+
- PostgreSQL
|
|
45
|
+
- MySQL
|
|
46
|
+
- MongoDB
|
|
47
|
+
|
|
48
|
+
## Decision
|
|
49
|
+
|
|
50
|
+
We will use **PostgreSQL** as our primary database.
|
|
51
|
+
|
|
52
|
+
## Rationale
|
|
53
|
+
|
|
54
|
+
### Considered Options
|
|
55
|
+
|
|
56
|
+
#### PostgreSQL
|
|
57
|
+
- **Pros**: ACID compliant, excellent query planner, JSONB for flexible schemas,
|
|
58
|
+
strong extension ecosystem (PostGIS, pg_tron), read replicas
|
|
59
|
+
- **Cons**: Vertical scaling limits, more complex than MySQL
|
|
60
|
+
|
|
61
|
+
#### MySQL
|
|
62
|
+
- **Pros**: Widely adopted, good performance, simpler operations
|
|
63
|
+
- **Cons**: Weaker JSON support, fewer advanced features
|
|
64
|
+
|
|
65
|
+
#### MongoDB
|
|
66
|
+
- **Pros**: Flexible schema, horizontal scaling, document model
|
|
67
|
+
- **Cons**: Not ACID by default, eventual consistency concerns for financial data
|
|
68
|
+
|
|
69
|
+
### Decision Drivers
|
|
70
|
+
|
|
71
|
+
1. **ACID compliance is non-negotiable** for financial transactions
|
|
72
|
+
2. **JSONB** allows flexible metadata without sacrificing query performance
|
|
73
|
+
3. **Team expertise** — 4 of 5 engineers have PostgreSQL experience
|
|
74
|
+
4. **Ecosystem** — Better tooling for our stack (Prisma, TypeORM)
|
|
75
|
+
|
|
76
|
+
## Consequences
|
|
77
|
+
|
|
78
|
+
### Positive
|
|
79
|
+
- Strong consistency guarantees
|
|
80
|
+
- Can use advanced features (CTEs, window functions)
|
|
81
|
+
- Familiar to most team members
|
|
82
|
+
|
|
83
|
+
### Negative
|
|
84
|
+
- Need to plan for vertical scaling limits
|
|
85
|
+
- More operational complexity than managed MongoDB
|
|
86
|
+
- Schema migrations required for structural changes
|
|
87
|
+
|
|
88
|
+
### Neutral
|
|
89
|
+
- Will use read replicas for scaling reads
|
|
90
|
+
- Need to establish connection pooling strategy
|
|
91
|
+
|
|
92
|
+
## Related Decisions
|
|
93
|
+
|
|
94
|
+
- ADR-002: Use Prisma as ORM
|
|
95
|
+
- ADR-005: Database connection pooling strategy
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Minimal ADR Format
|
|
99
|
+
|
|
100
|
+
For simpler decisions, use the Nygard format:
|
|
101
|
+
|
|
102
|
+
```markdown
|
|
103
|
+
# ADR-003: Use TypeScript Strict Mode
|
|
104
|
+
|
|
105
|
+
## Status
|
|
106
|
+
|
|
107
|
+
Accepted
|
|
108
|
+
|
|
109
|
+
## Context
|
|
110
|
+
|
|
111
|
+
We need to decide on TypeScript configuration for the project.
|
|
112
|
+
Strict mode catches more errors but requires more explicit typing.
|
|
113
|
+
|
|
114
|
+
## Decision
|
|
115
|
+
|
|
116
|
+
Enable TypeScript strict mode for all new code.
|
|
117
|
+
|
|
118
|
+
## Consequences
|
|
119
|
+
|
|
120
|
+
- Catches null/undefined errors at compile time
|
|
121
|
+
- Requires explicit return types on functions
|
|
122
|
+
- May slow initial development slightly
|
|
123
|
+
- Significantly reduces runtime errors
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Y-Statement Format (Ultra-Minimal)
|
|
127
|
+
|
|
128
|
+
For quick documentation of smaller decisions:
|
|
129
|
+
|
|
130
|
+
```markdown
|
|
131
|
+
# ADR-004: JWT Token Storage
|
|
132
|
+
|
|
133
|
+
In the context of **user authentication**,
|
|
134
|
+
facing **the need to persist auth tokens across page refreshes**,
|
|
135
|
+
we decided for **httpOnly cookies**
|
|
136
|
+
to achieve **XSS protection**,
|
|
137
|
+
accepting **CSRF token overhead**.
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## File Organization
|
|
141
|
+
|
|
142
|
+
### Directory Structure
|
|
143
|
+
|
|
144
|
+
```
|
|
145
|
+
docs/
|
|
146
|
+
└── adr/
|
|
147
|
+
├── README.md # Index of all ADRs
|
|
148
|
+
├── adr-001-database.md
|
|
149
|
+
├── adr-002-orm.md
|
|
150
|
+
├── adr-003-typescript.md
|
|
151
|
+
└── templates/
|
|
152
|
+
├── madr.md # Full template
|
|
153
|
+
└── minimal.md # Minimal template
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Naming Convention
|
|
157
|
+
|
|
158
|
+
```
|
|
159
|
+
adr-NNN-short-title.md
|
|
160
|
+
|
|
161
|
+
Examples:
|
|
162
|
+
- adr-001-use-postgresql.md
|
|
163
|
+
- adr-002-authentication-strategy.md
|
|
164
|
+
- adr-003-api-versioning.md
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### Index File
|
|
168
|
+
|
|
169
|
+
```markdown
|
|
170
|
+
# Architecture Decision Records
|
|
171
|
+
|
|
172
|
+
| ADR | Title | Status | Date |
|
|
173
|
+
|-----|-------|--------|------|
|
|
174
|
+
| [001](./adr-001-database.md) | Use PostgreSQL | Accepted | 2024-01-15 |
|
|
175
|
+
| [002](./adr-002-orm.md) | Use Prisma ORM | Accepted | 2024-01-16 |
|
|
176
|
+
| [003](./adr-003-auth.md) | JWT Authentication | Superseded by 007 | 2024-01-20 |
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## ADR Lifecycle
|
|
180
|
+
|
|
181
|
+
### Statuses
|
|
182
|
+
|
|
183
|
+
| Status | Meaning |
|
|
184
|
+
|--------|---------|
|
|
185
|
+
| **Proposed** | Under discussion, not yet decided |
|
|
186
|
+
| **Accepted** | Decision made, being implemented |
|
|
187
|
+
| **Deprecated** | Still valid but no longer preferred |
|
|
188
|
+
| **Superseded** | Replaced by a newer ADR |
|
|
189
|
+
| **Rejected** | Considered but not accepted |
|
|
190
|
+
|
|
191
|
+
### Updating ADRs
|
|
192
|
+
|
|
193
|
+
```markdown
|
|
194
|
+
## Status
|
|
195
|
+
|
|
196
|
+
Superseded by [ADR-007](./adr-007-session-auth.md)
|
|
197
|
+
|
|
198
|
+
## Supersession Note
|
|
199
|
+
|
|
200
|
+
Added 2024-03-15: After 2 months in production, JWT refresh token
|
|
201
|
+
management proved more complex than anticipated. Moving to
|
|
202
|
+
session-based auth. See ADR-007 for details.
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
**Never delete ADRs** — they document the decision history, including mistakes.
|
|
206
|
+
|
|
207
|
+
## When to Write an ADR
|
|
208
|
+
|
|
209
|
+
### Write an ADR When
|
|
210
|
+
|
|
211
|
+
- Choosing between multiple valid approaches
|
|
212
|
+
- Making decisions with long-term consequences
|
|
213
|
+
- Introducing new patterns or technologies
|
|
214
|
+
- Deviating from established conventions
|
|
215
|
+
- Multiple team members have different opinions
|
|
216
|
+
|
|
217
|
+
### Skip the ADR When
|
|
218
|
+
|
|
219
|
+
- Following established patterns
|
|
220
|
+
- Making easily reversible choices
|
|
221
|
+
- Standard library/framework usage
|
|
222
|
+
- Implementation details (not architecture)
|
|
223
|
+
|
|
224
|
+
## Decision Criteria to Document
|
|
225
|
+
|
|
226
|
+
Always capture:
|
|
227
|
+
|
|
228
|
+
1. **Requirements/Constraints** — What must the solution do?
|
|
229
|
+
2. **Options Considered** — What alternatives were evaluated?
|
|
230
|
+
3. **Decision Drivers** — What factors influenced the choice?
|
|
231
|
+
4. **Tradeoffs** — What are we giving up?
|
|
232
|
+
5. **Consequences** — What changes as a result?
|
|
233
|
+
|
|
234
|
+
## Anti-Patterns
|
|
235
|
+
|
|
236
|
+
### Documenting After the Fact
|
|
237
|
+
|
|
238
|
+
```markdown
|
|
239
|
+
<!-- Bad: Written 6 months later -->
|
|
240
|
+
## Context
|
|
241
|
+
We needed a database. We picked PostgreSQL.
|
|
242
|
+
|
|
243
|
+
<!-- Good: Written during decision -->
|
|
244
|
+
## Context
|
|
245
|
+
Evaluating databases for user data storage. Requirements:
|
|
246
|
+
- ACID for transactions
|
|
247
|
+
- JSON support for flexible metadata
|
|
248
|
+
- Team has PostgreSQL experience
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### Missing Alternatives
|
|
252
|
+
|
|
253
|
+
```markdown
|
|
254
|
+
<!-- Bad: No alternatives -->
|
|
255
|
+
## Decision
|
|
256
|
+
Use React.
|
|
257
|
+
|
|
258
|
+
<!-- Good: Shows the analysis -->
|
|
259
|
+
## Considered Options
|
|
260
|
+
1. React — Large ecosystem, team experience
|
|
261
|
+
2. Vue — Simpler learning curve
|
|
262
|
+
3. Svelte — Better performance, smaller ecosystem
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### Vague Consequences
|
|
266
|
+
|
|
267
|
+
```markdown
|
|
268
|
+
<!-- Bad: Not actionable -->
|
|
269
|
+
## Consequences
|
|
270
|
+
This will have some impact on performance.
|
|
271
|
+
|
|
272
|
+
<!-- Good: Specific and measurable -->
|
|
273
|
+
## Consequences
|
|
274
|
+
- Initial page load increases ~50KB (React bundle)
|
|
275
|
+
- Need to implement code splitting for routes
|
|
276
|
+
- Requires React testing library for component tests
|
|
277
|
+
```
|
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
# API Documentation
|
|
2
|
+
|
|
3
|
+
Guidelines for documenting APIs, including REST endpoints, GraphQL schemas, and library interfaces.
|
|
4
|
+
|
|
5
|
+
## Design-First Approach
|
|
6
|
+
|
|
7
|
+
**Write the API specification before implementation.** This:
|
|
8
|
+
- Catches design issues early
|
|
9
|
+
- Enables parallel frontend/backend development
|
|
10
|
+
- Creates documentation as a natural byproduct
|
|
11
|
+
- Prevents implementation details from leaking into contracts
|
|
12
|
+
|
|
13
|
+
## OpenAPI/Swagger Specification
|
|
14
|
+
|
|
15
|
+
### Basic Structure
|
|
16
|
+
|
|
17
|
+
```yaml
|
|
18
|
+
openapi: 3.1.0
|
|
19
|
+
info:
|
|
20
|
+
title: Payment API
|
|
21
|
+
version: 1.0.0
|
|
22
|
+
description: |
|
|
23
|
+
API for processing payments and managing transactions.
|
|
24
|
+
|
|
25
|
+
## Authentication
|
|
26
|
+
All endpoints require Bearer token authentication.
|
|
27
|
+
|
|
28
|
+
## Rate Limits
|
|
29
|
+
- Standard: 100 requests/minute
|
|
30
|
+
- Burst: 200 requests/minute
|
|
31
|
+
|
|
32
|
+
servers:
|
|
33
|
+
- url: https://api.example.com/v1
|
|
34
|
+
description: Production
|
|
35
|
+
- url: https://api.staging.example.com/v1
|
|
36
|
+
description: Staging
|
|
37
|
+
|
|
38
|
+
paths:
|
|
39
|
+
/payments:
|
|
40
|
+
post:
|
|
41
|
+
summary: Create a payment
|
|
42
|
+
description: |
|
|
43
|
+
Initiates a new payment transaction.
|
|
44
|
+
|
|
45
|
+
The payment will be processed asynchronously. Use the
|
|
46
|
+
returned `payment_id` to check status via GET /payments/{id}.
|
|
47
|
+
operationId: createPayment
|
|
48
|
+
tags:
|
|
49
|
+
- Payments
|
|
50
|
+
requestBody:
|
|
51
|
+
required: true
|
|
52
|
+
content:
|
|
53
|
+
application/json:
|
|
54
|
+
schema:
|
|
55
|
+
$ref: '#/components/schemas/CreatePaymentRequest'
|
|
56
|
+
examples:
|
|
57
|
+
credit_card:
|
|
58
|
+
summary: Credit card payment
|
|
59
|
+
value:
|
|
60
|
+
amount: 1000
|
|
61
|
+
currency: USD
|
|
62
|
+
method: credit_card
|
|
63
|
+
card_token: tok_visa_4242
|
|
64
|
+
responses:
|
|
65
|
+
'201':
|
|
66
|
+
description: Payment created successfully
|
|
67
|
+
content:
|
|
68
|
+
application/json:
|
|
69
|
+
schema:
|
|
70
|
+
$ref: '#/components/schemas/Payment'
|
|
71
|
+
'400':
|
|
72
|
+
$ref: '#/components/responses/BadRequest'
|
|
73
|
+
'401':
|
|
74
|
+
$ref: '#/components/responses/Unauthorized'
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Schema Documentation
|
|
78
|
+
|
|
79
|
+
```yaml
|
|
80
|
+
components:
|
|
81
|
+
schemas:
|
|
82
|
+
Payment:
|
|
83
|
+
type: object
|
|
84
|
+
description: Represents a payment transaction
|
|
85
|
+
required:
|
|
86
|
+
- id
|
|
87
|
+
- amount
|
|
88
|
+
- currency
|
|
89
|
+
- status
|
|
90
|
+
properties:
|
|
91
|
+
id:
|
|
92
|
+
type: string
|
|
93
|
+
format: uuid
|
|
94
|
+
description: Unique payment identifier
|
|
95
|
+
example: "pay_1234567890"
|
|
96
|
+
amount:
|
|
97
|
+
type: integer
|
|
98
|
+
description: Amount in smallest currency unit (cents for USD)
|
|
99
|
+
minimum: 1
|
|
100
|
+
example: 1000
|
|
101
|
+
currency:
|
|
102
|
+
type: string
|
|
103
|
+
description: ISO 4217 currency code
|
|
104
|
+
enum: [USD, EUR, GBP]
|
|
105
|
+
example: USD
|
|
106
|
+
status:
|
|
107
|
+
type: string
|
|
108
|
+
description: Current payment status
|
|
109
|
+
enum: [pending, processing, completed, failed]
|
|
110
|
+
example: completed
|
|
111
|
+
created_at:
|
|
112
|
+
type: string
|
|
113
|
+
format: date-time
|
|
114
|
+
description: When the payment was created
|
|
115
|
+
example: "2024-01-15T10:30:00Z"
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Endpoint Documentation Requirements
|
|
119
|
+
|
|
120
|
+
### Every Endpoint Must Have
|
|
121
|
+
|
|
122
|
+
1. **Summary** - One-line description
|
|
123
|
+
2. **Description** - Detailed behavior explanation
|
|
124
|
+
3. **Parameters** - All path, query, header parameters
|
|
125
|
+
4. **Request body** - Schema with examples
|
|
126
|
+
5. **Responses** - All possible response codes
|
|
127
|
+
6. **Authentication** - Required auth method
|
|
128
|
+
7. **Examples** - Real-world usage examples
|
|
129
|
+
|
|
130
|
+
### Response Documentation
|
|
131
|
+
|
|
132
|
+
Document all response codes:
|
|
133
|
+
|
|
134
|
+
```yaml
|
|
135
|
+
responses:
|
|
136
|
+
'200':
|
|
137
|
+
description: Success
|
|
138
|
+
content:
|
|
139
|
+
application/json:
|
|
140
|
+
schema:
|
|
141
|
+
$ref: '#/components/schemas/User'
|
|
142
|
+
'400':
|
|
143
|
+
description: |
|
|
144
|
+
Bad Request. Possible reasons:
|
|
145
|
+
- Missing required field
|
|
146
|
+
- Invalid field format
|
|
147
|
+
- Business rule violation
|
|
148
|
+
content:
|
|
149
|
+
application/json:
|
|
150
|
+
schema:
|
|
151
|
+
$ref: '#/components/schemas/Error'
|
|
152
|
+
examples:
|
|
153
|
+
missing_field:
|
|
154
|
+
summary: Missing required field
|
|
155
|
+
value:
|
|
156
|
+
error: validation_error
|
|
157
|
+
message: "Field 'email' is required"
|
|
158
|
+
field: email
|
|
159
|
+
invalid_format:
|
|
160
|
+
summary: Invalid format
|
|
161
|
+
value:
|
|
162
|
+
error: validation_error
|
|
163
|
+
message: "Invalid email format"
|
|
164
|
+
field: email
|
|
165
|
+
'401':
|
|
166
|
+
description: Authentication required or token invalid
|
|
167
|
+
'403':
|
|
168
|
+
description: Authenticated but not authorized for this resource
|
|
169
|
+
'404':
|
|
170
|
+
description: Resource not found
|
|
171
|
+
'429':
|
|
172
|
+
description: Rate limit exceeded
|
|
173
|
+
'500':
|
|
174
|
+
description: Internal server error
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## GraphQL Documentation
|
|
178
|
+
|
|
179
|
+
### Schema Documentation
|
|
180
|
+
|
|
181
|
+
```graphql
|
|
182
|
+
"""
|
|
183
|
+
A user account in the system.
|
|
184
|
+
|
|
185
|
+
Users can have multiple roles and belong to organizations.
|
|
186
|
+
"""
|
|
187
|
+
type User {
|
|
188
|
+
"""Unique identifier"""
|
|
189
|
+
id: ID!
|
|
190
|
+
|
|
191
|
+
"""User's email address (unique, used for login)"""
|
|
192
|
+
email: String!
|
|
193
|
+
|
|
194
|
+
"""Display name shown in the UI"""
|
|
195
|
+
displayName: String
|
|
196
|
+
|
|
197
|
+
"""
|
|
198
|
+
User's current status.
|
|
199
|
+
|
|
200
|
+
ACTIVE users can log in and perform actions.
|
|
201
|
+
SUSPENDED users cannot log in until reactivated.
|
|
202
|
+
"""
|
|
203
|
+
status: UserStatus!
|
|
204
|
+
|
|
205
|
+
"""Organizations this user belongs to"""
|
|
206
|
+
organizations: [Organization!]!
|
|
207
|
+
|
|
208
|
+
"""When the account was created"""
|
|
209
|
+
createdAt: DateTime!
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
"""
|
|
213
|
+
Possible states for a user account
|
|
214
|
+
"""
|
|
215
|
+
enum UserStatus {
|
|
216
|
+
"""User can log in and use the system"""
|
|
217
|
+
ACTIVE
|
|
218
|
+
|
|
219
|
+
"""User is blocked from logging in"""
|
|
220
|
+
SUSPENDED
|
|
221
|
+
|
|
222
|
+
"""User has been soft-deleted"""
|
|
223
|
+
DELETED
|
|
224
|
+
}
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### Query/Mutation Documentation
|
|
228
|
+
|
|
229
|
+
```graphql
|
|
230
|
+
type Query {
|
|
231
|
+
"""
|
|
232
|
+
Retrieve a user by ID.
|
|
233
|
+
|
|
234
|
+
Returns null if user doesn't exist or caller lacks permission.
|
|
235
|
+
"""
|
|
236
|
+
user(id: ID!): User
|
|
237
|
+
|
|
238
|
+
"""
|
|
239
|
+
Search users with optional filters.
|
|
240
|
+
|
|
241
|
+
Results are paginated. Use `after` cursor for subsequent pages.
|
|
242
|
+
Maximum 100 results per page.
|
|
243
|
+
"""
|
|
244
|
+
users(
|
|
245
|
+
"""Filter by organization membership"""
|
|
246
|
+
organizationId: ID
|
|
247
|
+
|
|
248
|
+
"""Filter by status"""
|
|
249
|
+
status: UserStatus
|
|
250
|
+
|
|
251
|
+
"""Number of results (max 100)"""
|
|
252
|
+
first: Int = 20
|
|
253
|
+
|
|
254
|
+
"""Cursor for pagination"""
|
|
255
|
+
after: String
|
|
256
|
+
): UserConnection!
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
type Mutation {
|
|
260
|
+
"""
|
|
261
|
+
Create a new user account.
|
|
262
|
+
|
|
263
|
+
Sends a verification email to the provided address.
|
|
264
|
+
User cannot log in until email is verified.
|
|
265
|
+
|
|
266
|
+
Requires ADMIN role.
|
|
267
|
+
"""
|
|
268
|
+
createUser(input: CreateUserInput!): CreateUserPayload!
|
|
269
|
+
}
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
## Library/SDK Documentation
|
|
273
|
+
|
|
274
|
+
### Function Documentation
|
|
275
|
+
|
|
276
|
+
```typescript
|
|
277
|
+
/**
|
|
278
|
+
* Payment processing client.
|
|
279
|
+
*
|
|
280
|
+
* @example Basic usage
|
|
281
|
+
* ```ts
|
|
282
|
+
* const client = new PaymentClient({ apiKey: 'sk_test_...' });
|
|
283
|
+
* const payment = await client.createPayment({
|
|
284
|
+
* amount: 1000,
|
|
285
|
+
* currency: 'usd',
|
|
286
|
+
* });
|
|
287
|
+
* ```
|
|
288
|
+
*
|
|
289
|
+
* @example With error handling
|
|
290
|
+
* ```ts
|
|
291
|
+
* try {
|
|
292
|
+
* const payment = await client.createPayment(params);
|
|
293
|
+
* } catch (error) {
|
|
294
|
+
* if (error instanceof CardDeclinedError) {
|
|
295
|
+
* // Handle declined card
|
|
296
|
+
* }
|
|
297
|
+
* }
|
|
298
|
+
* ```
|
|
299
|
+
*/
|
|
300
|
+
class PaymentClient {
|
|
301
|
+
/**
|
|
302
|
+
* Creates a new payment client instance.
|
|
303
|
+
*
|
|
304
|
+
* @param options - Configuration options
|
|
305
|
+
* @param options.apiKey - Your API key (starts with sk_)
|
|
306
|
+
* @param options.timeout - Request timeout in ms (default: 30000)
|
|
307
|
+
* @param options.maxRetries - Max retry attempts (default: 3)
|
|
308
|
+
*/
|
|
309
|
+
constructor(options: PaymentClientOptions);
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Creates a new payment.
|
|
313
|
+
*
|
|
314
|
+
* @param params - Payment parameters
|
|
315
|
+
* @returns The created payment object
|
|
316
|
+
* @throws {CardDeclinedError} Card was declined by issuer
|
|
317
|
+
* @throws {InvalidParameterError} Invalid parameter provided
|
|
318
|
+
* @throws {RateLimitError} Rate limit exceeded
|
|
319
|
+
*
|
|
320
|
+
* @see {@link https://docs.example.com/payments | Payment Guide}
|
|
321
|
+
*/
|
|
322
|
+
async createPayment(params: CreatePaymentParams): Promise<Payment>;
|
|
323
|
+
}
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
## Documentation Anti-Patterns
|
|
327
|
+
|
|
328
|
+
### Missing Error Documentation
|
|
329
|
+
|
|
330
|
+
```yaml
|
|
331
|
+
# Bad: Only documents success
|
|
332
|
+
responses:
|
|
333
|
+
'200':
|
|
334
|
+
description: Success
|
|
335
|
+
|
|
336
|
+
# Good: Documents all outcomes
|
|
337
|
+
responses:
|
|
338
|
+
'200':
|
|
339
|
+
description: Success
|
|
340
|
+
'400':
|
|
341
|
+
description: Invalid request parameters
|
|
342
|
+
'401':
|
|
343
|
+
description: Missing or invalid authentication
|
|
344
|
+
'404':
|
|
345
|
+
description: Resource not found
|
|
346
|
+
'500':
|
|
347
|
+
description: Internal server error
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
### Vague Descriptions
|
|
351
|
+
|
|
352
|
+
```yaml
|
|
353
|
+
# Bad: Doesn't help the developer
|
|
354
|
+
description: Gets the thing
|
|
355
|
+
|
|
356
|
+
# Good: Specific and actionable
|
|
357
|
+
description: |
|
|
358
|
+
Retrieves a user by their unique ID.
|
|
359
|
+
|
|
360
|
+
Returns the full user profile including email, display name,
|
|
361
|
+
and organization memberships. Requires read:users scope.
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
### No Examples
|
|
365
|
+
|
|
366
|
+
```yaml
|
|
367
|
+
# Bad: No examples
|
|
368
|
+
schema:
|
|
369
|
+
type: object
|
|
370
|
+
properties:
|
|
371
|
+
status:
|
|
372
|
+
type: string
|
|
373
|
+
|
|
374
|
+
# Good: Clear examples
|
|
375
|
+
schema:
|
|
376
|
+
type: object
|
|
377
|
+
properties:
|
|
378
|
+
status:
|
|
379
|
+
type: string
|
|
380
|
+
enum: [pending, active, cancelled]
|
|
381
|
+
example: active
|
|
382
|
+
example:
|
|
383
|
+
status: active
|
|
384
|
+
created_at: "2024-01-15T10:30:00Z"
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
## Keeping API Docs in Sync
|
|
388
|
+
|
|
389
|
+
### Single Source of Truth
|
|
390
|
+
|
|
391
|
+
- Generate docs from code annotations when possible
|
|
392
|
+
- Use OpenAPI spec as source, generate code from it
|
|
393
|
+
- Never maintain parallel documentation
|
|
394
|
+
|
|
395
|
+
### CI Integration
|
|
396
|
+
|
|
397
|
+
```yaml
|
|
398
|
+
# .github/workflows/api-docs.yml
|
|
399
|
+
- name: Validate OpenAPI spec
|
|
400
|
+
run: npx @redocly/cli lint openapi.yaml
|
|
401
|
+
|
|
402
|
+
- name: Check for breaking changes
|
|
403
|
+
run: npx @redocly/cli diff openapi.yaml main:openapi.yaml
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
### Versioning
|
|
407
|
+
|
|
408
|
+
- Document version in API path (`/v1/`, `/v2/`)
|
|
409
|
+
- Maintain docs for all supported versions
|
|
410
|
+
- Clearly mark deprecated endpoints
|
|
411
|
+
- Include migration guides for breaking changes
|