Add web-frontend, web-project-audit and web-project-scaffold-containerized-python skills

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Neil Bantoc 2026-11-04 14:46:25 -08:00
parent 59fc08fa5f
commit 5201aa9bd5
63 changed files with 3042 additions and 0 deletions

View file

@ -0,0 +1,67 @@
# File-auditor prompt
Use this verbatim (fill the `{…}` placeholders) when spawning a subagent for one batch. The main model follows the same rules when it audits files itself.
---
You are auditing part of a web codebase. Your job is to read source files **one at a time, in full**, and record what they reveal about how the app is implemented into a shared library of audit docs. Documentation (README, docs/, KDoc claims, comments describing intent) is NOT evidence — only code and build config is. If a comment says one thing and the code does another, record what the code does (and note the mismatch under `observations`).
- Project root: `{PROJECT_ROOT}`
- Audit workspace: `{AUDIT_DIR}`
- Helper: `A="{SKILL_DIR}/scripts/audit.sh"`
- Your batch: `{AUDIT_DIR}/batches/{BATCH_FILE}` (one project-relative path per line)
- Orientation context (from the main pass): {ORIENTATION_SUMMARY}
## Before starting
1. `bash $A patterns {AUDIT_DIR}` — see what is already documented, so you don't re-describe known patterns.
2. Skim `{AUDIT_DIR}/library/<category>.md` headers for the categories your batch likely touches.
## For each file in the batch, in order
1. **Read the whole file** with the file-read tool (`Read` / `read`), one file per call (never judge from the filename or a grep, and never `cat` groups of files through Bash). For very large files (>800 lines) read it in chunks, but read all of it.
2. Decide what it shows. Categories: `build-and-tooling file-organization architecture module-interactions routing rendering ui-components styling state-management data-fetching forms-validation api-backend persistence auth-security background-jobs i18n-a11y performance observability testing deployment features observations`. One file can feed several categories.
3. For each thing it shows, choose ONE of:
- **New pattern** → record it:
```bash
bash $A finding {AUDIT_DIR} <category> <kebab-slug> <path> "<Short title>" <<'EOF'
- **What:** concrete mechanism (library + version if visible, class/function names)
- **How:** 2–5 bullets on how it actually works here, citing `path:line` for key lines
- **Why it matters / where it connects:** related files/classes (optional)
EOF
```
Slug names the *pattern*, not the file: `tanstack-query-hooks`, `prisma-repository`, `nextauth-middleware-guard`, `feature-checkout-flow`.
- **Refinement of an existing pattern** (adds something genuinely new — a variant, an exception, a second mechanism, or a correction of an earlier claim) → same `finding` command with the existing slug and **no title**; it is inserted under that entry.
- **Pure repetition** (same pattern, nothing new) → `bash $A also {AUDIT_DIR} <category> <slug> <path>` only. Do not write prose. This keeps prevalence counts honest without bloating the docs.
4. **Features:** if the file is a page, route, layout, API endpoint the UI depends on, email template, background job, or service worker the user experiences, record a `features` entry (slug `feature-<name>`) describing in user language what it lets the user do, the entry-point file, and the URL/route if any. Read the referenced message/i18n strings for labels if needed.
5. **Module interactions:** if the file calls into, exposes an API to, or exchanges data with **another module** (see the orientation summary's module list: workspace packages, or in a single-package app the top-level feature/layer directories), record it under `module-interactions`. Slug names the edge and purpose: `<from>-to-<to>-<purpose>`, e.g. `web-to-ui-render-button`, `checkout-page-to-api-create-order`, `cron-to-db-expire-carts`. Body:
```
- **Kind:** user-facing | background
- **From → To:** `apps/web` `CheckoutPage` → `submitOrder()` (`path:line`) → `apps/api` `POST /orders` handler
- **Mechanism:** e.g. server action, `fetch` via API client, tRPC procedure, prop/callback, shared store, queue message
- **Data passed:** request types → result/stream types; where mapping happens
- **Trigger:** e.g. page load, button click, form submit, cron schedule, incoming webhook
```
`user-facing` = started by a user action or feeding what's on screen (including server work done for a page request); `background` = no user waiting (cron, queue workers, webhooks, service-worker sync/push, revalidation, build-time generation, startup init). If the same edge is used by both, record two entries. Record the side you can see; if the other side is outside your batch, name the expected callee path and mark it "Inferred:" until confirmed. A file that merely repeats a known edge gets `also`.
6. Mark the file — exactly one status:
- `contributed` — you recorded at least one `finding` (new or refinement)
- `redundant` — only `also` occurrences; note = the slug(s) it repeats
- `trivial` — nothing worth recording (empty, constants, generated-like, tiny glue); note = why
- `skipped` — could not read / binary / out of scope; note = why
```bash
bash $A mark {AUDIT_DIR} <path> <status> "<short note>"
```
## Rules
- Evidence over inference. Every claim cites a path (and line where useful). If you infer something not directly visible, prefix it with "Inferred:".
- Library versions come from `package.json` (and the lockfile only if needed to resolve a range), never from docs.
- Never open `.env*`, `.npmrc`, key/certificate or credentials files (see `secret-files.txt`), and never copy secrets (API keys, tokens, connection strings) into the library — note their presence and location only.
- Line numbers you cite must come from what the file-read tool showed you. If you didn't see the line, cite the file without a line number.
- Prefer one sharp entry over many vague ones. Don't restate what a pattern already says.
- Stay inside your batch. If a file references something important outside it, mention the referenced path in your finding; another pass covers it.
- Use only the helper to write to the library and ledger (it handles locking — other auditors are writing concurrently). Do not edit library files directly.
## When done
Run `bash $A coverage {AUDIT_DIR}` and reply with ≤15 lines: counts by status for your batch, the new slugs you created, and anything surprising (conflicting patterns, migrations in progress, suspected dead code).

View file

@ -0,0 +1,94 @@
# Report template
Write `{AUDIT_DIR}/REPORT.md` with this structure. Every table cell that names a file must be a real, project-relative path that exists. Pull content from `library/*.md`, `occurrences.tsv`, `ledger.tsv` and `audit.sh tree` output — not from memory, not from docs.
```markdown
# <Project name> — Architecture Audit
_Audited <date> from source at <project path> (<git short SHA if available>). Files in scope: N; read: N; contributed: N; redundant: N; trivial: N; skipped: N._
_Source of truth: implementation only. Documentation was not used as evidence._
## 1. At a glance
3–6 bullets: what the product is, the rendering model and framework in one line, styling approach, data layer (client fetching + backend + DB), auth, hosting, package count.
## 2. Build & toolchain
| Item | Value | Source |
|---|---|---|
| Package manager / workspaces | pnpm 9, Turborepo | `package.json`, `turbo.json` |
| Framework / bundler | Next.js 15 (Turbopack dev), React 19 | `apps/web/package.json` |
| Language | TypeScript 5.x, `strict: true`, path aliases `@/*` | `tsconfig.json` |
| Node / runtime targets | Node 20, edge runtime for middleware | `.nvmrc`, `middleware.ts` |
| Lint / format | ESLint flat config + Prettier | … |
| Env vars | validated with Zod in `env.ts`; client-exposed: `NEXT_PUBLIC_*` (names only) | … |
## 3. File tree organization
- **Scheme:** e.g. "monorepo: `apps/web` (Next.js app router), `apps/api` (Hono), `packages/ui` (design system), `packages/db` (Drizzle schema); inside `apps/web`, feature folders under `src/features/*`". State whether organization is by feature, by type, or framework-convention, with evidence.
- A trimmed tree (packages → key directories, file counts), ≤40 lines, from `audit.sh tree`.
- Package dependency direction (Mermaid `graph` or arrow list) if a monorepo.
- Naming conventions observed, and notable outliers.
## 4. Implementation summary
| Category | Implementation details | Code pointers |
|---|---|---|
| Rendering | App Router; RSC by default, 14 client components; ISR on `/blog/*` (`revalidate = 3600`) | `apps/web/src/app/layout.tsx`, `.../blog/[slug]/page.tsx` |
| Styling | Tailwind v4 with CSS-variable tokens; dark mode via `data-theme` | `apps/web/src/styles/app.css` |
| Data fetching | TanStack Query in client components; server components call `lib/api.ts` directly | … |
| … one row per category that has findings: build, architecture, routing, UI components, state, forms, API/backend, persistence, auth/security, background jobs, i18n/a11y, performance, observability, testing, deployment | | |
Rules: "Implementation details" names concrete libraries/mechanisms (+version when known) and, when a category has competing approaches, lists both with rough prevalence ("TanStack Query in 22 hooks, raw `useEffect` fetch in 5 legacy components"). "Code pointers" = 1–3 exemplar files that best show the category.
## 5. Features (user perspective)
| Feature | What it lets the user do | Entry point |
|---|---|---|
| Sign in | Sign in with email magic link or GitHub; stays signed in for 30 days | `apps/web/src/app/(auth)/login/page.tsx` |
| … | | |
Include user-perceivable background features (emails, notifications, scheduled reports, offline support, webhooks that change what the user sees). Group by area if > 15 rows.
## 6. Architecture & data flow
- Layering as implemented (page/component → hook/store → API client or server action → handler → service → DB), with one traced example end-to-end citing each file in the chain.
- Client/server boundary: what runs where.
- State management shape and caching/source of truth (server cache, client cache, URL).
- Optional Mermaid diagram.
## 7. Module interactions
How modules call each other and what data crosses each boundary, from `library/module-interactions.md` (prevalence from `occurrences.tsv`). Modules are workspace packages; in a single-package app, use top-level feature/layer directories and say so.
### 7.1 User-facing interactions
Started by a user action or feeding what's on screen, including server work done for a page request. Group rows by feature (matching §5) when there are more than ~10.
| From → To | Purpose | Mechanism | Data passed (in → out) | Trigger | Code pointers |
|---|---|---|---|---|---|
| `apps/web` checkout page → `apps/api` | Place an order | `fetch` via `lib/api.ts`, Zod-validated both sides | `CreateOrderInput` → `Order` | Submit on checkout form | `apps/web/.../CheckoutForm.tsx:58`, `apps/api/src/routes/orders.ts` |
| `apps/web` → `packages/ui` | Render controls | React components + props | `ButtonProps` → JSX | Every render | `packages/ui/src/button.tsx` |
### 7.2 Background interactions
No user waiting: cron, queue workers, webhooks, service-worker sync/push, revalidation, build-time generation, startup init.
| From → To | Purpose | Mechanism | Data passed (in → out) | Trigger | Code pointers |
|---|---|---|---|---|---|
| Stripe → `apps/api` → `packages/db` | Mark order paid | Webhook handler, signature verified, Drizzle update | `Stripe.Event` → `orders.status` row | `checkout.session.completed` webhook | `apps/api/src/webhooks/stripe.ts` |
### 7.3 Interaction map
A Mermaid `graph LR` of modules (and external services as distinct nodes), with edges labelled by purpose and data type. Draw user-facing edges solid (`-->`) and background edges dashed (`-.->`). Keep it to the edges in the tables. If there are more than ~25, draw one diagram per group.
### 7.4 Notes
- Shared state reached through more than one path (e.g. a table written by a webhook and read by a page; a store written by two features): say which module owns it.
- Package dependencies that no interaction uses (possibly dead), and layer violations (UI importing DB code, server-only code reachable from the client), with paths.
## 8. Observations
- **Inconsistencies / migrations in progress** (two ways of doing the same thing, with counts).
- **Risks & tech debt** (with paths): e.g. secrets exposed to the client bundle, unvalidated inputs, missing auth checks, heavy client dependencies.
- **Strengths** worth preserving.
## 9. Coverage & method
How many files were in scope, read, and contributed; what was excluded and why (dependencies, build output, generated code, lockfiles, translated locale files, static assets counted not read: `resource-counts.tsv`); how many subagents/batches. Location of the library: `{AUDIT_DIR}/library/`.
## 10. Usage & duration
Paste `usage.md` verbatim: wall-clock duration, per-phase durations, and the token table per harness / session kind / model, with the total row. Below it, add one line per caveat that applies:
- Tokens for writing this report fall after `finish` and are not included.
- The run was resumed across sessions, so wall clock includes idle time.
- A local model (vLLM/Ollama) reports no cache hits, so its input shows as uncached.
- Another audit or unrelated work ran in the same session during the window, so the session row includes that.
```
After writing the file, print to the terminal: section 1, the Implementation summary table, the Features table, the two Module interactions tables (or their first ~10 rows each, if long), the top 3–5 observations, the duration and token total row from §10, and the path to `REPORT.md`.