forgetrail 0.3.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 (98) hide show
  1. package/CONTINUATION_PROMPT.md +42 -0
  2. package/INITIAL_PROMPT.md +214 -0
  3. package/LICENSE +201 -0
  4. package/README.md +198 -0
  5. package/TRACKING_SCHEMA.md +162 -0
  6. package/TRY_FORGETRAIL.md +78 -0
  7. package/WORKFLOW.md +921 -0
  8. package/content/AGENT_INTEGRATION_claude.md +38 -0
  9. package/content/AGENT_INTEGRATION_cursor.md +53 -0
  10. package/content/AGENT_INTEGRATION_generic.md +50 -0
  11. package/content/AGENT_INTEGRATION_grok.md +82 -0
  12. package/content/DEV_AUTOMATION_SCRIPTS.md +103 -0
  13. package/content/FORGETRAIL_LITE.md +1202 -0
  14. package/content/FORGETRAIL_LITE_UPDATES.md +13 -0
  15. package/content/FORGETRAIL_PROGRESS.md +26 -0
  16. package/content/GENESIS_SPEC_PROMPT.md +70 -0
  17. package/content/GENESIS_STUB.md +18 -0
  18. package/content/GREENFIELD_INTAKE.md +76 -0
  19. package/content/KICKOFF_WITHOUT_MCP.md +16 -0
  20. package/content/LITE_WORKFLOW_TRACKING.json +42 -0
  21. package/content/NEW_PROJECT_BOOTSTRAP.md +180 -0
  22. package/content/ONE_CLICK_DEV_SETUP.md +142 -0
  23. package/content/PLAN_MODE_PATTERNS.md +43 -0
  24. package/content/POCKETBASE_SCHEMA_SCRIPT.md +52 -0
  25. package/content/POST_BOOTSTRAP_USER_MESSAGE.md +51 -0
  26. package/content/SCAFFOLD_INSTALL.json +110 -0
  27. package/content/SESSION_RESUME_MCP.md +35 -0
  28. package/content/SYSTEM_HEALTH_CHECKS.md +131 -0
  29. package/content/USER_REPLY_FORMAT.md +41 -0
  30. package/content/cursor-rules/forgetrail-lessons-gate.mdc +30 -0
  31. package/content/cursor-rules/forgetrail-lessons-mcp.mdc +24 -0
  32. package/content/cursor-rules/forgetrail-no-trailer.mdc +49 -0
  33. package/content/cursor-rules/forgetrail-phase-status.mdc +61 -0
  34. package/content/cursor-rules/forgetrail-updates-log.mdc +30 -0
  35. package/content/cursor-rules/spec-completion.mdc +33 -0
  36. package/content/cursor-rules/specs-and-todo.mdc +26 -0
  37. package/content/cursor-rules/url-host-matching.mdc +31 -0
  38. package/content/cursor-rules/us-english.mdc +9 -0
  39. package/content/cursor-rules/user-facing-content.mdc +31 -0
  40. package/content/examples/GENESIS_SAMPLE_mars-habitat-roster.md +154 -0
  41. package/content/forgetrail-workspace-README.md +43 -0
  42. package/content/scripts/forgetrail-dev-launcher.mjs +208 -0
  43. package/content/scripts/forgetrail-env.mjs +51 -0
  44. package/content/scripts/setup-ollama.mjs +207 -0
  45. package/content/scripts/setup-pocketbase.mjs +133 -0
  46. package/content/scripts/test-ollama.mjs +71 -0
  47. package/content/scripts/test-pocketbase.mjs +110 -0
  48. package/content/skills/forgetrail/SKILL.md +92 -0
  49. package/docs/AUTOMATED_TESTING.md +269 -0
  50. package/docs/BLACK_HAT_REPORT.md +143 -0
  51. package/docs/BRAND_AND_PRODUCT.md +381 -0
  52. package/docs/BUGS.md +62 -0
  53. package/docs/BUSINESS_PLAN.md +256 -0
  54. package/docs/CODE_QUALITY.md +170 -0
  55. package/docs/CONTEXT_PROMPT.md +357 -0
  56. package/docs/DEPLOYMENT.md +181 -0
  57. package/docs/DESIGN_SYSTEM.md +414 -0
  58. package/docs/DEV_ESTIMATE.md +127 -0
  59. package/docs/FORGETRAIL_RENAME.md +193 -0
  60. package/docs/IDEAS.md +19 -0
  61. package/docs/MARKETING_GROWTH.md +301 -0
  62. package/docs/NAMING_EXPLORATION.md +406 -0
  63. package/docs/NPM.md +98 -0
  64. package/docs/PHASE_1_BRIEF.md +161 -0
  65. package/docs/README.md +75 -0
  66. package/docs/SPEC_FEATURE_TEMPLATE.md +155 -0
  67. package/docs/SPEC_UI_CHROME_NAV_TEMPLATE.md +48 -0
  68. package/docs/TECHNICAL_REFERENCE.md +836 -0
  69. package/docs/TEST_PLAN.md +467 -0
  70. package/docs/TODO.md +125 -0
  71. package/package.json +68 -0
  72. package/prompts/black-hat-audit.md +235 -0
  73. package/prompts/brand-copy-edit-pass.md +55 -0
  74. package/prompts/cialdini-marketing-audit.md +141 -0
  75. package/prompts/competitor-deep-dive.md +201 -0
  76. package/prompts/docs-alignment-audit.md +108 -0
  77. package/prompts/engineering-skill-library.md +75 -0
  78. package/prompts/landing-page-rewrite.md +63 -0
  79. package/prompts/microcopy-centralization.md +128 -0
  80. package/prompts/panel-usability-audit.md +197 -0
  81. package/prompts/personal-beta-outreach.md +195 -0
  82. package/prompts/pre-launch-audit.md +148 -0
  83. package/prompts/product-feedback-to-spec.md +76 -0
  84. package/prompts/propagate-to-forgetrail.md +315 -0
  85. package/prompts/user-facing-content-sync-audit.md +200 -0
  86. package/prompts/ux-cohesion-audit.md +165 -0
  87. package/scripts/ensure-lease.mjs +23 -0
  88. package/scripts/forgetrail-cli.mjs +85 -0
  89. package/scripts/install-forgetrail-lite.mjs +11 -0
  90. package/scripts/install-forgetrail.mjs +11 -0
  91. package/scripts/install-lib.mjs +115 -0
  92. package/scripts/install.mjs +163 -0
  93. package/scripts/link-global.mjs +100 -0
  94. package/scripts/mcp-lib.mjs +177 -0
  95. package/scripts/mcp-status.mjs +155 -0
  96. package/scripts/publish-gate.mjs +110 -0
  97. package/scripts/rename-to-forgetrail.mjs +273 -0
  98. package/workflow_tracking.json +124 -0
