@xaviele/ag-kit 1.0.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 +20 -0
- package/bin/cli.js +63 -0
- package/package.json +27 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/charts.csv +26 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/colors.csv +97 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/icons.csv +101 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/landing.csv +31 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/products.csv +97 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/prompts.csv +24 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/react-performance.csv +45 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/stacks/react.csv +54 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/stacks/vue.csv +50 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/styles.csv +59 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/typography.csv +58 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/web-interface.csv +31 -0
- package/template/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/core.cpython-313.pyc +0 -0
- package/template/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-313.pyc +0 -0
- package/template/.agent/.shared/ui-ux-pro-max/scripts/core.py +258 -0
- package/template/.agent/.shared/ui-ux-pro-max/scripts/design_system.py +1067 -0
- package/template/.agent/.shared/ui-ux-pro-max/scripts/search.py +106 -0
- package/template/.agent/ARCHITECTURE.md +281 -0
- package/template/.agent/agents/backend-specialist.md +263 -0
- package/template/.agent/agents/code-archaeologist.md +106 -0
- package/template/.agent/agents/database-architect.md +226 -0
- package/template/.agent/agents/debugger.md +225 -0
- package/template/.agent/agents/devops-engineer.md +242 -0
- package/template/.agent/agents/documentation-writer.md +104 -0
- package/template/.agent/agents/explorer-agent.md +73 -0
- package/template/.agent/agents/frontend-specialist.md +593 -0
- package/template/.agent/agents/game-developer.md +162 -0
- package/template/.agent/agents/mobile-developer.md +377 -0
- package/template/.agent/agents/orchestrator.md +416 -0
- package/template/.agent/agents/penetration-tester.md +188 -0
- package/template/.agent/agents/performance-optimizer.md +187 -0
- package/template/.agent/agents/product-manager.md +112 -0
- package/template/.agent/agents/product-owner.md +95 -0
- package/template/.agent/agents/project-planner.md +406 -0
- package/template/.agent/agents/qa-automation-engineer.md +103 -0
- package/template/.agent/agents/security-auditor.md +170 -0
- package/template/.agent/agents/seo-specialist.md +111 -0
- package/template/.agent/agents/test-engineer.md +158 -0
- package/template/.agent/mcp_config.json +24 -0
- package/template/.agent/rules/GEMINI.md +273 -0
- package/template/.agent/scripts/auto_preview.py +148 -0
- package/template/.agent/scripts/checklist.py +217 -0
- package/template/.agent/scripts/session_manager.py +120 -0
- package/template/.agent/scripts/verify_all.py +327 -0
- package/template/.agent/skills/adr/SKILL.md +282 -0
- package/template/.agent/skills/alirezarezvani-code-to-prd/SKILL.md +499 -0
- package/template/.agent/skills/api-patterns/SKILL.md +81 -0
- package/template/.agent/skills/api-patterns/api-style.md +42 -0
- package/template/.agent/skills/api-patterns/auth.md +24 -0
- package/template/.agent/skills/api-patterns/documentation.md +26 -0
- package/template/.agent/skills/api-patterns/graphql.md +41 -0
- package/template/.agent/skills/api-patterns/rate-limiting.md +31 -0
- package/template/.agent/skills/api-patterns/response.md +37 -0
- package/template/.agent/skills/api-patterns/rest.md +40 -0
- package/template/.agent/skills/api-patterns/scripts/api_validator.py +211 -0
- package/template/.agent/skills/api-patterns/security-testing.md +122 -0
- package/template/.agent/skills/api-patterns/trpc.md +41 -0
- package/template/.agent/skills/api-patterns/versioning.md +22 -0
- package/template/.agent/skills/app-builder/SKILL.md +75 -0
- package/template/.agent/skills/app-builder/agent-coordination.md +71 -0
- package/template/.agent/skills/app-builder/feature-building.md +53 -0
- package/template/.agent/skills/app-builder/project-detection.md +34 -0
- package/template/.agent/skills/app-builder/scaffolding.md +118 -0
- package/template/.agent/skills/app-builder/tech-stack.md +41 -0
- package/template/.agent/skills/app-builder/templates/SKILL.md +39 -0
- package/template/.agent/skills/app-builder/templates/astro-static/TEMPLATE.md +76 -0
- package/template/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +92 -0
- package/template/.agent/skills/app-builder/templates/cli-tool/TEMPLATE.md +88 -0
- package/template/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +88 -0
- package/template/.agent/skills/app-builder/templates/express-api/TEMPLATE.md +83 -0
- package/template/.agent/skills/app-builder/templates/flutter-app/TEMPLATE.md +90 -0
- package/template/.agent/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +90 -0
- package/template/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +122 -0
- package/template/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +122 -0
- package/template/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +169 -0
- package/template/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +134 -0
- package/template/.agent/skills/app-builder/templates/python-fastapi/TEMPLATE.md +83 -0
- package/template/.agent/skills/app-builder/templates/react-native-app/TEMPLATE.md +119 -0
- package/template/.agent/skills/architecture/SKILL.md +55 -0
- package/template/.agent/skills/architecture/context-discovery.md +43 -0
- package/template/.agent/skills/architecture/examples.md +94 -0
- package/template/.agent/skills/architecture/pattern-selection.md +68 -0
- package/template/.agent/skills/architecture/patterns-reference.md +50 -0
- package/template/.agent/skills/architecture/trade-off-analysis.md +77 -0
- package/template/.agent/skills/bash-linux/SKILL.md +199 -0
- package/template/.agent/skills/behavioral-modes/SKILL.md +242 -0
- package/template/.agent/skills/brainstorming/SKILL.md +163 -0
- package/template/.agent/skills/brainstorming/dynamic-questioning.md +350 -0
- package/template/.agent/skills/claudekit-ai-multimodal/SKILL.md +353 -0
- package/template/.agent/skills/clean-code/SKILL.md +201 -0
- package/template/.agent/skills/code-review-checklist/SKILL.md +109 -0
- package/template/.agent/skills/database-design/SKILL.md +52 -0
- package/template/.agent/skills/database-design/database-selection.md +43 -0
- package/template/.agent/skills/database-design/indexing.md +39 -0
- package/template/.agent/skills/database-design/migrations.md +48 -0
- package/template/.agent/skills/database-design/optimization.md +36 -0
- package/template/.agent/skills/database-design/orm-selection.md +30 -0
- package/template/.agent/skills/database-design/schema-design.md +56 -0
- package/template/.agent/skills/database-design/scripts/schema_validator.py +172 -0
- package/template/.agent/skills/deployment-procedures/SKILL.md +241 -0
- package/template/.agent/skills/doc.md +177 -0
- package/template/.agent/skills/document/SKILL.md +250 -0
- package/template/.agent/skills/documentation-templates/SKILL.md +194 -0
- package/template/.agent/skills/frontend-design/SKILL.md +452 -0
- package/template/.agent/skills/frontend-design/animation-guide.md +331 -0
- package/template/.agent/skills/frontend-design/color-system.md +311 -0
- package/template/.agent/skills/frontend-design/decision-trees.md +418 -0
- package/template/.agent/skills/frontend-design/motion-graphics.md +306 -0
- package/template/.agent/skills/frontend-design/scripts/accessibility_checker.py +183 -0
- package/template/.agent/skills/frontend-design/scripts/ux_audit.py +722 -0
- package/template/.agent/skills/frontend-design/typography-system.md +345 -0
- package/template/.agent/skills/frontend-design/ux-psychology.md +1116 -0
- package/template/.agent/skills/frontend-design/visual-effects.md +383 -0
- package/template/.agent/skills/game-development/2d-games/SKILL.md +119 -0
- package/template/.agent/skills/game-development/3d-games/SKILL.md +135 -0
- package/template/.agent/skills/game-development/SKILL.md +167 -0
- package/template/.agent/skills/game-development/game-art/SKILL.md +185 -0
- package/template/.agent/skills/game-development/game-audio/SKILL.md +190 -0
- package/template/.agent/skills/game-development/game-design/SKILL.md +129 -0
- package/template/.agent/skills/game-development/mobile-games/SKILL.md +108 -0
- package/template/.agent/skills/game-development/multiplayer/SKILL.md +132 -0
- package/template/.agent/skills/game-development/pc-games/SKILL.md +144 -0
- package/template/.agent/skills/game-development/vr-ar/SKILL.md +123 -0
- package/template/.agent/skills/game-development/web-games/SKILL.md +150 -0
- package/template/.agent/skills/geo-fundamentals/SKILL.md +156 -0
- package/template/.agent/skills/geo-fundamentals/scripts/geo_checker.py +289 -0
- package/template/.agent/skills/i18n-localization/SKILL.md +154 -0
- package/template/.agent/skills/i18n-localization/scripts/i18n_checker.py +241 -0
- package/template/.agent/skills/intelligent-routing/SKILL.md +335 -0
- package/template/.agent/skills/lint-and-validate/SKILL.md +45 -0
- package/template/.agent/skills/lint-and-validate/scripts/lint_runner.py +184 -0
- package/template/.agent/skills/lint-and-validate/scripts/type_coverage.py +173 -0
- package/template/.agent/skills/mcp-builder/SKILL.md +176 -0
- package/template/.agent/skills/mindrally-meta-prompt/SKILL.md +129 -0
- package/template/.agent/skills/mobile-design/SKILL.md +394 -0
- package/template/.agent/skills/mobile-design/decision-trees.md +516 -0
- package/template/.agent/skills/mobile-design/mobile-backend.md +491 -0
- package/template/.agent/skills/mobile-design/mobile-color-system.md +420 -0
- package/template/.agent/skills/mobile-design/mobile-debugging.md +122 -0
- package/template/.agent/skills/mobile-design/mobile-design-thinking.md +357 -0
- package/template/.agent/skills/mobile-design/mobile-navigation.md +458 -0
- package/template/.agent/skills/mobile-design/mobile-performance.md +767 -0
- package/template/.agent/skills/mobile-design/mobile-testing.md +356 -0
- package/template/.agent/skills/mobile-design/mobile-typography.md +433 -0
- package/template/.agent/skills/mobile-design/platform-android.md +666 -0
- package/template/.agent/skills/mobile-design/platform-ios.md +561 -0
- package/template/.agent/skills/mobile-design/scripts/mobile_audit.py +670 -0
- package/template/.agent/skills/mobile-design/touch-psychology.md +537 -0
- package/template/.agent/skills/nextjs-react-expert/1-async-eliminating-waterfalls.md +351 -0
- package/template/.agent/skills/nextjs-react-expert/2-bundle-bundle-size-optimization.md +240 -0
- package/template/.agent/skills/nextjs-react-expert/3-server-server-side-performance.md +490 -0
- package/template/.agent/skills/nextjs-react-expert/4-client-client-side-data-fetching.md +264 -0
- package/template/.agent/skills/nextjs-react-expert/5-rerender-re-render-optimization.md +581 -0
- package/template/.agent/skills/nextjs-react-expert/6-rendering-rendering-performance.md +432 -0
- package/template/.agent/skills/nextjs-react-expert/7-js-javascript-performance.md +684 -0
- package/template/.agent/skills/nextjs-react-expert/8-advanced-advanced-patterns.md +150 -0
- package/template/.agent/skills/nextjs-react-expert/9-cache-components.md +103 -0
- package/template/.agent/skills/nextjs-react-expert/SKILL.md +293 -0
- package/template/.agent/skills/nextjs-react-expert/scripts/convert_rules.py +222 -0
- package/template/.agent/skills/nextjs-react-expert/scripts/react_performance_checker.py +252 -0
- package/template/.agent/skills/nodejs-best-practices/SKILL.md +333 -0
- package/template/.agent/skills/parallel-agents/SKILL.md +175 -0
- package/template/.agent/skills/performance-profiling/SKILL.md +143 -0
- package/template/.agent/skills/performance-profiling/scripts/lighthouse_audit.py +76 -0
- package/template/.agent/skills/plan-writing/SKILL.md +152 -0
- package/template/.agent/skills/pm-skills-create-prd/SKILL.md +88 -0
- package/template/.agent/skills/powershell-windows/SKILL.md +167 -0
- package/template/.agent/skills/prompt-engineering/SKILL.md +566 -0
- package/template/.agent/skills/python-patterns/SKILL.md +441 -0
- package/template/.agent/skills/red-team-tactics/SKILL.md +199 -0
- package/template/.agent/skills/rust-pro/SKILL.md +176 -0
- package/template/.agent/skills/seo-fundamentals/SKILL.md +129 -0
- package/template/.agent/skills/seo-fundamentals/scripts/seo_checker.py +219 -0
- package/template/.agent/skills/server-management/SKILL.md +161 -0
- package/template/.agent/skills/skills/adr/SKILL.md +282 -0
- package/template/.agent/skills/skills/alirezarezvani-code-to-prd/SKILL.md +499 -0
- package/template/.agent/skills/skills/claudekit-ai-multimodal/SKILL.md +353 -0
- package/template/.agent/skills/skills/document/SKILL.md +250 -0
- package/template/.agent/skills/skills/mindrally-meta-prompt/SKILL.md +129 -0
- package/template/.agent/skills/skills/pm-skills-create-prd/SKILL.md +88 -0
- package/template/.agent/skills/skills/prompt-engineering/SKILL.md +566 -0
- package/template/.agent/skills/systematic-debugging/SKILL.md +109 -0
- package/template/.agent/skills/tailwind-patterns/SKILL.md +269 -0
- package/template/.agent/skills/tdd-workflow/SKILL.md +149 -0
- package/template/.agent/skills/testing-patterns/SKILL.md +178 -0
- package/template/.agent/skills/testing-patterns/scripts/test_runner.py +219 -0
- package/template/.agent/skills/vulnerability-scanner/SKILL.md +276 -0
- package/template/.agent/skills/vulnerability-scanner/checklists.md +121 -0
- package/template/.agent/skills/vulnerability-scanner/scripts/security_scan.py +458 -0
- package/template/.agent/skills/web-design-guidelines/SKILL.md +57 -0
- package/template/.agent/skills/webapp-testing/SKILL.md +187 -0
- package/template/.agent/skills/webapp-testing/scripts/playwright_runner.py +173 -0
- package/template/.agent/skills/zalo-mini-app/SKILL.md +81 -0
- package/template/.agent/skills/zalo-mini-app/references/api-device.md +121 -0
- package/template/.agent/skills/zalo-mini-app/references/api-overview.md +88 -0
- package/template/.agent/skills/zalo-mini-app/references/api-storage.md +74 -0
- package/template/.agent/skills/zalo-mini-app/references/api-ui.md +124 -0
- package/template/.agent/skills/zalo-mini-app/references/api-user.md +113 -0
- package/template/.agent/skills/zalo-mini-app/references/api-zalo.md +127 -0
- package/template/.agent/skills/zalo-mini-app/references/design-guidelines.md +70 -0
- package/template/.agent/skills/zalo-mini-app/references/getting-started.md +95 -0
- package/template/.agent/skills/zalo-mini-app/references/react-best-practices.md +790 -0
- package/template/.agent/skills/zalo-mini-app/references/web-design-guidelines.md +591 -0
- package/template/.agent/skills/zalo-mini-app/references/zaui-display.md +103 -0
- package/template/.agent/skills/zalo-mini-app/references/zaui-form.md +108 -0
- package/template/.agent/skills/zalo-mini-app/references/zaui-layout.md +94 -0
- package/template/.agent/skills/zalo-mini-app/references/zaui-overlay.md +98 -0
- package/template/.agent/skills/zalo-mini-app/references/zaui-overview.md +82 -0
- package/template/.agent/workflows/brainstorm.md +113 -0
- package/template/.agent/workflows/create.md +59 -0
- package/template/.agent/workflows/debug.md +103 -0
- package/template/.agent/workflows/deploy.md +176 -0
- package/template/.agent/workflows/enhance.md +63 -0
- package/template/.agent/workflows/orchestrate.md +237 -0
- package/template/.agent/workflows/plan.md +89 -0
- package/template/.agent/workflows/preview.md +81 -0
- package/template/.agent/workflows/status.md +86 -0
- package/template/.agent/workflows/test.md +144 -0
- package/template/.agent/workflows/ui-ux-pro-max.md +296 -0
- package/template/.agent/workflows/veo-marketing.md +46 -0
|
@@ -0,0 +1,499 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: "code-to-prd"
|
|
3
|
+
description: "Reverse-engineer any codebase into a complete Product Requirements Document (PRD).
|
|
4
|
+
Analyzes routes, components, state management, API integrations, and user interactions to produce
|
|
5
|
+
business-readable documentation detailed enough for engineers or AI agents to fully reconstruct
|
|
6
|
+
every page and endpoint. Works with frontend frameworks (React, Vue, Angular, Svelte, Next.js, Nuxt),
|
|
7
|
+
backend frameworks (NestJS, Django, Express, FastAPI), and fullstack applications.
|
|
8
|
+
|
|
9
|
+
Trigger when users mention: generate PRD, reverse-engineer requirements, code to documentation,
|
|
10
|
+
extract product specs from code, document page logic, analyze page fields and interactions,
|
|
11
|
+
create a functional inventory, write requirements from an existing codebase, document API endpoints,
|
|
12
|
+
or analyze backend routes."
|
|
13
|
+
version: 1.0.0
|
|
14
|
+
category: build
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Name
|
|
18
|
+
|
|
19
|
+
Code → PRD
|
|
20
|
+
|
|
21
|
+
## Description
|
|
22
|
+
|
|
23
|
+
Reverse-engineer any frontend, backend, or fullstack codebase into a complete Product Requirements Document (PRD). Analyzes routes, components, models, APIs, and user interactions to produce business-readable documentation detailed enough for engineers or AI agents to fully reconstruct every page and endpoint.
|
|
24
|
+
|
|
25
|
+
# Code → PRD: Reverse-Engineer Any Codebase into Product Requirements
|
|
26
|
+
|
|
27
|
+
## Features
|
|
28
|
+
|
|
29
|
+
- **3-phase workflow**: global scan → page-by-page analysis → structured document generation
|
|
30
|
+
- **Frontend support**: React, Vue, Angular, Svelte, Next.js (App + Pages Router), Nuxt, SvelteKit, Remix
|
|
31
|
+
- **Backend support**: NestJS, Express, Django, Django REST Framework, FastAPI, Flask
|
|
32
|
+
- **Fullstack support**: Combined frontend + backend analysis with unified PRD output
|
|
33
|
+
- **Mock detection**: Automatically distinguishes real API integrations from mock/fixture data
|
|
34
|
+
- **Enum extraction**: Exhaustively lists all status codes, type mappings, and constants
|
|
35
|
+
- **Model extraction**: Parses Django models, NestJS entities, Pydantic schemas
|
|
36
|
+
- **Automation scripts**: `codebase_analyzer.py` for scanning, `prd_scaffolder.py` for directory generation
|
|
37
|
+
- **Quality checklist**: Validation checklist for completeness, accuracy, readability
|
|
38
|
+
|
|
39
|
+
## Usage
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# Analyze a project and generate PRD skeleton
|
|
43
|
+
python3 scripts/codebase_analyzer.py /path/to/project -o analysis.json
|
|
44
|
+
python3 scripts/prd_scaffolder.py analysis.json -o prd/ -n "My App"
|
|
45
|
+
|
|
46
|
+
# Or use the slash command
|
|
47
|
+
/code-to-prd /path/to/project
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Examples
|
|
51
|
+
|
|
52
|
+
### Frontend (React)
|
|
53
|
+
```bash
|
|
54
|
+
/code-to-prd ./src
|
|
55
|
+
# → Scans components, routes, API calls, state management
|
|
56
|
+
# → Generates prd/ with per-page docs, enum dictionary, API inventory
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Backend (Django)
|
|
60
|
+
```bash
|
|
61
|
+
/code-to-prd ./myproject
|
|
62
|
+
# → Detects Django via manage.py, scans urls.py, views.py, models.py
|
|
63
|
+
# → Documents endpoints, model schemas, admin config, permissions
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Fullstack (Next.js)
|
|
67
|
+
```bash
|
|
68
|
+
/code-to-prd .
|
|
69
|
+
# → Analyzes both app/ pages and api/ routes
|
|
70
|
+
# → Generates unified PRD covering UI pages and API endpoints
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Role
|
|
76
|
+
|
|
77
|
+
You are a senior product analyst and technical architect. Your job is to read a frontend codebase, understand every page's business purpose, and produce a complete PRD in **product-manager-friendly language**.
|
|
78
|
+
|
|
79
|
+
### Dual Audience
|
|
80
|
+
|
|
81
|
+
1. **Product managers / business stakeholders** — need to understand *what* the system does, not *how*
|
|
82
|
+
2. **Engineers / AI agents** — need enough detail to **fully reconstruct** every page's fields, interactions, and relationships
|
|
83
|
+
|
|
84
|
+
Your document must describe functionality in non-technical language while omitting zero business details.
|
|
85
|
+
|
|
86
|
+
### Supported Stacks
|
|
87
|
+
|
|
88
|
+
| Stack | Frameworks |
|
|
89
|
+
|-------|-----------|
|
|
90
|
+
| **Frontend** | React, Vue, Angular, Svelte, Next.js (App/Pages Router), Nuxt, SvelteKit, Remix, Astro |
|
|
91
|
+
| **Backend** | NestJS, Express, Fastify, Django, Django REST Framework, FastAPI, Flask |
|
|
92
|
+
| **Fullstack** | Next.js (API routes + pages), Nuxt (server/ + pages/), Django (views + templates) |
|
|
93
|
+
|
|
94
|
+
For **backend-only** projects, the "page" concept maps to **API resource groups** or **admin views**. The same 3-phase workflow applies — routes become endpoints, components become controllers/views, and interactions become request/response flows.
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## Workflow
|
|
99
|
+
|
|
100
|
+
### Phase 1 — Project Global Scan
|
|
101
|
+
|
|
102
|
+
Build global context before diving into pages.
|
|
103
|
+
|
|
104
|
+
#### 1. Identify Project Structure
|
|
105
|
+
|
|
106
|
+
Scan the root directory and understand organization:
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
Frontend directories:
|
|
110
|
+
- Pages/routes (pages/, views/, routes/, app/, src/pages/)
|
|
111
|
+
- Components (components/, modules/)
|
|
112
|
+
- Route config (router.ts, routes.ts, App.tsx route definitions)
|
|
113
|
+
- API/service layer (services/, api/, requests/)
|
|
114
|
+
- State management (store/, models/, context/)
|
|
115
|
+
- i18n files (locales/, i18n/) — field display names often live here
|
|
116
|
+
|
|
117
|
+
Backend directories (NestJS):
|
|
118
|
+
- Modules (src/modules/, src/*.module.ts)
|
|
119
|
+
- Controllers (*.controller.ts) — route handlers
|
|
120
|
+
- Services (*.service.ts) — business logic
|
|
121
|
+
- DTOs (dto/, *.dto.ts) — request/response shapes
|
|
122
|
+
- Entities (entities/, *.entity.ts) — database models
|
|
123
|
+
- Guards/pipes/interceptors — auth, validation, transformation
|
|
124
|
+
|
|
125
|
+
Backend directories (Django):
|
|
126
|
+
- Apps (*/apps.py, */views.py, */models.py, */urls.py)
|
|
127
|
+
- URL config (urls.py, */urls.py)
|
|
128
|
+
- Views (views.py, viewsets.py) — route handlers
|
|
129
|
+
- Models (models.py) — database schema
|
|
130
|
+
- Serializers (serializers.py) — request/response shapes
|
|
131
|
+
- Forms (forms.py) — validation and field definitions
|
|
132
|
+
- Templates (templates/) — server-rendered pages
|
|
133
|
+
- Admin (admin.py) — admin panel configuration
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
**Identify framework** from `package.json` (Node.js frameworks) or project files (`manage.py` for Django, `requirements.txt`/`pyproject.toml` for Python). Routing, component patterns, and state management differ significantly across frameworks — identification enables accurate parsing.
|
|
137
|
+
|
|
138
|
+
#### 2. Build Route & Page Inventory
|
|
139
|
+
|
|
140
|
+
Extract all pages from route config into a complete **page inventory**:
|
|
141
|
+
|
|
142
|
+
| Field | Description |
|
|
143
|
+
|-------|-------------|
|
|
144
|
+
| Route path | e.g. `/user/list`, `/order/:id` |
|
|
145
|
+
| Page title | From route config, breadcrumbs, or page component |
|
|
146
|
+
| Module / menu level | Where it sits in navigation |
|
|
147
|
+
| Component file path | Source file(s) implementing this page |
|
|
148
|
+
|
|
149
|
+
For file-system routing (Next.js, Nuxt), infer from directory structure.
|
|
150
|
+
|
|
151
|
+
**For backend projects**, the page inventory becomes an **endpoint/resource inventory**:
|
|
152
|
+
|
|
153
|
+
| Field | Description |
|
|
154
|
+
|-------|-------------|
|
|
155
|
+
| Endpoint path | e.g. `/api/users`, `/api/orders/:id` |
|
|
156
|
+
| HTTP method | GET, POST, PUT, DELETE, PATCH |
|
|
157
|
+
| Controller/view | Source file handling this route |
|
|
158
|
+
| Module/app | Which NestJS module or Django app owns it |
|
|
159
|
+
| Auth required | Whether authentication/permissions are needed |
|
|
160
|
+
|
|
161
|
+
For NestJS: extract from `@Controller` + `@Get/@Post/@Put/@Delete` decorators.
|
|
162
|
+
For Django: extract from `urls.py` → `urlpatterns` and `viewsets.py` → router registrations.
|
|
163
|
+
|
|
164
|
+
#### 3. Map Global Context
|
|
165
|
+
|
|
166
|
+
Before analyzing individual pages, capture:
|
|
167
|
+
|
|
168
|
+
- **Global state** — user info, permissions, feature flags, config
|
|
169
|
+
- **Shared components** — layout, nav, auth guards, error boundaries
|
|
170
|
+
- **Enums & constants** — status codes, type mappings, role definitions
|
|
171
|
+
- **API base config** — base URL, interceptors, auth headers, error handling
|
|
172
|
+
- **Database models** (backend) — entity relationships, field types, constraints
|
|
173
|
+
- **Middleware** (backend) — auth middleware, rate limiting, logging, CORS
|
|
174
|
+
- **DTOs/Serializers** (backend) — request validation shapes, response formats
|
|
175
|
+
|
|
176
|
+
These will be referenced throughout page/endpoint analysis.
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
### Phase 2 — Page-by-Page Deep Analysis
|
|
181
|
+
|
|
182
|
+
Analyze every page in the inventory. **Each page produces its own Markdown file.**
|
|
183
|
+
|
|
184
|
+
#### Analysis Dimensions
|
|
185
|
+
|
|
186
|
+
For each page, answer:
|
|
187
|
+
|
|
188
|
+
##### A. Page Overview
|
|
189
|
+
- What does this page do? (one sentence)
|
|
190
|
+
- Where does it fit in the system?
|
|
191
|
+
- What scenario brings a user here?
|
|
192
|
+
|
|
193
|
+
##### B. Layout & Regions
|
|
194
|
+
- Major regions: search area, table, detail panel, action bar, tabs, etc.
|
|
195
|
+
- Spatial arrangement: top/bottom, left/right, nested
|
|
196
|
+
|
|
197
|
+
##### C. Field Inventory (core — be exhaustive)
|
|
198
|
+
|
|
199
|
+
**For form pages**, list every field:
|
|
200
|
+
|
|
201
|
+
| Field Name | Type | Required | Default | Validation | Business Description |
|
|
202
|
+
|-----------|------|----------|---------|------------|---------------------|
|
|
203
|
+
| Username | Text input | Yes | — | Max 20 chars | System login account |
|
|
204
|
+
|
|
205
|
+
**For table/list pages**, list:
|
|
206
|
+
- Search/filter fields (type, required, enum options)
|
|
207
|
+
- Table columns (name, format, sortable, filterable)
|
|
208
|
+
- Row action buttons (what each one does)
|
|
209
|
+
|
|
210
|
+
**Field name extraction priority:**
|
|
211
|
+
1. Hardcoded display text in code
|
|
212
|
+
2. i18n translation values
|
|
213
|
+
3. Component `placeholder` / `label` / `title` props
|
|
214
|
+
4. Variable names (last resort — provide reasonable display name)
|
|
215
|
+
|
|
216
|
+
##### D. Interaction Logic
|
|
217
|
+
|
|
218
|
+
Describe as **"user action → system response"**:
|
|
219
|
+
|
|
220
|
+
```
|
|
221
|
+
[Action] User clicks "Create"
|
|
222
|
+
[Response] Modal opens with form fields: ...
|
|
223
|
+
[Validation] Name required, phone format check
|
|
224
|
+
[API] POST /api/user/create with form data
|
|
225
|
+
[Success] Toast "Created successfully", close modal, refresh list
|
|
226
|
+
[Failure] Show API error message
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
**Cover all interaction types:**
|
|
230
|
+
- Page load / initialization (default queries, preloaded data)
|
|
231
|
+
- Search / filter / reset
|
|
232
|
+
- CRUD operations (create, read, update, delete)
|
|
233
|
+
- Table: pagination, sorting, row selection, bulk actions
|
|
234
|
+
- Form submission & validation
|
|
235
|
+
- Status transitions (e.g. approval flows: pending → approved → rejected)
|
|
236
|
+
- Import / export
|
|
237
|
+
- Field interdependencies (selecting value A changes options in field B)
|
|
238
|
+
- Permission controls (buttons/fields visible only to certain roles)
|
|
239
|
+
- Polling / auto-refresh / real-time updates
|
|
240
|
+
|
|
241
|
+
##### E. API Dependencies
|
|
242
|
+
|
|
243
|
+
**Case 1: API is integrated** (real HTTP calls in code)
|
|
244
|
+
|
|
245
|
+
| API Name | Method | Path | Trigger | Key Params | Notes |
|
|
246
|
+
|----------|--------|------|---------|-----------|-------|
|
|
247
|
+
| Get users | GET | /api/user/list | Load, search | page, size, keyword | Paginated |
|
|
248
|
+
|
|
249
|
+
**Case 2: API not integrated** (mock/hardcoded data)
|
|
250
|
+
|
|
251
|
+
When the page uses mock data, hardcoded fixtures, `setTimeout` simulations, or `Promise.resolve()` stubs — the API isn't real yet. **Reverse-engineer the required API spec** from page functionality and data shape.
|
|
252
|
+
|
|
253
|
+
For each needed API, document:
|
|
254
|
+
- Method, suggested path, trigger
|
|
255
|
+
- Input params (name, type, required, description)
|
|
256
|
+
- Output fields (name, type, description)
|
|
257
|
+
- Core business logic description
|
|
258
|
+
|
|
259
|
+
**Detection signals:**
|
|
260
|
+
- `setTimeout` / `Promise.resolve()` returning data → mock
|
|
261
|
+
- Data defined in component or `*.mock.*` files → mock
|
|
262
|
+
- Real HTTP calls (`axios`, `fetch`, service layer) with real paths → integrated
|
|
263
|
+
- `__mocks__` directory → mock
|
|
264
|
+
|
|
265
|
+
##### F. Page Relationships
|
|
266
|
+
|
|
267
|
+
- **Inbound**: Which pages link here? What parameters do they pass?
|
|
268
|
+
- **Outbound**: Where can users navigate from here? What parameters?
|
|
269
|
+
- **Data coupling**: Which pages share data or trigger refreshes in each other?
|
|
270
|
+
|
|
271
|
+
---
|
|
272
|
+
|
|
273
|
+
### Phase 3 — Generate Documentation
|
|
274
|
+
|
|
275
|
+
#### Output Structure
|
|
276
|
+
|
|
277
|
+
Create `prd/` in project root (or user-specified directory):
|
|
278
|
+
|
|
279
|
+
```
|
|
280
|
+
prd/
|
|
281
|
+
├── README.md # System overview
|
|
282
|
+
├── pages/
|
|
283
|
+
│ ├── 01-user-mgmt-list.md # One file per page
|
|
284
|
+
│ ├── 02-user-mgmt-detail.md
|
|
285
|
+
│ ├── 03-order-mgmt-list.md
|
|
286
|
+
│ └── ...
|
|
287
|
+
└── appendix/
|
|
288
|
+
├── enum-dictionary.md # All enums, status codes, type mappings
|
|
289
|
+
├── page-relationships.md # Navigation map between pages
|
|
290
|
+
└── api-inventory.md # Complete API reference
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
#### README.md Template
|
|
294
|
+
|
|
295
|
+
```markdown
|
|
296
|
+
# [System Name] — Product Requirements Document
|
|
297
|
+
|
|
298
|
+
## System Overview
|
|
299
|
+
[2-3 paragraphs: what the system does, business context, primary users]
|
|
300
|
+
|
|
301
|
+
## Module Overview
|
|
302
|
+
|
|
303
|
+
| Module | Pages | Core Functionality |
|
|
304
|
+
|--------|-------|--------------------|
|
|
305
|
+
| User Management | User list, User detail, Role mgmt | CRUD users, assign roles and permissions |
|
|
306
|
+
|
|
307
|
+
## Page Inventory
|
|
308
|
+
|
|
309
|
+
| # | Page Name | Route | Module | Doc Link |
|
|
310
|
+
|---|-----------|-------|--------|----------|
|
|
311
|
+
| 1 | User List | /user/list | User Mgmt | [→](./pages/01-user-mgmt-list.md) |
|
|
312
|
+
|
|
313
|
+
## Global Notes
|
|
314
|
+
|
|
315
|
+
### Permission Model
|
|
316
|
+
[Summarize auth/role system if present in code]
|
|
317
|
+
|
|
318
|
+
### Common Interaction Patterns
|
|
319
|
+
[Global rules: all deletes require confirmation, lists default to created_at desc, etc.]
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
#### Per-Page Document Template
|
|
323
|
+
|
|
324
|
+
```markdown
|
|
325
|
+
# [Page Name]
|
|
326
|
+
|
|
327
|
+
> **Route:** `/xxx/xxx`
|
|
328
|
+
> **Module:** [Module name]
|
|
329
|
+
> **Generated:** [Date]
|
|
330
|
+
|
|
331
|
+
## Overview
|
|
332
|
+
[2-3 sentences: core function and use case]
|
|
333
|
+
|
|
334
|
+
## Layout
|
|
335
|
+
[Region breakdown — text description or ASCII diagram]
|
|
336
|
+
|
|
337
|
+
## Fields
|
|
338
|
+
|
|
339
|
+
### [Region: e.g. "Search Filters"]
|
|
340
|
+
| Field | Type | Required | Options / Enum | Default | Notes |
|
|
341
|
+
|-------|------|----------|---------------|---------|-------|
|
|
342
|
+
|
|
343
|
+
### [Region: e.g. "Data Table"]
|
|
344
|
+
| Column | Format | Sortable | Filterable | Notes |
|
|
345
|
+
|--------|--------|----------|-----------|-------|
|
|
346
|
+
|
|
347
|
+
### [Region: e.g. "Actions"]
|
|
348
|
+
| Button | Visibility Condition | Behavior |
|
|
349
|
+
|--------|---------------------|----------|
|
|
350
|
+
|
|
351
|
+
## Interactions
|
|
352
|
+
|
|
353
|
+
### Page Load
|
|
354
|
+
[What happens on mount]
|
|
355
|
+
|
|
356
|
+
### [Scenario: e.g. "Search"]
|
|
357
|
+
- **Trigger:** [User action]
|
|
358
|
+
- **Behavior:** [System response]
|
|
359
|
+
- **Special rules:** [If any]
|
|
360
|
+
|
|
361
|
+
### [Scenario: e.g. "Create"]
|
|
362
|
+
- **Trigger:** ...
|
|
363
|
+
- **Modal/drawer content:** [Fields and logic inside]
|
|
364
|
+
- **Validation:** ...
|
|
365
|
+
- **On success:** ...
|
|
366
|
+
|
|
367
|
+
## API Dependencies
|
|
368
|
+
|
|
369
|
+
| API | Method | Path | Trigger | Notes |
|
|
370
|
+
|-----|--------|------|---------|-------|
|
|
371
|
+
| ... | ... | ... | ... | ... |
|
|
372
|
+
|
|
373
|
+
## Page Relationships
|
|
374
|
+
- **From:** [Source pages + params]
|
|
375
|
+
- **To:** [Target pages + params]
|
|
376
|
+
- **Data coupling:** [Cross-page refresh triggers]
|
|
377
|
+
|
|
378
|
+
## Business Rules
|
|
379
|
+
[Anything that doesn't fit above]
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
---
|
|
383
|
+
|
|
384
|
+
## Key Principles
|
|
385
|
+
|
|
386
|
+
### 1. Business Language First
|
|
387
|
+
Don't write "calls `useState` to manage loading state." Write "search button shows a spinner to prevent duplicate submissions."
|
|
388
|
+
|
|
389
|
+
Don't write "useEffect fetches on mount." Write "page automatically loads the first page of results on open."
|
|
390
|
+
|
|
391
|
+
Include technical details only when they **directly affect product behavior**: API paths (engineers need them), validation rules (affect UX), permission conditions (affect visibility).
|
|
392
|
+
|
|
393
|
+
### 2. Don't Miss Hidden Logic
|
|
394
|
+
Code contains logic PMs may not realize exists:
|
|
395
|
+
- Field interdependencies (type A shows field X; type B shows field Y)
|
|
396
|
+
- Conditional button visibility
|
|
397
|
+
- Data formatting (currency with 2 decimals, date formats, status label mappings)
|
|
398
|
+
- Default sort order and page size
|
|
399
|
+
- Debounce/throttle effects on user input
|
|
400
|
+
- Polling / auto-refresh intervals
|
|
401
|
+
|
|
402
|
+
### 3. Exhaustively List Enums
|
|
403
|
+
When code defines enums (status codes, type codes, role types), list **every value and its meaning**. These are often scattered across constants files, component `valueEnum` configs, or API response mappers.
|
|
404
|
+
|
|
405
|
+
### 4. Mark Uncertainty — Don't Guess
|
|
406
|
+
If a field or logic's business meaning can't be determined from code (e.g. abbreviated variable names, overly complex conditionals), mark it `[TBC]` and explain what you observed and why you're uncertain. Never fabricate business meaning.
|
|
407
|
+
|
|
408
|
+
### 5. Keep Page Files Self-Contained
|
|
409
|
+
Each page's Markdown should be **standalone** — reading just that file gives complete understanding. Use relative links when referencing other pages or appendix entries.
|
|
410
|
+
|
|
411
|
+
---
|
|
412
|
+
|
|
413
|
+
## Page Type Strategies
|
|
414
|
+
|
|
415
|
+
### Frontend Pages
|
|
416
|
+
|
|
417
|
+
| Page Type | Focus Areas |
|
|
418
|
+
|-----------|------------|
|
|
419
|
+
| **List / Table** | Search conditions, columns, row actions, pagination, bulk ops |
|
|
420
|
+
| **Form / Create-Edit** | Every field, validation, interdependencies, post-submit behavior |
|
|
421
|
+
| **Detail / View** | Displayed info, tab/section organization, available actions |
|
|
422
|
+
| **Modal / Drawer** | Describe as part of triggering page — not a separate file. But fully document content |
|
|
423
|
+
| **Dashboard** | Data cards, charts, metrics meaning, filter dimensions, refresh frequency |
|
|
424
|
+
|
|
425
|
+
### Backend Endpoints (NestJS / Django / Express)
|
|
426
|
+
|
|
427
|
+
| Endpoint Type | Focus Areas |
|
|
428
|
+
|---------------|------------|
|
|
429
|
+
| **CRUD resource** | All fields (from DTO/serializer), validation rules, permissions, pagination, filtering, sorting |
|
|
430
|
+
| **Auth endpoints** | Login/register flow, token format, refresh logic, password reset, OAuth providers |
|
|
431
|
+
| **File upload** | Accepted types, size limits, storage destination, processing pipeline |
|
|
432
|
+
| **Webhook / event** | Trigger conditions, payload shape, retry policy, idempotency |
|
|
433
|
+
| **Background job** | Trigger, schedule, input/output, failure handling, monitoring |
|
|
434
|
+
| **Admin views** (Django) | Registered models, list_display, search_fields, filters, inline models, custom actions |
|
|
435
|
+
|
|
436
|
+
---
|
|
437
|
+
|
|
438
|
+
## Execution Pacing
|
|
439
|
+
|
|
440
|
+
**Large projects (>15 pages):** Work in batches of 3-5 pages per module. Complete system overview + page inventory first. Output each batch for user review before proceeding.
|
|
441
|
+
|
|
442
|
+
**Small projects (≤15 pages):** Complete all analysis in one pass.
|
|
443
|
+
|
|
444
|
+
---
|
|
445
|
+
|
|
446
|
+
## Common Pitfalls
|
|
447
|
+
|
|
448
|
+
| Pitfall | Fix |
|
|
449
|
+
|---------|-----|
|
|
450
|
+
| Using component names as page names | `UserManagementTable` → "User Management List" |
|
|
451
|
+
| Skipping modals and drawers | They contain critical business logic — document fully |
|
|
452
|
+
| Missing i18n field names | Check translation files, not just component JSX |
|
|
453
|
+
| Ignoring dynamic route params | `/order/:id` = page requires an order ID to load |
|
|
454
|
+
| Forgetting permission controls | Document which roles see which buttons/pages |
|
|
455
|
+
| Assuming all APIs are real | Check for mock data patterns before documenting endpoints |
|
|
456
|
+
| Skipping Django admin customization | `admin.py` often contains critical business rules (list filters, custom actions, inlines) |
|
|
457
|
+
| Missing NestJS guards/pipes | `@UseGuards`, `@UsePipes` contain auth and validation logic that affects behavior |
|
|
458
|
+
| Ignoring database constraints | Model field constraints (unique, max_length, choices) are validation rules for the PRD |
|
|
459
|
+
| Overlooking middleware | Auth middleware, rate limiters, and CORS config define system-wide behavior |
|
|
460
|
+
|
|
461
|
+
---
|
|
462
|
+
|
|
463
|
+
## Tooling
|
|
464
|
+
|
|
465
|
+
### Scripts
|
|
466
|
+
|
|
467
|
+
| Script | Purpose | Usage |
|
|
468
|
+
|--------|---------|-------|
|
|
469
|
+
| `scripts/codebase_analyzer.py` | Scan codebase → extract routes, APIs, models, enums, structure | `python3 codebase_analyzer.py /path/to/project` |
|
|
470
|
+
| `scripts/prd_scaffolder.py` | Generate PRD directory skeleton from analysis JSON | `python3 prd_scaffolder.py analysis.json` |
|
|
471
|
+
|
|
472
|
+
**Recommended workflow:**
|
|
473
|
+
```bash
|
|
474
|
+
# 1. Analyze the project (JSON output — works for frontend, backend, or fullstack)
|
|
475
|
+
python3 scripts/codebase_analyzer.py /path/to/project -o analysis.json
|
|
476
|
+
|
|
477
|
+
# 2. Review the analysis (markdown summary)
|
|
478
|
+
python3 scripts/codebase_analyzer.py /path/to/project -f markdown
|
|
479
|
+
|
|
480
|
+
# 3. Scaffold the PRD directory with stubs
|
|
481
|
+
python3 scripts/prd_scaffolder.py analysis.json -o prd/ -n "My App"
|
|
482
|
+
|
|
483
|
+
# 4. Fill in TODO sections page-by-page using the SKILL.md workflow
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
Both scripts are **stdlib-only** — no pip install needed.
|
|
487
|
+
|
|
488
|
+
### References
|
|
489
|
+
|
|
490
|
+
| File | Contents |
|
|
491
|
+
|------|----------|
|
|
492
|
+
| `references/prd-quality-checklist.md` | Validation checklist for completeness, accuracy, readability |
|
|
493
|
+
| `references/framework-patterns.md` | Framework-specific patterns for routes, state, APIs, forms, permissions |
|
|
494
|
+
|
|
495
|
+
---
|
|
496
|
+
|
|
497
|
+
## Attribution
|
|
498
|
+
|
|
499
|
+
This skill was inspired by [code-to-prd](https://github.com/lihanglogan/code-to-prd) by [@lihanglogan](https://github.com/lihanglogan), who proposed the original concept and methodology in [PR #368](https://github.com/alirezarezvani/claude-skills/pull/368). The core three-phase workflow (global scan → page-by-page analysis → structured document generation) originated from that work. This version was rebuilt from scratch in English with added tooling (analysis scripts, scaffolder, framework reference, quality checklist).
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: api-patterns
|
|
3
|
+
description: API design principles and decision-making. REST vs GraphQL vs tRPC selection, response formats, versioning, pagination.
|
|
4
|
+
allowed-tools: Read, Write, Edit, Glob, Grep
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# API Patterns
|
|
8
|
+
|
|
9
|
+
> API design principles and decision-making for 2025.
|
|
10
|
+
> **Learn to THINK, not copy fixed patterns.**
|
|
11
|
+
|
|
12
|
+
## 🎯 Selective Reading Rule
|
|
13
|
+
|
|
14
|
+
**Read ONLY files relevant to the request!** Check the content map, find what you need.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## 📑 Content Map
|
|
19
|
+
|
|
20
|
+
| File | Description | When to Read |
|
|
21
|
+
|------|-------------|--------------|
|
|
22
|
+
| `api-style.md` | REST vs GraphQL vs tRPC decision tree | Choosing API type |
|
|
23
|
+
| `rest.md` | Resource naming, HTTP methods, status codes | Designing REST API |
|
|
24
|
+
| `response.md` | Envelope pattern, error format, pagination | Response structure |
|
|
25
|
+
| `graphql.md` | Schema design, when to use, security | Considering GraphQL |
|
|
26
|
+
| `trpc.md` | TypeScript monorepo, type safety | TS fullstack projects |
|
|
27
|
+
| `versioning.md` | URI/Header/Query versioning | API evolution planning |
|
|
28
|
+
| `auth.md` | JWT, OAuth, Passkey, API Keys | Auth pattern selection |
|
|
29
|
+
| `rate-limiting.md` | Token bucket, sliding window | API protection |
|
|
30
|
+
| `documentation.md` | OpenAPI/Swagger best practices | Documentation |
|
|
31
|
+
| `security-testing.md` | OWASP API Top 10, auth/authz testing | Security audits |
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## 🔗 Related Skills
|
|
36
|
+
|
|
37
|
+
| Need | Skill |
|
|
38
|
+
|------|-------|
|
|
39
|
+
| API implementation | `@[skills/backend-development]` |
|
|
40
|
+
| Data structure | `@[skills/database-design]` |
|
|
41
|
+
| Security details | `@[skills/security-hardening]` |
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## ✅ Decision Checklist
|
|
46
|
+
|
|
47
|
+
Before designing an API:
|
|
48
|
+
|
|
49
|
+
- [ ] **Asked user about API consumers?**
|
|
50
|
+
- [ ] **Chosen API style for THIS context?** (REST/GraphQL/tRPC)
|
|
51
|
+
- [ ] **Defined consistent response format?**
|
|
52
|
+
- [ ] **Planned versioning strategy?**
|
|
53
|
+
- [ ] **Considered authentication needs?**
|
|
54
|
+
- [ ] **Planned rate limiting?**
|
|
55
|
+
- [ ] **Documentation approach defined?**
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## ❌ Anti-Patterns
|
|
60
|
+
|
|
61
|
+
**DON'T:**
|
|
62
|
+
- Default to REST for everything
|
|
63
|
+
- Use verbs in REST endpoints (/getUsers)
|
|
64
|
+
- Return inconsistent response formats
|
|
65
|
+
- Expose internal errors to clients
|
|
66
|
+
- Skip rate limiting
|
|
67
|
+
|
|
68
|
+
**DO:**
|
|
69
|
+
- Choose API style based on context
|
|
70
|
+
- Ask about client requirements
|
|
71
|
+
- Document thoroughly
|
|
72
|
+
- Use appropriate status codes
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Script
|
|
77
|
+
|
|
78
|
+
| Script | Purpose | Command |
|
|
79
|
+
|--------|---------|---------|
|
|
80
|
+
| `scripts/api_validator.py` | API endpoint validation | `python scripts/api_validator.py <project_path>` |
|
|
81
|
+
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# API Style Selection (2025)
|
|
2
|
+
|
|
3
|
+
> REST vs GraphQL vs tRPC - Hangi durumda hangisi?
|
|
4
|
+
|
|
5
|
+
## Decision Tree
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
Who are the API consumers?
|
|
9
|
+
│
|
|
10
|
+
├── Public API / Multiple platforms
|
|
11
|
+
│ └── REST + OpenAPI (widest compatibility)
|
|
12
|
+
│
|
|
13
|
+
├── Complex data needs / Multiple frontends
|
|
14
|
+
│ └── GraphQL (flexible queries)
|
|
15
|
+
│
|
|
16
|
+
├── TypeScript frontend + backend (monorepo)
|
|
17
|
+
│ └── tRPC (end-to-end type safety)
|
|
18
|
+
│
|
|
19
|
+
├── Real-time / Event-driven
|
|
20
|
+
│ └── WebSocket + AsyncAPI
|
|
21
|
+
│
|
|
22
|
+
└── Internal microservices
|
|
23
|
+
└── gRPC (performance) or REST (simplicity)
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Comparison
|
|
27
|
+
|
|
28
|
+
| Factor | REST | GraphQL | tRPC |
|
|
29
|
+
|--------|------|---------|------|
|
|
30
|
+
| **Best for** | Public APIs | Complex apps | TS monorepos |
|
|
31
|
+
| **Learning curve** | Low | Medium | Low (if TS) |
|
|
32
|
+
| **Over/under fetching** | Common | Solved | Solved |
|
|
33
|
+
| **Type safety** | Manual (OpenAPI) | Schema-based | Automatic |
|
|
34
|
+
| **Caching** | HTTP native | Complex | Client-based |
|
|
35
|
+
|
|
36
|
+
## Selection Questions
|
|
37
|
+
|
|
38
|
+
1. Who are the API consumers?
|
|
39
|
+
2. Is the frontend TypeScript?
|
|
40
|
+
3. How complex are the data relationships?
|
|
41
|
+
4. Is caching critical?
|
|
42
|
+
5. Public or internal API?
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Authentication Patterns
|
|
2
|
+
|
|
3
|
+
> Choose auth pattern based on use case.
|
|
4
|
+
|
|
5
|
+
## Selection Guide
|
|
6
|
+
|
|
7
|
+
| Pattern | Best For |
|
|
8
|
+
|---------|----------|
|
|
9
|
+
| **JWT** | Stateless, microservices |
|
|
10
|
+
| **Session** | Traditional web, simple |
|
|
11
|
+
| **OAuth 2.0** | Third-party integration |
|
|
12
|
+
| **API Keys** | Server-to-server, public APIs |
|
|
13
|
+
| **Passkey** | Modern passwordless (2025+) |
|
|
14
|
+
|
|
15
|
+
## JWT Principles
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
Important:
|
|
19
|
+
├── Always verify signature
|
|
20
|
+
├── Check expiration
|
|
21
|
+
├── Include minimal claims
|
|
22
|
+
├── Use short expiry + refresh tokens
|
|
23
|
+
└── Never store sensitive data in JWT
|
|
24
|
+
```
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# API Documentation Principles
|
|
2
|
+
|
|
3
|
+
> Good docs = happy developers = API adoption.
|
|
4
|
+
|
|
5
|
+
## OpenAPI/Swagger Essentials
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
Include:
|
|
9
|
+
├── All endpoints with examples
|
|
10
|
+
├── Request/response schemas
|
|
11
|
+
├── Authentication requirements
|
|
12
|
+
├── Error response formats
|
|
13
|
+
└── Rate limiting info
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Good Documentation Has
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
Essentials:
|
|
20
|
+
├── Quick start / Getting started
|
|
21
|
+
├── Authentication guide
|
|
22
|
+
├── Complete API reference
|
|
23
|
+
├── Error handling guide
|
|
24
|
+
├── Code examples (multiple languages)
|
|
25
|
+
└── Changelog
|
|
26
|
+
```
|