codecruise 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 (129) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +111 -0
  3. package/bin/codecruise.js +68 -0
  4. package/config/CLAUDE.md +107 -0
  5. package/config/agents/analyst.md +48 -0
  6. package/config/agents/architect-reviewer.md +161 -0
  7. package/config/agents/architect.md +119 -0
  8. package/config/agents/critic.md +63 -0
  9. package/config/agents/developer.md +96 -0
  10. package/config/agents/devops.md +81 -0
  11. package/config/agents/orchestrator.md +91 -0
  12. package/config/agents/planner.md +139 -0
  13. package/config/agents/retro.md +52 -0
  14. package/config/agents/reviewer.md +101 -0
  15. package/config/agents/security-reviewer.md +57 -0
  16. package/config/agents/stack/expo/AGENT.md +473 -0
  17. package/config/agents/stack/expo/rules/critical.md +427 -0
  18. package/config/agents/stack/expo/rules/native.md +455 -0
  19. package/config/agents/stack/expo/rules/navigation.md +445 -0
  20. package/config/agents/stack/expo/rules/performance.md +415 -0
  21. package/config/agents/stack/fastify/AGENT.md +397 -0
  22. package/config/agents/stack/fastify/rules/api-design.md +283 -0
  23. package/config/agents/stack/fastify/rules/critical.md +232 -0
  24. package/config/agents/stack/fastify/rules/queues.md +303 -0
  25. package/config/agents/stack/fastify/rules/security.md +384 -0
  26. package/config/agents/stack/index.yaml +48 -0
  27. package/config/agents/stack/nextjs/AGENT.md +421 -0
  28. package/config/agents/stack/nextjs/rules/components.md +413 -0
  29. package/config/agents/stack/nextjs/rules/critical.md +391 -0
  30. package/config/agents/stack/nextjs/rules/performance.md +403 -0
  31. package/config/agents/stack/nextjs/rules/styling.md +334 -0
  32. package/config/agents/stack/shared-ts/AGENT.md +384 -0
  33. package/config/agents/stack/shared-ts/rules/critical.md +315 -0
  34. package/config/agents/stack/shared-ts/rules/patterns.md +384 -0
  35. package/config/agents/stack/shared-ts/rules/zod.md +427 -0
  36. package/config/agents/tester.md +79 -0
  37. package/config/commands/architect-discuss.md +366 -0
  38. package/config/commands/architect-list.md +160 -0
  39. package/config/commands/architect-review.md +111 -0
  40. package/config/commands/architect.md +118 -0
  41. package/config/commands/compact.md +118 -0
  42. package/config/commands/companion.md +279 -0
  43. package/config/commands/dashboard.md +152 -0
  44. package/config/commands/doctor.md +227 -0
  45. package/config/commands/dogfood-report.md +101 -0
  46. package/config/commands/flags/run-autonomous.md +110 -0
  47. package/config/commands/flags/run-pause.md +80 -0
  48. package/config/commands/ingest.md +173 -0
  49. package/config/commands/init.md +128 -0
  50. package/config/commands/metrics.md +87 -0
  51. package/config/commands/parallel.md +320 -0
  52. package/config/commands/pause.md +55 -0
  53. package/config/commands/plan-review.md +130 -0
  54. package/config/commands/plan.md +216 -0
  55. package/config/commands/production-check.md +308 -0
  56. package/config/commands/refine.md +323 -0
  57. package/config/commands/resume.md +72 -0
  58. package/config/commands/retro.md +121 -0
  59. package/config/commands/retry.md +75 -0
  60. package/config/commands/role.md +310 -0
  61. package/config/commands/run.md +417 -0
  62. package/config/commands/scope.md +85 -0
  63. package/config/commands/setup-permissions.md +104 -0
  64. package/config/commands/skip.md +75 -0
  65. package/config/commands/spec-forge.md +213 -0
  66. package/config/commands/spec-help.md +194 -0
  67. package/config/commands/spec-patch.md +342 -0
  68. package/config/commands/spec-resolve.md +110 -0
  69. package/config/commands/spec-review.md +153 -0
  70. package/config/commands/status.md +114 -0
  71. package/config/commands/sync.md +131 -0
  72. package/config/commands/task.md +138 -0
  73. package/config/commands/verify.md +124 -0
  74. package/config/hooks/README.md +632 -0
  75. package/config/hooks/activity-log.sh +187 -0
  76. package/config/hooks/anti-rationalize.sh +52 -0
  77. package/config/hooks/capture-verification.sh +112 -0
  78. package/config/hooks/collect-metrics.sh +135 -0
  79. package/config/hooks/enforce-file-scope.sh +75 -0
  80. package/config/hooks/enforce-state-machine.sh +161 -0
  81. package/config/hooks/enforce-tdd.sh +180 -0
  82. package/config/hooks/format.sh +40 -0
  83. package/config/hooks/lib/activity-helpers.sh +162 -0
  84. package/config/hooks/lib/read-settings.sh +71 -0
  85. package/config/hooks/load-context-skills.sh +95 -0
  86. package/config/hooks/notify.sh +81 -0
  87. package/config/hooks/pre-commit.sample +35 -0
  88. package/config/hooks/protect-files.sh +63 -0
  89. package/config/hooks/track-agents.sh +41 -0
  90. package/config/hooks/track-commands.sh +37 -0
  91. package/config/hooks/track-enforcement.sh +44 -0
  92. package/config/hooks/track-ooda.sh +77 -0
  93. package/config/hooks/validate-commit-msg.sh +35 -0
  94. package/config/hooks/validate-plan.sh +213 -0
  95. package/config/hooks/verify-criteria.sh +46 -0
  96. package/config/hooks/verify-todo-completion.sh +140 -0
  97. package/config/rules/comments.md +25 -0
  98. package/config/rules/decision-rules.md +308 -0
  99. package/config/rules/hygiene.md +247 -0
  100. package/config/rules/pattern-detection.md +372 -0
  101. package/config/rules/profiles.md +193 -0
  102. package/config/rules/recovery.md +83 -0
  103. package/config/rules/scope-detection.md +213 -0
  104. package/config/rules/standards.md +127 -0
  105. package/config/rules/workflow.md +121 -0
  106. package/config/schemas.md +767 -0
  107. package/config/settings.json +195 -0
  108. package/config/skills/backend/SKILL.md +734 -0
  109. package/config/skills/database/SKILL.md +426 -0
  110. package/config/skills/frontend/SKILL.md +434 -0
  111. package/config/skills/git/SKILL.md +396 -0
  112. package/config/skills/index.yaml +36 -0
  113. package/config/skills/observability/SKILL.md +430 -0
  114. package/config/skills/package-dev/SKILL.md +498 -0
  115. package/config/skills/performance/SKILL.md +378 -0
  116. package/config/skills/resilience/SKILL.md +573 -0
  117. package/config/skills/testing/SKILL.md +398 -0
  118. package/config/skills/testing-patterns/SKILL.md +276 -0
  119. package/config/skills/typescript/SKILL.md +152 -0
  120. package/config/templates/CLAUDE.md +70 -0
  121. package/config/templates/README.md +117 -0
  122. package/config/templates/steering/adr-template.md +102 -0
  123. package/config/templates/steering/product.md +60 -0
  124. package/config/templates/steering/rfc-template.md +159 -0
  125. package/config/templates/steering/structure.md +146 -0
  126. package/config/templates/steering/tech.md +85 -0
  127. package/package.json +40 -0
  128. package/src/install.js +163 -0
  129. package/src/report.js +310 -0
