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:
parent
59fc08fa5f
commit
5201aa9bd5
63 changed files with 3042 additions and 0 deletions
129
skills/web-project-audit/SKILL.md
Normal file
129
skills/web-project-audit/SKILL.md
Normal file
|
|
@ -0,0 +1,129 @@
|
|||
---
|
||||
name: web-project-audit
|
||||
description: Audit-level architecture report for an existing web project (frontend, full-stack or monorepo — React/Next.js, Vue/Nuxt, Svelte/SvelteKit, Astro, Angular, Node backends), built by reading the source files themselves (not README/docs, which may be stale). Use when the user wants to understand, audit, map, or document how a web app is architected — its file/package organization, the libraries and mechanisms behind each implementation category (rendering, routing, styling, state, data fetching, API/backend, persistence, auth, background jobs, etc.) with code pointers, how modules interact and pass data to each other (grouped into user-facing and background interactions), and the user-facing features. Crawls files one by one (optionally fanned out to subagents), records findings into a library of per-category audit docs, then synthesizes a REPORT.md with an implementation table, a module interaction map and a features table.
|
||||
---
|
||||
|
||||
# Web Project Audit
|
||||
|
||||
Goal: a report of how the app is built **as implemented today**. Every claim traces to a source file the auditor actually read. Documentation (README, `docs/`, wiki, ADRs, comments describing intent) is **not evidence** — it is excluded from the crawl and must not be used to fill gaps. Where code is unclear, say so; don't backfill from docs.
|
||||
|
||||
The audit runs in phases. All state lives in an **audit workspace** so the work can be resumed and split across subagents:
|
||||
|
||||
```
|
||||
<AUDIT_DIR>/
|
||||
ledger.tsv every in-scope file + status (pending/contributed/redundant/trivial/skipped)
|
||||
library/<cat>.md one audit doc per implementation category — the findings library
|
||||
occurrences.tsv further files that repeat an already-documented pattern (prevalence)
|
||||
batches/ file lists for subagents
|
||||
modules.txt, resource-counts.tsv
|
||||
timeline.tsv phase start timestamps (duration tracking)
|
||||
usage.md/.json token usage + duration, written by `finish`
|
||||
REPORT.md final synthesized report
|
||||
```
|
||||
|
||||
**Timing and tokens:** `init` starts the clock. Run `bash $A phase $AUDIT_DIR <name>` as the first command of each later phase (`orientation`, `per-file`, `gate`, `cross-cutting`, `report`). `bash $A finish $AUDIT_DIR` stops the clock and writes `usage.md`. Usage is read from the harness's own logs: Claude Code transcripts (main session, subagents and headless local workers) or OpenCode's session DB. Calls are counted only inside the audit window, and only from sessions whose transcript mentions `AUDIT_DIR`. Nothing to track by hand.
|
||||
|
||||
## Harness notes (Claude Code and OpenCode)
|
||||
|
||||
This skill is shared by Claude Code and OpenCode, which both load it from `~/.claude/skills/`.
|
||||
- **`SKILL_DIR`** is the directory containing this SKILL.md. Claude Code provides it; elsewhere use the skill's reported location, normally `~/.claude/skills/web-project-audit`.
|
||||
- **Tool names:** "file-read tool" means `Read` in Claude Code and `read` in OpenCode. "Subagent" means the `Agent` tool with `general-purpose` in Claude Code, and the `task` tool with the `general` agent in OpenCode.
|
||||
- **Local model:** if you yourself are running on a locally hosted model (e.g. OpenCode pointed at vLLM or Ollama), your subagents already run locally. Never use `local-worker-handoff` from there; it exists only to move work off Anthropic models in Claude Code.
|
||||
|
||||
Helper: `A="$SKILL_DIR/scripts/audit.sh"` (run `bash $A` with no args for usage). It is the only way findings and statuses are written — it validates categories, keeps one entry per pattern slug, and locks for concurrent subagents.
|
||||
|
||||
## Phase 0 — Set up
|
||||
|
||||
1. Confirm the project root (the dir with the top-level `package.json` or backend manifest, or the workspace root of a monorepo). If the user didn't give one, use the cwd if it qualifies; otherwise ask.
|
||||
2. `AUDIT_DIR` defaults to `<project>/.web-audit/`. Tell the user it was created there and suggest adding it to `.gitignore` (don't edit `.gitignore` yourself unless asked). Use another location if the user names one.
|
||||
3. If `AUDIT_DIR/ledger.tsv` already exists with progress, **resume**: skip to the phase `bash $A coverage $AUDIT_DIR` indicates. `init` refuses to overwrite progress.
|
||||
4. Record the git SHA if the project is a repo (`git -C <project> rev-parse --short HEAD`) for the report header.
|
||||
|
||||
## Phase 1 — Inventory
|
||||
|
||||
```bash
|
||||
bash $A init <project> <AUDIT_DIR> # builds ledger + empty library docs; prints counts by module/kind
|
||||
bash $A tree <AUDIT_DIR> # package → top-level area → directory tree with file counts
|
||||
bash $A signals <AUDIT_DIR> # import/dependency hits per library
|
||||
```
|
||||
|
||||
- Modules are directories holding a `package.json` or a backend manifest (`requirements.txt`, `pyproject.toml`, `go.mod`, `Gemfile`, `Cargo.toml`, `composer.json`). Projects with a non-Node backend and no-build frontends (plain ES modules served from `static/`) are in scope.
|
||||
- The inventory includes source (`.ts .tsx .js .jsx .mjs .cjs`), backend code (`.py .go .rb .php .rs .ex .cs`), server templates (Jinja, EJS, Handlebars, ERB), shell scripts and Makefiles, framework components (`.vue .svelte .astro`), styles (`.css .scss .sass .less`), markup (`.html .mdx`), schemas (`.prisma .graphql .sql .proto`, migrations), `package.json` and workspace files, tooling config (`tsconfig`, `*.config.*`, lint/format rc files), infra (Dockerfiles, compose, `vercel.json`, `netlify.toml`, `wrangler.toml`), CI config, and JSON/TOML/YAML data. Each file gets a kind: `build config source component server style markup template schema data test story infra script ci other`. It excludes `node_modules`, build outputs (`dist`, `.next`, `.nuxt`, `.svelte-kit`, `.astro`, `.turbo`, `coverage`…), generated dirs, lockfiles, minified bundles and source maps, `vendor/` directories, Python venvs and caches, images/fonts/media under `public/`/`static/`/`assets/` (counted only; hand-written code there is kept), translated locale files (English kept), and all documentation (listed in `docs.txt` for the optional drift step only).
|
||||
- `secret-files.txt` lists `.env*`, `*.env`, `.npmrc`, `.dev.vars`, keys/certificates and credentials JSON. They are kept out of the ledger. **Never open them.** Record their existence and role from the code that reads them (e.g. "`STRIPE_SECRET_KEY` read via `process.env` in `lib/stripe.ts`") under `auth-security`, and note which variables are exposed to the client bundle (`NEXT_PUBLIC_*`, `VITE_*`, `PUBLIC_*`).
|
||||
- `signals` output is a **map of where to look, not evidence**. A library on the classpath may be unused; an import may be dead. Nothing goes into the library from `signals` alone.
|
||||
- If the ledger has obvious noise (e.g. a vendored library, an example app, large JSON fixtures or data dumps, a generated API client the filters missed), mark those `skipped` with a reason and tell the user what was excluded.
|
||||
|
||||
## Phase 2 — Orientation pass (main model, always)
|
||||
|
||||
`bash $A phase $AUDIT_DIR orientation`
|
||||
|
||||
Read these yourself first, in full, recording findings and marking each file. They establish the vocabulary every later reader needs:
|
||||
|
||||
1. Root `package.json` and workspace config (`pnpm-workspace.yaml`, `turbo.json`, `nx.json`), root `tsconfig*.json`, and the framework/bundler config (`next.config.*`, `vite.config.*`, `nuxt.config.*`, `svelte.config.*`, `astro.config.*`, `angular.json`).
|
||||
2. Each package's `package.json`: dependencies with versions, scripts, and `workspace:` dependencies on other packages → package graph.
|
||||
3. Entry points: the root layout/`_app`/`App.tsx`/`main.ts`, the router definition or the top of the file-based route tree, middleware (`middleware.ts`, server hooks), and the server entry if there is a backend (`server.ts`, `app.ts`, `src/index.ts`).
|
||||
4. Env handling (`env.ts`, `import.meta.env` usage) and the global stylesheet / theme / Tailwind config.
|
||||
|
||||
Then write a 10–20 line **orientation summary** (packages and what each is for, framework + rendering model, core libraries + versions, architectural style as seen so far, slug names already used; for a single-package app, the top-level feature/layer directories that will be treated as modules). Keep it in your context; it is passed to every subagent.
|
||||
|
||||
## Phase 3 — Per-file audit
|
||||
|
||||
`bash $A phase $AUDIT_DIR per-file`
|
||||
|
||||
Every remaining `pending` file is read **one by one, in full**, and filed into the right library doc. The exact procedure — read, pick category, new pattern vs. refinement vs. repetition, features, mark status — is in **`references/file-auditor-prompt.md`**. Read it before starting this phase; it applies to you as much as to subagents.
|
||||
|
||||
Reading: use one file-read call per file (several independent reads in one message is fine). Don't `cat` whole packages through Bash — it blurs the per-file judgement and large UI packages overflow tool output.
|
||||
|
||||
Key rule on redundancy: a file does not need to contribute. When a file is "more of the same" (the 12th shadcn primitive, the 30th page component with the identical data-loading shape) log it with `also` and mark it `redundant`. Only write prose when the file shows something not already in the library. Before writing, check `bash $A patterns $AUDIT_DIR <category>`.
|
||||
|
||||
**Choose an execution mode** from the pending count (`bash $A coverage $AUDIT_DIR`):
|
||||
|
||||
- **≤ 150 pending files → main model alone.** Loop: `bash $A next $AUDIT_DIR 10`, read and file each, repeat until `coverage` exits 0.
|
||||
- **> 150, or the user asked to offload to a local model → batched workers.** `bash $A batch $AUDIT_DIR 40` (batches stay within one package where possible). Fill the prompt in `references/file-auditor-prompt.md` per batch (`{PROJECT_ROOT}`, `{AUDIT_DIR}`, `{SKILL_DIR}`, `{BATCH_FILE}`, `{ORIENTATION_SUMMARY}`). Then pick the worker backend:
|
||||
1. **Local worker (Claude Code only, preferred when available).** If you are in Claude Code on an Anthropic model and the `local-worker-handoff` skill is installed, load it and run its `check`. On success, write each filled prompt to a file and dispatch it through that skill's `run`, with `--cwd <project>` and `--allow "Read Grep Glob Bash(bash $A:*)"`, respecting the backend's `max_parallel`. Use batches of ~20 files for local workers. This skill never names a server, model or key; those belong to the handoff skill's config.
|
||||
2. **Native subagents.** This is the default in OpenCode and the fallback in Claude Code when the handoff skill is absent or `check` fails (say so in one line). Spawn one subagent per batch (see Harness notes for the tool), several in a single message: **up to 6 at a time** on hosted models, **2–3 at a time** on a local model so they don't queue on one GPU. Local-model subagents get batches of ~20 files and the heavier spot-check in Phase 4.
|
||||
|
||||
When a wave finishes, run `patterns` and pass any notable new slugs into the next wave's orientation summary so later workers reuse them instead of inventing synonyms. Tell the user the batch count and backend before launching, and give a one-line update per wave.
|
||||
- If the user asked for a quick/cheaper run, say what you'll reduce (e.g. read all source and components but only sample styles, stories and JSON data) and mark the unsampled files `skipped` with note `sampled-out` — never silently drop coverage.
|
||||
|
||||
## Phase 4 — Coverage gate
|
||||
|
||||
`bash $A phase $AUDIT_DIR gate`
|
||||
|
||||
1. `bash $A gate $AUDIT_DIR` must print `GATE: PASS`: no `pending` files, every `contributed` file is cited by a finding, every `redundant` file has a logged occurrence. Fix or re-audit whatever it lists. (`coverage` is the non-failing progress view.)
|
||||
2. **Spot-check delegated work** (skip in main-model mode). Per batch, pick ~3 files marked `redundant`/`trivial` and ~2 `contributed` exemplars, open them, and confirm the status and the finding are right. Check local-worker batches more heavily (~5 + 3). If a batch looks skimmed (everything `trivial`, findings that don't match the file, invented line numbers), redo it with a built-in subagent or yourself and tell the user which batches were redone.
|
||||
3. Check for slug synonyms across workers (`patterns` output: e.g. `tanstack-query-hook` vs `react-query-custom-hook`). Treat them as one pattern in the report.
|
||||
|
||||
## Phase 4.5 — Cross-cutting entries (main model)
|
||||
|
||||
`bash $A phase $AUDIT_DIR cross-cutting`
|
||||
|
||||
The per-file loop doesn't naturally produce these, so write them now:
|
||||
- `file-organization`: the packaging scheme, naming conventions and outliers, from `audit.sh tree` plus what you read. Use source `(project)`.
|
||||
- Empty categories: `bash $A none $AUDIT_DIR <category> "<what you looked for>"`, so the report can say "None found in code" with evidence of looking.
|
||||
- `module-interactions`: close the gaps the per-file pass leaves. For every `workspace:` dependency in the package graph (Phase 2), check that at least one interaction entry explains what it is used for; read the files needed to fill any missing edge. Also check the client → server boundary, external services (payment, email, auth providers, webhooks) and every background entry point (cron, queue worker, webhook, service worker) for an entry. Confirm or correct "Inferred:" callee sides with a refinement. In a single-package app, do the same across the top-level feature/layer directories. If the app really is one undivided unit, record `none` saying so.
|
||||
- `observations`: inconsistencies across files, such as two mechanisms for one job or migrations in progress, that no single file reveals.
|
||||
- Superseded claims: the library is append-only. If an early finding was wrong or an "Inferred:" note was later confirmed, add a refinement to that slug saying so. The report uses the latest refinement.
|
||||
|
||||
## Phase 5 — Consolidate and report
|
||||
|
||||
`bash $A phase $AUDIT_DIR report`
|
||||
|
||||
1. Read **every** `library/*.md` in full and `occurrences.tsv` (prevalence per slug: `awk -F'\t' 'NR>1{print $1"/"$2}' occurrences.tsv | sort | uniq -c | sort -rn`).
|
||||
2. Resolve conflicts: where two mechanisms coexist (styled-components + Tailwind, SWR + TanStack Query), report both with counts — that is a finding, not noise. Note which is newer/dominant only if the code shows it.
|
||||
3. Pick **code pointers** per category: the 1–3 files that most clearly show the pattern (usually the exemplar, but prefer a clean canonical file over a first-seen edge case). Verify each path exists.
|
||||
4. Run `bash $A finish $AUDIT_DIR` immediately before writing the report. It stops the clock and writes `usage.md`, whose tables go verbatim into the report's "Usage & duration" section. Tokens spent writing the report itself fall after the clock stops; the report's section says so.
|
||||
5. Write `AUDIT_DIR/REPORT.md` following **`references/report-template.md`**: at-a-glance, build & toolchain, **file tree organization scheme**, **implementation summary table (Category | Implementation details | Code pointers)**, **features table (Feature | What it lets the user do | Entry point)**, architecture & data flow with one end-to-end trace, **module interactions** (user-facing and background tables of From → To | Mechanism | Data passed | Trigger, plus a diagram), observations (inconsistencies, risks, strengths), coverage & method.
|
||||
6. Print the summary to the terminal as the template's last paragraph describes, and give the full path to `REPORT.md` and the library dir.
|
||||
|
||||
If this skill is itself running inside a subagent and the harness refuses the `REPORT.md` write, don't work around it. Return the full report text as your final reply, with the intended path, so the parent session saves it.
|
||||
|
||||
Optional, only after the report is complete and only if documentation exists: add a **"Documentation drift"** section listing doc claims the code contradicts (e.g. README says Redux, code uses Zustand). This is the only point where docs are opened, and they are compared against the report — never used to write it.
|
||||
|
||||
## Guardrails
|
||||
|
||||
- Read files; don't infer content from names, grep hits, or `signals`.
|
||||
- Cite paths (and `:line` for key facts). Mark inferences as "Inferred:".
|
||||
- Versions from `package.json` / the backend manifest (lockfile only to resolve a range). For vendored libraries with no manifest, read only the version banner at the top of each file and say that's where the version came from.
|
||||
- Never open files in `secret-files.txt`, and never copy secret values into the library or report; note location and type only.
|
||||
- Don't modify the audited project. The only writes are inside `AUDIT_DIR`.
|
||||
67
skills/web-project-audit/references/file-auditor-prompt.md
Normal file
67
skills/web-project-audit/references/file-auditor-prompt.md
Normal 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).
|
||||
94
skills/web-project-audit/references/report-template.md
Normal file
94
skills/web-project-audit/references/report-template.md
Normal 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`.
|
||||
439
skills/web-project-audit/scripts/audit.sh
Normal file
439
skills/web-project-audit/scripts/audit.sh
Normal file
|
|
@ -0,0 +1,439 @@
|
|||
#!/usr/bin/env bash
|
||||
# web-project-audit helper.
|
||||
# All state lives in an audit workspace (AUDIT_DIR). Safe for concurrent use by
|
||||
# several subagents: every write goes through a mkdir-based lock.
|
||||
#
|
||||
# Usage:
|
||||
# audit.sh init <project-dir> <audit-dir> # inventory + library skeleton
|
||||
# audit.sh tree <audit-dir> # package/directory organization view
|
||||
# audit.sh signals <audit-dir> # import/dependency-based library hints (NOT evidence)
|
||||
# audit.sh batch <audit-dir> [size] # split pending files into batches
|
||||
# audit.sh next <audit-dir> [n] # next n pending files (single-agent mode)
|
||||
# audit.sh patterns <audit-dir> [category] # pattern slugs already documented (+ counts)
|
||||
# audit.sh finding <audit-dir> <category> <slug> <source-path|(project)> ["<title>"] # body on stdin
|
||||
# title required for a new slug; omit for a refinement of an existing slug
|
||||
# audit.sh none <audit-dir> <category> "<what was looked for>" # record an absence
|
||||
# audit.sh also <audit-dir> <category> <slug> <source-path> # another occurrence
|
||||
# audit.sh mark <audit-dir> <source-path> <status> [note]
|
||||
# status: contributed | redundant | trivial | skipped
|
||||
# audit.sh coverage <audit-dir> # progress report (always exits 0)
|
||||
# audit.sh phase <audit-dir> <name> # timestamp the start of a phase (for durations)
|
||||
# audit.sh finish <audit-dir> # stop the clock; write usage.md (tokens + duration)
|
||||
# audit.sh usage <audit-dir> [--json] # token usage + duration so far
|
||||
# audit.sh gate <audit-dir> # exit 1 if pending files or status/finding mismatches
|
||||
set -euo pipefail
|
||||
|
||||
SELF_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
TEMPLATES="$SELF_DIR/../templates"
|
||||
|
||||
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"
|
||||
|
||||
die() { echo "audit.sh: $*" >&2; exit 2; }
|
||||
now_ms() { python3 -I -c 'import time; print(int(time.time()*1000))'; }
|
||||
|
||||
lock() {
|
||||
local l="$AUDIT_DIR/.lock" i=0
|
||||
until mkdir "$l" 2>/dev/null; do
|
||||
i=$((i+1)); [ $i -gt 600 ] && die "could not acquire lock $l (stale? rmdir it)"
|
||||
sleep 0.1
|
||||
done
|
||||
trap 'rmdir "$AUDIT_DIR/.lock" 2>/dev/null || true' EXIT
|
||||
}
|
||||
unlock() { rmdir "$AUDIT_DIR/.lock" 2>/dev/null || true; trap - EXIT; }
|
||||
|
||||
need_dir() { AUDIT_DIR="${1:?audit-dir required}"; [ -f "$AUDIT_DIR/ledger.tsv" ] || die "no ledger in $AUDIT_DIR (run init first)"; }
|
||||
|
||||
valid_cat() { case " $CATEGORIES " in *" $1 "*) ;; *) die "unknown category '$1'. Valid: $CATEGORIES";; esac; }
|
||||
|
||||
# Normalise a source path to be project-relative (accepts absolute paths too).
|
||||
relpath() {
|
||||
local p="$1" root; root="$(cat "$AUDIT_DIR/.project_root")"
|
||||
[ "$p" = "(project)" ] && { printf '%s' "$p"; return; }
|
||||
case "$p" in "$root"/*) p="${p#"$root"/}";; esac
|
||||
printf '%s' "${p#./}"
|
||||
}
|
||||
|
||||
cmd_init() {
|
||||
local proj="${1:?project-dir required}" out="${2:?audit-dir required}"
|
||||
[ -d "$proj" ] || die "project dir not found: $proj"
|
||||
proj="$(cd "$proj" && pwd)"
|
||||
if [ -f "$out/ledger.tsv" ] && awk -F'\t' 'NR>1 && $7!="pending" {f=1} END {exit !f}' "$out/ledger.tsv" && [ "${FORCE:-}" != 1 ]; then
|
||||
die "$out already has audit progress. Resume with 'coverage'/'next'/'batch', or re-run with FORCE=1 to start over (wipe $out first)."
|
||||
fi
|
||||
mkdir -p "$out/library" "$out/batches"
|
||||
AUDIT_DIR="$(cd "$out" && pwd)"
|
||||
echo "$proj" > "$AUDIT_DIR/.project_root"
|
||||
now_ms > "$AUDIT_DIR/.started_at"; rm -f "$AUDIT_DIR/.finished_at"
|
||||
printf '%s\tinventory\n' "$(cat "$AUDIT_DIR/.started_at")" > "$AUDIT_DIR/timeline.tsv"
|
||||
|
||||
# Module roots = dirs holding a package.json or a backend manifest (requirements.txt, pyproject.toml, go.mod, Gemfile, Cargo.toml, composer.json).
|
||||
( cd "$proj" && find . \( -name node_modules -o -name .git -o -name dist -o -name build -o -name out -o -name .next -o -name .nuxt -o -name .output \
|
||||
-o -name .svelte-kit -o -name .astro -o -name .turbo -o -name .vercel -o -name .netlify -o -name coverage -o -name .cache \
|
||||
-o -name .parcel-cache -o -name storybook-static -o -name generated -o -name __generated__ -o -name .idea -o -name .vscode \
|
||||
-o -name vendor -o -name .web-audit -o -name .yarn -o -name .pnpm-store \
|
||||
-o -name .venv -o -name venv -o -name __pycache__ -o -name .pytest_cache -o -name .mypy_cache -o -name target \) -prune -o \
|
||||
\( -name package.json -o -name requirements.txt -o -name pyproject.toml -o -name go.mod -o -name Gemfile -o -name Cargo.toml \
|
||||
-o -name composer.json -o -name deno.json -o -name deno.jsonc \) -print ) \
|
||||
| sed 's#^\./##; s#/\{0,1\}[^/]*$##' | sort -u > "$AUDIT_DIR/modules.txt"
|
||||
[ -s "$AUDIT_DIR/modules.txt" ] || echo "" > "$AUDIT_DIR/modules.txt"
|
||||
|
||||
# Candidate source files. Documentation (*.md, docs/) is deliberately excluded:
|
||||
# this audit is about current implementation, not what docs claim.
|
||||
( cd "$proj" && find . \
|
||||
\( -name node_modules -o -name .git -o -name dist -o -name build -o -name out -o -name .next -o -name .nuxt -o -name .output \
|
||||
-o -name .svelte-kit -o -name .astro -o -name .turbo -o -name .vercel -o -name .netlify -o -name coverage -o -name .cache \
|
||||
-o -name .parcel-cache -o -name storybook-static -o -name generated -o -name __generated__ -o -name .idea -o -name .vscode \
|
||||
-o -name vendor -o -name .web-audit -o -name .yarn -o -name .pnpm-store \
|
||||
-o -name .venv -o -name venv -o -name __pycache__ -o -name .pytest_cache -o -name .mypy_cache -o -name target -o -name docs -o -name doc \) -prune -o \
|
||||
-type f \( -name '*.ts' -o -name '*.tsx' -o -name '*.js' -o -name '*.jsx' -o -name '*.mjs' -o -name '*.cjs' \
|
||||
-o -name '*.vue' -o -name '*.svelte' -o -name '*.astro' -o -name '*.css' -o -name '*.scss' -o -name '*.sass' -o -name '*.less' \
|
||||
-o -name '*.pcss' -o -name '*.html' -o -name '*.mdx' -o -name '*.json' -o -name '*.jsonc' -o -name '*.prisma' -o -name '*.graphql' \
|
||||
-o -name '*.gql' -o -name '*.sql' -o -name '*.proto' -o -name '*.toml' -o -name '*.yml' -o -name '*.yaml' -o -name 'Dockerfile*' \
|
||||
-o -name '.babelrc' -o -name '.eslintrc*' -o -name '.prettierrc*' -o -name '.browserslistrc' -o -name '.nvmrc' -o -name '.node-version' \
|
||||
-o -name 'Procfile' -o -name 'Caddyfile' -o -name 'nginx*.conf' \
|
||||
-o -name '*.py' -o -name '*.go' -o -name '*.rb' -o -name '*.php' -o -name '*.rs' -o -name '*.ex' -o -name '*.exs' -o -name '*.cs' \
|
||||
-o -name '*.sh' -o -name 'Makefile' -o -name 'justfile' -o -name 'requirements*.txt' -o -name 'go.mod' -o -name 'Gemfile' \
|
||||
-o -name '*.jinja' -o -name '*.jinja2' -o -name '*.j2' -o -name '*.hbs' -o -name '*.ejs' -o -name '*.njk' -o -name '*.erb' \) -print ) \
|
||||
| sed 's#^\./##' \
|
||||
| awk '
|
||||
# drop noise: lockfiles, minified/bundled output, source maps, translated locale files.
|
||||
# Hand-written code under public/ or static/ stays: no-build apps serve their whole frontend from there.
|
||||
/(^|\/)(package-lock\.json|npm-shrinkwrap\.json|yarn\.lock|pnpm-lock\.yaml|bun\.lockb?|composer\.lock)$/ { next }
|
||||
/\.min\.(js|css)$/ || /\.map$/ || /\.bundle\.js$/ { next }
|
||||
/(^|\/)(locales?|i18n|lang|translations|messages)\/.*/ { n=split($0,a,"/"); f=a[n]; d=a[n-1]
|
||||
if (f !~ /^en([-_][A-Za-z]+)?\.json$/ && d !~ /^en([-_][A-Za-z]+)?$/ && (f ~ /^[a-z][a-z]([-_][A-Za-z]+)?\.json$/ || d ~ /^[a-z][a-z]([-_][A-Za-z]+)?$/)) next }
|
||||
/\.ya?ml$/ && !/^\.github\// && !/^\.gitlab-ci/ && !/circleci|bitbucket-pipelines|azure-pipelines|docker-compose|compose\.ya?ml|pnpm-workspace|netlify|render\.ya?ml|fly|app\.ya?ml|openapi|swagger/ { next }
|
||||
{ print }' \
|
||||
| sort > "$AUDIT_DIR/.files"
|
||||
|
||||
# Build ledger: id module sourceset kind lines path status note
|
||||
awk -v root="$proj" '
|
||||
FILENAME==ARGV[1] { mods[++m]=$0; next }
|
||||
{
|
||||
path=$0; best=""; bl=-1
|
||||
for (i=1;i<=m;i++) { mod=mods[i]
|
||||
if (mod=="" ) { if (bl<0) { best="(root)"; bl=0 } continue }
|
||||
if (index(path, mod "/")==1 && length(mod)>bl) { best=mod; bl=length(mod) } }
|
||||
if (best=="") best="(root)"
|
||||
rel=path; if (best!="(root)") rel=substr(path, length(best)+2)
|
||||
ss="-"; if (index(rel, "/")) ss=substr(rel, 1, index(rel, "/")-1)
|
||||
f=path; sub(/.*\//, "", f)
|
||||
k="other"
|
||||
if (f=="package.json" || f ~ /^(pnpm-workspace\.yaml|turbo\.json|nx\.json|lerna\.json|rush\.json|deno\.jsonc?|requirements.*\.txt|pyproject\.toml|go\.mod|Gemfile|Cargo\.toml|composer\.json|Makefile|justfile)$/) k="build"
|
||||
else if (path ~ /^\.github\/|^\.gitlab-ci|circleci|bitbucket-pipelines|azure-pipelines/) k="ci"
|
||||
else if (f ~ /^(Dockerfile.*|docker-compose.*|compose\.ya?ml|Procfile|Caddyfile|nginx.*\.conf|vercel\.json|netlify\.toml|wrangler\.toml|fly\.toml|render\.ya?ml|firebase\.json|app\.ya?ml|serverless\.ya?ml)$/) k="infra"
|
||||
else if (f ~ /^(tsconfig.*|jsconfig.*)\.json$/ || f ~ /\.config\.(js|cjs|mjs|ts|mts|cts|json)$/ || f ~ /^\.(babelrc|eslintrc.*|prettierrc.*|browserslistrc|nvmrc|node-version)$/ || f ~ /^(biome|components|\.?swcrc)\.json$/) k="config"
|
||||
else if (f ~ /\.(test|spec)\.[cm]?[jt]sx?$/ || f ~ /^test_.*\.py$|_test\.(py|go)$|_spec\.rb$/ || path ~ /(^|\/)(__tests__|tests?|e2e|cypress|playwright)\//) k="test"
|
||||
else if (f ~ /\.stories\.[cm]?[jt]sx?$|\.stories\.(mdx|svelte|vue)$/) k="story"
|
||||
else if (f ~ /\.(prisma|graphql|gql|sql|proto)$/ || path ~ /(^|\/)(migrations?|schema)\//) k="schema"
|
||||
else if (f ~ /\.(css|scss|sass|less|pcss)$/) k="style"
|
||||
else if (f ~ /\.(html|mdx)$/) k="markup"
|
||||
else if (f ~ /\.(json|jsonc|toml|ya?ml)$/) k="data"
|
||||
else if (f ~ /\.(vue|svelte|astro)$/) k="component"
|
||||
else if (f ~ /\.(py|go|rb|php|rs|ex|exs|cs)$/) k="server"
|
||||
else if (f ~ /\.sh$/) k="script"
|
||||
else if (f ~ /\.(jinja2?|j2|hbs|ejs|njk|erb)$/) k="template"
|
||||
else if (f ~ /\.[cm]?[jt]sx?$/) k="source"
|
||||
cmd="wc -l < \"" root "/" path "\""; cmd | getline n; close(cmd); gsub(/ /,"",n)
|
||||
printf "%d\t%s\t%s\t%s\t%s\t%s\tpending\t\n", ++id, best, ss, k, n, path
|
||||
}' "$AUDIT_DIR/modules.txt" "$AUDIT_DIR/.files" > "$AUDIT_DIR/ledger.body"
|
||||
{ printf 'id\tmodule\tsourceset\tkind\tlines\tpath\tstatus\tnote\n'; cat "$AUDIT_DIR/ledger.body"; } > "$AUDIT_DIR/ledger.tsv"
|
||||
rm -f "$AUDIT_DIR/ledger.body" "$AUDIT_DIR/.files"
|
||||
[ -f "$AUDIT_DIR/occurrences.tsv" ] || printf 'category\tslug\tpath\n' > "$AUDIT_DIR/occurrences.tsv"
|
||||
|
||||
for c in $CATEGORIES; do
|
||||
f="$AUDIT_DIR/library/$c.md"
|
||||
[ -f "$f" ] || cp "$TEMPLATES/library/$c.md" "$f"
|
||||
done
|
||||
|
||||
# Static assets: counted, not read.
|
||||
( cd "$proj" && find . \( -name node_modules -o -name .git -o -name dist -o -name build -o -name out -o -name .next -o -name .nuxt -o -name .output \
|
||||
-o -name .svelte-kit -o -name .astro -o -name .turbo -o -name .vercel -o -name .netlify -o -name coverage -o -name .cache \
|
||||
-o -name .parcel-cache -o -name storybook-static -o -name generated -o -name __generated__ -o -name .idea -o -name .vscode \
|
||||
-o -name vendor -o -name .web-audit -o -name .yarn -o -name .pnpm-store \
|
||||
-o -name .venv -o -name venv -o -name __pycache__ -o -name .pytest_cache -o -name .mypy_cache -o -name target \) -prune -o -type f \( -path '*/public/*' -o -path '*/static/*' -o -path '*/assets/*' \) \
|
||||
\( -iname '*.png' -o -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.gif' -o -iname '*.webp' -o -iname '*.avif' -o -iname '*.svg' -o -iname '*.ico' \
|
||||
-o -iname '*.woff' -o -iname '*.woff2' -o -iname '*.ttf' -o -iname '*.otf' -o -iname '*.mp4' -o -iname '*.webm' -o -iname '*.mp3' -o -iname '*.pdf' \) -print ) \
|
||||
| awk '{ e=$0; sub(/.*\./, "", e); c[tolower(e)]++ } END { for (k in c) printf "%s\t%d\n", k, c[k] }' \
|
||||
| sort > "$AUDIT_DIR/resource-counts.tsv"
|
||||
|
||||
( cd "$proj" && find . \( -name node_modules -o -name .git -o -name dist -o -name build -o -name out -o -name .next -o -name .nuxt -o -name .output \
|
||||
-o -name .svelte-kit -o -name .astro -o -name .turbo -o -name .vercel -o -name .netlify -o -name coverage -o -name .cache \
|
||||
-o -name .parcel-cache -o -name storybook-static -o -name generated -o -name __generated__ -o -name .idea -o -name .vscode \
|
||||
-o -name vendor -o -name .web-audit -o -name .yarn -o -name .pnpm-store \
|
||||
-o -name .venv -o -name venv -o -name __pycache__ -o -name .pytest_cache -o -name .mypy_cache -o -name target \) -prune -o \
|
||||
-type f \( -iname '*.md' -o -iname '*.adoc' -o -iname '*.rst' \) -print ) | sed 's#^\./##' | sort > "$AUDIT_DIR/docs.txt"
|
||||
( cd "$proj" && find . \( -name node_modules -o -name .git -o -name dist -o -name build -o -name out -o -name .next -o -name .nuxt -o -name .output \
|
||||
-o -name .svelte-kit -o -name .astro -o -name .turbo -o -name .vercel -o -name .netlify -o -name coverage -o -name .cache \
|
||||
-o -name .parcel-cache -o -name storybook-static -o -name generated -o -name __generated__ -o -name .idea -o -name .vscode \
|
||||
-o -name vendor -o -name .web-audit -o -name .yarn -o -name .pnpm-store \
|
||||
-o -name .venv -o -name venv -o -name __pycache__ -o -name .pytest_cache -o -name .mypy_cache -o -name target \) -prune -o -type f \( -name '.env' -o -name '.env.*' -o -name '*.env' -o -name '*.pem' -o -name '*.key' \
|
||||
-o -name '*.p12' -o -name '*.pfx' -o -name '.npmrc' -o -name '.yarnrc.yml' -o -name 'credentials*.json' -o -name 'service-account*.json' \
|
||||
-o -name '*-sa.json' -o -name '.dev.vars' -o -name 'secrets.*' \) -print ) | sed 's#^\./##' | sort > "$AUDIT_DIR/secret-files.txt"
|
||||
# Secret-bearing files never enter the ledger.
|
||||
awk -F'\t' -v s="$AUDIT_DIR/secret-files.txt" 'BEGIN{while((getline l<s)>0) S[l]=1} NR==1 || !($6 in S)' "$AUDIT_DIR/ledger.tsv" > "$AUDIT_DIR/ledger.tmp" && mv "$AUDIT_DIR/ledger.tmp" "$AUDIT_DIR/ledger.tsv"
|
||||
echo "Project: $proj"
|
||||
echo "Audit dir: $AUDIT_DIR"
|
||||
echo "Modules: $(grep -c . "$AUDIT_DIR/modules.txt" || true)"
|
||||
echo "Files in ledger: $(($(wc -l < "$AUDIT_DIR/ledger.tsv")-1))"
|
||||
echo "Docs found (NOT audited; only for optional drift check): $(grep -c . "$AUDIT_DIR/docs.txt" || true) -> docs.txt"
|
||||
echo "Secret-bearing files (never open; note existence/role only): $(grep -c . "$AUDIT_DIR/secret-files.txt" || true) -> secret-files.txt"
|
||||
echo
|
||||
echo "By kind:"; awk -F'\t' 'NR>1{c[$4]++; l[$4]+=$5} END{for(k in c) printf " %-15s %5d files %8d lines\n", k, c[k], l[k]}' "$AUDIT_DIR/ledger.tsv" | sort
|
||||
echo "By module:"; awk -F'\t' 'NR>1{c[$2]++; l[$2]+=$5} END{for(k in c) printf " %-40s %5d files %8d lines\n", k, c[k], l[k]}' "$AUDIT_DIR/ledger.tsv" | sort
|
||||
}
|
||||
|
||||
cmd_tree() {
|
||||
need_dir "$1"
|
||||
echo "== Modules (dirs with package.json or a backend manifest) =="; sed 's/^$/(root)/; s/^/ /' "$AUDIT_DIR/modules.txt"
|
||||
echo
|
||||
echo "== Directories per module [top-level area] (code files per directory: source/component/server/style/markup/test/story/template) =="
|
||||
awk -F'\t' 'NR>1 && ($4=="source"||$4=="component"||$4=="server"||$4=="style"||$4=="test"||$4=="story"||$4=="markup"||$4=="template") {
|
||||
p=$6; if ($2!="(root)") p=substr(p, length($2)+2); if (index(p, "/")) sub(/\/[^\/]+$/, "", p); else p="."
|
||||
key=$2 " [" $3 "]"; d[key SUBSEP p]++ }
|
||||
END { for (k in d) { split(k, a, SUBSEP); printf "%s\t%s\t%d\n", a[1], a[2], d[k] } }' "$AUDIT_DIR/ledger.tsv" \
|
||||
| sort -t$'\t' -k1,1 -k2,2 \
|
||||
| awk -F'\t' '{ if ($1!=last) { print "\n" $1; last=$1 } printf " %-70s %4d\n", $2 "/", $3 }'
|
||||
echo
|
||||
echo "== Static assets (counted, not read) =="; sed 's/^/ /' "$AUDIT_DIR/resource-counts.tsv"
|
||||
}
|
||||
|
||||
cmd_signals() {
|
||||
need_dir "$1"; local root; root="$(cat "$AUDIT_DIR/.project_root")"
|
||||
echo "Import/plugin hits — HINTS ONLY. Confirm by reading files before recording anything."
|
||||
awk -F'\t' 'NR>1 && ($4=="source"||$4=="component"||$4=="server"||$4=="markup"||$4=="template"||$4=="build"||$4=="config"||$4=="test"||$4=="story"||$4=="style"||$4=="infra"||$4=="script") {print $6}' "$AUDIT_DIR/ledger.tsv" > "$AUDIT_DIR/.sig"
|
||||
while IFS='|' read -r label re; do
|
||||
hits=$(cd "$root" && tr '\n' '\0' < "$AUDIT_DIR/.sig" | xargs -0 grep -lE -- "$re" 2>/dev/null || true)
|
||||
[ -n "$hits" ] || continue
|
||||
printf ' %-34s %4d files e.g. %s\n' "$label" "$(printf '%s\n' "$hits" | wc -l)" "$(printf '%s\n' "$hits" | head -1)"
|
||||
done <<'EOF'
|
||||
React|from ['"]react['"]|"react":
|
||||
Next.js|from ['"]next/|"next":
|
||||
Remix / React Router framework|@remix-run/|@react-router/|"react-router":
|
||||
Vue|from ['"]vue['"]|\.vue['"]|"vue":
|
||||
Nuxt|"nuxt":|defineNuxtConfig|useFetch\(|useAsyncData\(
|
||||
Svelte / SvelteKit|"svelte":|@sveltejs/kit|\$app/
|
||||
Astro|"astro":|Astro\.props
|
||||
Angular|@angular/core
|
||||
SolidJS|from ['"]solid-js
|
||||
Qwik|@builder\.io/qwik
|
||||
Server components / actions|['"]use server['"]|['"]use client['"]
|
||||
Tailwind CSS|tailwindcss|@tailwind |@import ['"]tailwindcss
|
||||
CSS Modules|\.module\.(css|scss)
|
||||
Sass/SCSS|"sass":|\.scss['"]
|
||||
styled-components / Emotion|styled-components|@emotion/
|
||||
vanilla-extract / Panda / StyleX|@vanilla-extract|@pandacss|@stylexjs
|
||||
Radix / shadcn|@radix-ui/|components\.json|class-variance-authority
|
||||
Headless UI / Ark / React Aria|@headlessui/|@ark-ui/|react-aria
|
||||
MUI / Chakra / Mantine / Ant|@mui/|@chakra-ui/|@mantine/|from ['"]antd
|
||||
Lucide / other icon sets|lucide-|@heroicons/|react-icons|@iconify
|
||||
React Router|from ['"]react-router(-dom)?['"]
|
||||
TanStack Router|@tanstack/react-router
|
||||
Vue Router|vue-router
|
||||
TanStack Query|@tanstack/(react|vue|svelte)-query|react-query
|
||||
SWR|from ['"]swr['"]
|
||||
Apollo / urql / GraphQL|@apollo/client|from ['"]urql|graphql-request|gql`
|
||||
tRPC|@trpc/
|
||||
axios / ky / ofetch|from ['"](axios|ky|ofetch)['"]
|
||||
OpenAPI clients|openapi-fetch|openapi-typescript|@hey-api|orval
|
||||
Redux / RTK|@reduxjs/toolkit|from ['"]redux|react-redux
|
||||
Zustand / Jotai / Valtio|from ['"](zustand|jotai|valtio)
|
||||
Pinia / Vuex|from ['"](pinia|vuex)['"]
|
||||
XState|from ['"]xstate|@xstate/
|
||||
React Hook Form / Formik|react-hook-form|from ['"]formik
|
||||
TanStack Form / Superforms|@tanstack/(react-)?form|sveltekit-superforms
|
||||
Zod / Yup / Valibot|from ['"](zod|yup|valibot)['"]
|
||||
Express / Fastify / Koa|from ['"](express|fastify|koa)['"]|require\(['"](express|fastify|koa)['"]\)
|
||||
Hono / Elysia|from ['"](hono|elysia)
|
||||
NestJS|@nestjs/
|
||||
Route handlers / API routes|export (async )?function (GET|POST|PUT|PATCH|DELETE)|export const (GET|POST)|pages/api/
|
||||
Prisma|@prisma/client|PrismaClient
|
||||
Drizzle|drizzle-orm
|
||||
Kysely / Knex / TypeORM / Sequelize|from ['"](kysely|knex|typeorm|sequelize)
|
||||
Mongoose / MongoDB|from ['"](mongoose|mongodb)['"]
|
||||
Supabase|@supabase/
|
||||
Firebase|from ['"]firebase/|firebase-admin
|
||||
Redis|ioredis|from ['"]redis['"]|@upstash/redis
|
||||
localStorage / IndexedDB|localStorage\.|sessionStorage\.|indexedDB|from ['"](idb|dexie|localforage)
|
||||
Auth.js / NextAuth|next-auth|@auth/
|
||||
Clerk / Auth0 / Lucia / Better Auth|@clerk/|@auth0/|from ['"]lucia|better-auth
|
||||
JWT / sessions / cookies|jsonwebtoken|from ['"]jose['"]|iron-session|cookies\(\)|express-session
|
||||
Background jobs / queues|bullmq|from ['"]bull['"]|inngest|trigger\.dev|@vercel/functions|qstash|graphile-worker|pg-boss
|
||||
Cron / schedules|node-cron|cron-parser|"crons":|scheduled\(|schedule\(
|
||||
Webhooks|webhook|stripe\.webhooks|svix
|
||||
Service worker / PWA|serviceWorker\.register|workbox|vite-plugin-pwa|next-pwa|self\.addEventListener\(['"](fetch|install|push)
|
||||
WebSockets / realtime|new WebSocket|socket\.io|from ['"]ws['"]|pusher|ably|EventSource
|
||||
Stripe / payments|from ['"]stripe|@stripe/
|
||||
i18n|i18next|react-intl|next-intl|vue-i18n|@formatjs|paraglide|lingui
|
||||
Motion / animation|framer-motion|from ['"]motion|gsap|@react-spring|auto-animate
|
||||
Charts / viz|recharts|from ['"]d3|chart\.js|@visx/|echarts|@nivo/|apexcharts
|
||||
3D / canvas|from ['"]three|@react-three/|pixi\.js|konva
|
||||
Dates|date-fns|dayjs|moment|luxon|@internationalized/date
|
||||
Markdown / MDX|react-markdown|@mdx-js|remark-|rehype-|marked|shiki|prismjs
|
||||
Sentry / error tracking|@sentry/|bugsnag|(^|[^A-Za-z])rollbar
|
||||
Analytics|posthog|@vercel/analytics|plausible|@segment/|mixpanel|gtag\(|amplitude
|
||||
Logging|from ['"](pino|winston)['"]|consola
|
||||
Feature flags|launchdarkly|growthbook|@vercel/flags|unleash|flagsmith
|
||||
Vitest|from ['"]vitest['"]|"vitest":
|
||||
Jest|from ['"]@jest/|jest\.fn|"jest":
|
||||
Testing Library|@testing-library/
|
||||
Playwright|@playwright/test
|
||||
Cypress|cypress
|
||||
MSW|from ['"]msw
|
||||
Storybook|@storybook/
|
||||
Vite|from ['"]vite['"]|"vite":
|
||||
Webpack / Rspack / Turbopack|webpack|@rspack|--turbo
|
||||
ESLint / Prettier / Biome|eslint|prettier|@biomejs
|
||||
Monorepo tooling|turbo\.json|nx\.json|pnpm-workspace|"workspaces":|lerna
|
||||
Docker|^FROM |docker-compose
|
||||
Vercel / Netlify / Cloudflare|vercel\.json|netlify\.toml|wrangler|@cloudflare/
|
||||
No-build ES modules / import maps|<script type="module"|type="importmap"
|
||||
FastAPI / Starlette|from fastapi|from starlette|import fastapi
|
||||
Flask / Django|from flask|import flask|from django|django\.
|
||||
Python DB (SQLAlchemy / sqlite3)|sqlalchemy|import sqlite3|from sqlmodel
|
||||
Go HTTP (net/http, Gin, Echo, Chi)|"net/http"|gin-gonic|labstack/echo|go-chi
|
||||
Rails / Sinatra|Rails\.application|ActiveRecord|require .sinatra
|
||||
pytest|import pytest|def test_
|
||||
Node test runner|from ['"]node:test['"]|node --test
|
||||
EOF
|
||||
rm -f "$AUDIT_DIR/.sig"
|
||||
}
|
||||
|
||||
cmd_batch() {
|
||||
need_dir "$1"; local size="${2:-40}"
|
||||
rm -f "$AUDIT_DIR"/batches/batch-*.txt
|
||||
# Pending files, grouped by module then path, so a batch stays within one area.
|
||||
# Build + config files are expected to be handled in the orientation pass, so they sort first.
|
||||
awk -F'\t' 'NR>1 && $7=="pending" { pr=($4=="build"||$4=="config")?0:1; print pr "\t" $2 "\t" $6 }' "$AUDIT_DIR/ledger.tsv" \
|
||||
| sort -t$'\t' -k1,1n -k2,2 -k3,3 \
|
||||
| awk -F'\t' -v size="$size" -v dir="$AUDIT_DIR/batches" '
|
||||
{ if (n==0 || cnt>=size || ($2!=lastmod && cnt>=size/2)) { n++; cnt=0; f=sprintf("%s/batch-%03d.txt", dir, n) }
|
||||
print $3 > f; cnt++; lastmod=$2 }
|
||||
END { print n+0 " batches written to " dir }'
|
||||
for f in "$AUDIT_DIR"/batches/batch-*.txt; do [ -f "$f" ] && printf ' %s %3d files %s\n' "$(basename "$f")" "$(wc -l < "$f")" "$(head -1 "$f")"; done
|
||||
}
|
||||
|
||||
cmd_next() {
|
||||
need_dir "$1"; local n="${2:-10}"
|
||||
awk -F'\t' -v n="$n" 'NR>1 && $7=="pending" { pr=($4=="build"||$4=="config")?0:1; print pr "\t" $2 "\t" $6 }' "$AUDIT_DIR/ledger.tsv" \
|
||||
| sort -t$'\t' -k1,1n -k2,2 -k3,3 | head -n "$n" | cut -f3
|
||||
}
|
||||
|
||||
cmd_patterns() {
|
||||
need_dir "$1"; local cat="${2:-}"
|
||||
local files; if [ -n "$cat" ]; then valid_cat "$cat"; files="$AUDIT_DIR/library/$cat.md"; else files="$AUDIT_DIR/library/*.md"; fi
|
||||
# shellcheck disable=SC2086
|
||||
grep -H '^### \[' $files 2>/dev/null | sed 's#.*/library/\([^.]*\)\.md:\#\#\# \[\([^]]*\)\] *\(.*\)#\1\t\2\t\3#' \
|
||||
| while IFS=$'\t' read -r c s t; do
|
||||
occ=$(awk -F'\t' -v c="$c" -v s="$s" '$1==c && $2==s' "$AUDIT_DIR/occurrences.tsv" | wc -l)
|
||||
printf '%-22s %-40s +%-3d %s\n' "$c" "$s" "$occ" "$t"
|
||||
done
|
||||
}
|
||||
|
||||
cmd_finding() {
|
||||
need_dir "$1"; local cat="${2:?category}" slug="${3:?slug}" src="${4:?source-path}" title="${5:-}"
|
||||
valid_cat "$cat"
|
||||
[[ "$slug" =~ ^[a-z0-9][a-z0-9-]*$ ]] || die "slug must be kebab-case: $slug"
|
||||
src="$(relpath "$src")"
|
||||
local body; body="$(cat)"; [ -n "$body" ] || die "finding body (stdin) is empty"
|
||||
local f="$AUDIT_DIR/library/$cat.md"
|
||||
lock
|
||||
# A workspace from an older skill version may lack a newer category's doc: seed it from the template.
|
||||
[ -f "$f" ] || cp "$TEMPLATES/library/$cat.md" "$f"
|
||||
if grep -q "^### \[$slug\]" "$f"; then
|
||||
# Same pattern already documented: insert the refinement right after that entry's block.
|
||||
printf '\n#### +[%s] refinement from `%s`\n%s\n\n' "$slug" "$src" "$body" > "$f.ins"
|
||||
awk -v slug="$slug" -v ins="$f.ins" '
|
||||
function flush() { while ((getline l < ins) > 0) print l; close(ins); done=1 }
|
||||
/^### \[/ { if (inblk && !done) flush(); inblk = (index($0, "### [" slug "]")==1) }
|
||||
{ print } END { if (!done) flush() }' "$f" > "$f.tmp" && mv "$f.tmp" "$f"; rm -f "$f.ins"
|
||||
else
|
||||
[ -n "$title" ] || { unlock; die "title required for new slug [$slug]"; }
|
||||
printf '\n### [%s] %s\n- **Exemplar:** `%s`\n%s\n' "$slug" "$title" "$src" "$body" >> "$f"
|
||||
fi
|
||||
unlock
|
||||
echo "recorded $cat/$slug from $src"
|
||||
}
|
||||
|
||||
cmd_phase() {
|
||||
need_dir "$1"; local name="${2:?phase name}"
|
||||
lock; printf '%s\t%s\n' "$(now_ms)" "${name//$'\t'/ }" >> "$AUDIT_DIR/timeline.tsv"; unlock
|
||||
echo "phase '$name' started"
|
||||
}
|
||||
|
||||
cmd_usage() { need_dir "$1"; shift; python3 -I "$SELF_DIR/usage.py" "$AUDIT_DIR" "$@"; }
|
||||
|
||||
cmd_finish() {
|
||||
need_dir "$1"
|
||||
[ -f "$AUDIT_DIR/.finished_at" ] || now_ms > "$AUDIT_DIR/.finished_at"
|
||||
python3 -I "$SELF_DIR/usage.py" "$AUDIT_DIR" > "$AUDIT_DIR/usage.md"
|
||||
python3 -I "$SELF_DIR/usage.py" "$AUDIT_DIR" --json > "$AUDIT_DIR/usage.json"
|
||||
cat "$AUDIT_DIR/usage.md"
|
||||
}
|
||||
|
||||
cmd_none() {
|
||||
need_dir "$1"; local cat="${2:?category}" what="${3:?what was looked for}"
|
||||
valid_cat "$cat"; lock
|
||||
printf '\n### [none] None found in code\n- **Exemplar:** `(project)`\n- Looked for: %s\n' "$what" >> "$AUDIT_DIR/library/$cat.md"
|
||||
unlock; echo "recorded absence in $cat"
|
||||
}
|
||||
|
||||
cmd_also() {
|
||||
need_dir "$1"; local cat="${2:?category}" slug="${3:?slug}" src="${4:?source-path}"
|
||||
valid_cat "$cat"; src="$(relpath "$src")"
|
||||
grep -q "^### \[$slug\]" "$AUDIT_DIR/library/$cat.md" || die "no pattern [$slug] in $cat.md — record it with 'finding' first"
|
||||
lock; printf '%s\t%s\t%s\n' "$cat" "$slug" "$src" >> "$AUDIT_DIR/occurrences.tsv"; unlock
|
||||
}
|
||||
|
||||
cmd_mark() {
|
||||
need_dir "$1"; local src="${2:?source-path}" st="${3:?status}" note="${4:-}"
|
||||
case "$st" in contributed|redundant|trivial|skipped) ;; *) die "status must be contributed|redundant|trivial|skipped";; esac
|
||||
src="$(relpath "$src")"; note="${note//$'\t'/ }"; note="${note//$'\n'/ }"
|
||||
lock
|
||||
awk -F'\t' -v OFS='\t' -v p="$src" -v s="$st" -v n="$note" '
|
||||
NR>1 && $6==p { $7=s; $8=n; hit=1 } { print }
|
||||
END { if (!hit) exit 3 }' "$AUDIT_DIR/ledger.tsv" > "$AUDIT_DIR/ledger.tmp" \
|
||||
&& mv "$AUDIT_DIR/ledger.tmp" "$AUDIT_DIR/ledger.tsv" \
|
||||
|| { rm -f "$AUDIT_DIR/ledger.tmp"; unlock; die "path not in ledger: $src"; }
|
||||
unlock
|
||||
}
|
||||
|
||||
cmd_coverage() {
|
||||
need_dir "$1"
|
||||
awk -F'\t' 'NR>1 { c[$7]++; t++ } END { for (k in c) printf " %-12s %5d (%.0f%%)\n", k, c[k], 100*c[k]/t; printf " %-12s %5d\n", "total", t }' "$AUDIT_DIR/ledger.tsv"
|
||||
echo "Patterns documented: $(grep -h '^### \[' "$AUDIT_DIR"/library/*.md | wc -l) extra occurrences: $(($(wc -l < "$AUDIT_DIR/occurrences.tsv")-1))"
|
||||
local p; p=$(awk -F'\t' 'NR>1 && $7=="pending"' "$AUDIT_DIR/ledger.tsv" | wc -l)
|
||||
if [ "$p" -gt 0 ]; then
|
||||
echo "PENDING: $p (first 20):"; awk -F'\t' 'NR>1 && $7=="pending" {print " " $6}' "$AUDIT_DIR/ledger.tsv" | head -20
|
||||
else echo "All files accounted for."; fi
|
||||
}
|
||||
|
||||
# Files whose status disagrees with the library: contributed with no finding, redundant with no occurrence.
|
||||
mismatches() {
|
||||
cat "$AUDIT_DIR"/library/*.md | grep -oE '^- \*\*Exemplar:\*\* `[^`]+`|^#### \+\[[^]]+\] refinement from `[^`]+`' \
|
||||
| sed 's/.*`\([^`]*\)`$/\1/' | sort -u > "$AUDIT_DIR/.contrib"
|
||||
awk -F'\t' 'NR>1 {print $3}' "$AUDIT_DIR/occurrences.tsv" | sort -u > "$AUDIT_DIR/.occ"
|
||||
awk -F'\t' -v c="$AUDIT_DIR/.contrib" -v o="$AUDIT_DIR/.occ" '
|
||||
BEGIN { while ((getline l < c) > 0) C[l]=1; while ((getline l < o) > 0) O[l]=1 }
|
||||
NR>1 && $7=="contributed" && !($6 in C) { print " contributed but no finding cites it: " $6 }
|
||||
NR>1 && $7=="redundant" && !($6 in O) && !($6 in C) { print " redundant but no occurrence logged: " $6 }' "$AUDIT_DIR/ledger.tsv"
|
||||
rm -f "$AUDIT_DIR/.contrib" "$AUDIT_DIR/.occ"
|
||||
}
|
||||
|
||||
cmd_gate() {
|
||||
need_dir "$1"; cmd_coverage "$1"
|
||||
local p m; p=$(awk -F'\t' 'NR>1 && $7=="pending"' "$AUDIT_DIR/ledger.tsv" | wc -l); m="$(mismatches)"
|
||||
[ -n "$m" ] && { echo "Status/library mismatches:"; echo "$m"; }
|
||||
[ "$p" -eq 0 ] && [ -z "$m" ] && { echo "GATE: PASS"; return 0; }
|
||||
echo "GATE: FAIL"; return 1
|
||||
}
|
||||
|
||||
sub="${1:-}"; shift || true
|
||||
case "$sub" in
|
||||
init) cmd_init "$@";; tree) cmd_tree "$@";; signals) cmd_signals "$@";; batch) cmd_batch "$@";;
|
||||
next) cmd_next "$@";; patterns) cmd_patterns "$@";; finding) cmd_finding "$@";; also) cmd_also "$@";;
|
||||
mark) cmd_mark "$@";; coverage) cmd_coverage "$@";; gate) cmd_gate "$@";; none) cmd_none "$@";;
|
||||
phase) cmd_phase "$@";; usage) cmd_usage "$@";; finish) cmd_finish "$@";;
|
||||
""|-h|--help|help) sed -n '2,28p' "$0";;
|
||||
*) sed -n '2,28p' "$0"; exit 2;;
|
||||
esac
|
||||
133
skills/web-project-audit/scripts/usage.py
Normal file
133
skills/web-project-audit/scripts/usage.py
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
#!/usr/bin/env python3
|
||||
"""Token usage + duration for one audit run.
|
||||
|
||||
usage.py <audit-dir> [--json]
|
||||
|
||||
Window: <audit-dir>/.started_at .. .finished_at (or now), epoch ms.
|
||||
Attribution: any session (main, subagent, headless worker) whose transcript mentions
|
||||
the audit dir path; only model calls made inside the window are counted.
|
||||
|
||||
Sources (read-only):
|
||||
Claude Code ~/.claude/projects/*/**/*.jsonl (assistant message.usage, deduped by message id)
|
||||
OpenCode ~/.local/share/opencode/opencode.db (message.data.tokens; subagents = child sessions)
|
||||
"""
|
||||
import glob, json, os, sqlite3, sys, time
|
||||
from collections import defaultdict
|
||||
from datetime import datetime
|
||||
|
||||
def iso_ms(s):
|
||||
try: return int(datetime.fromisoformat(s.replace("Z", "+00:00")).timestamp() * 1000)
|
||||
except Exception: return None
|
||||
|
||||
def read_ms(path, default=None):
|
||||
try: return int(open(path).read().strip())
|
||||
except Exception: return default
|
||||
|
||||
def empty(): return {"calls": 0, "input": 0, "cache_write": 0, "cache_read": 0, "output": 0, "sessions": set()}
|
||||
|
||||
def claude_code(audit_dir, start, end, rows):
|
||||
needle = audit_dir.encode()
|
||||
root = os.path.expanduser("~/.claude/projects")
|
||||
for f in glob.glob(os.path.join(root, "**", "*.jsonl"), recursive=True):
|
||||
try:
|
||||
if os.path.getmtime(f) * 1000 < start: continue
|
||||
with open(f, "rb") as fh: data = fh.read()
|
||||
except OSError: continue
|
||||
if needle not in data: continue
|
||||
kind = "subagent" if "/subagents/" in f else "session"
|
||||
seen = {}
|
||||
for line in data.splitlines():
|
||||
try: o = json.loads(line)
|
||||
except Exception: continue
|
||||
m = o.get("message") or {}
|
||||
if o.get("type") != "assistant" or not m.get("usage"): continue
|
||||
ts = iso_ms(o.get("timestamp", ""))
|
||||
if ts is None or ts < start or ts > end: continue
|
||||
seen[m.get("id") or id(o)] = (m.get("model") or "?", m["usage"]) # last write wins
|
||||
for model, u in seen.values():
|
||||
r = rows[("claude-code", kind, model)]
|
||||
r["calls"] += 1; r["sessions"].add(f)
|
||||
r["input"] += u.get("input_tokens") or 0
|
||||
r["cache_write"] += u.get("cache_creation_input_tokens") or 0
|
||||
r["cache_read"] += u.get("cache_read_input_tokens") or 0
|
||||
r["output"] += u.get("output_tokens") or 0
|
||||
|
||||
def opencode(audit_dir, start, end, rows):
|
||||
db = os.path.expanduser("~/.local/share/opencode/opencode.db")
|
||||
if not os.path.exists(db): return
|
||||
try: c = sqlite3.connect(f"file:{db}?mode=ro", uri=True)
|
||||
except Exception: return
|
||||
try:
|
||||
roots = {r[0] for r in c.execute(
|
||||
"select distinct p.session_id from part p join session s on s.id=p.session_id "
|
||||
"where s.time_updated >= ? and p.data like ?", (start, f"%{audit_dir}%"))}
|
||||
# include all descendants (subagent sessions) of matching sessions
|
||||
allids, frontier = set(roots), set(roots)
|
||||
while frontier:
|
||||
q = ",".join("?" * len(frontier))
|
||||
kids = {r[0] for r in c.execute(f"select id from session where parent_id in ({q})", tuple(frontier))}
|
||||
frontier = kids - allids; allids |= kids
|
||||
parent = dict(c.execute("select id, parent_id from session"))
|
||||
for sid in allids:
|
||||
kind = "subagent" if parent.get(sid) else "session"
|
||||
for (d,) in c.execute("select data from message where session_id=?", (sid,)):
|
||||
o = json.loads(d); t = o.get("tokens")
|
||||
ts = (o.get("time") or {}).get("created")
|
||||
if o.get("role") != "assistant" or not t or ts is None or ts < start or ts > end: continue
|
||||
r = rows[("opencode", kind, f'{o.get("providerID")}/{o.get("modelID")}')]
|
||||
r["calls"] += 1; r["sessions"].add(sid)
|
||||
r["input"] += t.get("input") or 0
|
||||
r["cache_write"] += (t.get("cache") or {}).get("write") or 0
|
||||
r["cache_read"] += (t.get("cache") or {}).get("read") or 0
|
||||
r["output"] += (t.get("output") or 0) + (t.get("reasoning") or 0)
|
||||
finally: c.close()
|
||||
|
||||
def fmt_dur(ms):
|
||||
s = max(0, ms // 1000); return f"{s//3600}h {s%3600//60:02d}m {s%60:02d}s" if s >= 3600 else f"{s//60}m {s%60:02d}s"
|
||||
|
||||
def main():
|
||||
audit_dir = os.path.abspath(sys.argv[1]); as_json = "--json" in sys.argv
|
||||
start = read_ms(os.path.join(audit_dir, ".started_at"))
|
||||
if start is None: sys.exit("usage.py: no .started_at in audit dir (run audit.sh init)")
|
||||
fin = read_ms(os.path.join(audit_dir, ".finished_at")); end = fin or int(time.time() * 1000)
|
||||
rows = defaultdict(empty)
|
||||
claude_code(audit_dir, start, end, rows); opencode(audit_dir, start, end, rows)
|
||||
|
||||
phases = []
|
||||
tl = os.path.join(audit_dir, "timeline.tsv")
|
||||
if os.path.exists(tl):
|
||||
marks = [l.rstrip("\n").split("\t") for l in open(tl) if l.strip()]
|
||||
marks = [(int(t), n) for t, n in marks]
|
||||
for i, (t, n) in enumerate(marks):
|
||||
nxt = marks[i + 1][0] if i + 1 < len(marks) else end
|
||||
phases.append((n, nxt - t))
|
||||
|
||||
tot = empty()
|
||||
for r in rows.values():
|
||||
for k in ("calls", "input", "cache_write", "cache_read", "output"): tot[k] += r[k]
|
||||
if as_json:
|
||||
print(json.dumps({"start_ms": start, "end_ms": end, "finished": bool(fin), "duration_ms": end - start,
|
||||
"phases": [{"phase": n, "ms": ms} for n, ms in phases],
|
||||
"rows": [dict(harness=h, kind=k, model=m, **{x: v for x, v in r.items() if x != "sessions"}, session_count=len(r["sessions"]))
|
||||
for (h, k, m), r in sorted(rows.items())],
|
||||
"total": {k: v for k, v in tot.items() if k != "sessions"}}, indent=2)); return
|
||||
|
||||
n = lambda v: f"{v:,}"
|
||||
out = [f"**Duration:** {fmt_dur(end - start)} wall clock "
|
||||
f"({datetime.fromtimestamp(start/1000):%Y-%m-%d %H:%M} → {datetime.fromtimestamp(end/1000):%H:%M}"
|
||||
f"{'' if fin else ', still running'})", ""]
|
||||
if phases:
|
||||
out += ["| Phase | Duration |", "|---|---|"] + [f"| {p} | {fmt_dur(ms)} |" for p, ms in phases] + [""]
|
||||
out += ["| Harness | Kind | Model | Sessions | Calls | Input (uncached) | Cache write | Cache read | Output | Total input |",
|
||||
"|---|---|---|---|---|---|---|---|---|---|"]
|
||||
for (h, k, m), r in sorted(rows.items()):
|
||||
ti = r["input"] + r["cache_write"] + r["cache_read"]
|
||||
out.append(f"| {h} | {k} | {m} | {len(r['sessions'])} | {n(r['calls'])} | {n(r['input'])} | {n(r['cache_write'])} | {n(r['cache_read'])} | {n(r['output'])} | {n(ti)} |")
|
||||
ti = tot["input"] + tot["cache_write"] + tot["cache_read"]
|
||||
out.append(f"| **Total** | | | | **{n(tot['calls'])}** | **{n(tot['input'])}** | **{n(tot['cache_write'])}** | **{n(tot['cache_read'])}** | **{n(tot['output'])}** | **{n(ti)}** |")
|
||||
out += ["", "_Total input = uncached + cache write + cache read; output includes reasoning/thinking tokens. "
|
||||
"Counted: model calls inside the audit window from sessions whose transcript mentions this audit dir._"]
|
||||
if not rows: out.append("_No matching sessions found — usage unavailable for this harness._")
|
||||
print("\n".join(out))
|
||||
|
||||
if __name__ == "__main__": main()
|
||||
11
skills/web-project-audit/templates/library/api-backend.md
Normal file
11
skills/web-project-audit/templates/library/api-backend.md
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# API & Backend
|
||||
|
||||
> Audit library doc. Findings come from reading source files — never from README/docs.
|
||||
> Each pattern is one `### [slug] Title` entry (written via `audit.sh finding`), with an exemplar file.
|
||||
> Further files that repeat a known pattern are logged with `audit.sh also`, not re-described.
|
||||
|
||||
**Scope:** Server code in this repo: endpoints and business logic.
|
||||
|
||||
**Look for:** framework (route handlers, Express/Fastify/Hono/Nest, serverless functions); endpoint list and methods; input validation; error format; middleware chain; rate limiting; external service integrations (payments, email, storage); OpenAPI/GraphQL schema; BFF patterns.
|
||||
|
||||
## Findings
|
||||
11
skills/web-project-audit/templates/library/architecture.md
Normal file
11
skills/web-project-audit/templates/library/architecture.md
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# Architecture & Layering
|
||||
|
||||
> Audit library doc. Findings come from reading source files — never from README/docs.
|
||||
> Each pattern is one `### [slug] Title` entry (written via `audit.sh finding`), with an exemplar file.
|
||||
> Further files that repeat a known pattern are logged with `audit.sh also`, not re-described.
|
||||
|
||||
**Scope:** Overall shape: rendering model, layers, boundaries, data flow.
|
||||
|
||||
**Look for:** SPA vs SSR/SSG/ISR vs islands; client/server boundary (`use client`, server components, loaders); layering (UI → hooks/stores → services/API clients → backend → DB); domain types vs DTOs; where business logic lives; shared packages; unidirectional data flow; layer violations (components calling DB, fetch scattered in UI).
|
||||
|
||||
## Findings
|
||||
11
skills/web-project-audit/templates/library/auth-security.md
Normal file
11
skills/web-project-audit/templates/library/auth-security.md
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# Auth & Security
|
||||
|
||||
> Audit library doc. Findings come from reading source files — never from README/docs.
|
||||
> Each pattern is one `### [slug] Title` entry (written via `audit.sh finding`), with an exemplar file.
|
||||
> Further files that repeat a known pattern are logged with `audit.sh also`, not re-described.
|
||||
|
||||
**Scope:** Identity, access control and security posture.
|
||||
|
||||
**Look for:** auth provider/library; session vs JWT; where tokens live (httpOnly cookie vs storage); route/middleware protection; role/permission checks; CSRF/CORS config; security headers/CSP; input sanitization/XSS (`dangerouslySetInnerHTML`, `v-html`); secrets handling (env vars, which are exposed to the client); dependency on `secret-files.txt` entries by name only.
|
||||
|
||||
## Findings
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
# Background Jobs & Async Work
|
||||
|
||||
> Audit library doc. Findings come from reading source files — never from README/docs.
|
||||
> Each pattern is one `### [slug] Title` entry (written via `audit.sh finding`), with an exemplar file.
|
||||
> Further files that repeat a known pattern are logged with `audit.sh also`, not re-described.
|
||||
|
||||
**Scope:** Work that runs without a user waiting.
|
||||
|
||||
**Look for:** cron/scheduled functions; queues and workers (BullMQ, Inngest, …); webhooks received; email sending; revalidation/ISR triggers; service-worker background sync and push; build-time data generation; long-running processes.
|
||||
|
||||
## Findings
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
# Build & Tooling
|
||||
|
||||
> Audit library doc. Findings come from reading source files — never from README/docs.
|
||||
> Each pattern is one `### [slug] Title` entry (written via `audit.sh finding`), with an exemplar file.
|
||||
> Further files that repeat a known pattern are logged with `audit.sh also`, not re-described.
|
||||
|
||||
**Scope:** Package manager, workspaces, bundler/framework config, TypeScript setup, scripts, lint/format, versions.
|
||||
|
||||
**Look for:** package manager + lockfile type; workspaces/monorepo tool (pnpm/npm/yarn workspaces, Turborepo, Nx); framework + bundler and versions from package.json; tsconfig strictness, path aliases, project references; package.json scripts (dev/build/test/lint); env var loading (`import.meta.env`, `process.env`, `NEXT_PUBLIC_*`) and where it is validated; ESLint/Prettier/Biome config; browserslist/targets; build plugins.
|
||||
|
||||
## Findings
|
||||
11
skills/web-project-audit/templates/library/data-fetching.md
Normal file
11
skills/web-project-audit/templates/library/data-fetching.md
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# Data Fetching & API Clients
|
||||
|
||||
> Audit library doc. Findings come from reading source files — never from README/docs.
|
||||
> Each pattern is one `### [slug] Title` entry (written via `audit.sh finding`), with an exemplar file.
|
||||
> Further files that repeat a known pattern are logged with `audit.sh also`, not re-described.
|
||||
|
||||
**Scope:** How the frontend gets and mutates data.
|
||||
|
||||
**Look for:** TanStack Query/SWR/Apollo/tRPC/plain fetch; API client wrappers, base URLs, interceptors, auth headers; request/response typing and runtime validation (Zod); caching, invalidation, optimistic updates; pagination/infinite scroll; error and retry handling; server actions; realtime (WebSocket/SSE).
|
||||
|
||||
## Findings
|
||||
11
skills/web-project-audit/templates/library/deployment.md
Normal file
11
skills/web-project-audit/templates/library/deployment.md
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# Deployment & CI
|
||||
|
||||
> Audit library doc. Findings come from reading source files — never from README/docs.
|
||||
> Each pattern is one `### [slug] Title` entry (written via `audit.sh finding`), with an exemplar file.
|
||||
> Further files that repeat a known pattern are logged with `audit.sh also`, not re-described.
|
||||
|
||||
**Scope:** How code gets to users.
|
||||
|
||||
**Look for:** CI workflows (steps, checks, caching); hosting target (Vercel, Netlify, Cloudflare, Docker/K8s, static host); Dockerfiles and compose; environment separation (preview/staging/prod); env var injection; release/versioning; database migration step in deploy.
|
||||
|
||||
## Findings
|
||||
11
skills/web-project-audit/templates/library/features.md
Normal file
11
skills/web-project-audit/templates/library/features.md
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# Features (user perspective)
|
||||
|
||||
> Audit library doc. Findings come from reading source files — never from README/docs.
|
||||
> Each pattern is one `### [slug] Title` entry (written via `audit.sh finding`), with an exemplar file.
|
||||
> Further files that repeat a known pattern are logged with `audit.sh also`, not re-described.
|
||||
|
||||
**Scope:** What the product lets users do, as implemented.
|
||||
|
||||
**Look for:** one entry per user-perceivable capability (`feature-<name>`): what it lets the user do, entry point (route/page/component), and any background part (emails, notifications, scheduled reports, offline support).
|
||||
|
||||
## Findings
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
# File Organization
|
||||
|
||||
> Audit library doc. Findings come from reading source files — never from README/docs.
|
||||
> Each pattern is one `### [slug] Title` entry (written via `audit.sh finding`), with an exemplar file.
|
||||
> Further files that repeat a known pattern are logged with `audit.sh also`, not re-described.
|
||||
|
||||
**Scope:** How the codebase is laid out and named.
|
||||
|
||||
**Look for:** by-feature vs by-type vs framework-convention (file-based routes); where components, hooks, stores, services, utils live; barrel files; path aliases in use; naming conventions (PascalCase components, kebab-case files, `.client`/`.server` suffixes); co-located tests/styles/stories; outliers.
|
||||
|
||||
## Findings
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
# Forms & Validation
|
||||
|
||||
> Audit library doc. Findings come from reading source files — never from README/docs.
|
||||
> Each pattern is one `### [slug] Title` entry (written via `audit.sh finding`), with an exemplar file.
|
||||
> Further files that repeat a known pattern are logged with `audit.sh also`, not re-described.
|
||||
|
||||
**Scope:** How input is collected and validated.
|
||||
|
||||
**Look for:** form library; schema validation shared between client and server; field components; error display; submission handling and pending states; file uploads; multi-step forms.
|
||||
|
||||
## Findings
|
||||
11
skills/web-project-audit/templates/library/i18n-a11y.md
Normal file
11
skills/web-project-audit/templates/library/i18n-a11y.md
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# Internationalization & Accessibility
|
||||
|
||||
> Audit library doc. Findings come from reading source files — never from README/docs.
|
||||
> Each pattern is one `### [slug] Title` entry (written via `audit.sh finding`), with an exemplar file.
|
||||
> Further files that repeat a known pattern are logged with `audit.sh also`, not re-described.
|
||||
|
||||
**Scope:** Language support and accessible UI as implemented.
|
||||
|
||||
**Look for:** i18n library, locale detection, message files (count locales from `ledger` / excluded files), formatting via `Intl`; RTL support; semantic HTML, ARIA usage, focus management, keyboard support, skip links, reduced-motion handling, alt text practices, a11y lint rules/tests.
|
||||
|
||||
## Findings
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
# Module Interactions
|
||||
|
||||
> Audit library doc. Findings come from reading source files — never from README/docs.
|
||||
> Each pattern is one `### [slug] Title` entry (written via `audit.sh finding`), with an exemplar file.
|
||||
> Further files that repeat a known pattern are logged with `audit.sh also`, not re-described.
|
||||
|
||||
**Scope:** How modules call each other and what data crosses each boundary. One entry per interaction (caller → callee for one purpose). "Module" means a workspace package; in a single-package app, use top-level feature/layer directories (e.g. `src/features/*`, `src/lib/*`, `server/`) instead.
|
||||
|
||||
**Look for:** imports of another package/feature; props/callbacks and context passed across feature boundaries; route params and search params between pages; client → server calls (fetch, server actions, tRPC, GraphQL) and their request/response types; server → DB/external API calls; events (custom events, event bus, BroadcastChannel, postMessage); shared stores read/written by several modules; queue/job payloads; webhook payloads; service-worker messages; shared DB tables/cache keys written by one module and read by another; layer violations.
|
||||
|
||||
**Each entry states:** **Kind** (`user-facing`: started by a user action or feeding what is on screen, including the request/response of a page load; `background`: no user waiting, e.g. cron, queue workers, webhooks, service-worker sync/push, revalidation, build-time generation, startup init), **From → To** (module + function/component, `path:line`), **Mechanism**, **Data passed** (types in each direction, where mapping/validation happens), **Trigger**.
|
||||
|
||||
## Findings
|
||||
11
skills/web-project-audit/templates/library/observability.md
Normal file
11
skills/web-project-audit/templates/library/observability.md
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# Observability
|
||||
|
||||
> Audit library doc. Findings come from reading source files — never from README/docs.
|
||||
> Each pattern is one `### [slug] Title` entry (written via `audit.sh finding`), with an exemplar file.
|
||||
> Further files that repeat a known pattern are logged with `audit.sh also`, not re-described.
|
||||
|
||||
**Scope:** Errors, logs, analytics, monitoring.
|
||||
|
||||
**Look for:** error tracking (Sentry, …) client and server; error boundaries; logging library and format; analytics/event tracking and which events; feature flags; health checks; tracing.
|
||||
|
||||
## Findings
|
||||
11
skills/web-project-audit/templates/library/observations.md
Normal file
11
skills/web-project-audit/templates/library/observations.md
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# Observations
|
||||
|
||||
> Audit library doc. Findings come from reading source files — never from README/docs.
|
||||
> Each pattern is one `### [slug] Title` entry (written via `audit.sh finding`), with an exemplar file.
|
||||
> Further files that repeat a known pattern are logged with `audit.sh also`, not re-described.
|
||||
|
||||
**Scope:** Cross-cutting notes no single category owns.
|
||||
|
||||
**Look for:** inconsistencies (two mechanisms for one job, with counts); migrations in progress; dead code suspicions; risky patterns; comment-vs-code mismatches; strengths worth keeping.
|
||||
|
||||
## Findings
|
||||
11
skills/web-project-audit/templates/library/performance.md
Normal file
11
skills/web-project-audit/templates/library/performance.md
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# Performance
|
||||
|
||||
> Audit library doc. Findings come from reading source files — never from README/docs.
|
||||
> Each pattern is one `### [slug] Title` entry (written via `audit.sh finding`), with an exemplar file.
|
||||
> Further files that repeat a known pattern are logged with `audit.sh also`, not re-described.
|
||||
|
||||
**Scope:** Mechanisms that affect load and runtime speed.
|
||||
|
||||
**Look for:** code splitting and lazy loading; image optimization (`next/image`, srcset); font loading; bundle analysis config; memoization patterns; virtualization of long lists; prefetching; web-vitals reporting; heavy dependencies imported on the client.
|
||||
|
||||
## Findings
|
||||
11
skills/web-project-audit/templates/library/persistence.md
Normal file
11
skills/web-project-audit/templates/library/persistence.md
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# Persistence & Storage
|
||||
|
||||
> Audit library doc. Findings come from reading source files — never from README/docs.
|
||||
> Each pattern is one `### [slug] Title` entry (written via `audit.sh finding`), with an exemplar file.
|
||||
> Further files that repeat a known pattern are logged with `audit.sh also`, not re-described.
|
||||
|
||||
**Scope:** Where data is stored, server and client.
|
||||
|
||||
**Look for:** database + ORM/query builder (Prisma, Drizzle, …); schema and migrations; connection handling; caching layers (Redis, in-memory, HTTP cache); object storage; client storage (localStorage, IndexedDB, cookies); seed data.
|
||||
|
||||
## Findings
|
||||
11
skills/web-project-audit/templates/library/rendering.md
Normal file
11
skills/web-project-audit/templates/library/rendering.md
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# Rendering & Delivery
|
||||
|
||||
> Audit library doc. Findings come from reading source files — never from README/docs.
|
||||
> Each pattern is one `### [slug] Title` entry (written via `audit.sh finding`), with an exemplar file.
|
||||
> Further files that repeat a known pattern are logged with `audit.sh also`, not re-described.
|
||||
|
||||
**Scope:** Where and when HTML is produced.
|
||||
|
||||
**Look for:** CSR/SSR/SSG/ISR per route; streaming and Suspense boundaries; hydration strategy/islands; caching directives (`revalidate`, `cache`, `Cache-Control`, CDN headers); edge vs node runtimes; static export; prerendered routes.
|
||||
|
||||
## Findings
|
||||
11
skills/web-project-audit/templates/library/routing.md
Normal file
11
skills/web-project-audit/templates/library/routing.md
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# Routing & Navigation
|
||||
|
||||
> Audit library doc. Findings come from reading source files — never from README/docs.
|
||||
> Each pattern is one `### [slug] Title` entry (written via `audit.sh finding`), with an exemplar file.
|
||||
> Further files that repeat a known pattern are logged with `audit.sh also`, not re-described.
|
||||
|
||||
**Scope:** How URLs map to screens and how users move between them.
|
||||
|
||||
**Look for:** file-based vs config routes; layouts and nested routes; dynamic segments; route guards/middleware and redirects; loaders/actions; search-param state; 404/error boundaries; links vs programmatic navigation; i18n route prefixes; deep links.
|
||||
|
||||
## Findings
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
# State Management
|
||||
|
||||
> Audit library doc. Findings come from reading source files — never from README/docs.
|
||||
> Each pattern is one `### [slug] Title` entry (written via `audit.sh finding`), with an exemplar file.
|
||||
> Further files that repeat a known pattern are logged with `audit.sh also`, not re-described.
|
||||
|
||||
**Scope:** Client state: where it lives and how it changes.
|
||||
|
||||
**Look for:** local component state; context; stores (Redux/Zustand/Jotai/Pinia/XState); URL as state; persisted state (localStorage); derived state; global vs feature stores; server-state caches used as client state; prop drilling hot spots.
|
||||
|
||||
## Findings
|
||||
11
skills/web-project-audit/templates/library/styling.md
Normal file
11
skills/web-project-audit/templates/library/styling.md
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# Styling & Theming
|
||||
|
||||
> Audit library doc. Findings come from reading source files — never from README/docs.
|
||||
> Each pattern is one `### [slug] Title` entry (written via `audit.sh finding`), with an exemplar file.
|
||||
> Further files that repeat a known pattern are logged with `audit.sh also`, not re-described.
|
||||
|
||||
**Scope:** How visual design is expressed in code.
|
||||
|
||||
**Look for:** Tailwind / CSS Modules / Sass / CSS-in-JS / plain CSS; design tokens (CSS variables, Tailwind theme); dark mode mechanism; fonts and how they load; responsive approach (breakpoints, container queries); global styles and resets; hard-coded colors/sizes vs tokens; animation approach.
|
||||
|
||||
## Findings
|
||||
11
skills/web-project-audit/templates/library/testing.md
Normal file
11
skills/web-project-audit/templates/library/testing.md
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# Testing
|
||||
|
||||
> Audit library doc. Findings come from reading source files — never from README/docs.
|
||||
> Each pattern is one `### [slug] Title` entry (written via `audit.sh finding`), with an exemplar file.
|
||||
> Further files that repeat a known pattern are logged with `audit.sh also`, not re-described.
|
||||
|
||||
**Scope:** How the code is tested.
|
||||
|
||||
**Look for:** unit/integration runner (Vitest/Jest); component testing (Testing Library); e2e (Playwright/Cypress); API mocking (MSW); fixtures/factories; visual/snapshot tests; Storybook stories and interaction tests; coverage config; which areas are tested and which are not.
|
||||
|
||||
## Findings
|
||||
11
skills/web-project-audit/templates/library/ui-components.md
Normal file
11
skills/web-project-audit/templates/library/ui-components.md
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# UI Components
|
||||
|
||||
> Audit library doc. Findings come from reading source files — never from README/docs.
|
||||
> Each pattern is one `### [slug] Title` entry (written via `audit.sh finding`), with an exemplar file.
|
||||
> Further files that repeat a known pattern are logged with `audit.sh also`, not re-described.
|
||||
|
||||
**Scope:** Component architecture and the design system as implemented.
|
||||
|
||||
**Look for:** component library (own design system, shadcn/Radix, MUI, …); primitives vs composites; variants API (cva, props); icon set; layout components; composition patterns (slots, compound components, render props); modals/toasts; component size and reuse; duplicated components.
|
||||
|
||||
## Findings
|
||||
Loading…
Add table
Add a link
Reference in a new issue