@malamute/ai-rules 1.0.0 → 1.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.
Files changed (145) hide show
  1. package/README.md +272 -121
  2. package/bin/cli.js +5 -2
  3. package/configs/_shared/CLAUDE.md +52 -149
  4. package/configs/_shared/rules/conventions/documentation.md +324 -0
  5. package/configs/_shared/rules/conventions/git.md +265 -0
  6. package/configs/_shared/rules/conventions/npm.md +80 -0
  7. package/configs/_shared/{.claude/rules → rules/conventions}/performance.md +1 -1
  8. package/configs/_shared/rules/conventions/principles.md +334 -0
  9. package/configs/_shared/rules/devops/ci-cd.md +262 -0
  10. package/configs/_shared/rules/devops/docker.md +275 -0
  11. package/configs/_shared/rules/devops/nx.md +194 -0
  12. package/configs/_shared/rules/domain/backend/api-design.md +203 -0
  13. package/configs/_shared/rules/lang/csharp/async.md +220 -0
  14. package/configs/_shared/rules/lang/csharp/csharp.md +314 -0
  15. package/configs/_shared/rules/lang/csharp/linq.md +210 -0
  16. package/configs/_shared/rules/lang/python/async.md +337 -0
  17. package/configs/_shared/rules/lang/python/celery.md +476 -0
  18. package/configs/_shared/rules/lang/python/config.md +339 -0
  19. package/configs/{python/.claude/rules → _shared/rules/lang/python}/database/sqlalchemy.md +6 -1
  20. package/configs/_shared/rules/lang/python/deployment.md +523 -0
  21. package/configs/_shared/rules/lang/python/error-handling.md +330 -0
  22. package/configs/_shared/rules/lang/python/migrations.md +421 -0
  23. package/configs/_shared/rules/lang/python/python.md +172 -0
  24. package/configs/_shared/rules/lang/python/repository.md +383 -0
  25. package/configs/{python/.claude/rules → _shared/rules/lang/python}/testing.md +2 -69
  26. package/configs/_shared/rules/lang/typescript/async.md +447 -0
  27. package/configs/_shared/rules/lang/typescript/generics.md +356 -0
  28. package/configs/_shared/rules/lang/typescript/typescript.md +212 -0
  29. package/configs/_shared/rules/quality/error-handling.md +48 -0
  30. package/configs/_shared/rules/quality/logging.md +45 -0
  31. package/configs/_shared/rules/quality/observability.md +240 -0
  32. package/configs/_shared/rules/quality/testing-patterns.md +65 -0
  33. package/configs/_shared/rules/security/secrets-management.md +222 -0
  34. package/configs/_shared/skills/analysis/explore/SKILL.md +257 -0
  35. package/configs/_shared/skills/analysis/security-audit/SKILL.md +184 -0
  36. package/configs/_shared/skills/dev/api-endpoint/SKILL.md +126 -0
  37. package/configs/_shared/{.claude/commands/generate-tests.md → skills/dev/generate-tests/SKILL.md} +6 -0
  38. package/configs/_shared/{.claude/commands/fix-issue.md → skills/git/fix-issue/SKILL.md} +6 -0
  39. package/configs/_shared/{.claude/commands/review-pr.md → skills/git/review-pr/SKILL.md} +6 -0
  40. package/configs/_shared/skills/infra/deploy/SKILL.md +139 -0
  41. package/configs/_shared/skills/infra/docker/SKILL.md +95 -0
  42. package/configs/_shared/skills/infra/migration/SKILL.md +158 -0
  43. package/configs/_shared/skills/nx/nx-affected/SKILL.md +72 -0
  44. package/configs/_shared/skills/nx/nx-lib/SKILL.md +375 -0
  45. package/configs/angular/CLAUDE.md +24 -216
  46. package/configs/angular/{.claude/rules → rules/core}/components.md +69 -15
  47. package/configs/angular/rules/core/resource.md +285 -0
  48. package/configs/angular/rules/core/signals.md +323 -0
  49. package/configs/angular/rules/http.md +338 -0
  50. package/configs/angular/rules/routing.md +291 -0
  51. package/configs/angular/rules/ssr.md +312 -0
  52. package/configs/angular/rules/state/signal-store.md +408 -0
  53. package/configs/angular/{.claude/rules → rules/state}/state.md +2 -2
  54. package/configs/angular/{.claude/rules → rules}/testing.md +7 -7
  55. package/configs/angular/rules/ui/aria.md +422 -0
  56. package/configs/angular/rules/ui/forms.md +424 -0
  57. package/configs/angular/rules/ui/pipes-directives.md +335 -0
  58. package/configs/angular/{.claude/settings.json → settings.json} +3 -0
  59. package/configs/dotnet/CLAUDE.md +53 -286
  60. package/configs/dotnet/rules/background-services.md +552 -0
  61. package/configs/dotnet/rules/configuration.md +426 -0
  62. package/configs/dotnet/rules/ddd.md +447 -0
  63. package/configs/dotnet/rules/dependency-injection.md +343 -0
  64. package/configs/dotnet/rules/mediatr.md +320 -0
  65. package/configs/dotnet/rules/middleware.md +489 -0
  66. package/configs/dotnet/rules/result-pattern.md +363 -0
  67. package/configs/dotnet/rules/validation.md +388 -0
  68. package/configs/dotnet/settings.json +29 -0
  69. package/configs/fastapi/CLAUDE.md +144 -0
  70. package/configs/fastapi/rules/background-tasks.md +254 -0
  71. package/configs/fastapi/rules/dependencies.md +170 -0
  72. package/configs/{python/.claude → fastapi}/rules/fastapi.md +61 -1
  73. package/configs/fastapi/rules/lifespan.md +274 -0
  74. package/configs/fastapi/rules/middleware.md +229 -0
  75. package/configs/fastapi/rules/pydantic.md +433 -0
  76. package/configs/fastapi/rules/responses.md +251 -0
  77. package/configs/fastapi/rules/routers.md +202 -0
  78. package/configs/fastapi/rules/security.md +222 -0
  79. package/configs/fastapi/rules/testing.md +251 -0
  80. package/configs/fastapi/rules/websockets.md +298 -0
  81. package/configs/fastapi/settings.json +35 -0
  82. package/configs/flask/CLAUDE.md +166 -0
  83. package/configs/flask/rules/blueprints.md +208 -0
  84. package/configs/flask/rules/cli.md +285 -0
  85. package/configs/flask/rules/configuration.md +281 -0
  86. package/configs/flask/rules/context.md +238 -0
  87. package/configs/flask/rules/error-handlers.md +278 -0
  88. package/configs/flask/rules/extensions.md +278 -0
  89. package/configs/flask/rules/flask.md +171 -0
  90. package/configs/flask/rules/marshmallow.md +206 -0
  91. package/configs/flask/rules/security.md +267 -0
  92. package/configs/flask/rules/testing.md +284 -0
  93. package/configs/flask/settings.json +35 -0
  94. package/configs/nestjs/CLAUDE.md +57 -215
  95. package/configs/nestjs/rules/common-patterns.md +300 -0
  96. package/configs/nestjs/rules/filters.md +376 -0
  97. package/configs/nestjs/rules/interceptors.md +317 -0
  98. package/configs/nestjs/rules/middleware.md +321 -0
  99. package/configs/nestjs/{.claude/rules → rules}/modules.md +26 -0
  100. package/configs/nestjs/rules/pipes.md +351 -0
  101. package/configs/nestjs/rules/websockets.md +451 -0
  102. package/configs/nestjs/settings.json +31 -0
  103. package/configs/nextjs/CLAUDE.md +69 -331
  104. package/configs/nextjs/rules/api-routes.md +358 -0
  105. package/configs/nextjs/rules/authentication.md +355 -0
  106. package/configs/nextjs/{.claude/rules → rules}/components.md +52 -0
  107. package/configs/nextjs/rules/data-fetching.md +249 -0
  108. package/configs/nextjs/rules/database.md +400 -0
  109. package/configs/nextjs/rules/middleware.md +303 -0
  110. package/configs/nextjs/rules/routing.md +324 -0
  111. package/configs/nextjs/rules/seo.md +350 -0
  112. package/configs/nextjs/rules/server-actions.md +353 -0
  113. package/configs/nextjs/{.claude/rules → rules}/state/zustand.md +6 -6
  114. package/configs/nextjs/{.claude/settings.json → settings.json} +7 -0
  115. package/package.json +24 -9
  116. package/src/cli.js +218 -0
  117. package/src/config.js +63 -0
  118. package/src/index.js +4 -0
  119. package/src/installer.js +414 -0
  120. package/src/merge.js +109 -0
  121. package/src/tech-config.json +45 -0
  122. package/src/utils.js +88 -0
  123. package/configs/dotnet/.claude/settings.json +0 -9
  124. package/configs/nestjs/.claude/settings.json +0 -15
  125. package/configs/python/.claude/rules/flask.md +0 -332
  126. package/configs/python/.claude/settings.json +0 -18
  127. package/configs/python/CLAUDE.md +0 -273
  128. package/src/install.js +0 -315
  129. /package/configs/_shared/{.claude/rules → rules/domain/frontend}/accessibility.md +0 -0
  130. /package/configs/_shared/{.claude/rules → rules/security}/security.md +0 -0
  131. /package/configs/_shared/{.claude/skills → skills/dev}/debug/SKILL.md +0 -0
  132. /package/configs/_shared/{.claude/skills → skills/dev}/learning/SKILL.md +0 -0
  133. /package/configs/_shared/{.claude/skills → skills/dev}/spec/SKILL.md +0 -0
  134. /package/configs/_shared/{.claude/skills → skills/git}/review/SKILL.md +0 -0
  135. /package/configs/dotnet/{.claude/rules → rules}/api.md +0 -0
  136. /package/configs/dotnet/{.claude/rules → rules}/architecture.md +0 -0
  137. /package/configs/dotnet/{.claude/rules → rules}/database/efcore.md +0 -0
  138. /package/configs/dotnet/{.claude/rules → rules}/testing.md +0 -0
  139. /package/configs/nestjs/{.claude/rules → rules}/auth.md +0 -0
  140. /package/configs/nestjs/{.claude/rules → rules}/database/prisma.md +0 -0
  141. /package/configs/nestjs/{.claude/rules → rules}/database/typeorm.md +0 -0
  142. /package/configs/nestjs/{.claude/rules → rules}/testing.md +0 -0
  143. /package/configs/nestjs/{.claude/rules → rules}/validation.md +0 -0
  144. /package/configs/nextjs/{.claude/rules → rules}/state/redux-toolkit.md +0 -0
  145. /package/configs/nextjs/{.claude/rules → rules}/testing.md +0 -0
