ai-core-framework 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 (103) hide show
  1. package/.claude-plugin/plugin.json +21 -0
  2. package/.codex-plugin/plugin.json +35 -0
  3. package/.cursor-plugin/plugin.json +22 -0
  4. package/README.md +173 -0
  5. package/bin/ai-core-framework.js +110 -0
  6. package/core/README.md +162 -0
  7. package/core/agents/README.md +32 -0
  8. package/core/agents/business-analyst.md +269 -0
  9. package/core/agents/developer.md +375 -0
  10. package/core/agents/qa-tester.md +477 -0
  11. package/core/agents/scrum-master.md +136 -0
  12. package/core/agents/tech-lead.md +345 -0
  13. package/core/config/backlog.schema.json +38 -0
  14. package/core/config/docs-policy.default.json +37 -0
  15. package/core/config/release.schema.json +120 -0
  16. package/core/config/ticket.schema.json +253 -0
  17. package/core/rules/00-global-rules.md +373 -0
  18. package/core/rules/01-git-workflow.md +388 -0
  19. package/core/rules/02-code-quality.md +77 -0
  20. package/core/rules/03-security.md +78 -0
  21. package/core/rules/04-documentation.md +72 -0
  22. package/core/rules/05-testing-mandatory.md +374 -0
  23. package/core/rules/06-approval-gates.md +388 -0
  24. package/core/rules/07-definition-of-ready.md +112 -0
  25. package/core/rules/08-definition-of-done.md +149 -0
  26. package/core/scripts/ai-core.sh +456 -0
  27. package/core/scripts/generate-views.sh +210 -0
  28. package/core/scripts/install-codex-prompts.sh +127 -0
  29. package/core/scripts/log-user-request.sh +113 -0
  30. package/core/scripts/setup-project.sh +183 -0
  31. package/core/scripts/sync-platforms.sh +322 -0
  32. package/core/scripts/validate-audit-log.sh +73 -0
  33. package/core/scripts/validate-docs.sh +365 -0
  34. package/core/scripts/validate-permissions.sh +132 -0
  35. package/core/scripts/validate-state.sh +611 -0
  36. package/core/scripts/workflow.sh +513 -0
  37. package/core/skills/README.md +21 -0
  38. package/core/skills/ai-core-commands/SKILL.md +86 -0
  39. package/core/skills/brainstorming/SKILL.md +40 -0
  40. package/core/skills/development-implement-task/SKILL.md +308 -0
  41. package/core/skills/executing-ticket/SKILL.md +28 -0
  42. package/core/skills/git-branch-status/SKILL.md +56 -0
  43. package/core/skills/git-cleanup-branches/SKILL.md +57 -0
  44. package/core/skills/git-scan-untracked/SKILL.md +50 -0
  45. package/core/skills/meta-generate-views/SKILL.md +54 -0
  46. package/core/skills/meta-request-log/SKILL.md +61 -0
  47. package/core/skills/meta-sprint-report/SKILL.md +59 -0
  48. package/core/skills/meta-sync-platforms/SKILL.md +53 -0
  49. package/core/skills/meta-ticket-health/SKILL.md +61 -0
  50. package/core/skills/meta-validate-audit-log/SKILL.md +42 -0
  51. package/core/skills/meta-validate-docs/SKILL.md +58 -0
  52. package/core/skills/meta-validate-permissions/SKILL.md +53 -0
  53. package/core/skills/meta-validate-state/SKILL.md +58 -0
  54. package/core/skills/planning-analyze-requirements/SKILL.md +471 -0
  55. package/core/skills/planning-backlog-status/SKILL.md +57 -0
  56. package/core/skills/planning-document-existing-requirements/SKILL.md +246 -0
  57. package/core/skills/planning-estimate-task/SKILL.md +60 -0
  58. package/core/skills/planning-groom-ticket/SKILL.md +442 -0
  59. package/core/skills/planning-mark-ready/SKILL.md +111 -0
  60. package/core/skills/planning-plan-refactor/SKILL.md +66 -0
  61. package/core/skills/planning-plan-sprint/SKILL.md +112 -0
  62. package/core/skills/planning-prioritize-backlog/SKILL.md +62 -0
  63. package/core/skills/planning-write-plan/SKILL.md +68 -0
  64. package/core/skills/project-detect-stack/SKILL.md +71 -0
  65. package/core/skills/project-discover-codebase/SKILL.md +74 -0
  66. package/core/skills/project-setup-project/SKILL.md +113 -0
  67. package/core/skills/qa-bug-status/SKILL.md +52 -0
  68. package/core/skills/qa-report-bug/SKILL.md +518 -0
  69. package/core/skills/qa-smoke-test/SKILL.md +387 -0
  70. package/core/skills/qa-triage-bug/SKILL.md +62 -0
  71. package/core/skills/qa-verify-fix/SKILL.md +446 -0
  72. package/core/skills/release-hotfix/SKILL.md +117 -0
  73. package/core/skills/release-release/SKILL.md +123 -0
  74. package/core/skills/release-rollback/SKILL.md +62 -0
  75. package/core/skills/review-create-pr/SKILL.md +418 -0
  76. package/core/skills/review-merge-pr/SKILL.md +425 -0
  77. package/core/skills/review-techlead-review/SKILL.md +547 -0
  78. package/core/skills/using-ai-core/SKILL.md +72 -0
  79. package/core/skills/verification-before-done/SKILL.md +35 -0
  80. package/core/skills/writing-implementation-plan/SKILL.md +45 -0
  81. package/core/templates/ci/ai-core-governance.yml +112 -0
  82. package/core/templates/ci/node-pnpm.yml +35 -0
  83. package/core/templates/pm/retrospective-template.md +47 -0
  84. package/core/templates/pm/sprint-plan-template.md +45 -0
  85. package/core/templates/pr/pull-request-template.md +247 -0
  86. package/core/templates/project/CODEOWNERS +11 -0
  87. package/core/templates/project/docs-policy.json +3 -0
  88. package/core/templates/project/project-config.yaml +137 -0
  89. package/core/templates/project/project-structure.yaml +76 -0
  90. package/core/templates/qa/bug-report-template.md +371 -0
  91. package/core/templates/qa/test-plan-template.md +57 -0
  92. package/core/templates/release/release-record-template.json +67 -0
  93. package/core/templates/requirements/PRD-template.md +58 -0
  94. package/core/templates/requirements/user-story-template.md +381 -0
  95. package/core/templates/technical/ADR-template.md +46 -0
  96. package/core/templates/technical/refactor-plan-template.md +84 -0
  97. package/core/templates/technical/tech-design-template.md +71 -0
  98. package/core/workflows/bug-lifecycle.md +56 -0
  99. package/core/workflows/feature-lifecycle.md +347 -0
  100. package/core/workflows/hotfix-lifecycle.md +65 -0
  101. package/core/workflows/sprint-lifecycle.md +56 -0
  102. package/lib/install-codex.js +85 -0
  103. package/package.json +36 -0
