forgedev 1.0.2 → 1.1.3

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 (55) hide show
  1. package/README.md +122 -26
  2. package/bin/devforge.js +10 -1
  3. package/package.json +1 -1
  4. package/src/claude-configurator.js +29 -6
  5. package/src/cli.js +11 -0
  6. package/src/doctor-prompts.js +9 -2
  7. package/src/doctor.js +19 -0
  8. package/src/index.js +7 -0
  9. package/src/update-check.js +49 -0
  10. package/src/update.js +33 -0
  11. package/templates/auth/jwt-custom/backend/app/core/security.py.template +4 -1
  12. package/templates/backend/fastapi/backend/app/core/config.py.template +2 -2
  13. package/templates/claude-code/agents/architect.md +70 -0
  14. package/templates/claude-code/agents/build-error-resolver.md +30 -0
  15. package/templates/claude-code/agents/chief-of-staff.md +52 -0
  16. package/templates/claude-code/agents/database-reviewer.md +58 -0
  17. package/templates/claude-code/agents/doc-updater.md +39 -0
  18. package/templates/claude-code/agents/docs-lookup.md +51 -0
  19. package/templates/claude-code/agents/e2e-runner.md +57 -0
  20. package/templates/claude-code/agents/harness-optimizer.md +65 -0
  21. package/templates/claude-code/agents/loop-operator.md +52 -0
  22. package/templates/claude-code/agents/planner.md +60 -0
  23. package/templates/claude-code/agents/refactor-cleaner.md +42 -0
  24. package/templates/claude-code/agents/tdd-guide.md +47 -0
  25. package/templates/claude-code/agents/uat-validator.md +2 -1
  26. package/templates/claude-code/claude-md/base.md +29 -1
  27. package/templates/claude-code/claude-md/fastapi.md +8 -0
  28. package/templates/claude-code/claude-md/fullstack.md +8 -0
  29. package/templates/claude-code/claude-md/nextjs.md +8 -0
  30. package/templates/claude-code/commands/build-fix.md +43 -0
  31. package/templates/claude-code/commands/code-review.md +44 -0
  32. package/templates/claude-code/commands/full-audit.md +60 -0
  33. package/templates/claude-code/commands/plan.md +21 -0
  34. package/templates/claude-code/commands/resume-session.md +50 -0
  35. package/templates/claude-code/commands/save-session.md +69 -0
  36. package/templates/claude-code/commands/tdd.md +80 -0
  37. package/templates/claude-code/commands/workflows.md +12 -1
  38. package/templates/claude-code/hooks/polyglot.json +2 -2
  39. package/templates/claude-code/hooks/python.json +2 -2
  40. package/templates/claude-code/hooks/scripts/autofix-polyglot.mjs +44 -0
  41. package/templates/claude-code/hooks/scripts/autofix-python.mjs +38 -0
  42. package/templates/claude-code/hooks/scripts/autofix-typescript.mjs +38 -0
  43. package/templates/claude-code/hooks/scripts/guard-protected-files.mjs +34 -0
  44. package/templates/claude-code/hooks/typescript.json +2 -2
  45. package/templates/claude-code/skills/ai-prompts/SKILL.md +1 -0
  46. package/templates/claude-code/skills/fastapi/SKILL.md +1 -1
  47. package/templates/claude-code/skills/git-workflow/SKILL.md +64 -0
  48. package/templates/claude-code/skills/playwright/SKILL.md +2 -2
  49. package/templates/claude-code/skills/security-api/SKILL.md +2 -2
  50. package/templates/claude-code/skills/testing-patterns/SKILL.md +97 -0
  51. package/templates/database/sqlalchemy-postgres/.env.example +1 -0
  52. package/templates/claude-code/hooks/scripts/autofix-polyglot.sh +0 -16
  53. package/templates/claude-code/hooks/scripts/autofix-python.sh +0 -14
  54. package/templates/claude-code/hooks/scripts/autofix-typescript.sh +0 -14
  55. package/templates/claude-code/hooks/scripts/guard-protected-files.sh +0 -21
@@ -16,7 +16,7 @@ description: API security best practices
16
16
  - Validate all input with Pydantic models
17
17
  - Set max lengths on string fields
18
18
  - Validate email formats, URLs, phone numbers
19
- - Reject unexpected fields (Pydantic does this by default)
19
+ - Reject unexpected fields (set `extra = "forbid"` in Pydantic model config)
20
20
  - Validate file uploads (size, type, extension)
21
21
 
22
22
  ## SQL Injection Prevention