@@ -0,0 +1,269 @@
1
+ # Automated Testing β€” Specification
2
+
3
+ **Status:** Draft for implementation (ForgeTrail template β€” child projects adapt paths and stack lines.)
4
+ **Related:** [TEST_PLAN.md](TEST_PLAN.md) (manual QA walkthrough)
5
+ **Provenance:** Generalized from Exec Foundry `specs/automated-testing.md` (2026-04-16).
6
+ **Stack context (example β€” adjust per app):** SvelteKit 2, Vite, TypeScript, a BaaS (e.g. PocketBase), Zod validation, payments webhooks, optional LLM providers. Many apps already depend on `playwright` for scraping or screenshots without a dedicated `@playwright/test` app-QA config β€” this spec describes how to add one deliberately.
7
+
8
+ ---
9
+
10
+ ## 1. Purpose and principles
11
+
12
+ ### 1.1 What this spec is for
13
+
14
+ Define a **practical** automated testing strategy that:
15
+
16
+ - Catches **regressions** in business rules, API contracts, and critical user paths before merge or deploy.
17
+ - Gives **confidence in deployment** without replacing human judgment on LLM output quality, third-party job sites, or full billing flows in every CI run.
18
+ - Stays **fast enough for daily use** (local and CI), with slower suites scheduled or opt-in.
19
+ - **Does not** optimize for coverage percentage. Coverage may be reported for discovery only, not as a merge gate.
20
+
21
+ ### 1.2 What to avoid
22
+
23
+ | Anti-pattern | Why it hurts |
24
+ |--------------|--------------|
25
+ | Enforcing a coverage threshold (e.g. 80%) | Incentivizes trivial tests, noisy refactors, and testing implementation details. |
26
+ | Testing every Svelte component in isolation | High cost; many components are thin wrappers around PocketBase + LLM; value is often in integration. |
27
+ | Large E2E suites hitting real LLM / real scrapers | Flaky, slow, non-deterministic; belongs in manual TEST_PLAN or occasional staging runs. |
28
+ | Duplicating the entire TEST_PLAN in automation | Diminishing returns; automate the **highest-risk and most repetitive** checks first. |
29
+
30
+ ### 1.3 What β€œgood” looks like
31
+
32
+ - A **failed unit test** points to a specific function (e.g. wrong limit for `pro` plan after a code change).
33
+ - A **failed API test** points to a route + status code + body shape (e.g. unauthenticated request returns 401).
34
+ - A **failed E2E test** points to a broken journey (e.g. cannot log in, board does not load) after a routing or auth change.
35
+ - **Manual TEST_PLAN** remains the source of truth for exploratory QA, Stripe webhook end-to-end behavior, OAuth provider quirks, and β€œdoes the AI answer make sense?”
36
+
37
+ ---
38
+
39
+ ## 2. Recommended test pyramid (for this product)
40
+
41
+ ```
42
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
43
+ β”‚ E2E (few) β”‚ Critical smoke + 1–2 journeys
44
+ β”‚ Playwright β”‚ Mock or stub LLM/scrape where possible
45
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
46
+ β”‚
47
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
48
+ β”‚ Integration / API tests β”‚ +server handlers, hooks behavior
49
+ β”‚ (Vitest + request mocking) β”‚ Auth, validation, 401/402/429
50
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
51
+ β”‚
52
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
53
+ β”‚ Unit tests (many, fast) β”‚
54
+ β”‚ Pure functions, Zod schemas, limits β”‚
55
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
56
+ ```
57
+
58
+ ### 2.1 Unit tests (primary volume)
59
+
60
+ **Target:** Pure or nearly pure modulesβ€”no network, no PocketBase, no browser.
61
+
62
+ **High-value areas in this codebase:**
63
+
64
+ | Area | Examples | Rationale |
65
+ |------|----------|-----------|
66
+ | **Zod schemas** | `src/lib/server/validation.ts` β€” `signupSchema`, password rules, job IDs | Cheap to test; failures become 400s in production. |
67
+ | **Plan / entitlements math** | `src/lib/server/entitlements.ts`, `src/lib/server/planLimitValues.ts`, `src/lib/productLimits.ts` | Billing and feature gating bugs are high impact; logic is table-driven and testable. |
68
+ | **Pure utilities** | `src/lib/salary.ts`, search/filter helpers, date/trial helpers | Regression-prone when refactored. |
69
+ | **Rate-limit constants** | `src/lib/server/rateLimits.ts` | Assert documented limits (60/min general, 10/min LLM) match product intent. |
70
+
71
+ **Lower priority for unit tests:** Individual `.svelte` files unless they contain substantial client-side logic (e.g. complex state machines). Prefer E2E or thin component tests only where bugs have historically occurred.
72
+
73
+ ### 2.2 Integration / API tests (medium volume)
74
+
75
+ **Target:** SvelteKit `+server.ts` handlers and shared server utilities with **controlled doubles** (mock PocketBase client, mock Stripe, or HTTP-level mocks).
76
+
77
+ **High-value behaviors:**
78
+
79
+ - **Authentication:** Routes that must return `401` without a valid session (see TEST_PLAN Β§13.4).
80
+ - **Validation:** `POST` with invalid JSON or invalid body β†’ `400` with stable error shape (via `parseBody` / Zod).
81
+ - **Authorization:** User A cannot read/update user B’s job (if enforced in APIβ€”assert with mocked PB records).
82
+ - **Entitlements:** When a user record is in `expired` / `pro` state, a given action returns `402` or is allowed as documented (TEST_PLAN Β§9).
83
+ - **Rate limiting:** With a **test-only hook** or exported `checkRateLimit` used only in tests, assert 429 after N requests (avoid full 60-request loops in CI by testing the limiter function with injectable clock/map).
84
+
85
+ **Implementation options (pick one primary approach):**
86
+
87
+ 1. **Vitest + `import` of handler + `Request`/`Response` mocks** β€” Good for validation-only routes.
88
+ 2. **Vitest + `@sveltejs/kit` test utilities** β€” If available for your Kit version; exercise `GET`/`POST` with a fake `RequestEvent`.
89
+ 3. **PocketBase test instance** β€” Docker or local binary with a **seed script** for users/jobs. Heavier setup; use for a small β€œgolden path” subset.
90
+
91
+ **Stripe webhooks:** Do **not** rely on live Stripe in default CI. Prefer:
92
+
93
+ - Unit tests for **signature verification** and **idempotency** logic with fixture payloads; or
94
+ - Stripe CLI in a **manual** or **nightly** job; or
95
+ - Recorded webhook fixtures (JSON) processed by the handler in isolation.
96
+
97
+ ### 2.3 End-to-end tests (small, stable set)
98
+
99
+ **Tool:** `@playwright/test` (already in `package.json`). Add `playwright.config.ts` at repo root for **app** testing (separate from `scripts/screenshots.ts` usage).
100
+
101
+ **Scope:**
102
+
103
+ 1. **Smoke (every PR or every push to `main`):**
104
+ - App responds (e.g. `GET /` or `/start` returns 200).
105
+ - `GET /api/health` returns 200 when PocketBase is up (or skip in CI without PBβ€”see Β§5).
106
+
107
+ 2. **Auth shell (optional second phase):**
108
+ - With a **test user** in a seeded PocketBase: login β†’ land on dashboard β†’ session cookie present.
109
+ - Avoid testing full signup email verification unless PB test mode supports it.
110
+
111
+ 3. **One data journey (optional third phase):**
112
+ - Create job via API or minimal UI flow with **LLM mocked** (route interception or env flag that returns stub JSON)β€”so CI does not call Anthropic.
113
+
114
+ **Explicitly out of default E2E:** Full resume DOCX pipeline, job scraping from real URLs, Stripe Checkout redirect, OAuth redirects, NPS timing tied to real tailoring counts.
115
+
116
+ ---
117
+
118
+ ## 3. Mapping TEST_PLAN sections to automation
119
+
120
+ _The rows below mirror one product’s TEST_PLAN outline; **replace section labels** when your manual plan differs._
121
+
122
+ | TEST_PLAN area | Automation suggestion | Notes |
123
+ |----------------|----------------------|--------|
124
+ | Β§0 Environment | Documented in CI Β§5; optional smoke script | Keep README / TEST_PLAN / `package.json` dev port consistent to avoid flaky local E2E. |
125
+ | Β§1 Auth | E2E login smoke + API 401 tests | OAuth stays manual. |
126
+ | Β§2 Resume & Documents | Mostly manual; optional API test for upload validation (reject non-DOCX) | LLM steps stay manual or stubbed. |
127
+ | Β§3 Job pipeline | E2E stubbed β€œadd job” OR API integration with mock scrape | Real scraping is flaky. |
128
+ | Β§4 AI features | Stub LLM responses in integration tests | Assert UI/API contract, not prose quality. |
129
+ | Β§5–8 People, filters, STAR, branding | Selective API + occasional E2E | Prioritize duplicate detection and filter persistence (localStorage) if tested at all. |
130
+ | Β§9 Billing | Webhook unit tests + manual Stripe | Full checkout E2E in staging only. |
131
+ | Β§10 Delegation | API tests if routes are isolated | Complex; lower priority. |
132
+ | Β§11 Analytics | API/auth gating tests | Chart correctness manual. |
133
+ | Β§12 UI | Playwright visual smoke only if needed | Theme/responsive: manual or periodic. |
134
+ | Β§13 Security | API tests for CSRF/auth; rate limit unit tests | CSP: optional lint or Playwright console listener in one E2E. |
135
+ | Β§14–16 Admin / feedback / NPS | API tests for admin-only routes + NPS 409 behavior | Survey timing: manual. |
136
+
137
+ ---
138
+
139
+ ## 4. Tooling choices
140
+
141
+ ### 4.1 Test runner: Vitest
142
+
143
+ - Aligns with Vite; fast cold start; native ESM; good TypeScript support.
144
+ - **Add:** `vitest`, `@vitest/coverage-v8` (optional, **report-only**).
145
+ - **Config:** `vitest.config.ts` with `environment: 'node'` for server tests; use `pool: 'forks'` if any PB-related flakiness appears.
146
+
147
+ ### 4.2 Component tests (optional, low priority)
148
+
149
+ - If needed: `@testing-library/svelte` + `jsdom` environment for specific components.
150
+ - Use sparinglyβ€”prefer unit tests on extracted logic or E2E for critical UI.
151
+
152
+ ### 4.3 E2E: Playwright
153
+
154
+ - **Config:** `playwright.config.ts` β€” `baseURL: 'http://127.0.0.1:5151'` (or env `PLAYWRIGHT_BASE_URL`), `webServer` command: `pnpm dev` with reuse for local dev.
155
+ - **Artifacts:** `test-results/`, traces on failure, HTML report in CI as downloadable artifact.
156
+
157
+ ### 4.4 Lint / typecheck (already valuable)
158
+
159
+ - Keep **`pnpm check`** (svelte-check) in CI as a **static** gateβ€”it catches many regressions without being β€œtests” in the coverage sense.
160
+
161
+ ---
162
+
163
+ ## 5. CI and local workflows
164
+
165
+ ### 5.1 Proposed npm/pnpm scripts
166
+
167
+ | Script | Purpose |
168
+ |--------|---------|
169
+ | `test` | Run Vitest unit + integration |
170
+ | `test:unit` | Fast subset (e.g. `src/lib/**/*.test.ts`) |
171
+ | `test:e2e` | Playwright |
172
+ | `test:e2e:smoke` | Single smoke project/tag |
173
+ | `test:all` | `check` + `test` + `test:e2e` (optional locally) |
174
+
175
+ ### 5.2 GitHub Actions layout
176
+
177
+ **Option A β€” Single workflow (simplest):**
178
+
179
+ - **On PR + push to `main`:** `pnpm install`, `pnpm check`, `pnpm test`, optionally `pnpm test:e2e:smoke` with services.
180
+
181
+ **Option B β€” Split:**
182
+
183
+ - **`ci.yml`:** `check` + Vitest (always).
184
+ - **`e2e.yml`:** Playwright on schedule or on `main` only (saves minutes).
185
+
186
+ ### 5.3 Services in CI
187
+
188
+ | Dependency | Approach |
189
+ |------------|----------|
190
+ | PocketBase | Run official Docker image; run `scripts/setup-pocketbase.js` or a minimal seed; health wait then tests. **Or** skip PB-dependent E2E on PR and run nightly. |
191
+ | Anthropic / Ollama | Never required in CI; use mocks. |
192
+ | Stripe | Fixtures only. |
193
+
194
+ ### 5.4 Deploy pipeline (`deploy.yml`)
195
+
196
+ Today: build + deploy, no tests. **Recommendation:** Add a **`ci`** job (or prerequisite workflow) that runs `pnpm check` and `pnpm test` before deploy. Optionally require `main` to be green from PR checks.
197
+
198
+ **Playwright browsers on deploy:** Production already installs Chromium for scraping; E2E does not need to run **on the droplet**β€”only in GitHub Actions.
199
+
200
+ ---
201
+
202
+ ## 6. Directory and naming conventions
203
+
204
+ ```
205
+ prime-contender/
206
+ β”œβ”€β”€ playwright.config.ts # E2E config
207
+ β”œβ”€β”€ vitest.config.ts
208
+ β”œβ”€β”€ e2e/ # or tests/e2e/
209
+ β”‚ β”œβ”€β”€ smoke.spec.ts
210
+ β”‚ └── auth.spec.ts
211
+ β”œβ”€β”€ src/
212
+ β”‚ └── lib/
213
+ β”‚ └── server/
214
+ β”‚ β”œβ”€β”€ entitlements.ts
215
+ β”‚ └── entitlements.test.ts # colocated, or **/__tests__/
216
+ ```
217
+
218
+ - **Colocate** unit tests next to modules (`*.test.ts`) or under `src/lib/**/__tests__/` β€” pick one and stay consistent.
219
+ - **E2E** lives outside `src/` so it is clearly not bundled.
220
+
221
+ ---
222
+
223
+ ## 7. Coverage policy
224
+
225
+ - **Do not** gate merges on line coverage.
226
+ - Optional: generate **HTML or lcov** in CI for human review after refactors.
227
+ - Focus on **critical paths** listed in Β§2.1–2.2.
228
+
229
+ ---
230
+
231
+ ## 8. Test data and secrets
232
+
233
+ - **CI secrets:** None for default unit tests. E2E with PB may need `PUBLIC_POCKETBASE_URL` and a test admin user created in seed.
234
+ - **Never** commit real API keys; use `.env.example` and CI secrets for optional integration jobs.
235
+ - **User IDs:** Tests should use fixed seed IDs from PB test data for predictable assertions.
236
+
237
+ ---
238
+
239
+ ## 9. Phased rollout (recommended)
240
+
241
+ | Phase | Deliverables | Exit criteria |
242
+ |-------|--------------|---------------|
243
+ | **0** | `vitest.config.ts`, `pnpm test`, first tests for `validation.ts` schemas + one entitlements case | CI runs Vitest + `check` on PR |
244
+ | **1** | Tests for `planLimitValues` / entitlements edge cases; rate limit helper tests | No coverage gate; team agrees tests are readable |
245
+ | **2** | `playwright.config.ts` + `e2e/smoke.spec.ts` (health + home) | CI runs smoke with or without PB (document which) |
246
+ | **3** | API tests for 401/400 on selected routes with mocks | Regression suite for security checklist Β§13 |
247
+ | **4** | Seeded PB + login E2E **or** Stripe webhook unit tests | Staging/manual still required for full billing |
248
+
249
+ ---
250
+
251
+ ## 10. Maintenance
252
+
253
+ - When **TEST_PLAN** gains a new critical path, ask: β€œWould a unit or API test have caught this?” If yes, add automation.
254
+ - **Review quarterly:** Drop flaky E2E; fix or replace with lower-level tests.
255
+ - Keep **manual TEST_PLAN** updated when product behavior changes; automation spec should reference it, not duplicate step-by-step prose.
256
+
257
+ ---
258
+
259
+ ## 11. Open decisions (to resolve during implementation)
260
+
261
+ 1. **Single vs split CI workflows** for cost vs feedback speed.
262
+ 2. **PocketBase in CI** for every PR vs nightly only (cost/complexity tradeoff).
263
+ 3. **Whether to extract** small pure functions from large Svelte components for testability vs E2E-onlyβ€”case by case.
264
+
265
+ ---
266
+
267
+ ## 12. Summary
268
+
269
+ The best combination for most ForgeTrail-derived apps is **many fast unit tests** on validation and entitlements (or equivalent business rules), **targeted API/integration tests** for auth and error contracts, and **a small Playwright smoke suite** for regressions that only appear in a real browser. **Coverage is not a goal.** The manual **TEST_PLAN** remains essential for LLM quality, billing, OAuth, and third-party integrations. This division maximizes future development speed and deployment confidence without gaming metrics.
@@ -0,0 +1,143 @@
1
+ # [App Name]: Security Audit Report
2
+
3
+ _Comprehensive black hat security audit performed against the codebase. White-box approach: full source code access, attacker mindset._
4
+
5
+ _For code quality findings (type safety, error handling, consistency), see [CODE_QUALITY.md](CODE_QUALITY.md). For deployment readiness, see [DEPLOYMENT.md](DEPLOYMENT.md)._
6
+
7
+ _Instructions: Generate this document during Phase 7 (Hardening) by running the black hat audit prompt from `_forgetrail/prompts/black-hat-audit.md`. This is separate from CODE_QUALITY.md β€” that doc covers engineering quality; this doc covers exploitable security vulnerabilities. After generating, triage all findings into TODO.md with P0/P1/P2 priority. Annotate each finding here with its TODO status._
8
+
9
+ ---
10
+
11
+ > πŸ’‘ **Lesson learned:** Splitting security audit (BLACK_HAT_REPORT.md) from code quality review (CODE_QUALITY.md) is worth the extra file. They have different audiences and urgency:
12
+ > - BLACK_HAT_REPORT is "what can an attacker exploit?" β€” findings are prioritized by exploitability and impact. Fix before launch.
13
+ > - CODE_QUALITY is "what will bite us during maintenance?" β€” findings are prioritized by tech debt and reliability.
14
+ >
15
+ > The audit prompt (prompts/black-hat-audit.md) covers 11 areas systematically. Running it with 2-3 subagents in parallel produces better coverage than a single pass because each agent can focus deeply on a subset of areas.
16
+ >
17
+ > After generating the report:
18
+ > 1. Add ALL actionable findings to TODO.md under a "Security Audit" section, organized by priority (P0/P1/P2)
19
+ > 2. Annotate each finding in this report with `β†’ *Added to TODO (Pn)*`
20
+ > 3. As fixes are implemented, update both the finding status here AND the TODO checkbox
21
+
22
+ ## Executive Summary
23
+
24
+ **Audit Date:** [date]
25
+ **Auditor:** [AI model + human reviewer]
26
+ **Scope:** Full application codebase (white-box)
27
+
28
+ | Severity | Count |
29
+ | --------- | ----- |
30
+ | CRITICAL | |
31
+ | HIGH | |
32
+ | MEDIUM | |
33
+ | LOW | |
34
+ | INFO | |
35
+ | **Total** | |
36
+
37
+ **Key findings:** [2-3 sentence summary of the most impactful issues]
38
+
39
+ **Overall posture:** [Assessment: strong/moderate/needs-work. What's the biggest systemic risk?]
40
+
41
+ ## Critical Findings
42
+
43
+ _Directly exploitable. Fix before any public exposure._
44
+
45
+ ### C1: [Finding Title]
46
+
47
+ **Area:** [Auth / IDOR / Injection / SSRF / Business Logic / etc.]
48
+ **File:** `[path/to/file.ts]:[line]`
49
+ **Impact:** [What an attacker can achieve]
50
+
51
+ **Vulnerability:**
52
+ [Description with code snippet if helpful]
53
+
54
+ **Attack Scenario:**
55
+
56
+ 1. [Step-by-step exploitation]
57
+
58
+ **Fix:**
59
+ [Specific remediation with code example]
60
+
61
+ **Status:** [ ] Not started β†’ _Added to TODO (P0)_
62
+
63
+ ## High Findings
64
+
65
+ ### H1: [Finding Title]
66
+
67
+ **Area:** [area]
68
+ **File:** `[path]`
69
+ **Impact:** [impact]
70
+
71
+ **Vulnerability:**
72
+ [Description]
73
+
74
+ **Fix:**
75
+ [Remediation]
76
+
77
+ **Status:** [ ] Not started β†’ _Added to TODO (P0/P1)_
78
+
79
+ ## Medium Findings
80
+
81
+ ### M1: [Finding Title]
82
+
83
+ **Area:** [area]
84
+ **File:** `[path]`
85
+ **Impact:** [impact]
86
+
87
+ **Vulnerability:**
88
+ [Description]
89
+
90
+ **Fix:**
91
+ [Remediation]
92
+
93
+ **Status:** [ ] Not started β†’ _Added to TODO (P1/P2)_
94
+
95
+ ## Low Findings
96
+
97
+ ### L1: [Finding Title]
98
+
99
+ **Area:** [area]
100
+ **File:** `[path]`
101
+
102
+ **Issue:**
103
+ [Description]
104
+
105
+ **Fix:**
106
+ [Remediation]
107
+
108
+ **Status:** [ ] Not started β†’ _Added to TODO (P2)_
109
+
110
+ ## Informational
111
+
112
+ ### I1: [Finding Title]
113
+
114
+ **Observation:**
115
+ [Description. Not exploitable, but worth noting.]
116
+
117
+ ## What's Done Well
118
+
119
+ _Security practices already in place. Replicate these patterns._
120
+
121
+ | Practice | Where | Notes |
122
+ | --------------- | ----------- | ------------------------- |
123
+ | [good practice] | [file/area] | [what makes it effective] |
124
+
125
+ ## Remediation Priority
126
+
127
+ ### Immediate (Before Launch)
128
+
129
+ | ID | Finding | Fix Description |
130
+ | ---- | ------- | ---------------------- |
131
+ | [C1] | [title] | [one-line fix summary] |
132
+
133
+ ### Short-Term (Next Sprint)
134
+
135
+ | ID | Finding | Fix Description |
136
+ | ---- | ------- | ---------------------- |
137
+ | [H1] | [title] | [one-line fix summary] |
138
+
139
+ ### Backlog
140
+
141
+ | ID | Finding | Fix Description |
142
+ | ---- | ------- | ---------------------- |
143
+ | [M1] | [title] | [one-line fix summary] |