@@ -0,0 +1,547 @@
1
+ ---
2
+ name: review-techlead-review
3
+ description: Use when the user asks to run /techlead-review, review a pull request as tech lead, assess architecture/security/test risk, or post an approve/comment/changes-requested decision.
4
+ command: /techlead-review
5
+ display_name: "Tech Lead Review"
6
+ version: 1.0.0
7
+ owner_agent: tech-lead
8
+ model_preference: opus # Deep analysis needed
9
+ args:
10
+ - name: pr_number
11
+ required: true
12
+ type: integer
13
+ description: "PR number to review"
14
+ - name: depth
15
+ required: false
16
+ type: string
17
+ default: "full"
18
+ enum: [quick, full, security-focused]
19
+ description: "Review depth"
20
+ preconditions:
21
+ - pr_exists: true
22
+ - pr_open: true
23
+ - pr_not_own: true # Tech lead can't review own PR
24
+ - ci_status: green # Block if CI red
25
+ - ticket_status: IN_REVIEW
26
+ postconditions:
27
+ - review_posted: true
28
+ - review_decision: APPROVED | CHANGES_REQUESTED | COMMENTED
29
+ - owasp_checklist_completed: true
30
+ ---
31
+
32
+ # /techlead-review
33
+
34
+ > Thorough code review by Tech Lead: architecture, security, performance, testing, maintainability.
35
+ > **Gate**: Required approval before `/merge-pr`.
36
+
37
+ ## 🎯 Purpose
38
+
39
+ Ensure code quality meets project standards BEFORE merge. Catch:
40
+ - Architecture violations
41
+ - Security issues (OWASP)
42
+ - Performance regressions
43
+ - Test gaps
44
+ - Maintainability concerns
45
+
46
+ And **teach** developers through review feedback.
47
+
48
+ ## 🚦 Trigger
49
+
50
+ **Manual**:
51
+ ```
52
+ /techlead-review 123 # PR #123, full review
53
+ /techlead-review 123 --depth=quick # Quick skim for minor changes
54
+ /techlead-review 123 --depth=security-focused # For auth/data/payment PRs
55
+ ```
56
+
57
+ **Auto-assignment**: When `/create-pr` runs, tech-lead gets notification. They then invoke this command.
58
+
59
+ ## 📋 Preconditions (STRICT)
60
+
61
+ ### 1. PR exists and open
62
+ ```bash
63
+ gh pr view "$PR_NUMBER" --json state,author | jq -e '.state == "OPEN"' || ABORT
64
+ ```
65
+
66
+ ### 2. PR author != reviewer (no self-review)
67
+ ```bash
68
+ pr_author=$(gh pr view "$PR_NUMBER" --json author --jq .author.login)
69
+ current_user=$(gh api user --jq .login)
70
+ [ "$pr_author" != "$current_user" ] || ABORT "Cannot review own PR (RULE TL-005)"
71
+ ```
72
+
73
+ ### 3. CI status green
74
+ ```bash
75
+ ci_status=$(gh pr checks "$PR_NUMBER" --json status --jq '.[].status')
76
+ [ "$ci_status" = "SUCCESS" ] || ABORT "CI not green. Wait or notify author."
77
+ ```
78
+
79
+ ### 4. Ticket in IN_REVIEW
80
+ Read ticket (from branch name), verify status = IN_REVIEW.
81
+
82
+ ### 5. PR description filled
83
+ Check PR has description using template (not empty / not default).
84
+
85
+ ## 🔄 Execution Flow
86
+
87
+ ```
88
+ ┌──────────────────────────────────────────────────────────┐
89
+ │ STEP 1: Load context │
90
+ │ - PR metadata (title, description, author, branch) │
91
+ │ - Ticket JSON + AC + grooming notes │
92
+ │ - ADRs referenced │
93
+ │ - Related code (imports, callers) │
94
+ │ - Commit history │
95
+ ├──────────────────────────────────────────────────────────┤
96
+ │ STEP 2: Read PR description │
97
+ │ - Does it follow template? │
98
+ │ - Self-review checklist filled? │
99
+ │ - Testing notes present? │
100
+ │ - Screenshots (if UI change)? │
101
+ ├──────────────────────────────────────────────────────────┤
102
+ │ STEP 3: AC Coverage Check │
103
+ │ For each AC scenario in ticket: │
104
+ │ - Find corresponding test │
105
+ │ - Verify test actually validates scenario │
106
+ │ Score: N/N scenarios covered │
107
+ ├──────────────────────────────────────────────────────────┤
108
+ │ STEP 4: Architecture Review │
109
+ │ - Layer separation (UI/logic/data) │
110
+ │ - Consistent with existing patterns │
111
+ │ - ADRs followed │
112
+ │ - No premature abstraction │
113
+ │ - No god classes/functions │
114
+ ├──────────────────────────────────────────────────────────┤
115
+ │ STEP 5: Security Review (OWASP Top 10) │
116
+ │ Go through each relevant item: │
117
+ │ A01 - Access Control │
118
+ │ A02 - Cryptographic Failures │
119
+ │ A03 - Injection │
120
+ │ A04 - Insecure Design │
121
+ │ A05 - Security Misconfiguration │
122
+ │ A06 - Vulnerable Components │
123
+ │ A07 - Identification & Auth Failures │
124
+ │ A08 - Software & Data Integrity │
125
+ │ A09 - Security Logging Failures │
126
+ │ A10 - SSRF │
127
+ │ │
128
+ │ Mark each: ✓ Pass | ⚠ Concern | ✗ Block | N/A │
129
+ ├──────────────────────────────────────────────────────────┤
130
+ │ STEP 6: Performance Review │
131
+ │ - Hot paths: O(N²) or worse? │
132
+ │ - N+1 queries? │
133
+ │ - Unnecessary synchronous blocks? │
134
+ │ - Memory leaks (subscriptions, listeners)? │
135
+ │ - Caching opportunities? │
136
+ │ - Database indexes needed? │
137
+ ├──────────────────────────────────────────────────────────┤
138
+ │ STEP 7: Testing Review │
139
+ │ - Coverage: meets 80% diff threshold? │
140
+ │ - Test quality (see rules/05-testing-mandatory): │
141
+ │ - Descriptive names │
142
+ │ - AAA structure │
143
+ │ - Minimal mocking │
144
+ │ - Edge cases covered │
145
+ │ - Integration tests for integration points? │
146
+ │ - E2E for critical flows? │
147
+ ├──────────────────────────────────────────────────────────┤
148
+ │ STEP 8: Maintainability Review │
149
+ │ - Names clear (not `x`, `tmp`, `data`) │
150
+ │ - Functions < 50 lines? │
151
+ │ - Files < 500 lines? │
152
+ │ - Cyclomatic complexity < 10? │
153
+ │ - DRY (no copy-paste) │
154
+ │ - Comments explain WHY (not WHAT) │
155
+ │ - No magic numbers │
156
+ ├──────────────────────────────────────────────────────────┤
157
+ │ STEP 9: Documentation Review │
158
+ │ - API docs updated (if endpoint changed)? │
159
+ │ - README updated (if setup changed)? │
160
+ │ - CHANGELOG entry added? │
161
+ │ - ADR created (if architecture decision)? │
162
+ │ - Inline docs for complex logic? │
163
+ ├──────────────────────────────────────────────────────────┤
164
+ │ STEP 10: Commit Hygiene │
165
+ │ - Conventional commits format? │
166
+ │ - Atomic commits? │
167
+ │ - TDD flow visible (test commits before feat)? │
168
+ │ - No WIP/debug commits? │
169
+ │ - No secrets in history? │
170
+ ├──────────────────────────────────────────────────────────┤
171
+ │ STEP 11: Compile Review │
172
+ │ - Aggregate findings │
173
+ │ - Categorize: MUST_FIX | SHOULD_FIX | NIT | PRAISE │
174
+ │ - Decide: APPROVED | REQUEST_CHANGES │
175
+ ├──────────────────────────────────────────────────────────┤
176
+ │ STEP 12: Post Review │
177
+ │ - Inline comments on specific lines │
178
+ │ - Summary comment │
179
+ │ - Approve or request changes │
180
+ │ - Update ticket (add review comment) │
181
+ └──────────────────────────────────────────────────────────┘
182
+ ```
183
+
184
+ ## 🔒 Hard Rules
185
+
186
+ ### RULE TR-001: OWASP checklist mandatory
187
+ **MUST** go through ALL 10 OWASP items, even if N/A. Document "N/A" with reason.
188
+
189
+ ### RULE TR-002: MUST_FIX categorization strict
190
+ Only MUST_FIX items block merge. Categorize accurately:
191
+ - **MUST_FIX**: Security issue, bug, broken functionality, policy violation
192
+ - **SHOULD_FIX**: Design/architecture concerns, performance issues (non-critical), testing gaps
193
+ - **NIT**: Style preferences, minor naming, micro-optimizations
194
+ - **PRAISE**: Positive feedback (do this!)
195
+
196
+ **DO NOT** inflate issues to MUST_FIX to force rework. Be fair.
197
+
198
+ ### RULE TR-003: Constructive comments
199
+ Every MUST_FIX / SHOULD_FIX **MUST** include:
200
+ - **Problem**: What's wrong
201
+ - **Why**: Why it matters (impact)
202
+ - **Suggestion**: Specific fix (not just "fix this")
203
+
204
+ ### RULE TR-004: Teach, don't dictate
205
+ When rejecting approach:
206
+ - Explain tradeoffs, not just preferences
207
+ - Reference principles (SOLID, DRY, etc.) or ADRs
208
+ - Acknowledge valid perspectives
209
+ - Invite discussion if uncertain
210
+
211
+ ### RULE TR-005: No approval without OWASP
212
+ Even "simple" PRs require OWASP skim. Document quickly if all N/A.
213
+
214
+ ### RULE TR-006: Performance concerns need evidence
215
+ If flagging performance issue, **SHOULD** provide:
216
+ - Estimated complexity (Big O)
217
+ - Example scenario where it matters
218
+ - Benchmark if available
219
+
220
+ Don't flag "feels slow" without basis.
221
+
222
+ ### RULE TR-007: Test adequacy check
223
+ If diff coverage ≥ 80% but tests are bad quality (tautological, over-mocked), flag it. Coverage number is not sufficient.
224
+
225
+ ### RULE TR-008: Approve only if deployable
226
+ Only approve if would happily deploy to production immediately. "Good enough" is NOT good enough.
227
+
228
+ ### RULE TR-009: Respect developer time
229
+ - Don't re-review full PR on minor fix (spot-check only)
230
+ - Don't change mind arbitrarily (if approved once, don't unapprove for NITs)
231
+ - Respond to re-review requests within 4 hours SLA
232
+
233
+ ### RULE TR-010: Praise publicly, correct kindly
234
+ - Use PRAISE category generously (positive reinforcement)
235
+ - Frame corrections as learning opportunities
236
+ - Assume positive intent from developer
237
+
238
+ ## 📥 Input Examples
239
+
240
+ ```
241
+ /techlead-review 123 # Full review of PR #123
242
+ /techlead-review 123 --depth=quick # Minor typo fix etc.
243
+ /techlead-review 123 --depth=security-focused # Auth/payment PRs
244
+ ```
245
+
246
+ ## 📤 Output Format (Approved)
247
+
248
+ ```markdown
249
+ ## 🔍 Code Review: PR #123 (TICKET-042)
250
+
251
+ **Overall Decision**: ✅ **APPROVED**
252
+
253
+ **PR**: feat(TICKET-042): add password reset via email
254
+ **Author**: @alice
255
+ **Files**: 12 | **+234 / -45**
256
+ **Review depth**: Full
257
+ **Review duration**: 45 min
258
+
259
+ ### Summary
260
+ Solid implementation of password reset flow. TDD followed properly, security considerations addressed, rate limiting well-designed. A few minor NITs but nothing blocking.
261
+
262
+ ### AC Coverage: ✅ 4/4
263
+ - ✅ Scenario 1 (happy path) → `reset-password.test.ts:23`
264
+ - ✅ Scenario 2 (email not exist) → `reset-password.test.ts:67`
265
+ - ✅ Scenario 3 (link expired) → `reset-password.test.ts:104`
266
+ - ✅ Scenario 4 (rate limit) → `rate-limit.test.ts:15`
267
+
268
+ ### Architecture: ✅
269
+ - Follows existing controller/service/repository pattern
270
+ - Middleware pattern consistent with auth middleware
271
+ - Rate limiter properly extracted as reusable utility
272
+ - No layer violations
273
+
274
+ ### Security: ✅ (OWASP Top 10)
275
+ - [x] **A01 Access Control**: Reset token scoped to user ID
276
+ - [x] **A02 Crypto**: crypto.randomBytes(32), bcrypt hashing
277
+ - [x] **A03 Injection**: Parameterized queries throughout
278
+ - [x] **A04 Insecure Design**: Timing-safe comparison, no email enumeration
279
+ - [x] **A05 Misconfig**: N/A (no config changes)
280
+ - [x] **A06 Vulnerable Components**: New deps reviewed (bcrypt@5.1, express-rate-limit@7.0)
281
+ - [x] **A07 Auth Failures**: Token single-use, short TTL (24h)
282
+ - [x] **A08 Integrity**: Password updated atomically
283
+ - [x] **A09 Logging**: Auth events logged to audit log
284
+ - [x] **A10 SSRF**: N/A (no URL fetching)
285
+
286
+ ### Performance: ✅
287
+ - Bcrypt work factor: 10 (acceptable balance)
288
+ - DB query: single indexed lookup (token_hash)
289
+ - Email send: async via queue (doesn't block request)
290
+ - No N+1 concerns
291
+
292
+ ### Testing: ✅
293
+ - Coverage: 87% diff (target 80%) ✅
294
+ - Unit: 15 new tests (well-named, AAA structure)
295
+ - Integration: 4 tests (real DB, real request/response)
296
+ - Edge cases: covered (case sensitivity, boundary times)
297
+ - No flaky tests detected
298
+
299
+ ### Maintainability: ✅
300
+ - Function sizes reasonable (< 30 lines)
301
+ - Clear naming (`generateResetToken`, not `genTkn`)
302
+ - Constants extracted (`TOKEN_TTL_MS`, `RATE_LIMIT_MAX`)
303
+ - Comments explain non-obvious decisions
304
+
305
+ ### Documentation: ✅
306
+ - API docs: updated `docs/project/api/auth.md`
307
+ - CHANGELOG: entry added
308
+ - ADR-0012 created for rate limiting strategy
309
+
310
+ ### Commits: ✅
311
+ TDD flow evident:
312
+ - test commits before feat commits ✓
313
+ - atomic, descriptive commits ✓
314
+ - conventional format ✓
315
+
316
+ ### Inline Comments
317
+
318
+ #### [PRAISE] `src/auth/reset-password.ts:45`
319
+ Nice use of `timingSafeEqual` to prevent timing attacks on token comparison. Exactly what I'd want.
320
+
321
+ #### [PRAISE] `tests/auth/reset-password.test.ts:89`
322
+ Great test for case-sensitivity edge case. Would have missed that in dev.
323
+
324
+ #### [NIT] `src/auth/reset-password.ts:78`
325
+ Consider extracting magic number 3600000 to `ONE_HOUR_MS` constant. Already have `TOKEN_TTL_MS`, consistent style.
326
+
327
+ (Non-blocking, address if easy)
328
+
329
+ ### Decision
330
+
331
+ ✅ **APPROVED** - Ready to merge after optional NIT (if fixing).
332
+
333
+ ### Next Steps
334
+ 1. **Developer**: Address NIT if easy (< 5 min)
335
+ 2. **Developer**: `/merge-pr 123`
336
+
337
+ ### Ticket Update
338
+ Adding review comment to TICKET-042:
339
+ - "Approved by tech-lead-agent on 2026-04-18"
340
+ - No status change (still IN_REVIEW, awaiting merge)
341
+
342
+ ---
343
+ HANDOFF → developer
344
+ ```
345
+
346
+ ## 📤 Output Format (Request Changes)
347
+
348
+ ```markdown
349
+ ## 🔍 Code Review: PR #123 (TICKET-042)
350
+
351
+ **Overall Decision**: ⚠️ **CHANGES REQUESTED**
352
+
353
+ **Blockers**: 2 MUST_FIX (1 security, 1 testing)
354
+ **Nice to have**: 3 SHOULD_FIX + 2 NITs
355
+
356
+ ### Summary
357
+ Good direction overall. Core implementation works but has a critical security issue in rate limiting and a test gap that makes me uncertain about edge case behavior. Fix the 2 blockers, then I'll re-approve.
358
+
359
+ ### AC Coverage: ⚠️ 3/4
360
+ - ✅ Scenario 1 → covered
361
+ - ✅ Scenario 2 → covered
362
+ - ✅ Scenario 3 → covered
363
+ - ❌ Scenario 4 (rate limit) → **test exists but doesn't actually validate rate limit trigger**
364
+
365
+ ### Security: ⚠️ 1 Blocker
366
+
367
+ #### [MUST_FIX] [Security] `src/auth/rate-limit.ts:23`
368
+
369
+ **Problem**: Rate limit counter keyed by raw email, allowing bypass via case variation.
370
+
371
+ ```typescript
372
+ // Current:
373
+ const key = `reset:${email}`; // "User@x.com" and "user@x.com" are different keys
374
+ ```
375
+
376
+ **Why it matters**: Attacker can bypass rate limit by:
377
+ - `user@example.com`
378
+ - `User@example.com`
379
+ - `USER@example.com`
380
+ - etc.
381
+ Each would have its own 5-request budget. Effectively unlimited.
382
+
383
+ **Suggestion**: Normalize email before key:
384
+ ```typescript
385
+ const key = `reset:${email.toLowerCase().trim()}`;
386
+ ```
387
+
388
+ Add test:
389
+ ```typescript
390
+ it('should rate limit across case variations', async () => {
391
+ await request('user@x.com'); // 1
392
+ await request('User@x.com'); // 2
393
+ await request('USER@x.com'); // 3
394
+ await request('uSeR@x.com'); // 4
395
+ await request('user@x.com'); // 5
396
+ const response = await request('User@x.com'); // 6 - should be limited
397
+ expect(response.status).toBe(429);
398
+ });
399
+ ```
400
+
401
+ ### Testing: ⚠️ 1 Blocker
402
+
403
+ #### [MUST_FIX] [Testing] `tests/auth/rate-limit.test.ts:15`
404
+
405
+ **Problem**: Test for Scenario 4 sets rate limit to 1 req/hour but only calls once. Never actually triggers the limit.
406
+
407
+ ```typescript
408
+ // Current test:
409
+ it('should rate limit', async () => {
410
+ const response = await request.post('/auth/reset');
411
+ expect(response.status).toBe(200); // ❌ This is happy path, not rate limit
412
+ });
413
+ ```
414
+
415
+ **Why it matters**: Scenario 4 (rate limit) has 0 actual coverage. Could silently regress.
416
+
417
+ **Suggestion**: Make request N+1 times, verify 429 on last:
418
+ ```typescript
419
+ it('should return 429 after limit exceeded', async () => {
420
+ for (let i = 0; i < 5; i++) {
421
+ const r = await request.post('/auth/reset').send({ email: 'x@y.com' });
422
+ expect(r.status).toBe(200);
423
+ }
424
+ const overLimit = await request.post('/auth/reset').send({ email: 'x@y.com' });
425
+ expect(overLimit.status).toBe(429);
426
+ expect(overLimit.body.error).toBe('RATE_LIMIT_EXCEEDED');
427
+ });
428
+ ```
429
+
430
+ ### Performance: ⚠️
431
+
432
+ #### [SHOULD_FIX] [Performance] `src/email/send.ts:23`
433
+
434
+ **Problem**: Awaiting SendGrid call synchronously in request handler.
435
+
436
+ **Why it matters**: User request blocked 300-800ms waiting for external service. Bad UX.
437
+
438
+ **Suggestion**: Queue the job, return 202 immediately:
439
+ ```typescript
440
+ // Instead of:
441
+ await sendGrid.send(email);
442
+ return 200;
443
+
444
+ // Use:
445
+ await jobQueue.enqueue('send-reset-email', { email, token });
446
+ return 202; // Accepted, processing async
447
+ ```
448
+
449
+ (Requires job queue infra - check ADR-0008)
450
+
451
+ ### Maintainability
452
+
453
+ #### [SHOULD_FIX] [Maintainability] `src/auth/reset-password.ts:78`
454
+
455
+ Function `validateAndResetPassword` is 67 lines, does 4 things. Consider extracting:
456
+ - `validateResetToken(token)`
457
+ - `updateUserPassword(userId, newPassword)`
458
+ - `invalidateToken(token)`
459
+ - `sendConfirmationEmail(user)`
460
+
461
+ Not blocking but will pay off as feature grows.
462
+
463
+ #### [SHOULD_FIX] [Maintainability] `src/auth/reset-password.ts:45`
464
+
465
+ Magic number `86400000` - extract:
466
+ ```typescript
467
+ const TOKEN_TTL_MS = 24 * 60 * 60 * 1000;
468
+ ```
469
+
470
+ #### [NIT] [Style] `src/auth/reset-password.ts:92`
471
+ Unused variable `requestId`. Remove or prefix `_requestId`.
472
+
473
+ #### [NIT] [Docs] `src/auth/reset-password.ts:15`
474
+ JSDoc missing `@throws` for `InvalidTokenError` case.
475
+
476
+ ### Praise
477
+
478
+ #### [PRAISE] `tests/email/send.test.ts:34`
479
+ Excellent test for email template rendering. Nice touch.
480
+
481
+ ### Decision
482
+
483
+ ⚠️ **REQUEST CHANGES**
484
+
485
+ **Blockers (MUST_FIX)**:
486
+ 1. Rate limit bypass via email case
487
+ 2. Rate limit test doesn't actually test rate limit
488
+
489
+ **After fixing blockers**: I'll re-review (mostly spot-check).
490
+
491
+ ### Next Steps
492
+
493
+ 1. **Developer**: Address 2 MUST_FIX items
494
+ 2. **Developer**: Consider SHOULD_FIX items (optional but recommended)
495
+ 3. **Developer**: Re-request review: comment `@tech-lead ready for re-review`
496
+ 4. **Tech Lead**: Re-review (spot-check)
497
+
498
+ ### Ticket Update
499
+ Added review comment. No status change (still IN_REVIEW).
500
+
501
+ ---
502
+ HANDOFF → developer
503
+ Re-review expected within 1 iteration.
504
+ ```
505
+
506
+ ## 🚨 Failure Modes
507
+
508
+ | Scenario | Action |
509
+ |----------|--------|
510
+ | PR closed / merged | ABORT, cannot review |
511
+ | Own PR | ABORT with RULE TL-005 reference |
512
+ | CI red | ABORT, instruct fix CI first |
513
+ | Huge PR (>1000 lines changed) | Suggest split, but proceed with warning |
514
+ | No tests added | MUST_FIX, coverage failed already |
515
+ | Secrets in diff | CRITICAL: Block + immediate notification |
516
+ | Review paralysis (too many issues) | Prioritize top 3 MUST_FIX, defer rest to follow-up |
517
+
518
+ ## 🔗 Related Commands
519
+
520
+ - **Before**: `/create-pr` (Developer's step)
521
+ - **Alternatives**: `/security-review` (security-focused only)
522
+ - **After approval**: `/merge-pr` (by Tech Lead)
523
+ - **After changes requested**: Developer fixes, re-requests, back to this command
524
+
525
+ ## 📊 Metrics Tracked
526
+
527
+ ```json
528
+ {
529
+ "timestamp": "2026-04-18T15:00:00Z",
530
+ "pr_number": 123,
531
+ "ticket_id": "TICKET-042",
532
+ "reviewer": "tech-lead-agent",
533
+ "review_duration_seconds": 2700,
534
+ "depth": "full",
535
+ "decision": "CHANGES_REQUESTED",
536
+ "must_fix_count": 2,
537
+ "should_fix_count": 3,
538
+ "nit_count": 2,
539
+ "praise_count": 1,
540
+ "owasp_concerns": 1,
541
+ "iterations": 1
542
+ }
543
+ ```
544
+
545
+ ---
546
+ **Last updated**: 2026-04-18
547
+ **Maintainer**: Tech Lead agent
@@ -0,0 +1,72 @@
1
+ ---
2
+ name: using-ai-core
3
+ description: Use at the start of any AI Core project conversation. Establishes chat-first command handling, agent inference, state governance, documentation rules, and guided next-step reporting.
4
+ ---
5
+
6
+ # Using AI Core
7
+
8
+ AI Core is a chat-first enterprise SDLC framework. The user should interact through the AI chat window, not by running shell wrappers.
9
+
10
+ ## Mandatory Behavior
11
+
12
+ Before responding to a project workflow request, check whether one of these applies:
13
+
14
+ - The user typed a slash command such as `/analyze-requirements`.
15
+ - The user typed a guided command such as `guide /groom-ticket TICKET-001 5`.
16
+ - The user asked for the next workflow step, status, sprint, ticket, release, docs, review, QA, or implementation.
17
+ - The user asked to modify production code.
18
+
19
+ If any applies, use AI Core rules, commands, and state.
20
+
21
+ ## Chat Interface
22
+
23
+ Users type:
24
+
25
+ ```text
26
+ /analyze-requirements "User can reset password"
27
+ /groom-ticket TICKET-001 5
28
+ guide /mark-ready TICKET-001
29
+ next TICKET-001
30
+ ```
31
+
32
+ Do not ask users to type `bash core/scripts/ai-core.sh` or `AI_AGENT=...` during normal use. Those are internal tools for deterministic execution and CI.
33
+
34
+ ## Agent Selection
35
+
36
+ Infer the agent from command metadata:
37
+
38
+ - `owner_agent`
39
+ - `requires_agents`
40
+
41
+ If command metadata and user intent conflict, explain the conflict and stop.
42
+
43
+ ## Source Of Truth
44
+
45
+ - `project/` is machine-readable runtime state.
46
+ - `docs/` is human-readable project documentation.
47
+ - `config/` is project configuration.
48
+ - `core/` is portable framework code.
49
+
50
+ Do not move backlog, tickets, releases, bugs, sprints, or audit records into `docs/`. Generate human-readable summaries in `project/views/` and keep longer narrative docs in `docs/`.
51
+
52
+ ## Guided Report
53
+
54
+ After completing a workflow step, report:
55
+
56
+ - completed command
57
+ - inferred agent
58
+ - ticket state before and after, if applicable
59
+ - files created or updated
60
+ - validation results
61
+ - suggested next chat command
62
+
63
+ Ask before running the next step. Do not continue automatically when the next command needs missing arguments.
64
+
65
+ ## Required Gates
66
+
67
+ - No production code without an active `IN_PROGRESS` ticket.
68
+ - No skipped state transitions.
69
+ - No self-approval.
70
+ - No DONE without fresh verification evidence.
71
+ - No public API, setup, migration, architecture, or release-impacting change without the required docs evidence.
72
+
@@ -0,0 +1,35 @@
1
+ ---
2
+ name: verification-before-done
3
+ description: Use before claiming a ticket, PR, release, or fix is complete. Requires fresh evidence before completion claims.
4
+ ---
5
+
6
+ # Verification Before Done
7
+
8
+ Do not claim work is complete without fresh verification evidence from this session.
9
+
10
+ ## Gate
11
+
12
+ Before saying a workflow step is complete:
13
+
14
+ 1. Identify what proves the claim.
15
+ 2. Run or inspect the relevant verification.
16
+ 3. Read the result.
17
+ 4. Record evidence in `project/test-runs/`, `project/verifications/`, or the ticket.
18
+ 5. Only then report completion.
19
+
20
+ ## Required Evidence
21
+
22
+ For DONE tickets:
23
+
24
+ - `qa_evidence.path`
25
+ - `qa_evidence.verified_by`
26
+ - `qa_evidence.verified_at`
27
+ - `dod_checklist.tests_passed = true`
28
+ - `dod_checklist.qa_verified = true`
29
+
30
+ For docs-sensitive changes:
31
+
32
+ - `documentation.paths`
33
+ - ADR path when architecture changed
34
+ - runbook path when migration or operations changed
35
+
@@ -0,0 +1,45 @@
1
+ ---
2
+ name: writing-implementation-plan
3
+ description: Use after a ticket has a spec and is groomed or ready. Creates a detailed implementation plan before coding.
4
+ ---
5
+
6
+ # Writing Implementation Plans
7
+
8
+ Use this skill when creating `docs/project/plans/TICKET-XXX-<slug>-plan.md`.
9
+
10
+ ## Plan Requirements
11
+
12
+ The plan must be specific enough for an agent to execute without guessing.
13
+
14
+ Include:
15
+
16
+ - goal
17
+ - linked ticket
18
+ - linked spec, if available
19
+ - affected files
20
+ - task checklist
21
+ - test strategy
22
+ - documentation updates
23
+ - verification commands
24
+ - rollback notes
25
+ - risks and open questions
26
+
27
+ ## Task Quality Bar
28
+
29
+ Each task should be small, verifiable, and ordered:
30
+
31
+ - exact files to create or modify
32
+ - exact tests to write or run
33
+ - expected verification result
34
+ - docs to update
35
+
36
+ Avoid placeholders such as `TODO`, `TBD`, `add tests`, or `handle edge cases` without details.
37
+
38
+ ## Handoff
39
+
40
+ After writing the plan:
41
+
42
+ - link it from the ticket as `implementation_plan_path`
43
+ - run state validation
44
+ - suggest `/implement-task TICKET-XXX`
45
+