claude/skills/web-project-audit/references/file-auditor-prompt.md
Neil Bantoc 5201aa9bd5 Add web-frontend, web-project-audit and web-project-scaffold-containerized-python skills
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 16:26:33 -08:00

6.2 KiB
Raw Permalink Blame History

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 $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 $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).