@patricio0312rev/skillset 0.1.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 (115) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/LICENSE +21 -0
  3. package/README.md +176 -0
  4. package/bin/cli.js +37 -0
  5. package/package.json +55 -0
  6. package/src/commands/init.js +301 -0
  7. package/src/index.js +168 -0
  8. package/src/lib/config.js +200 -0
  9. package/src/lib/generator.js +166 -0
  10. package/src/utils/display.js +95 -0
  11. package/src/utils/readme.js +196 -0
  12. package/src/utils/tool-specific.js +233 -0
  13. package/templates/ai-engineering/agent-orchestration-planner/ SKILL.md +266 -0
  14. package/templates/ai-engineering/cost-latency-optimizer/ SKILL.md +270 -0
  15. package/templates/ai-engineering/doc-to-vector-dataset-generator/ SKILL.md +239 -0
  16. package/templates/ai-engineering/evaluation-harness/ SKILL.md +219 -0
  17. package/templates/ai-engineering/guardrails-safety-filter-builder/ SKILL.md +226 -0
  18. package/templates/ai-engineering/llm-debugger/ SKILL.md +283 -0
  19. package/templates/ai-engineering/prompt-regression-tester/ SKILL.md +216 -0
  20. package/templates/ai-engineering/prompt-template-builder/ SKILL.md +393 -0
  21. package/templates/ai-engineering/rag-pipeline-builder/ SKILL.md +244 -0
  22. package/templates/ai-engineering/tool-function-schema-designer/ SKILL.md +219 -0
  23. package/templates/architecture/adr-writer/ SKILL.md +250 -0
  24. package/templates/architecture/api-versioning-deprecation-planner/ SKILL.md +331 -0
  25. package/templates/architecture/domain-model-boundaries-mapper/ SKILL.md +300 -0
  26. package/templates/architecture/migration-planner/ SKILL.md +376 -0
  27. package/templates/architecture/performance-budget-setter/ SKILL.md +318 -0
  28. package/templates/architecture/reliability-strategy-builder/ SKILL.md +286 -0
  29. package/templates/architecture/rfc-generator/ SKILL.md +362 -0
  30. package/templates/architecture/scalability-playbook/ SKILL.md +279 -0
  31. package/templates/architecture/system-design-generator/ SKILL.md +339 -0
  32. package/templates/architecture/tech-debt-prioritizer/ SKILL.md +329 -0
  33. package/templates/backend/api-contract-normalizer/ SKILL.md +487 -0
  34. package/templates/backend/api-endpoint-generator/ SKILL.md +415 -0
  35. package/templates/backend/auth-module-builder/ SKILL.md +99 -0
  36. package/templates/backend/background-jobs-designer/ SKILL.md +166 -0
  37. package/templates/backend/caching-strategist/ SKILL.md +190 -0
  38. package/templates/backend/error-handling-standardizer/ SKILL.md +174 -0
  39. package/templates/backend/rate-limiting-abuse-protection/ SKILL.md +147 -0
  40. package/templates/backend/rbac-permissions-builder/ SKILL.md +158 -0
  41. package/templates/backend/service-layer-extractor/ SKILL.md +269 -0
  42. package/templates/backend/webhook-receiver-hardener/ SKILL.md +211 -0
  43. package/templates/ci-cd/artifact-sbom-publisher/ SKILL.md +236 -0
  44. package/templates/ci-cd/caching-strategy-optimizer/ SKILL.md +195 -0
  45. package/templates/ci-cd/deployment-checklist-generator/ SKILL.md +381 -0
  46. package/templates/ci-cd/github-actions-pipeline-creator/ SKILL.md +348 -0
  47. package/templates/ci-cd/monorepo-ci-optimizer/ SKILL.md +298 -0
  48. package/templates/ci-cd/preview-environments-builder/ SKILL.md +187 -0
  49. package/templates/ci-cd/quality-gates-enforcer/ SKILL.md +342 -0
  50. package/templates/ci-cd/release-automation-builder/ SKILL.md +281 -0
  51. package/templates/ci-cd/rollback-workflow-builder/ SKILL.md +372 -0
  52. package/templates/ci-cd/secrets-env-manager/ SKILL.md +242 -0
  53. package/templates/db-management/backup-restore-runbook-generator/ SKILL.md +505 -0
  54. package/templates/db-management/data-integrity-auditor/ SKILL.md +505 -0
  55. package/templates/db-management/data-retention-archiving-planner/ SKILL.md +430 -0
  56. package/templates/db-management/data-seeding-fixtures-builder/ SKILL.md +375 -0
  57. package/templates/db-management/db-performance-watchlist/ SKILL.md +425 -0
  58. package/templates/db-management/etl-sync-job-builder/ SKILL.md +457 -0
  59. package/templates/db-management/multi-tenant-safety-checker/ SKILL.md +398 -0
  60. package/templates/db-management/prisma-migration-assistant/ SKILL.md +379 -0
  61. package/templates/db-management/schema-consistency-checker/ SKILL.md +440 -0
  62. package/templates/db-management/sql-query-optimizer/ SKILL.md +324 -0
  63. package/templates/foundation/changelog-writer/ SKILL.md +431 -0
  64. package/templates/foundation/code-formatter-installer/ SKILL.md +320 -0
  65. package/templates/foundation/codebase-summarizer/ SKILL.md +360 -0
  66. package/templates/foundation/dependency-doctor/ SKILL.md +163 -0
  67. package/templates/foundation/dev-environment-bootstrapper/ SKILL.md +259 -0
  68. package/templates/foundation/dev-onboarding-builder/ SKILL.md +556 -0
  69. package/templates/foundation/docs-starter-kit/ SKILL.md +574 -0
  70. package/templates/foundation/explaining-code/SKILL.md +13 -0
  71. package/templates/foundation/git-hygiene-enforcer/ SKILL.md +455 -0
  72. package/templates/foundation/project-scaffolder/ SKILL.md +65 -0
  73. package/templates/foundation/project-scaffolder/references/templates.md +126 -0
  74. package/templates/foundation/repo-structure-linter/ SKILL.md +0 -0
  75. package/templates/foundation/repo-structure-linter/references/conventions.md +98 -0
  76. package/templates/frontend/animation-micro-interaction-pack/ SKILL.md +41 -0
  77. package/templates/frontend/component-scaffold-generator/ SKILL.md +562 -0
  78. package/templates/frontend/design-to-component-translator/ SKILL.md +547 -0
  79. package/templates/frontend/form-wizard-builder/ SKILL.md +553 -0
  80. package/templates/frontend/frontend-refactor-planner/ SKILL.md +37 -0
  81. package/templates/frontend/i18n-frontend-implementer/ SKILL.md +44 -0
  82. package/templates/frontend/modal-drawer-system/ SKILL.md +377 -0
  83. package/templates/frontend/page-layout-builder/ SKILL.md +630 -0
  84. package/templates/frontend/state-ux-flow-builder/ SKILL.md +23 -0
  85. package/templates/frontend/table-builder/ SKILL.md +350 -0
  86. package/templates/performance/alerting-dashboard-builder/ SKILL.md +162 -0
  87. package/templates/performance/backend-latency-profiler-helper/ SKILL.md +108 -0
  88. package/templates/performance/caching-cdn-strategy-planner/ SKILL.md +150 -0
  89. package/templates/performance/capacity-planning-helper/ SKILL.md +242 -0
  90. package/templates/performance/core-web-vitals-tuner/ SKILL.md +126 -0
  91. package/templates/performance/incident-runbook-generator/ SKILL.md +162 -0
  92. package/templates/performance/load-test-scenario-builder/ SKILL.md +256 -0
  93. package/templates/performance/observability-setup/ SKILL.md +232 -0
  94. package/templates/performance/postmortem-writer/ SKILL.md +203 -0
  95. package/templates/performance/structured-logging-standardizer/ SKILL.md +122 -0
  96. package/templates/security/auth-security-reviewer/ SKILL.md +428 -0
  97. package/templates/security/dependency-vulnerability-triage/ SKILL.md +495 -0
  98. package/templates/security/input-validation-sanitization-auditor/ SKILL.md +76 -0
  99. package/templates/security/pii-redaction-logging-policy-builder/ SKILL.md +65 -0
  100. package/templates/security/rbac-policy-tester/ SKILL.md +80 -0
  101. package/templates/security/secrets-scanner/ SKILL.md +462 -0
  102. package/templates/security/secure-headers-csp-builder/ SKILL.md +404 -0
  103. package/templates/security/security-incident-playbook-generator/ SKILL.md +76 -0
  104. package/templates/security/security-pr-checklist-skill/ SKILL.md +62 -0
  105. package/templates/security/threat-model-generator/ SKILL.md +394 -0
  106. package/templates/testing/contract-testing-builder/ SKILL.md +492 -0
  107. package/templates/testing/coverage-strategist/ SKILL.md +436 -0
  108. package/templates/testing/e2e-test-builder/ SKILL.md +382 -0
  109. package/templates/testing/flaky-test-detective/ SKILL.md +416 -0
  110. package/templates/testing/integration-test-builder/ SKILL.md +525 -0
  111. package/templates/testing/mocking-assistant/ SKILL.md +383 -0
  112. package/templates/testing/snapshot-test-refactorer/ SKILL.md +375 -0
  113. package/templates/testing/test-data-factory-builder/ SKILL.md +449 -0
  114. package/templates/testing/test-reporting-triage-skill/ SKILL.md +469 -0
  115. package/templates/testing/unit-test-generator/ SKILL.md +548 -0