@@ -1,174 +1,77 @@
1
1
  # Shared Conventions
2
2
 
3
- ## Git Workflow
4
-
5
- ### Branch Naming
6
-
7
- ```
8
- feature/[ticket-id]-short-description
9
- fix/[ticket-id]-short-description
10
- refactor/description
11
- chore/description
12
- ```
3
+ ## Code Quality
13
4
 
14
- ### Commit Messages (Conventional Commits)
5
+ ### Naming - Be Explicit
15
6
 
16
- ```
17
- type(scope): description
7
+ - No cryptic names: No `c`, `x`, `tmp`, `data`
8
+ - No magic numbers: Use named constants
9
+ - Small functions: < 30 lines, single responsibility
10
+ - Max nesting: 3 levels, use early returns
11
+ - No dead code: Delete, don't comment out
18
12
 
19
- [optional body]
13
+ ### Lint Disable - Only With Justification
20
14
 
21
- [optional footer]
22
- ```
15
+ Never disable lint rules without an explicit reason and ticket reference.
23
16
 
24
- Types:
25
- - `feat`: New feature
26
- - `fix`: Bug fix
27
- - `docs`: Documentation only
28
- - `style`: Formatting, no code change
29
- - `refactor`: Code change that neither fixes a bug nor adds a feature
30
- - `perf`: Performance improvement
31
- - `test`: Adding or updating tests
32
- - `chore`: Maintenance tasks
17
+ ## Error Handling
33
18
 