@@ -38,7 +38,7 @@ description: API security best practices
38
38
  - Never expose stack traces to clients
39
39
  - Use generic error messages for auth failures
40
40
  - Log detailed errors server-side only
41
- - Return structured error responses: `{ error: { code, message } }`
41
+ - Return structured error responses: `{ "error": { "code": "ERR_CODE", "message": "Error description" } }`
42
42
 
43
43
  ## Secrets Management
44
44
  - Store secrets in environment variables, never in code
@@ -0,0 +1,97 @@
1
+ ---
2
+ name: testing-patterns
3
+ description: Universal testing principles — test pyramid, AAA pattern, mocking strategies, and coverage targets
4
+ ---
5
+
6
+ ## Test Pyramid
7
+
8
+ ```
9
+ / E2E \ — Few, slow, high confidence
10
+ / Integration \ — Some, medium speed
11
+ / Unit Tests \— Many, fast, focused
12
+ ```
13
+
14
+ - **Unit tests** (70%): Test individual functions in isolation. Fast, many.
15
+ - **Integration tests** (20%): Test modules working together (API + DB, component + hook).
16
+ - **E2E tests** (10%): Test full user journeys through the real app. Slow, few.
17
+
18
+ ## Arrange-Act-Assert (AAA)
19
+
20
+ Every test follows this structure:
21
+
22
+ ```
23
+ test('should calculate total with tax', () => {
24
+ // Arrange — set up test data
25
+ const items = [{ price: 10 }, { price: 20 }];
26
+ const taxRate = 0.1;
27
+
28
+ // Act — execute the function
29
+ const total = calculateTotal(items, taxRate);
30
+
31
+ // Assert — verify the result
32
+ expect(total).toBe(33);
33
+ });
34
+ ```
35
+
36
+ ## What to Test
37
+
38
+ **Always test:**
39
+ - Happy path (normal inputs → expected output)
40
+ - Edge cases (empty, null, undefined, zero, max values)
41
+ - Error cases (invalid input, missing data, network failure)
42
+ - Boundary values (off-by-one, exactly at limits)
43
+ - Security-critical paths (auth, permissions, input validation)
44
+
45
+ **Don't test:**
46
+ - Implementation details (private methods, internal state)
47
+ - Third-party library internals
48
+ - Trivial getters/setters with no logic
49
+ - CSS styling or pixel-perfect layouts
50
+
51
+ ## Mocking Strategy
52
+
53
+ | What | When to Mock |
54
+ |------|-------------|
55
+ | External APIs | Always — they're slow and unreliable |
56
+ | Database | Integration tests use real DB, unit tests mock |
57
+ | Time/Date | When testing time-dependent logic |
58
+ | File system | When testing file operations |
59
+ | Environment | When testing env-dependent behavior |
60
+
61
+ Rules:
62
+ - Mock at the boundary, not deep inside
63
+ - Prefer dependency injection over global mocks
64
+ - Reset mocks between tests (`beforeEach` / `afterEach`)
65
+ - Never mock what you're testing
66
+
67
+ ## Test Naming
68
+
69
+ Use descriptive names that explain the scenario:
70
+
71
+ ```
72
+ // Good
73
+ "should return 404 when user does not exist"
74
+ "should hash password before saving to database"
75
+ "should retry failed request up to 3 times"
76
+
77
+ // Bad
78
+ "test1"
79
+ "works correctly"
80
+ "handles error"
81
+ ```
82
+
83
+ ## Coverage Targets
84
+
85
+ - **80% minimum** for all code
86
+ - **100% required** for: auth logic, financial calculations, security-critical code
87
+ - Coverage measures lines hit, not correctness — high coverage with weak assertions is useless
88
+ - Focus on meaningful assertions, not just line coverage
89
+
90
+ ## Common Anti-Patterns
91
+
92
+ - Testing implementation instead of behavior
93
+ - Tests that pass regardless of the implementation
94
+ - Shared mutable state between tests (tests must be independent)
95
+ - Over-mocking (prefer integration tests when possible)
96
+ - Ignoring flaky tests (fix the root cause immediately)
97
+ - Testing only the happy path
@@ -1 +1,2 @@
1
1
  DATABASE_URL="postgresql+asyncpg://postgres:postgres@localhost:5432/{{PROJECT_NAME_SNAKE}}"
2
+ JWT_SECRET_KEY="change-me-generate-a-random-secret"
@@ -1,16 +0,0 @@
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
@@ -1,14 +0,0 @@
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
@@ -1,14 +0,0 @@
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
@@ -1,21 +0,0 @@
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