@@ -0,0 +1,130 @@
1
+ ---
2
+ name: plan-review
3
+ description: Validate roadmap plans for correctness, completeness, and quality
4
+ model: sonnet
5
+ tools: Read, Glob, Grep
6
+ ---
7
+
8
+ # /plan-review — Plan Validation
9
+
10
+ Validate roadmap plans for structure, quality, traceability, and risks.
11
+
12
+ ## Usage
13
+
14
+ ```bash
15
+ /plan-review # Review all plans
16
+ /plan-review phase-01 # Review specific phase
17
+ /plan-review --quick # Structural checks only
18
+ /plan-review --strict # Fail on warnings
19
+ /plan-review --coverage # Focus on spec coverage
20
+ /plan-review --fix # Auto-fix minor issues
21
+ ```
22
+
23
+ ## Validation Categories
24
+
25
+ ### Structural (Error severity)
26
+
27
+ | Check | Description |
28
+ |-------|-------------|
29
+ | YAML_SYNTAX | Valid YAML |
30
+ | REQUIRED_FIELDS | id, description, status, files, criteria |
31
+ | UNIQUE_IDS | No duplicate IDs |
32
+ | VALID_REFERENCES | depends_on points to existing TODOs |
33
+ | NO_CIRCULAR_DEPS | Acyclic dependency graph |
34
+ | VALID_STATUS | pending, in_progress, done, blocked |
35
+
36
+ ### Quality (Warning severity)
37
+
38
+ | Check | Description |
39
+ |-------|-------------|
40
+ | TESTABLE_CRITERIA | Can be objectively verified |
41
+ | REASONABLE_SCOPE | 1-5 files per TODO |
42
+ | CRITERIA_COUNT | 1-10 criteria |
43
+ | NO_VAGUE_WORDS | No "properly", "correctly", "good" |
44
+ | HAS_TESTS_FIELD | tests field present (recommended) |
45
+
46
+ ### Traceability (Warning severity)
47
+
48
+ | Check | Description |
49
+ |-------|-------------|
50
+ | FR_COVERAGE | All FR-XXX have TODOs |
51
+ | NFR_COVERAGE | Non-functional requirements addressed |
52
+ | ADR_ALIGNMENT | TODOs don't contradict decisions |
53
+ | NO_ORPHAN_TODOS | Every TODO belongs to a feature |
54
+
55
+ ### Risk Detection (Info severity)
56
+
57
+ | Check | Description |
58
+ |-------|-------------|
59
+ | LARGE_TODO | >5 files or >10 criteria |
60
+ | LONG_DEP_CHAIN | Dependency chain >5 deep |
61
+ | SECURITY_TODO | Contains auth/token/secret keywords |
62
+ | MANY_DEPENDENTS | >5 TODOs depend on this one |
63
+
64
+ ### Completeness (Error severity)
65
+
66
+ | Check | Description |
67
+ |-------|-------------|
68
+ | PHASE_HAS_FEATURES | No empty phases |
69
+ | FEATURE_HAS_TODOS | No empty features |
70
+ | FEATURE_HAS_BRANCH | Branch specified |
71
+ | TODO_HAS_FILES | Files specified |
72
+
73
+ ## Auto-Fix (`--fix`)
74
+
75
+ | Issue | Action |
76
+ |-------|--------|
77
+ | Missing `status` | Set to `pending` |
78
+ | Missing `depends_on` | Set to `[]` |
79
+ | Missing `owner` | Set to `dev` |
80
+ | Missing `tests` | Add `tests: []` |
81
+ | Inconsistent indentation | Normalize |
82
+
83
+ **Cannot auto-fix**: Missing criteria, vague descriptions, circular deps
84
+
85
+ ## Output Summary
86
+
87
+ ```
88
+ STRUCTURAL: ✓ PASS
89
+ QUALITY: ⚠ 3 WARNINGS
90
+ ⚠ todo-1.3a-005: missing 'tests' field
91
+ ⚠ todo-1.8b-003: vague criteria "works correctly"
92
+ TRACEABILITY: ⚠ 1 WARNING
93
+ ⚠ Missing: FR-046, FR-047
94
+ RISK: ⚠ 2 FLAGS
95
+ ⚠ SECURITY: todo-1.6a-008 (JWT handling)
96
+ COMPLETENESS: ✓ PASS
97
+
98
+ Result: ⚠ PASS WITH WARNINGS
99
+ Errors: 0 | Warnings: 6
100
+
101
+ Actions:
102
+ 1. Add 'tests' field to todo-1.3a-005
103
+ 2. Clarify criteria in todo-1.8b-003
104
+ 3. Add TODOs for FR-046, FR-047
105
+ ```
106
+
107
+ ## Exit Codes
108
+
109
+ | Code | Meaning |
110
+ |------|---------|
111
+ | 0 | Pass |
112
+ | 1 | Pass with warnings |
113
+ | 2 | Fail (errors) |
114
+ | 3 | Cannot run (missing files) |
115
+
116
+ ## Quick Mode
117
+
118
+ Structural checks only, fast pre-flight for /run:
119
+
120
+ ```
121
+ STRUCTURAL: ✓ PASS
122
+ ✓ YAML valid | ✓ Fields OK | ✓ IDs unique | ✓ Deps valid
123
+ ```
124
+
125
+ ## Quality Bar
126
+
127
+ - Validates all files in <5 seconds
128
+ - Clear, actionable output
129
+ - Specific line numbers for issues
130
+ - No false positives on structural checks
@@ -0,0 +1,216 @@
1
+ ---
2
+ name: plan
3
+ description: Create or update project roadmap with phases, features, and TODOs
4
+ disable-model-invocation: true
5
+ tools: Read, Write, Glob, Grep, Bash
6
+ model: sonnet
7
+ ---
8
+
9
+ # /plan Command
10
+
11
+ Create or update the project roadmap.
12
+
13
+ ## Usage
14
+
15
+ ```
16
+ /plan # Create full roadmap from EDD
17
+ /plan "auth feature" # Plan specific feature only
18
+ /plan --phase 2 # Plan specific phase
19
+ /plan --from-edd docs/arch/edd.md # Specify EDD source
20
+ ```
21
+
22
+ ### Arguments
23
+
24
+ | Argument | Description | Example |
25
+ |----------|-------------|---------|
26
+ | (positional) | Feature or phase to plan | `/plan "user authentication"` |
27
+ | `--phase` | Plan specific phase number | `/plan --phase 2` |
28
+ | `--from-edd` | Specify EDD file path | `/plan --from-edd docs/architecture/edd-auth.md` |
29
+ | `--todos-only` | Generate TODOs only (skip phase/feature) | `/plan "login" --todos-only` |
30
+ | `--max-todos` | Max TODOs per feature (default 8) | `/plan --max-todos 6` |
31
+
32
+ ### Examples
33
+
34
+ ```bash
35
+ # Full roadmap from EDD
36
+ /plan
37
+
38
+ # Plan specific feature with TODO breakdown
39
+ /plan "payment processing"
40
+
41
+ # Plan phase 2 only
42
+ /plan --phase 2
43
+
44
+ # Quick TODO breakdown for small feature
45
+ /plan "add logout button" --todos-only
46
+ ```
47
+
48
+ ## Read First
49
+
50
+ 1. `~/.claude/rules/workflow.md`
51
+ 2. Project `CLAUDE.md` for tech stack and context
52
+
53
+ ## Process
54
+
55
+ ### 1. Gather Context
56
+
57
+ Use Explore subagent to:
58
+ - Read project `CLAUDE.md`
59
+ - Scan existing `roadmap/` if present
60
+ - Understand codebase structure
61
+ - Identify current state from `progress.yaml`
62
+ - Read `docs/context/*.yaml` if exists (feature constraints, decisions)
63
+ - Read `docs/canon/spec.md` if exists (requirements)
64
+
65
+ ### 2. If No Roadmap Exists
66
+
67
+ Create initial structure:
68
+
69
+ ```bash
70
+ mkdir -p roadmap dashboard
71
+ touch progress.yaml
72
+ ```
73
+
74
+ ### 3. Discuss with User
75
+
76
+ Ask clarifying questions:
77
+ - What is the project goal?
78
+ - What are the major phases?
79
+ - Any existing work to incorporate?
80
+ - Timeline constraints?
81
+
82
+ ### 4. Create Roadmap
83
+
84
+ For each phase, create `roadmap/phase-NN.md`:
85
+
86
+ ```markdown
87
+ # Phase N: {Name}
88
+
89
+ ## Metadata
90
+ \`\`\`yaml
91
+ id: phase-NN
92
+ status: pending
93
+ started: null
94
+ completed: null
95
+ \`\`\`
96
+
97
+ ## Requirements
98
+ - {requirement 1}
99
+ - {requirement 2}
100
+
101
+ ---
102
+
103
+ ## feature-N.1: {Name}
104
+
105
+ \`\`\`yaml
106
+ id: feature-N.1
107
+ branch: feature/{slug}
108
+ status: pending
109
+ \`\`\`
110
+
111
+ ### Requirements
112
+ - {requirement}
113
+
114
+ ### Todos
115
+
116
+ ```yaml
117
+ todos:
118
+ - id: todo-001
119
+ description: {description}
120
+ owner: dev
121
+ status: pending
122
+ files:
123
+ - {file}
124
+ criteria:
125
+ - {acceptance criterion}
126
+ constraints: # From docs/context/{feature}.yaml
127
+ - {constraint 1}
128
+ - {constraint 2}
129
+ depends_on: []
130
+ ```
131
+
132
+ **Note:** If `docs/context/{feature}.yaml` exists, include relevant constraints in each TODO to ensure implementation honors documented decisions.
133
+ ```
134
+
135
+ ### 5. Create Project Metadata
136
+
137
+ Create `roadmap/project.yaml`:
138
+
139
+ ```yaml
140
+ name: {Project Name}
141
+ description: {One-liner}
142
+
143
+ tech_stack:
144
+ language: {e.g., TypeScript}
145
+ framework: {e.g., Next.js 15}
146
+ database: {e.g., PostgreSQL}
147
+ testing: {e.g., Vitest + Playwright}
148
+
149
+ branch_strategy:
150
+ main: main
151
+ feature_prefix: feature/
152
+
153
+ phases:
154
+ - id: phase-01
155
+ name: {Phase Name}
156
+ status: pending
157
+ ```
158
+
159
+ ### 6. Initialize Progress
160
+
161
+ Create `progress.yaml`:
162
+
163
+ ```yaml
164
+ project: {name}
165
+ generated: {ISO timestamp}
166
+
167
+ current_phase: phase-01
168
+ current_feature: null
169
+ current_todo: null
170
+
171
+ active_todos: []
172
+
173
+ stats:
174
+ total_phases: {N}
175
+ completed_phases: 0
176
+ total_features: {N}
177
+ completed_features: 0
178
+ total_todos: {N}
179
+ completed_todos: 0
180
+ percent_complete: 0
181
+
182
+ blocked: []
183
+ last_updated: {ISO timestamp}
184
+ ```
185
+
186
+ ### 7. Generate Dashboard
187
+
188
+ Run `/dashboard` to create visual progress view.
189
+
190
+ ## Feature Decomposition
191
+
192
+ For complex features, invoke the planner agent:
193
+
194
+ ```
195
+ Use the planner agent to break down {feature} into TODOs
196
+ ```
197
+
198
+ The planner follows TODO format from `~/.claude/rules/workflow.md`.
199
+
200
+ ## Output
201
+
202
+ ```
203
+ ✓ Roadmap created
204
+
205
+ Phases: {N}
206
+ Features: {N}
207
+ TODOs: {N}
208
+
209
+ Files created:
210
+ - roadmap/project.yaml
211
+ - roadmap/phase-01.md
212
+ - progress.yaml
213
+ - dashboard/dashboard.md
214
+
215
+ Next: Run /task to start first TODO
216
+ ```
@@ -0,0 +1,308 @@
1
+ ---
2
+ name: production-check
3
+ description: Comprehensive production readiness audit before deployment
4
+ tools: Read, Glob, Grep, Bash
5
+ model: opus
6
+ ---
7
+
8
+ # /production-check — Production Readiness Audit
9
+
10
+ ## Goal
11
+
12
+ Validate that the codebase is production-ready across all quality dimensions before deployment.
13
+
14
+ ## Usage
15
+
16
+ ```
17
+ /production-check # Full audit
18
+ /production-check --section security # Specific section
19
+ /production-check --quick # Fast checks only (no deep analysis)
20
+ ```
21
+
22
+ ## Process
23
+
24
+ ### 1. Gather Context
25
+
26
+ Read project configuration:
27
+ - `package.json` — dependencies, scripts
28
+ - `tsconfig.json` — TypeScript config
29
+ - `.env.example` — required environment variables
30
+ - `CLAUDE.md` — project context
31
+
32
+ ### 2. Run Automated Checks
33
+
34
+ ```bash
35
+ # Type safety
36
+ npm run typecheck
37
+
38
+ # Linting
39
+ npm run lint
40
+
41
+ # Tests with coverage
42
+ npm run test:coverage
43
+
44
+ # Security audit
45
+ npm audit --audit-level=high
46
+ ```
47
+
48
+ ### 3. Manual Audit Checklist
49
+
50
+ #### Security (Weight: Critical)
51
+
52
+ | Check | Command/Method | Pass Criteria |
53
+ |-------|----------------|---------------|
54
+ | No secrets in code | `grep -r "API_KEY\|SECRET\|PASSWORD" --include="*.ts"` | No matches in source |
55
+ | Auth on protected routes | Manual review | All /api/* routes have auth middleware |
56
+ | Input validation | Check controllers | Zod schemas at all boundaries |
57
+ | SQL injection | Check queries | All queries parameterized |
58
+ | XSS prevention | Check responses | Output encoding present |
59
+ | Rate limiting | Check middleware | Configured on /auth, /api |
60
+ | CORS | Check config | Specific origins, not `*` |
61
+ | Security headers | Check middleware | CSP, X-Frame-Options, etc. |
62
+ | Dependencies | `npm audit` | No high/critical vulnerabilities |
63
+
64
+ #### Type Safety (Weight: High)
65
+
66
+ | Check | Command/Method | Pass Criteria |
67
+ |-------|----------------|---------------|
68
+ | Strict mode | Check tsconfig.json | `strict: true` |
69
+ | No `any` types | `grep -r ": any" --include="*.ts"` | Zero matches |
70
+ | Explicit returns | Manual review | All exports have return types |
71
+ | Zod validation | Check API routes | All inputs validated |
72
+ | AppError hierarchy | Check error handling | Custom errors used |
73
+
74
+ #### Performance (Weight: High)
75
+
76
+ | Check | Command/Method | Pass Criteria |
77
+ |-------|----------------|---------------|
78
+ | N+1 queries | Check DB calls | All use includes/joins |
79
+ | Database indexes | Check schema | FKs and filters indexed |
80
+ | Pagination | Check list endpoints | Cursor pagination used |
81
+ | Caching | Check hot paths | Cache strategy documented |
82
+ | Bundle size | `npm run build && ls -la dist` | Within budget |
83
+
84
+ #### Resilience (Weight: High)
85
+
86
+ | Check | Command/Method | Pass Criteria |
87
+ |-------|----------------|---------------|
88
+ | Error handling | Check async functions | All have try/catch |
89
+ | Circuit breakers | Check external calls | Pattern implemented |
90
+ | Timeouts | Check HTTP clients | All configured |
91
+ | Retry logic | Check critical paths | Exponential backoff |
92
+ | Graceful shutdown | Check server setup | SIGTERM handled |
93
+ | Health endpoints | Check routes | /health, /health/ready exist |
94
+
95
+ #### Observability (Weight: Medium)
96
+
97
+ | Check | Command/Method | Pass Criteria |
98
+ |-------|----------------|---------------|
99
+ | Structured logging | `grep -r "console.log" --include="*.ts"` | Zero in src/ |
100
+ | Correlation IDs | Check middleware | Propagated on all requests |
101
+ | PII redaction | Check logger | Sensitive fields redacted |
102
+ | Metrics | Check instrumentation | Key paths tracked |
103
+ | Error tracking | Check config | Sentry/similar configured |
104
+
105
+ #### Testing (Weight: High)
106
+
107
+ | Check | Command/Method | Pass Criteria |
108
+ |-------|----------------|---------------|
109
+ | Unit tests | Check coverage | > 80% for business logic |
110
+ | Integration tests | Check test files | API endpoints covered |
111
+ | E2E tests | Check playwright/cypress | Critical flows covered |
112
+ | Test determinism | Run tests 3x | All pass consistently |
113
+
114
+ #### Documentation (Weight: Medium)
115
+
116
+ | Check | Command/Method | Pass Criteria |
117
+ |-------|----------------|---------------|
118
+ | README | Check README.md | Setup, usage documented |
119
+ | API docs | Check /docs or OpenAPI | All endpoints documented |
120
+ | Environment | Check .env.example | All required vars listed |
121
+ | Architecture | Check docs/ | Key decisions documented |
122
+
123
+ #### Infrastructure (Weight: Medium)
124
+
125
+ | Check | Command/Method | Pass Criteria |
126
+ |-------|----------------|---------------|
127
+ | Docker | Check Dockerfile | Multi-stage, non-root user |
128
+ | CI/CD | Check .github/workflows | Build, test, deploy stages |
129
+ | Database migrations | Check migrations | Idempotent, reversible |
130
+ | Feature flags | Check config | Risky features flagged |
131
+ | Rollback plan | Check docs | Documented procedure |
132
+
133
+ ### 4. Calculate Score
134
+
135
+ ```typescript
136
+ interface AuditResult {
137
+ section: string;
138
+ weight: 'critical' | 'high' | 'medium';
139
+ score: number; // 0-10
140
+ issues: Issue[];
141
+ }
142
+
143
+ const weights = {
144
+ critical: 2.0,
145
+ high: 1.5,
146
+ medium: 1.0,
147
+ };
148
+
149
+ function calculateGrade(results: AuditResult[]): Grade {
150
+ let totalWeight = 0;
151
+ let weightedScore = 0;
152
+
153
+ for (const result of results) {
154
+ const weight = weights[result.weight];
155
+ totalWeight += weight;
156
+ weightedScore += result.score * weight;
157
+ }
158
+
159
+ const score = weightedScore / totalWeight;
160
+
161
+ if (score >= 9.0) return 'A';
162
+ if (score >= 8.0) return 'B';
163
+ if (score >= 7.0) return 'C';
164
+ if (score >= 6.0) return 'D';
165
+ return 'F';
166
+ }
167
+ ```
168
+
169
+ ### 5. Generate Report
170
+
171
+ ## Output Format
172
+
173
+ ```markdown
174
+ # Production Readiness Report
175
+
176
+ **Project**: {name}
177
+ **Date**: {ISO timestamp}
178
+ **Auditor**: /production-check
179
+
180
+ ## Executive Summary
181
+
182
+ **Grade**: B (7.8/10)
183
+ **Verdict**: ⚠️ READY WITH CAVEATS
184
+
185
+ | Section | Score | Status |
186
+ |---------|-------|--------|
187
+ | Security | 8/10 | ⚠️ |
188
+ | Type Safety | 9/10 | ✓ |
189
+ | Performance | 7/10 | ⚠️ |
190
+ | Resilience | 6/10 | ✗ |
191
+ | Observability | 8/10 | ✓ |
192
+ | Testing | 8/10 | ✓ |
193
+ | Documentation | 7/10 | ⚠️ |
194
+ | Infrastructure | 8/10 | ✓ |
195
+
196
+ ## Blockers (Must Fix Before Deploy)
197
+
198
+ 1. **No circuit breaker on payment API**
199
+ - File: `src/services/payment.ts`
200
+ - Risk: Cascading failure if Stripe is down
201
+ - Fix: Implement circuit breaker pattern
202
+
203
+ 2. **Missing rate limiting on /auth endpoints**
204
+ - File: `src/routes/auth.ts`
205
+ - Risk: Brute force attacks
206
+ - Fix: Add rate limiter middleware
207
+
208
+ ## Warnings (Should Fix Soon)
209
+
210
+ 1. **Test coverage at 75%**
211
+ - Missing: Error handling paths
212
+ - Recommendation: Add tests for edge cases
213
+
214
+ 2. **No graceful shutdown**
215
+ - Risk: Dropped requests during deploy
216
+ - Fix: Handle SIGTERM, drain connections
217
+
218
+ ## Passed Checks ✓
219
+
220
+ - No secrets in code
221
+ - All inputs validated with Zod
222
+ - Strict TypeScript mode enabled
223
+ - No `any` types found
224
+ - All queries parameterized
225
+ - Health endpoints present
226
+ - Structured logging configured
227
+ - CI/CD pipeline complete
228
+
229
+ ## Recommendations
230
+
231
+ ### Before Deploy
232
+ 1. Add circuit breaker to payment service
233
+ 2. Configure rate limiting on auth endpoints
234
+
235
+ ### Post-Deploy
236
+ 1. Monitor error rates for 24h
237
+ 2. Verify all health checks pass
238
+ 3. Test rollback procedure
239
+
240
+ ### Next Sprint
241
+ 1. Increase test coverage to 85%
242
+ 2. Add E2E tests for checkout flow
243
+ 3. Document API with OpenAPI
244
+
245
+ ---
246
+
247
+ ## Quick Checklist (Print & Sign Off)
248
+
249
+ ### Security
250
+ - [ ] No secrets in code
251
+ - [ ] Auth on all protected routes
252
+ - [ ] Input validation everywhere
253
+ - [ ] Rate limiting configured
254
+ - [ ] CORS restricted
255
+ - [ ] Dependencies audited
256
+
257
+ ### Reliability
258
+ - [ ] Circuit breakers on external calls
259
+ - [ ] Timeouts configured
260
+ - [ ] Graceful shutdown implemented
261
+ - [ ] Health check endpoints exist
262
+
263
+ ### Observability
264
+ - [ ] Structured logging (no console.log)
265
+ - [ ] Correlation IDs propagated
266
+ - [ ] Error tracking configured
267
+
268
+ ### Quality
269
+ - [ ] No `any` types
270
+ - [ ] Test coverage > 80%
271
+ - [ ] TypeScript strict mode
272
+
273
+ ### Infrastructure
274
+ - [ ] CI/CD passes
275
+ - [ ] Migrations tested
276
+ - [ ] Rollback plan documented
277
+
278
+ **Sign-off**: _________________ **Date**: _________________
279
+ ```
280
+
281
+ ## Grading Criteria
282
+
283
+ | Grade | Score | Meaning | Action |
284
+ |-------|-------|---------|--------|
285
+ | A | 9.0+ | Excellent | Ship it |
286
+ | B | 8.0-8.9 | Good | Ship with monitoring |
287
+ | C | 7.0-7.9 | Acceptable | Fix warnings, then ship |
288
+ | D | 6.0-6.9 | Poor | Fix blockers first |
289
+ | F | < 6.0 | Failing | Major rework needed |
290
+
291
+ **Minimum to deploy: C (7.0) with no blockers**
292
+
293
+ ## Terminal Output
294
+
295
+ ```
296
+ ✓ Production readiness audit complete
297
+
298
+ Grade: B (7.8/10)
299
+ Verdict: READY WITH CAVEATS
300
+
301
+ Blockers: 2 (must fix)
302
+ Warnings: 4 (should fix)
303
+ Passed: 18 checks
304
+
305
+ Report: docs/production-audit.md
306
+
307
+ Next: Fix blockers, then deploy
308
+ ```