34
- Examples:
35
- ```
36
- feat(users): add user profile page
37
- fix(auth): resolve token refresh race condition
38
- refactor(api): simplify error handling
39
- test(cart): add unit tests for checkout flow
40
- ```
19
+ - Never swallow errors silently
20
+ - Log with context (user ID, request ID)
21
+ - User-facing: clear, actionable messages
22
+ - Internal: detailed logs, generic user message
41
23
 
42
- ### Pull Requests
24
+ ## Testing
43
25
 
44
- - Keep PRs small and focused
45
- - One feature/fix per PR
46
- - Write meaningful descriptions
47
- - Link related issues
48
-
49
- ## TypeScript Guidelines
50
-
51
- ### Strict Mode
52
-
53
- Always use strict TypeScript configuration:
54
- ```json
55
- {
56
- "compilerOptions": {
57
- "strict": true,
58
- "noImplicitAny": true,
59
- "strictNullChecks": true,
60
- "noImplicitReturns": true
61
- }
62
- }
63
- ```
64
-
65
- ### Type Definitions
66
-
67
- ```typescript
68
- // Prefer interfaces for object shapes
69
- interface User {
70
- id: string;
71
- name: string;
72
- email: string;
73
- }
74
-
75
- // Use type for unions, intersections, utility types
76
- type Status = 'pending' | 'active' | 'inactive';
77
- type UserWithRole = User & { role: Role };
78
-
79
- // Avoid 'any' - use 'unknown' if type is truly unknown
80
- function parse(input: unknown): Result {
81
- // ...
82
- }
83
- ```
84
-
85
- ### Naming Conventions
86
-
87
- | Element | Convention | Example |
88
- |---------|------------|---------|
89
- | Classes | PascalCase | `UserService` |
90
- | Interfaces | PascalCase | `UserProfile` |
91
- | Functions | camelCase | `getUserById` |
92
- | Variables | camelCase | `currentUser` |
93
- | Constants | UPPER_SNAKE_CASE | `MAX_RETRY_COUNT` |
94
- | Files | kebab-case | `user-profile.service.ts` |
95
- | Folders | kebab-case | `user-management/` |
96
-
97
- ### Explicit Return Types
98
-
99
- Always declare return types on public methods:
100
-
101
- ```typescript
102
- // Good
103
- function getUser(id: string): User | null {
104
- // ...
105
- }
106
-
107
- // Avoid
108
- function getUser(id: string) {
109
- // ...
110
- }
111
- ```
26
+ - Test behavior, not implementation
27
+ - Descriptive names: `should_returnUser_when_validId`
28
+ - One assertion per test when practical
29
+ - Mock external dependencies only
112
30
 
