forgedev 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/CLAUDE.md +38 -0
- package/LICENSE +21 -0
- package/README.md +246 -0
- package/bin/devforge.js +4 -0
- package/package.json +33 -0
- package/src/claude-configurator.js +260 -0
- package/src/cli.js +119 -0
- package/src/composer.js +214 -0
- package/src/doctor-checks.js +743 -0
- package/src/doctor-prompts.js +295 -0
- package/src/doctor.js +281 -0
- package/src/guided.js +315 -0
- package/src/index.js +148 -0
- package/src/init-mode.js +134 -0
- package/src/prompts.js +155 -0
- package/src/recommender.js +186 -0
- package/src/scanner.js +368 -0
- package/src/uat-generator.js +189 -0
- package/src/utils.js +57 -0
- package/templates/auth/jwt-custom/backend/app/api/auth.py.template +45 -0
- package/templates/auth/jwt-custom/backend/app/api/deps.py.template +16 -0
- package/templates/auth/jwt-custom/backend/app/core/security.py.template +34 -0
- package/templates/auth/nextauth/src/app/api/auth/[...nextauth]/route.ts.template +3 -0
- package/templates/auth/nextauth/src/lib/auth.ts.template +30 -0
- package/templates/auth/nextauth/src/middleware.ts.template +14 -0
- package/templates/backend/fastapi/backend/Dockerfile.template +12 -0
- package/templates/backend/fastapi/backend/app/__init__.py +0 -0
- package/templates/backend/fastapi/backend/app/api/__init__.py +0 -0
- package/templates/backend/fastapi/backend/app/api/health.py.template +32 -0
- package/templates/backend/fastapi/backend/app/core/__init__.py +0 -0
- package/templates/backend/fastapi/backend/app/core/config.py.template +25 -0
- package/templates/backend/fastapi/backend/app/core/errors.py +37 -0
- package/templates/backend/fastapi/backend/app/core/retry.py +32 -0
- package/templates/backend/fastapi/backend/app/main.py.template +58 -0
- package/templates/backend/fastapi/backend/app/models/__init__.py +0 -0
- package/templates/backend/fastapi/backend/app/schemas/__init__.py +0 -0
- package/templates/backend/fastapi/backend/pyproject.toml.template +19 -0
- package/templates/backend/fastapi/backend/requirements.txt.template +14 -0
- package/templates/base/.gitignore.template +29 -0
- package/templates/base/README.md.template +25 -0
- package/templates/claude-code/agents/code-quality-reviewer.md +41 -0
- package/templates/claude-code/agents/production-readiness.md +55 -0
- package/templates/claude-code/agents/security-reviewer.md +41 -0
- package/templates/claude-code/agents/spec-validator.md +34 -0
- package/templates/claude-code/agents/uat-validator.md +37 -0
- package/templates/claude-code/claude-md/base.md +33 -0
- package/templates/claude-code/claude-md/fastapi.md +12 -0
- package/templates/claude-code/claude-md/fullstack.md +12 -0
- package/templates/claude-code/claude-md/nextjs.md +11 -0
- package/templates/claude-code/commands/audit-security.md +11 -0
- package/templates/claude-code/commands/audit-spec.md +9 -0
- package/templates/claude-code/commands/audit-wiring.md +17 -0
- package/templates/claude-code/commands/done.md +19 -0
- package/templates/claude-code/commands/generate-prd.md +45 -0
- package/templates/claude-code/commands/generate-uat.md +35 -0
- package/templates/claude-code/commands/help.md +26 -0
- package/templates/claude-code/commands/next.md +20 -0
- package/templates/claude-code/commands/optimize-claude-md.md +31 -0
- package/templates/claude-code/commands/pre-pr.md +19 -0
- package/templates/claude-code/commands/run-uat.md +21 -0
- package/templates/claude-code/commands/status.md +24 -0
- package/templates/claude-code/commands/verify-all.md +11 -0
- package/templates/claude-code/hooks/polyglot.json +36 -0
- package/templates/claude-code/hooks/python.json +36 -0
- package/templates/claude-code/hooks/scripts/autofix-polyglot.sh +16 -0
- package/templates/claude-code/hooks/scripts/autofix-python.sh +14 -0
- package/templates/claude-code/hooks/scripts/autofix-typescript.sh +14 -0
- package/templates/claude-code/hooks/scripts/guard-protected-files.sh +21 -0
- package/templates/claude-code/hooks/typescript.json +36 -0
- package/templates/claude-code/skills/ai-prompts/SKILL.md +43 -0
- package/templates/claude-code/skills/fastapi/SKILL.md +38 -0
- package/templates/claude-code/skills/nextjs/SKILL.md +39 -0
- package/templates/claude-code/skills/playwright/SKILL.md +37 -0
- package/templates/claude-code/skills/security-api/SKILL.md +47 -0
- package/templates/claude-code/skills/security-web/SKILL.md +41 -0
- package/templates/database/prisma-postgres/.env.example +1 -0
- package/templates/database/prisma-postgres/prisma/schema.prisma.template +18 -0
- package/templates/database/sqlalchemy-postgres/.env.example +1 -0
- package/templates/database/sqlalchemy-postgres/backend/alembic/env.py.template +40 -0
- package/templates/database/sqlalchemy-postgres/backend/alembic/versions/.gitkeep +0 -0
- package/templates/database/sqlalchemy-postgres/backend/alembic.ini.template +36 -0
- package/templates/database/sqlalchemy-postgres/backend/app/db/__init__.py +0 -0
- package/templates/database/sqlalchemy-postgres/backend/app/db/base.py +5 -0
- package/templates/database/sqlalchemy-postgres/backend/app/db/session.py.template +48 -0
- package/templates/frontend/nextjs/next.config.ts.template +7 -0
- package/templates/frontend/nextjs/package.json.template +41 -0
- package/templates/frontend/nextjs/postcss.config.mjs +7 -0
- package/templates/frontend/nextjs/src/app/api/health/route.ts.template +10 -0
- package/templates/frontend/nextjs/src/app/globals.css +1 -0
- package/templates/frontend/nextjs/src/app/layout.tsx.template +22 -0
- package/templates/frontend/nextjs/src/app/page.tsx.template +10 -0
- package/templates/frontend/nextjs/src/lib/db.ts.template +40 -0
- package/templates/frontend/nextjs/src/lib/errors.ts +28 -0
- package/templates/frontend/nextjs/src/lib/utils.ts +6 -0
- package/templates/frontend/nextjs/tsconfig.json +23 -0
- package/templates/infra/docker-compose/docker-compose.yml.template +19 -0
- package/templates/testing/playwright/e2e/example.spec.ts.template +15 -0
- package/templates/testing/playwright/playwright.config.ts.template +22 -0
- package/templates/testing/vitest/src/__tests__/example.test.ts.template +12 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Run a focused security audit on all changed files.
|
|
2
|
+
|
|
3
|
+
1. Get list of changed files: `git diff --name-only`
|
|
4
|
+
2. Launch the security-reviewer agent on those files
|
|
5
|
+
3. Additionally check:
|
|
6
|
+
- No secrets committed (grep for API keys, tokens, passwords in code)
|
|
7
|
+
- No `.env` files in git tracking
|
|
8
|
+
- Dependencies have no known critical vulnerabilities
|
|
9
|
+
4. Report all findings by severity
|
|
10
|
+
|
|
11
|
+
For any CRITICAL findings, provide immediate remediation steps.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Run the spec-validator agent against the specification.
|
|
2
|
+
|
|
3
|
+
1. Find spec files in `docs/` (look for files with "spec", "requirements", or "PRD" in the name)
|
|
4
|
+
2. If no spec found, ask the user to provide the spec file path
|
|
5
|
+
3. Launch the spec-validator agent with the spec file
|
|
6
|
+
4. Report the traceability matrix
|
|
7
|
+
5. Highlight any MISSING or PARTIAL requirements
|
|
8
|
+
|
|
9
|
+
Focus on P0 requirements first, then P1, then P2.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Verify that all API endpoints are properly wired between frontend and backend.
|
|
2
|
+
|
|
3
|
+
1. Find all backend API endpoints (route handlers, FastAPI routers)
|
|
4
|
+
2. Find all frontend API calls (fetch, axios, server actions)
|
|
5
|
+
3. Cross-reference: every backend endpoint should have at least one frontend caller
|
|
6
|
+
4. Cross-reference: every frontend API call should hit a real backend endpoint
|
|
7
|
+
5. Check that request/response types match between frontend and backend
|
|
8
|
+
|
|
9
|
+
Output a wiring matrix:
|
|
10
|
+
| Backend Endpoint | Method | Frontend Caller | Type Match | Status |
|
|
11
|
+
|---|---|---|---|---|
|
|
12
|
+
| /api/users | GET | src/app/users/page.tsx | YES/NO | WIRED/ORPHAN |
|
|
13
|
+
|
|
14
|
+
Flag:
|
|
15
|
+
- ORPHAN backend endpoints (no frontend caller)
|
|
16
|
+
- DEAD frontend calls (no backend endpoint)
|
|
17
|
+
- TYPE MISMATCH (request/response shape differs)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Verify that the current task is actually complete before moving on.
|
|
2
|
+
|
|
3
|
+
## Checklist
|
|
4
|
+
|
|
5
|
+
1. Run lint and confirm it passes: `{{LINT_COMMAND}}`
|
|
6
|
+
2. Run type check and confirm it passes: `{{TYPE_CHECK_COMMAND}}`
|
|
7
|
+
3. Run tests and confirm they pass: `{{TEST_COMMAND}}`
|
|
8
|
+
4. Check that no `.env` files or secrets are in the changes
|
|
9
|
+
5. Review the git diff to make sure only intended files changed
|
|
10
|
+
6. Verify the feature works as described (manual check or UAT scenario)
|
|
11
|
+
|
|
12
|
+
## Output
|
|
13
|
+
|
|
14
|
+
If everything passes:
|
|
15
|
+
```
|
|
16
|
+
Task complete. Ready to commit or move on.
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
If something fails, explain what needs to be fixed before the task can be considered done.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
Generate a Product Requirements Document (PRD) for this project.
|
|
2
|
+
|
|
3
|
+
## Instructions
|
|
4
|
+
|
|
5
|
+
1. Read the entire codebase to understand:
|
|
6
|
+
- What the application does (features, user flows)
|
|
7
|
+
- Who the users are (roles, personas)
|
|
8
|
+
- What the tech stack is
|
|
9
|
+
- What's already built vs what's planned
|
|
10
|
+
|
|
11
|
+
2. Generate a PRD with these sections:
|
|
12
|
+
|
|
13
|
+
### Overview
|
|
14
|
+
- Product name and one-line description
|
|
15
|
+
- Problem statement (what problem does this solve?)
|
|
16
|
+
- Target users
|
|
17
|
+
|
|
18
|
+
### User Personas
|
|
19
|
+
- List each user type with their goals and pain points
|
|
20
|
+
|
|
21
|
+
### Feature Map
|
|
22
|
+
- Group features by category
|
|
23
|
+
- Mark each as: ✅ Built | 🚧 In Progress | 📋 Planned
|
|
24
|
+
- Include a Mermaid diagram showing the feature hierarchy
|
|
25
|
+
|
|
26
|
+
### User Flows
|
|
27
|
+
- For each major feature, describe the user flow
|
|
28
|
+
- Include Mermaid sequence diagrams for critical paths
|
|
29
|
+
|
|
30
|
+
### Data Model
|
|
31
|
+
- Entity relationship diagram (Mermaid ERD)
|
|
32
|
+
- Key entities and their relationships
|
|
33
|
+
|
|
34
|
+
### Non-Functional Requirements
|
|
35
|
+
- Performance targets
|
|
36
|
+
- Security requirements
|
|
37
|
+
- Scalability considerations
|
|
38
|
+
|
|
39
|
+
### Milestones
|
|
40
|
+
- Phase 1, 2, 3 with features in each
|
|
41
|
+
|
|
42
|
+
## Output
|
|
43
|
+
|
|
44
|
+
Save the PRD to `docs/PRD.md`. Use Mermaid diagrams (```mermaid blocks) for all visual elements.
|
|
45
|
+
Do NOT modify any code — this is a documentation-only task.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
Generate UAT (User Acceptance Test) scenarios for this project.
|
|
2
|
+
|
|
3
|
+
## Instructions
|
|
4
|
+
|
|
5
|
+
1. Read the codebase to identify all user-facing features:
|
|
6
|
+
- API endpoints and their purposes
|
|
7
|
+
- UI pages and forms
|
|
8
|
+
- Authentication flows
|
|
9
|
+
- Business logic and workflows
|
|
10
|
+
|
|
11
|
+
2. For each feature, create test scenarios covering:
|
|
12
|
+
- Happy path (expected usage)
|
|
13
|
+
- Edge cases (empty inputs, max values, special characters)
|
|
14
|
+
- Error cases (invalid data, unauthorized access, network failures)
|
|
15
|
+
- Integration points (features that depend on each other)
|
|
16
|
+
|
|
17
|
+
3. Prioritize scenarios:
|
|
18
|
+
- P0: Critical path — app is broken if these fail (login, core CRUD, data integrity)
|
|
19
|
+
- P1: Important — significant user impact (permissions, validation, error handling)
|
|
20
|
+
- P2: Nice to have — minor features, cosmetic issues
|
|
21
|
+
|
|
22
|
+
## Output
|
|
23
|
+
|
|
24
|
+
Generate two files:
|
|
25
|
+
|
|
26
|
+
### docs/uat/UAT_TEMPLATE.md
|
|
27
|
+
Markdown table with columns:
|
|
28
|
+
| ID | Feature | Scenario | Steps | Expected Result | Priority |
|
|
29
|
+
|
|
30
|
+
### docs/uat/UAT_CHECKLIST.csv
|
|
31
|
+
CSV with columns:
|
|
32
|
+
ID,Feature,Scenario,Priority,Status,Tester,Date,Notes
|
|
33
|
+
|
|
34
|
+
Include at least 5 P0 scenarios, 10 P1 scenarios, and 5 P2 scenarios.
|
|
35
|
+
Do NOT modify any code — this is a documentation-only task.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
Show the developer what workflows are available.
|
|
2
|
+
|
|
3
|
+
## Available Workflows
|
|
4
|
+
|
|
5
|
+
### Daily Development
|
|
6
|
+
- `/project:status` — Run all checks and show a project dashboard
|
|
7
|
+
- `/project:next` — Figure out what to work on next
|
|
8
|
+
- `/project:done` — Verify the current task is complete before moving on
|
|
9
|
+
|
|
10
|
+
### Verification
|
|
11
|
+
- `/project:verify-all` — Run lint, type check, tests, then launch all reviewers
|
|
12
|
+
- `/project:audit-spec` — Validate implementation against a spec/PRD
|
|
13
|
+
- `/project:audit-wiring` — Find dead or unwired features
|
|
14
|
+
- `/project:audit-security` — Run a security audit
|
|
15
|
+
|
|
16
|
+
### Release
|
|
17
|
+
- `/project:pre-pr` — Run the complete pre-PR checklist
|
|
18
|
+
- `/project:run-uat` — Execute UAT scenarios
|
|
19
|
+
|
|
20
|
+
### Generation
|
|
21
|
+
- `/project:generate-prd` — Generate a PRD from the current codebase
|
|
22
|
+
- `/project:generate-uat` — Generate UAT scenarios and checklists
|
|
23
|
+
- `/project:optimize-claude-md` — Slim down an oversized CLAUDE.md
|
|
24
|
+
|
|
25
|
+
## Quick Start
|
|
26
|
+
Run `/project:status` to see where things stand, then `/project:next` to pick up work.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Figure out what the developer should work on next.
|
|
2
|
+
|
|
3
|
+
## Steps
|
|
4
|
+
|
|
5
|
+
1. Check git log for recent commits to understand current progress
|
|
6
|
+
2. Look for TODO/FIXME/HACK comments in the codebase
|
|
7
|
+
3. Check if there are failing tests: `{{TEST_COMMAND}}`
|
|
8
|
+
4. Check if there are lint errors: `{{LINT_COMMAND}}`
|
|
9
|
+
5. Check if docs/uat/UAT_CHECKLIST.csv exists and has unchecked items
|
|
10
|
+
6. Look for open issues or PRs if this is a GitHub repo
|
|
11
|
+
|
|
12
|
+
## Priority Order
|
|
13
|
+
1. Failing tests or build errors (fix first)
|
|
14
|
+
2. Security issues (from recent audit or TODO comments)
|
|
15
|
+
3. Unchecked UAT scenarios
|
|
16
|
+
4. TODO/FIXME items in code
|
|
17
|
+
5. New feature work
|
|
18
|
+
|
|
19
|
+
## Output
|
|
20
|
+
Recommend the single most important thing to work on next, with a clear action.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
Analyze and optimize CLAUDE.md for this project.
|
|
2
|
+
|
|
3
|
+
## Instructions
|
|
4
|
+
|
|
5
|
+
1. Read the current CLAUDE.md and measure its size (line count).
|
|
6
|
+
|
|
7
|
+
2. The target is **under 150 lines**. CLAUDE.md should contain ONLY:
|
|
8
|
+
- WHAT: One-line project description
|
|
9
|
+
- HOW: Key commands (lint, test, build, dev)
|
|
10
|
+
- RULES: Universal rules that apply everywhere (max 10-15 rules)
|
|
11
|
+
- PITFALLS: Known gotchas specific to this project (max 5)
|
|
12
|
+
|
|
13
|
+
3. Identify content that should be **moved out**:
|
|
14
|
+
- Detailed schemas, specs, or data models → `.claude/skills/<topic>/SKILL.md`
|
|
15
|
+
- Backend-specific rules → `backend/CLAUDE.md`
|
|
16
|
+
- Frontend-specific rules → `src/CLAUDE.md` or `frontend/CLAUDE.md`
|
|
17
|
+
- Detailed API documentation → `docs/`
|
|
18
|
+
- Step-by-step procedures → `.claude/commands/`
|
|
19
|
+
- Lists of more than 5 items → `.claude/skills/`
|
|
20
|
+
|
|
21
|
+
4. Present a proposal as a table:
|
|
22
|
+
|
|
23
|
+
| Content | Current Location | Move To | Lines Saved |
|
|
24
|
+
|---------|-----------------|---------|-------------|
|
|
25
|
+
| ... | CLAUDE.md:45-80 | .claude/skills/schema/SKILL.md | 35 |
|
|
26
|
+
|
|
27
|
+
## Rules
|
|
28
|
+
- Do NOT modify any files until I explicitly approve the proposal
|
|
29
|
+
- Show the current line count and target line count
|
|
30
|
+
- Preserve all information — nothing gets deleted, only relocated
|
|
31
|
+
- Each skill file needs frontmatter: name, description, and relevant file patterns
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Run the complete pre-PR checklist before creating a pull request.
|
|
2
|
+
|
|
3
|
+
1. Run lint: `{{LINT_COMMAND}}`
|
|
4
|
+
2. Run type check: `{{TYPE_CHECK_COMMAND}}`
|
|
5
|
+
3. Run tests: `{{TEST_COMMAND}}`
|
|
6
|
+
4. Check for uncommitted changes
|
|
7
|
+
5. Launch code-quality-reviewer agent on the PR diff
|
|
8
|
+
6. Launch security-reviewer agent on the PR diff
|
|
9
|
+
7. Check that no `.env` files or secrets are staged
|
|
10
|
+
|
|
11
|
+
If all checks pass, output:
|
|
12
|
+
- Summary of changes (files changed, lines added/removed)
|
|
13
|
+
- Suggested PR title and description
|
|
14
|
+
- Any warnings (non-blocking issues)
|
|
15
|
+
|
|
16
|
+
If any check fails, output:
|
|
17
|
+
- Which checks failed
|
|
18
|
+
- How to fix each failure
|
|
19
|
+
- Do NOT proceed with PR creation
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Read docs/uat/UAT_TEMPLATE.md and execute the UAT verification process.
|
|
2
|
+
|
|
3
|
+
For each scenario in the UAT template:
|
|
4
|
+
1. Check if automated tests exist that cover this scenario
|
|
5
|
+
2. If automated: run the test and report PASS/FAIL
|
|
6
|
+
3. If not automated: flag as MANUAL REQUIRED
|
|
7
|
+
4. Update docs/uat/UAT_CHECKLIST.csv with results
|
|
8
|
+
|
|
9
|
+
Output:
|
|
10
|
+
- Automated coverage: X/Y scenarios have automated tests
|
|
11
|
+
- Results: X passed, Y failed, Z need manual testing
|
|
12
|
+
- Blocking issues: list any P0 failures
|
|
13
|
+
|
|
14
|
+
For P0 failures:
|
|
15
|
+
- Show the test output
|
|
16
|
+
- Suggest a fix if the failure is obvious
|
|
17
|
+
- Mark as BLOCKED in the checklist
|
|
18
|
+
|
|
19
|
+
For scenarios needing manual testing:
|
|
20
|
+
- Provide step-by-step instructions for the tester
|
|
21
|
+
- Note any test data or setup required
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
Run all validation checks and show a project dashboard.
|
|
2
|
+
|
|
3
|
+
## Steps
|
|
4
|
+
|
|
5
|
+
1. Run lint: `{{LINT_COMMAND}}`
|
|
6
|
+
2. Run type check: `{{TYPE_CHECK_COMMAND}}`
|
|
7
|
+
3. Run tests: `{{TEST_COMMAND}}`
|
|
8
|
+
4. Check git status for uncommitted changes
|
|
9
|
+
5. Check for any `.env` files accidentally tracked
|
|
10
|
+
|
|
11
|
+
## Output Format
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
{{PROJECT_NAME_PASCAL}} Status
|
|
15
|
+
──────────────────────────
|
|
16
|
+
Lint: PASS / FAIL (N issues)
|
|
17
|
+
Types: PASS / FAIL (N errors)
|
|
18
|
+
Tests: PASS / FAIL (N passed, M failed)
|
|
19
|
+
Git: clean / N uncommitted changes
|
|
20
|
+
Secrets: clean / WARNING
|
|
21
|
+
──────────────────────────
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
If anything fails, suggest the next step to fix it.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Run the full verification chain on the current changes.
|
|
2
|
+
|
|
3
|
+
1. Run lint: `{{LINT_COMMAND}}`
|
|
4
|
+
2. Run type check: `{{TYPE_CHECK_COMMAND}}`
|
|
5
|
+
3. Run tests: `{{TEST_COMMAND}}`
|
|
6
|
+
4. Launch the code-quality-reviewer agent on all changed files (use `git diff --name-only`)
|
|
7
|
+
5. Launch the security-reviewer agent on all changed files
|
|
8
|
+
6. Launch the production-readiness agent
|
|
9
|
+
|
|
10
|
+
Summarize all findings grouped by severity (critical, high, medium, low).
|
|
11
|
+
If any critical issues found, list them prominently at the top.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"hooks": {
|
|
3
|
+
"PreToolUse": [
|
|
4
|
+
{
|
|
5
|
+
"matcher": "Write|Edit",
|
|
6
|
+
"hooks": [
|
|
7
|
+
{
|
|
8
|
+
"type": "command",
|
|
9
|
+
"command": "bash .claude/hooks/guard-protected-files.sh"
|
|
10
|
+
}
|
|
11
|
+
]
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"PostToolUse": [
|
|
15
|
+
{
|
|
16
|
+
"matcher": "Write|Edit",
|
|
17
|
+
"hooks": [
|
|
18
|
+
{
|
|
19
|
+
"type": "command",
|
|
20
|
+
"command": "bash .claude/hooks/autofix-polyglot.sh"
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"Stop": [
|
|
26
|
+
{
|
|
27
|
+
"hooks": [
|
|
28
|
+
{
|
|
29
|
+
"type": "command",
|
|
30
|
+
"command": "cd frontend && npx tsc --noEmit 2>&1 && npx eslint . 2>&1 && cd ../backend && ruff check . 2>&1"
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"hooks": {
|
|
3
|
+
"PreToolUse": [
|
|
4
|
+
{
|
|
5
|
+
"matcher": "Write|Edit",
|
|
6
|
+
"hooks": [
|
|
7
|
+
{
|
|
8
|
+
"type": "command",
|
|
9
|
+
"command": "bash .claude/hooks/guard-protected-files.sh"
|
|
10
|
+
}
|
|
11
|
+
]
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"PostToolUse": [
|
|
15
|
+
{
|
|
16
|
+
"matcher": "Write|Edit",
|
|
17
|
+
"hooks": [
|
|
18
|
+
{
|
|
19
|
+
"type": "command",
|
|
20
|
+
"command": "bash .claude/hooks/autofix-python.sh"
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"Stop": [
|
|
26
|
+
{
|
|
27
|
+
"hooks": [
|
|
28
|
+
{
|
|
29
|
+
"type": "command",
|
|
30
|
+
"command": "cd backend && ruff check . 2>&1 && pyright 2>&1"
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Auto-fix lint issues on saved TypeScript or Python files (polyglot)
|
|
3
|
+
INPUT=$(cat)
|
|
4
|
+
FILE_PATH=$(echo "$INPUT" | jq -r ".tool_input.file_path // empty")
|
|
5
|
+
|
|
6
|
+
if [ -z "$FILE_PATH" ]; then
|
|
7
|
+
exit 0
|
|
8
|
+
fi
|
|
9
|
+
|
|
10
|
+
if [[ "$FILE_PATH" == *.ts || "$FILE_PATH" == *.tsx ]]; then
|
|
11
|
+
cd frontend && npx eslint --fix "$FILE_PATH" 2>&1 || true
|
|
12
|
+
elif [[ "$FILE_PATH" == *.py ]]; then
|
|
13
|
+
cd backend && ruff check --fix "$FILE_PATH" 2>&1 || true
|
|
14
|
+
fi
|
|
15
|
+
|
|
16
|
+
exit 0
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Auto-fix lint issues on saved Python files
|
|
3
|
+
INPUT=$(cat)
|
|
4
|
+
FILE_PATH=$(echo "$INPUT" | jq -r ".tool_input.file_path // empty")
|
|
5
|
+
|
|
6
|
+
if [ -z "$FILE_PATH" ]; then
|
|
7
|
+
exit 0
|
|
8
|
+
fi
|
|
9
|
+
|
|
10
|
+
if [[ "$FILE_PATH" == *.py ]]; then
|
|
11
|
+
cd backend && ruff check --fix "$FILE_PATH" 2>&1 || true
|
|
12
|
+
fi
|
|
13
|
+
|
|
14
|
+
exit 0
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Auto-fix lint issues on saved TypeScript files
|
|
3
|
+
INPUT=$(cat)
|
|
4
|
+
FILE_PATH=$(echo "$INPUT" | jq -r ".tool_input.file_path // empty")
|
|
5
|
+
|
|
6
|
+
if [ -z "$FILE_PATH" ]; then
|
|
7
|
+
exit 0
|
|
8
|
+
fi
|
|
9
|
+
|
|
10
|
+
if [[ "$FILE_PATH" == *.ts || "$FILE_PATH" == *.tsx ]]; then
|
|
11
|
+
npx eslint --fix "$FILE_PATH" 2>&1 || true
|
|
12
|
+
fi
|
|
13
|
+
|
|
14
|
+
exit 0
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Block modifications to .env files and migration files
|
|
3
|
+
INPUT=$(cat)
|
|
4
|
+
FILE_PATH=$(echo "$INPUT" | jq -r ".tool_input.file_path // empty")
|
|
5
|
+
|
|
6
|
+
if [ -z "$FILE_PATH" ]; then
|
|
7
|
+
exit 0
|
|
8
|
+
fi
|
|
9
|
+
|
|
10
|
+
case "$FILE_PATH" in
|
|
11
|
+
*.env|*.env.*)
|
|
12
|
+
echo "BLOCKED: Do not modify .env files directly" >&2
|
|
13
|
+
exit 2
|
|
14
|
+
;;
|
|
15
|
+
*/prisma/migrations/*|*/alembic/versions/*)
|
|
16
|
+
echo "BLOCKED: Do not modify migration files directly" >&2
|
|
17
|
+
exit 2
|
|
18
|
+
;;
|
|
19
|
+
esac
|
|
20
|
+
|
|
21
|
+
exit 0
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"hooks": {
|
|
3
|
+
"PreToolUse": [
|
|
4
|
+
{
|
|
5
|
+
"matcher": "Write|Edit",
|
|
6
|
+
"hooks": [
|
|
7
|
+
{
|
|
8
|
+
"type": "command",
|
|
9
|
+
"command": "bash .claude/hooks/guard-protected-files.sh"
|
|
10
|
+
}
|
|
11
|
+
]
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"PostToolUse": [
|
|
15
|
+
{
|
|
16
|
+
"matcher": "Write|Edit",
|
|
17
|
+
"hooks": [
|
|
18
|
+
{
|
|
19
|
+
"type": "command",
|
|
20
|
+
"command": "bash .claude/hooks/autofix-typescript.sh"
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"Stop": [
|
|
26
|
+
{
|
|
27
|
+
"hooks": [
|
|
28
|
+
{
|
|
29
|
+
"type": "command",
|
|
30
|
+
"command": "npx tsc --noEmit 2>&1 && npx eslint . 2>&1"
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: AI Prompts
|
|
3
|
+
description: AI/LLM integration patterns and best practices
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# AI/LLM Integration
|
|
7
|
+
|
|
8
|
+
## Structured Output
|
|
9
|
+
- Always validate AI responses with Pydantic (Python) or Zod (TypeScript)
|
|
10
|
+
- Never use raw string responses in application logic
|
|
11
|
+
- Define response schemas before making API calls
|
|
12
|
+
- Handle malformed responses gracefully
|
|
13
|
+
|
|
14
|
+
## Prompt Engineering
|
|
15
|
+
- Use system prompts for consistent behavior
|
|
16
|
+
- Include examples (few-shot) for complex tasks
|
|
17
|
+
- Be specific about output format
|
|
18
|
+
- Test prompts with edge cases
|
|
19
|
+
|
|
20
|
+
## Failover Patterns
|
|
21
|
+
- Implement rule-based fallback when AI is unavailable
|
|
22
|
+
- Set aggressive timeouts (30-60s for most calls)
|
|
23
|
+
- Retry with exponential backoff (max 3 attempts)
|
|
24
|
+
- Cache responses when appropriate
|
|
25
|
+
- Monitor token usage and costs
|
|
26
|
+
|
|
27
|
+
## Rate Limiting
|
|
28
|
+
- Implement client-side rate limiting before API calls
|
|
29
|
+
- Queue requests during high load
|
|
30
|
+
- Use batch APIs when processing multiple items
|
|
31
|
+
- Handle 429 responses gracefully
|
|
32
|
+
|
|
33
|
+
## Security
|
|
34
|
+
- Never include user secrets in prompts
|
|
35
|
+
- Sanitize user input before including in prompts
|
|
36
|
+
- Validate and sanitize AI output before using
|
|
37
|
+
- Don't trust AI output for security decisions
|
|
38
|
+
|
|
39
|
+
## Testing
|
|
40
|
+
- Use golden datasets for regression testing
|
|
41
|
+
- Mock AI responses in unit tests
|
|
42
|
+
- Test timeout and error handling paths
|
|
43
|
+
- Monitor response quality over time
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: FastAPI
|
|
3
|
+
description: FastAPI + SQLAlchemy 2.0 + Pydantic v2 patterns
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# FastAPI Backend
|
|
7
|
+
|
|
8
|
+
## Endpoint Patterns
|
|
9
|
+
- Use `APIRouter` for route grouping
|
|
10
|
+
- Type all parameters: path params, query params, request bodies
|
|
11
|
+
- Return Pydantic models, not dicts
|
|
12
|
+
- Use `Depends()` for dependency injection (DB sessions, auth, config)
|
|
13
|
+
- Use `status_code` parameter for non-200 responses
|
|
14
|
+
|
|
15
|
+
## Pydantic v2
|
|
16
|
+
- Use `model_config = ConfigDict(...)` not `class Config`
|
|
17
|
+
- Use `model_validator` not `root_validator`
|
|
18
|
+
- Use `field_validator` not `validator`
|
|
19
|
+
- `from_attributes=True` replaces `orm_mode=True`
|
|
20
|
+
|
|
21
|
+
## SQLAlchemy 2.0 Async
|
|
22
|
+
- Use `select()` statement style, not `session.query()`
|
|
23
|
+
- Use `async with async_session() as session` for scoped sessions
|
|
24
|
+
- Use `session.execute(select(Model))` then `.scalars().all()`
|
|
25
|
+
- Use `session.get(Model, id)` for single lookups
|
|
26
|
+
- Never use synchronous session methods
|
|
27
|
+
|
|
28
|
+
## Error Handling
|
|
29
|
+
- Raise `AppError` subclasses, never `HTTPException` with raw strings
|
|
30
|
+
- Global exception handler catches unhandled errors
|
|
31
|
+
- Never expose stack traces or internal details to clients
|
|
32
|
+
- Use structured error format: `{ error: { code, message } }`
|
|
33
|
+
|
|
34
|
+
## Testing
|
|
35
|
+
- Use `httpx.AsyncClient` with `ASGITransport` for async tests
|
|
36
|
+
- Use `conftest.py` fixtures for test client and DB setup
|
|
37
|
+
- Test both success and error paths
|
|
38
|
+
- Use `pytest.mark.asyncio` for async tests
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Next.js
|
|
3
|
+
description: Next.js 15 App Router patterns and best practices
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Next.js 15 App Router
|
|
7
|
+
|
|
8
|
+
## Routing
|
|
9
|
+
- File-based routing in `src/app/`
|
|
10
|
+
- `page.tsx` for pages, `layout.tsx` for layouts, `loading.tsx` for loading states
|
|
11
|
+
- `error.tsx` for error boundaries, `not-found.tsx` for 404s
|
|
12
|
+
- Route groups `(group)` for organization without URL impact
|
|
13
|
+
- Dynamic routes `[param]`, catch-all `[...slug]`, optional `[[...slug]]`
|
|
14
|
+
|
|
15
|
+
## Server vs Client Components
|
|
16
|
+
- All components are Server Components by default
|
|
17
|
+
- Add `'use client'` only when you need: event handlers, useState/useEffect, browser APIs
|
|
18
|
+
- Pass server data to client components via props
|
|
19
|
+
- Keep client components as leaves of the component tree
|
|
20
|
+
|
|
21
|
+
## Data Fetching
|
|
22
|
+
- Server Components: fetch directly in the component, use async/await
|
|
23
|
+
- Client Components: use SWR or React Query
|
|
24
|
+
- Server Actions: `'use server'` functions for mutations
|
|
25
|
+
- Route Handlers: `app/api/*/route.ts` for REST endpoints
|
|
26
|
+
|
|
27
|
+
## Patterns
|
|
28
|
+
- Use `next/image` for all images (automatic optimization)
|
|
29
|
+
- Use `next/link` for navigation (automatic prefetching)
|
|
30
|
+
- Use `next/font` for fonts (automatic optimization)
|
|
31
|
+
- Metadata API for SEO: export `metadata` object or `generateMetadata` function
|
|
32
|
+
- Parallel routes `@slot` for complex layouts
|
|
33
|
+
- Intercepting routes `(.)` for modals
|
|
34
|
+
|
|
35
|
+
## Common Mistakes
|
|
36
|
+
- Don't use `useEffect` for data fetching in Server Components
|
|
37
|
+
- Don't pass functions as props from Server to Client Components
|
|
38
|
+
- Don't use `router.push` when `<Link>` works
|
|
39
|
+
- Don't create API routes for data that Server Components can fetch directly
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Playwright
|
|
3
|
+
description: Playwright E2E testing patterns and best practices
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Playwright E2E Testing
|
|
7
|
+
|
|
8
|
+
## Test Structure
|
|
9
|
+
- Tests in `e2e/` directory
|
|
10
|
+
- Use `test.describe()` for grouping related tests
|
|
11
|
+
- Use `test.beforeEach()` for common setup (navigation, auth)
|
|
12
|
+
- Use page object pattern for complex pages
|
|
13
|
+
|
|
14
|
+
## Selectors
|
|
15
|
+
- Prefer `data-testid` attributes: `page.getByTestId('submit-btn')`
|
|
16
|
+
- Use accessible selectors: `page.getByRole('button', { name: 'Submit' })`
|
|
17
|
+
- Use text selectors: `page.getByText('Welcome')`
|
|
18
|
+
- Avoid CSS selectors — they break when styles change
|
|
19
|
+
|
|
20
|
+
## Assertions
|
|
21
|
+
- Use `expect(locator)` for element assertions
|
|
22
|
+
- `toBeVisible()`, `toHaveText()`, `toHaveValue()`, `toHaveCount()`
|
|
23
|
+
- Use `expect(response)` for API assertions
|
|
24
|
+
- Always await assertions
|
|
25
|
+
|
|
26
|
+
## Common Patterns
|
|
27
|
+
- Navigation: `await page.goto('/')` then assert page loaded
|
|
28
|
+
- Form filling: `await page.fill('[name=email]', 'test@example.com')`
|
|
29
|
+
- Clicking: `await page.click('button[type=submit]')` or `getByRole`
|
|
30
|
+
- Waiting: prefer auto-waiting over explicit waits
|
|
31
|
+
- Network: `page.waitForResponse()` for API-dependent tests
|
|
32
|
+
- Authentication: use `storageState` for persistent auth across tests
|
|
33
|
+
|
|
34
|
+
## Fixtures
|
|
35
|
+
- Define in `e2e/fixtures/` directory
|
|
36
|
+
- Use `test.extend()` for custom fixtures
|
|
37
|
+
- Share auth state across tests with `storageState`
|