@@ -0,0 +1,320 @@
1
+ ---
2
+ name: code-formatter-installer
3
+ description: Installs and configures Prettier, ESLint, EditorConfig, and other code quality tools to enforce consistent code style across the team. Generates config files, npm scripts, editor settings recommendations, and CI integration suggestions. Use when users request "setup prettier", "add eslint", "configure code formatting", or "enforce code style".
4
+ ---
5
+
6
+ # Code Formatter & Linter Installer
7
+
8
+ Establish consistent code formatting and linting across your project.
9
+
10
+ ## Core Workflow
11
+
12
+ 1. **Detect stack**: Identify language/framework (JS/TS, Python, Go, Rust)
13
+ 2. **Choose tools**: Select appropriate formatters and linters
14
+ 3. **Generate configs**: Create config files with best-practice rules
15
+ 4. **Add scripts**: Include npm/package scripts for format/lint
16
+ 5. **Configure editor**: Provide VS Code, IntelliJ, Vim settings
17
+ 6. **Setup pre-commit**: Add git hooks for automatic formatting
18
+ 7. **CI integration**: Suggest GitHub Actions or CI config
19
+
20
+ ## Tool Selection by Stack
21
+
22
+ ### JavaScript/TypeScript
23
+
24
+ - **Formatter**: Prettier
25
+ - **Linter**: ESLint + typescript-eslint
26
+ - **Editor**: EditorConfig
27
+ - **Hooks**: Husky + lint-staged
28
+
29
+ ### Python
30
+
31
+ - **Formatter**: Black + isort
32
+ - **Linter**: Ruff or Flake8 + mypy
33
+ - **Hooks**: pre-commit
34
+
35
+ ### Go
36
+
37
+ - **Formatter**: gofmt + goimports
38
+ - **Linter**: golangci-lint
39
+
40
+ ### Rust
41
+
42
+ - **Formatter**: rustfmt
43
+ - **Linter**: clippy
44
+
45
+ ## Configuration Templates
46
+
47
+ ### Prettier (.prettierrc.json)
48
+
49
+ ```json
50
+ {
51
+ "semi": true,
52
+ "trailingComma": "es5",
53
+ "singleQuote": true,
54
+ "printWidth": 100,
55
+ "tabWidth": 2,
56
+ "arrowParens": "avoid"
57
+ }
58
+ ```
59
+
60
+ ### ESLint (.eslintrc.json)
61
+
62
+ ```json
63
+ {
64
+ "extends": [
65
+ "eslint:recommended",
66
+ "plugin:@typescript-eslint/recommended",
67
+ "plugin:react/recommended",
68
+ "prettier"
69
+ ],
70
+ "rules": {
71
+ "no-console": "warn",
72
+ "@typescript-eslint/no-unused-vars": "error"
73
+ }
74
+ }
75
+ ```
76
+
77
+ ### EditorConfig (.editorconfig)
78
+
79
+ ```ini
80
+ root = true
81
+
82
+ [*]
83
+ indent_style = space
84
+ indent_size = 2
85
+ end_of_line = lf
86
+ charset = utf-8
87
+ trim_trailing_whitespace = true
88
+ insert_final_newline = true
89
+
90
+ [*.py]
91
+ indent_size = 4
92
+
93
+ [*.md]
94
+ trim_trailing_whitespace = false
95
+ ```
96
+
97
+ ### Python (pyproject.toml)
98
+
99
+ ```toml
100
+ [tool.black]
101
+ line-length = 100
102
+ target-version = ['py311']
103
+
104
+ [tool.isort]
105
+ profile = "black"
106
+ line_length = 100
107
+
108
+ [tool.mypy]
109
+ strict = true
110
+ warn_return_any = true
111
+ ```
112
+
113
+ ## Package Scripts
114
+
115
+ ### JavaScript/TypeScript (package.json)
116
+
117
+ ```json
118
+ {
119
+ "scripts": {
120
+ "format": "prettier --write .",
121
+ "format:check": "prettier --check .",
122
+ "lint": "eslint . --ext .ts,.tsx,.js,.jsx",
123
+ "lint:fix": "eslint . --ext .ts,.tsx,.js,.jsx --fix",
124
+ "typecheck": "tsc --noEmit"
125
+ }
126
+ }
127
+ ```
128
+
129
+ ### Python
130
+
131
+ ```bash
132
+ # Makefile or scripts
133
+ format:
134
+ black .
135
+ isort .
136
+
137
+ lint:
138
+ ruff check .
139
+ mypy .
140
+
141
+ format-check:
142
+ black --check .
143
+ isort --check .
144
+ ```
145
+
146
+ ## Git Hooks Setup
147
+
148
+ ### Husky + lint-staged (Node.js)
149
+
150
+ 1. Install dependencies:
151
+
152
+ ```bash
153
+ npm install --save-dev husky lint-staged
154
+ npx husky init
155
+ ```
156
+
157
+ 2. Configure lint-staged (.lintstagedrc.json):
158
+
159
+ ```json
160
+ {
161
+ "*.{ts,tsx,js,jsx}": ["eslint --fix", "prettier --write"],
162
+ "*.{json,md,yml}": ["prettier --write"]
163
+ }
164
+ ```
165
+
166
+ 3. Add pre-commit hook (.husky/pre-commit):
167
+
168
+ ```bash
169
+ #!/bin/sh
170
+ npx lint-staged
171
+ ```
172
+
173
+ ### pre-commit (Python)
174
+
175
+ 1. Create .pre-commit-config.yaml:
176
+
177
+ ```yaml
178
+ repos:
179
+ - repo: https://github.com/psf/black
180
+ rev: 24.1.1
181
+ hooks:
182
+ - id: black
183
+
184
+ - repo: https://github.com/pycqa/isort
185
+ rev: 5.13.2
186
+ hooks:
187
+ - id: isort
188
+
189
+ - repo: https://github.com/astral-sh/ruff-pre-commit
190
+ rev: v0.2.0
191
+ hooks:
192
+ - id: ruff
193
+ args: [--fix]
194
+
195
+ - repo: https://github.com/pre-commit/mirrors-mypy
196
+ rev: v1.8.0
197
+ hooks:
198
+ - id: mypy
199
+ ```
200
+
201
+ 2. Install:
202
+
203
+ ```bash
204
+ pip install pre-commit
205
+ pre-commit install
206
+ ```
207
+
208
+ ## Editor Configuration
209
+
210
+ ### VS Code (settings.json)
211
+
212
+ ```json
213
+ {
214
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
215
+ "editor.formatOnSave": true,
216
+ "editor.codeActionsOnSave": {
217
+ "source.fixAll.eslint": true
218
+ },
219
+ "[python]": {
220
+ "editor.defaultFormatter": "ms-python.black-formatter"
221
+ }
222
+ }
223
+ ```
224
+
225
+ ### VS Code Extensions (.vscode/extensions.json)
226
+
227
+ ```json
228
+ {
229
+ "recommendations": [
230
+ "esbenp.prettier-vscode",
231
+ "dbaeumer.vscode-eslint",
232
+ "editorconfig.editorconfig",
233
+ "ms-python.black-formatter"
234
+ ]
235
+ }
236
+ ```
237
+
238
+ ### IntelliJ/WebStorm
239
+
240
+ - Enable: Settings → Languages & Frameworks → JavaScript → Prettier → On save
241
+ - Enable: Settings → Tools → Actions on Save → Reformat code
242
+
243
+ ## CI Integration
244
+
245
+ ### GitHub Actions (.github/workflows/lint.yml)
246
+
247
+ ```yaml
248
+ name: Lint
249
+
250
+ on: [push, pull_request]
251
+
252
+ jobs:
253
+ lint:
254
+ runs-on: ubuntu-latest
255
+ steps:
256
+ - uses: actions/checkout@v4
257
+ - uses: actions/setup-node@v4
258
+ with:
259
+ node-version: 20
260
+ - run: npm ci
261
+ - run: npm run format:check
262
+ - run: npm run lint
263
+ - run: npm run typecheck
264
+ ```
265
+
266
+ ### Pre-merge checks
267
+
268
+ ```yaml
269
+ # .github/workflows/pr-checks.yml
270
+ - name: Check formatting
271
+ run: |
272
+ npm run format:check || {
273
+ echo "Code is not formatted. Run 'npm run format' locally."
274
+ exit 1
275
+ }
276
+ ```
277
+
278
+ ## Installation Checklist
279
+
280
+ For every setup, provide:
281
+
282
+ - [ ] Config files (.prettierrc, .eslintrc, .editorconfig, etc.)
283
+ - [ ] Ignore files (.prettierignore, .eslintignore)
284
+ - [ ] Package scripts (format, lint, format:check, lint:fix)
285
+ - [ ] Git hooks (husky/pre-commit)
286
+ - [ ] Editor settings (.vscode/settings.json)
287
+ - [ ] CI workflow (.github/workflows/lint.yml)
288
+ - [ ] Documentation (README section on running lint/format)
289
+
290
+ ## Best Practices
291
+
292
+ 1. **Run formatter last**: Prettier should override other formatting rules
293
+ 2. **Extend configs**: Use popular presets (Airbnb, Standard, etc.)
294
+ 3. **Ignore generated files**: Add build outputs to ignore files
295
+ 4. **Make hooks skippable**: Allow `git commit --no-verify` for emergencies
296
+ 5. **Document process**: Add "Code Style" section to CONTRIBUTING.md
297
+ 6. **Test on clean install**: Ensure configs work without local editor setup
298
+ 7. **Keep rules minimal**: Start strict, relax if needed
299
+
300
+ ## Common Configurations
301
+
302
+ See `assets/configs/` for ready-to-use config files:
303
+
304
+ - Next.js + TypeScript
305
+ - React + TypeScript
306
+ - Node.js + TypeScript
307
+ - Python FastAPI
308
+ - Python Django
309
+
310
+ ## Bypass Instructions (Emergencies)
311
+
312
+ ```bash
313
+ # Skip pre-commit hooks
314
+ git commit --no-verify
315
+
316
+ # Skip CI checks (not recommended)
317
+ git push --no-verify
318
+ ```
319
+
320
+ Document when bypass is acceptable (hotfixes, emergencies only).
@@ -0,0 +1,360 @@
1
+ ---
2
+ name: codebase-summarizer
3
+ description: Scans repository structure and generates comprehensive architecture documentation including system overview, entry points, module relationships, data flow diagrams, and "edit here for X" guides. Creates ARCHITECTURE.md for onboarding and navigation. Use when users request "document the codebase", "explain the architecture", "create onboarding docs", or "map the system".
4
+ ---
5
+
6
+ # Codebase Summarizer
7
+
8
+ Generate comprehensive architecture documentation from repository analysis.
9
+
10
+ ## Core Workflow
11
+
12
+ 1. **Scan structure**: Recursively analyze folder tree and file organization
13
+ 2. **Identify patterns**: Detect framework, architecture style, key directories
14
+ 3. **Map entry points**: Find main files, routes, APIs, CLI commands
15
+ 4. **Trace data flow**: Follow requests through layers (controllers → services → models)
16
+ 5. **Document modules**: Explain purpose and responsibilities of each directory
17
+ 6. **Create navigation**: Build "how to" guides for common tasks
18
+ 7. **Generate diagrams**: Add Mermaid diagrams for visual architecture
19
+
20
+ ## Documentation Structure
21
+
22
+ ### ARCHITECTURE.md Template
23
+
24
+ ````markdown
25
+ # Architecture Overview
26
+
27
+ ## System Summary
28
+
29
+ [Project Name] is a [type] application built with [stack]. It follows [architecture pattern] and handles [primary use cases].
30
+
31
+ **Tech Stack:**
32
+
33
+ - Frontend: [framework + key libraries]
34
+ - Backend: [framework + key libraries]
35
+ - Database: [database + ORM]
36
+ - Infrastructure: [hosting + CI/CD]
37
+
38
+ ## High-Level Architecture
39
+
40
+ ```mermaid
41
+ graph TB
42
+ Client[Client/Browser] --> API[API Layer]
43
+ API --> Services[Business Logic]
44
+ Services --> DB[(Database)]
45
+ Services --> Cache[(Redis Cache)]
46
+ API --> Queue[Message Queue]
47
+ ```
48
+ ````
49
+
50
+ ## Project Structure
51
+
52
+ ```
53
+ src/
54
+ ├── app/ # Application entry point and routing
55
+ ├── components/ # Reusable UI components
56
+ ├── lib/ # Utility functions and helpers
57
+ ├── services/ # Business logic layer
58
+ ├── models/ # Data models and schemas
59
+ └── types/ # TypeScript type definitions
60
+ ```
61
+
62
+ ## Key Components
63
+
64
+ ### Entry Points
65
+
66
+ **Main Application:** `src/app/page.tsx`
67
+
68
+ - Application entry point
69
+ - Initializes providers and routing
70
+ - Handles global error boundaries
71
+
72
+ **API Routes:** `src/app/api/`
73
+
74
+ - RESTful API endpoints
75
+ - Authentication middleware
76
+ - Request validation
77
+
78
+ ### Core Modules
79
+
80
+ **Authentication (`src/services/auth/`)**
81
+
82
+ - User login and registration
83
+ - JWT token management
84
+ - OAuth2 integration
85
+ - Dependencies: bcrypt, jsonwebtoken
86
+
87
+ **User Management (`src/services/users/`)**
88
+
89
+ - CRUD operations for users
90
+ - Profile management
91
+ - Role-based access control
92
+ - Dependencies: Prisma, validation libraries
93
+
94
+ **Data Layer (`src/models/`)**
95
+
96
+ - Database schemas
97
+ - Prisma models
98
+ - Query builders
99
+ - Dependencies: Prisma Client
100
+
101
+ ## Data Flow
102
+
103
+ ### User Registration Flow
104
+
105
+ ```mermaid
106
+ sequenceDiagram
107
+ Client->>API: POST /api/auth/register
108
+ API->>Validation: Validate input
109
+ Validation->>Services: UserService.create()
110
+ Services->>Database: Insert user
111
+ Database-->>Services: User created
112
+ Services->>Email: Send welcome email
113
+ Services-->>API: Return JWT
114
+ API-->>Client: 201 Created
115
+ ```
116
+
117
+ ### Request Lifecycle
118
+
119
+ 1. **Request arrives** → API route handler (`src/app/api/[endpoint]/route.ts`)
120
+ 2. **Middleware** → Auth, validation, rate limiting
121
+ 3. **Service layer** → Business logic (`src/services/`)
122
+ 4. **Data layer** → Database queries (`src/models/`)
123
+ 5. **Response** → Format and return data
124
+
125
+ ## Common Patterns
126
+
127
+ ### Service Pattern
128
+
129
+ ```typescript
130
+ // src/services/users/user.service.ts
131
+ export class UserService {
132
+ async findById(id: string) {
133
+ return prisma.user.findUnique({ where: { id } });
134
+ }
135
+
136
+ async create(data: CreateUserDto) {
137
+ // Validation, business logic, database operations
138
+ }
139
+ }
140
+ ```
141
+
142
+ ### Repository Pattern
143
+
144
+ ```typescript
145
+ // src/repositories/user.repository.ts
146
+ export class UserRepository {
147
+ async findAll() {
148
+ /* DB queries only */
149
+ }
150
+ async findById(id: string) {
151
+ /* DB queries only */
152
+ }
153
+ }
154
+ ```
155
+
156
+ ## How To Guides
157
+
158
+ ### Add a New API Endpoint
159
+
160
+ 1. **Create route file:** `src/app/api/[name]/route.ts`
161
+
162
+ ```typescript
163
+ export async function GET(req: Request) {
164
+ // Implementation
165
+ }
166
+ ```
167
+
168
+ 2. **Add service logic:** `src/services/[name].service.ts`
169
+ 3. **Define types:** `src/types/[name].ts`
170
+ 4. **Add tests:** `src/app/api/[name]/route.test.ts`
171
+ 5. **Update API docs:** Document in OpenAPI/Swagger
172
+
173
+ ### Add a New Database Model
174
+
175
+ 1. **Update schema:** `prisma/schema.prisma`
176
+
177
+ ```prisma
178
+ model NewModel {
179
+ id String @id @default(cuid())
180
+ // fields
181
+ }
182
+ ```
183
+
184
+ 2. **Run migration:** `npx prisma migrate dev --name add-new-model`
185
+ 3. **Generate types:** `npx prisma generate`
186
+ 4. **Create service:** `src/services/new-model.service.ts`
187
+ 5. **Add CRUD routes:** `src/app/api/new-model/`
188
+
189
+ ### Add a New React Component
190
+
191
+ 1. **Create component:** `src/components/NewComponent/NewComponent.tsx`
192
+ 2. **Add styles:** `NewComponent.module.css` or inline Tailwind
193
+ 3. **Write tests:** `NewComponent.test.tsx`
194
+ 4. **Add stories:** `NewComponent.stories.tsx` (if using Storybook)
195
+ 5. **Export:** Update `src/components/index.ts`
196
+
197
+ ### Modify Authentication
198
+
199
+ 1. **Service layer:** `src/services/auth/auth.service.ts`
200
+ 2. **Middleware:** `src/middleware/auth.middleware.ts`
201
+ 3. **Routes:** `src/app/api/auth/`
202
+ 4. **Update tests:** Ensure auth flows still work
203
+
204
+ ## Key Files Reference
205
+
206
+ | File | Purpose | Modify For |
207
+ | ---------------------- | ---------------------- | --------------------- |
208
+ | `src/app/layout.tsx` | Root layout, providers | Global layout changes |
209
+ | `src/lib/db.ts` | Database connection | Connection config |
210
+ | `src/lib/api.ts` | API client setup | Request interceptors |
211
+ | `src/middleware.ts` | Next.js middleware | Auth, redirects |
212
+ | `prisma/schema.prisma` | Database schema | Data model changes |
213
+ | `.env.example` | Environment vars | Adding config values |
214
+
215
+ ## Dependencies
216
+
217
+ ### Critical Dependencies
218
+
219
+ - `next` - React framework
220
+ - `prisma` - ORM and database toolkit
221
+ - `react` - UI library
222
+ - `typescript` - Type safety
223
+
224
+ ### Key Libraries
225
+
226
+ - `zod` - Schema validation
227
+ - `bcrypt` - Password hashing
228
+ - `jsonwebtoken` - JWT handling
229
+ - `date-fns` - Date utilities
230
+
231
+ ## Development Workflow
232
+
233
+ 1. **Local setup:** See [DEVELOPMENT.md](DEVELOPMENT.md)
234
+ 2. **Making changes:** Branch → Implement → Test → PR
235
+ 3. **Running tests:** `pnpm test`
236
+ 4. **Database changes:** Prisma migrate workflow
237
+ 5. **Deployment:** Vercel automatic deployment
238
+
239
+ ## Troubleshooting
240
+
241
+ **Database connection errors**
242
+
243
+ - Check DATABASE_URL in .env
244
+ - Ensure database is running
245
+ - Run `npx prisma generate`
246
+
247
+ **Type errors after schema changes**
248
+
249
+ - Run `npx prisma generate`
250
+ - Restart TypeScript server
251
+
252
+ **Build fails**
253
+
254
+ - Clear `.next` folder: `rm -rf .next`
255
+ - Clear node_modules: `rm -rf node_modules && pnpm install`
256
+
257
+ ## Additional Resources
258
+
259
+ - [API Documentation](./API.md) - Endpoint reference
260
+ - [Development Guide](./DEVELOPMENT.md) - Setup and workflow
261
+ - [Contributing Guide](./CONTRIBUTING.md) - Code standards
262
+ - [Database Schema](./DATABASE.md) - Data model details
263
+
264
+ ````
265
+
266
+ ## Analysis Techniques
267
+
268
+ ### Identify Framework
269
+ Look for telltale files:
270
+ - `next.config.js` → Next.js
271
+ - `vite.config.ts` → Vite
272
+ - `nest-cli.json` → NestJS
273
+ - `manage.py` → Django
274
+ - `Cargo.toml` → Rust
275
+
276
+ ### Map Entry Points
277
+ - Frontend: `index.html`, `main.tsx`, `app.tsx`, `_app.tsx`
278
+ - Backend: `main.ts`, `server.ts`, `app.py`, `index.js`
279
+ - CLI: `cli.ts`, `__main__.py`, `main.go`
280
+
281
+ ### Trace Request Flow
282
+ Follow typical paths:
283
+ 1. Route/endpoint definition
284
+ 2. Middleware/guards
285
+ 3. Controller/handler
286
+ 4. Service/business logic
287
+ 5. Repository/model
288
+ 6. Database query
289
+
290
+ ### Module Categories
291
+ - **Core**: Essential business logic
292
+ - **Infrastructure**: Database, cache, queue
293
+ - **Utilities**: Helpers, formatters, validators
294
+ - **Features**: User-facing functionality
295
+ - **Config**: Environment, settings
296
+
297
+ ## Mermaid Diagrams
298
+
299
+ ### Architecture Diagram
300
+ ```mermaid
301
+ graph LR
302
+ Client --> NextJS
303
+ NextJS --> API
304
+ API --> Services
305
+ Services --> Prisma
306
+ Prisma --> PostgreSQL
307
+ ````
308
+
309
+ ### Data Flow
310
+
311
+ ```mermaid
312
+ sequenceDiagram
313
+ participant Client
314
+ participant API
315
+ participant Service
316
+ participant DB
317
+ Client->>API: Request
318
+ API->>Service: Process
319
+ Service->>DB: Query
320
+ DB-->>Service: Data
321
+ Service-->>API: Result
322
+ API-->>Client: Response
323
+ ```
324
+
325
+ ### Module Relationships
326
+
327
+ ```mermaid
328
+ graph TB
329
+ API[API Layer] --> Auth[Auth Service]
330
+ API --> Users[User Service]
331
+ Auth --> DB[(Database)]
332
+ Users --> DB
333
+ Users --> Cache[(Cache)]
334
+ ```
335
+
336
+ ## Best Practices
337
+
338
+ 1. **Start high-level**: Overview before details
339
+ 2. **Visual first**: Use diagrams for complex flows
340
+ 3. **Be specific**: Reference actual file paths
341
+ 4. **Show examples**: Include code snippets
342
+ 5. **Link related docs**: Reference other documentation
343
+ 6. **Keep updated**: Update as architecture evolves
344
+ 7. **Developer-focused**: Write for onboarding and daily use
345
+
346
+ ## Output Checklist
347
+
348
+ Every codebase summary should include:
349
+
350
+ - [ ] System overview and tech stack
351
+ - [ ] High-level architecture diagram
352
+ - [ ] Project structure explanation
353
+ - [ ] Entry points identification
354
+ - [ ] Module/directory purposes
355
+ - [ ] Data flow diagrams
356
+ - [ ] Common patterns documented
357
+ - [ ] "How to" guides for common tasks
358
+ - [ ] Key files reference table
359
+ - [ ] Dependencies explanation
360
+ - [ ] Troubleshooting section