113
- ## Code Quality
31
+ ## Security
114
32
 
115
- ### Avoid
33
+ - **Never commit secrets** (use env vars)
34
+ - **Validate all inputs** (never trust user data)
35
+ - **Parameterized queries** (no string concatenation)
36
+ - **Sanitize outputs** (prevent XSS)
116
37
 
117
- - `any` type
118
- - Magic numbers (use named constants)
119
- - Deep nesting (max 3 levels)
120
- - Long functions (max ~50 lines)
121
- - Commented-out code
122
- - Useless comments (code should be self-documenting)
123
- - Cryptic variable names (`c`, `x`, `tmp`, `data`)
38
+ ## Documentation
124
39
 
125
- ### Prefer
40
+ - Self-documenting code first
41
+ - Comments explain "why", not "what"
42
+ - Keep comments up-to-date or delete them
126
43
 
127
- - Early returns
128
- - Descriptive variable names
129
- - Single responsibility principle
130
- - Composition over inheritance
131
- - Immutable data patterns
44
+ ## Git Workflow
132
45
 
133
- ### Naming - Be Explicit
46
+ ### Commits
134
47
 
135
- ```typescript
136
- // BAD
137
- const c = getConfig();
138
- users.filter(u => u.a);
139
- const handleClick = (e) => { ... };
48
+ - Atomic commits: one logical change per commit
49
+ - Conventional commits: `feat:`, `fix:`, `refactor:`, `docs:`, `test:`, `chore:`
50
+ - Present tense: "add feature" not "added feature"
140
51
 
141
- // GOOD
142
- const appConfig = getConfig();
143
- users.filter(user => user.isActive);
144
- const handleUserSelection = (event: MouseEvent) => { ... };
145
- ```
52
+ ### Branches
146
53
 
147
- ### Lint Rules - Never Disable Without Justification
54
+ - `feature/<ticket>-<description>` for new features
55
+ - `fix/<ticket>-<description>` for bug fixes
56
+ - `refactor/<description>` for refactoring
148
57
 
149
- ```typescript
150
- // FORBIDDEN
151
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
152
- const data: any = response;
58
+ ### Pull Requests
153
59
 
154
- // ONLY IF ABSOLUTELY NECESSARY - with explicit reason
155
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Legacy API returns untyped, see ticket TECH-456
156
- const legacyData: any = legacyApi.fetch();
157
- ```
60
+ - Small, focused PRs (< 400 lines)
61
+ - Clear description with context
62
+ - Link to related issues
158
63
 
159
- ## Documentation
64
+ ## Dependencies
160
65
 
161
- - Write self-documenting code first
162
- - Add JSDoc only when intent isn't obvious
163
- - Keep comments up-to-date or remove them
164
- - Document "why", not "what"
66
+ - Pin exact versions in lock files
67
+ - Regular security audits (`npm audit`, `pip-audit`)
68
+ - Prefer well-maintained packages with active communities
69
+ - Minimize dependency count
165
70
 
166
- ```typescript
167
- // Bad: describes what code does
168
- // Increment counter by 1
169
- counter++;
71
+ ## Performance
170
72
 
171
- // Good: explains why
172
- // Compensate for 0-based index in display
173
- counter++;
174
- ```
73
+ - Measure before optimizing
74
+ - Profile to find bottlenecks
75
+ - Cache expensive operations
76
+ - Lazy load when possible
77
+ - Avoid premature optimization
@@ -0,0 +1,324 @@
1
+ ---
2
+ paths:
3
+ - "**/README.md"
4
+ - "**/CHANGELOG.md"
5
+ - "**/docs/**"
6
+ - "**/ADR/**"
7
+ ---
8
+
9
+ # Documentation Standards
10
+
11
+ ## README Structure
12
+
13
+ ```markdown
14
+ # Project Name
15
+
16
+ Brief description (1-2 sentences).
17
+
18
+ ## Quick Start
19
+
20
+ \`\`\`bash
21
+ # Clone and setup
22
+ git clone <repo>
23
+ cd project
24
+ npm install
25
+ npm run dev
26
+ \`\`\`
27
+
28
+ ## Prerequisites
29
+
30
+ - Node.js 20+
31
+ - Docker
32
+ - PostgreSQL 16
33
+
34
+ ## Installation
35
+
36
+ Step-by-step setup instructions.
37
+
38
+ ## Usage
39
+
40
+ Basic usage examples.
41
+
42
+ ## API Reference
43
+
44
+ Link to API docs or brief overview.
45
+
46
+ ## Configuration
47
+
48
+ | Variable | Description | Default |
49
+ |----------|-------------|---------|
50
+ | `PORT` | Server port | `3000` |
51
+ | `DATABASE_URL` | DB connection | required |
52
+
53
+ ## Development
54
+
55
+ \`\`\`bash
56
+ npm run dev # Start dev server
57
+ npm run test # Run tests
58
+ npm run lint # Lint code
59
+ npm run build # Build for production
60
+ \`\`\`
61
+
62
+ ## Deployment
63
+
64
+ How to deploy to production.
65
+
66
+ ## Contributing
67
+
68
+ Link to CONTRIBUTING.md or brief guidelines.
69
+
70
+ ## License
71
+
72
+ MIT / Apache-2.0 / etc.
73
+ ```
74
+
75
+ ## Architecture Decision Records (ADR)
76
+
77
+ ### Template
78
+
79
+ ```markdown
80
+ # ADR-001: Use PostgreSQL as primary database
81
+
82
+ ## Status
83
+
84
+ Accepted | Proposed | Deprecated | Superseded by ADR-XXX
85
+
86
+ ## Date
87
+
88
+ 2024-01-15
89
+
90
+ ## Context
91
+
92
+ What is the issue we're facing? What are the constraints?
93
+
94
+ ## Decision
95
+
96
+ What is the change we're making?
97
+
98
+ ## Consequences
99
+
100
+ ### Positive
101
+ - Benefit 1
102
+ - Benefit 2
103
+
104
+ ### Negative
105
+ - Drawback 1
106
+ - Drawback 2
107
+
108
+ ### Risks
109
+ - Risk 1 and mitigation
110
+
111
+ ## Alternatives Considered
112
+
113
+ 1. **Alternative A**: Why rejected
114
+ 2. **Alternative B**: Why rejected
115
+ ```
116
+
117
+ ### Naming Convention
118
+
119
+ ```
120
+ docs/adr/
121
+ ├── 001-use-postgresql.md
122
+ ├── 002-adopt-microservices.md
123
+ ├── 003-authentication-strategy.md
124
+ └── README.md # Index of all ADRs
125
+ ```
126
+
127
+ ## Changelog
128
+
129
+ ### Format (Keep a Changelog)
130
+
131
+ ```markdown
132
+ # Changelog
133
+
134
+ All notable changes to this project.
135
+
136
+ ## [Unreleased]
137
+
138
+ ### Added
139
+ - New feature X
140
+
141
+ ### Changed
142
+ - Updated dependency Y
143
+
144
+ ## [1.2.0] - 2024-01-15
145
+
146
+ ### Added
147
+ - User authentication (#123)
148
+ - Email notifications (#124)
149
+
150
+ ### Fixed
151
+ - Login redirect issue (#125)
152
+
153
+ ### Security
154
+ - Patched XSS vulnerability (#126)
155
+
156
+ ## [1.1.0] - 2024-01-01
157
+
158
+ ### Added
159
+ - Initial release
160
+ ```
161
+
162
+ ### Categories
163
+
164
+ - **Added**: New features
165
+ - **Changed**: Changes in existing functionality
166
+ - **Deprecated**: Soon-to-be removed features
167
+ - **Removed**: Removed features
168
+ - **Fixed**: Bug fixes
169
+ - **Security**: Vulnerability fixes
170
+
171
+ ## API Documentation
172
+
173
+ ### OpenAPI/Swagger
174
+
175
+ ```yaml
176
+ openapi: 3.0.3
177
+ info:
178
+ title: My API
179
+ version: 1.0.0
180
+ description: API description
181
+
182
+ paths:
183
+ /users:
184
+ get:
185
+ summary: List users
186
+ description: Returns paginated list of users
187
+ parameters:
188
+ - name: page
189
+ in: query
190
+ schema:
191
+ type: integer
192
+ default: 1
193
+ responses:
194
+ '200':
195
+ description: Success
196
+ content:
197
+ application/json:
198
+ schema:
199
+ $ref: '#/components/schemas/UserList'
200
+ ```
201
+
202
+ ### Inline Documentation
203
+
204
+ ```typescript
205
+ /**
206
+ * Creates a new user account.
207
+ *
208
+ * @param data - User registration data
209
+ * @returns Created user object
210
+ * @throws {ValidationError} When email is invalid
211
+ * @throws {ConflictError} When email already exists
212
+ *
213
+ * @example
214
+ * const user = await createUser({
215
+ * email: 'user@example.com',
216
+ * password: 'secure123'
217
+ * });
218
+ */
219
+ async function createUser(data: CreateUserDto): Promise<User> {
220
+ // Implementation
221
+ }
222
+ ```
223
+
224
+ ## Code Comments
225
+
226
+ ### When to Comment
227
+
228
+ ```typescript
229
+ // GOOD: Explains WHY, not WHAT
230
+ // Using retry with exponential backoff because the external API
231
+ // has rate limiting and occasional timeouts
232
+ await retryWithBackoff(() => externalApi.call());
233
+
234
+ // BAD: Explains WHAT (obvious from code)
235
+ // Loop through users
236
+ for (const user of users) { ... }
237
+
238
+ // GOOD: Documents non-obvious behavior
239
+ // Note: Returns null instead of throwing when user not found
240
+ // to support optional user lookups in middleware
241
+ async function findUser(id: string): Promise<User | null>
242
+
243
+ // GOOD: TODO with context
244
+ // TODO(#123): Replace with proper caching once Redis is available
245
+ const cache = new Map();
246
+ ```
247
+
248
+ ### Comment Types
249
+
250
+ ```typescript
251
+ // TODO: Feature to implement
252
+ // FIXME: Known bug to fix
253
+ // HACK: Temporary workaround
254
+ // NOTE: Important information
255
+ // WARN: Potential issue
256
+ // DEPRECATED: Will be removed
257
+ ```
258
+
259
+ ## Project Structure Documentation
260
+
261
+ ```markdown
262
+ # Project Structure
263
+
264
+ \`\`\`
265
+ src/
266
+ ├── modules/ # Feature modules
267
+ │ ├── users/ # User management
268
+ │ │ ├── dto/ # Data transfer objects
269
+ │ │ ├── entities/ # Database entities
270
+ │ │ └── users.service.ts
271
+ │ └── orders/ # Order management
272
+ ├── common/ # Shared utilities
273
+ │ ├── decorators/ # Custom decorators
274
+ │ ├── filters/ # Exception filters
275
+ │ └── guards/ # Auth guards
276
+ ├── config/ # Configuration
277
+ └── main.ts # Entry point
278
+ \`\`\`
279
+ ```
280
+
281
+ ## Runbooks
282
+
283
+ ### Template
284
+
285
+ ```markdown
286
+ # Runbook: Database Connection Issues
287
+
288
+ ## Symptoms
289
+ - API returning 500 errors
290
+ - Logs show "Connection refused"
291
+
292
+ ## Diagnosis
293
+ 1. Check database status: `docker ps | grep postgres`
294
+ 2. Check connections: `SELECT count(*) FROM pg_stat_activity;`
295
+ 3. Check logs: `docker logs postgres`
296
+
297
+ ## Resolution
298
+
299
+ ### If database is down
300
+ \`\`\`bash
301
+ docker-compose restart db
302
+ \`\`\`
303
+
304
+ ### If too many connections
305
+ \`\`\`bash
306
+ # Kill idle connections
307
+ SELECT pg_terminate_backend(pid)
308
+ FROM pg_stat_activity
309
+ WHERE state = 'idle' AND query_start < now() - interval '1 hour';
310
+ \`\`\`
311
+
312
+ ## Escalation
313
+ Contact: @database-team in #incidents
314
+ ```
315
+
316
+ ## Anti-patterns
317
+
318
+ - No README
319
+ - Outdated documentation
320
+ - Documenting WHAT instead of WHY
321
+ - No ADRs for major decisions
322
+ - Missing changelog
323
+ - Undocumented environment variables
324
+ - No setup instructions