.agents/skills/deep-review/references/dimensions/reuse-architecture.md
Cross-file thinking: does this diff reinvent something the repo already has, ignore an established pattern, or erode an architectural boundary? This is the only dimension whose findings require repo-wide searching — never judge from the diff alone.
Reuse operates at three levels, and AI-authored diffs most often fail at the upper two — they write locally plausible code without checking how the repo already solves this class of problem:
lambdaClient, never useEffect + useState)packages/utils, src/utils/, src/hooks/, shared modulessetInterval + ref cleanup, string-concatenated paths, custom validation) — search before writinguseEffect/useState instead of the store SWR pipeline; hand-rolled modal state instead of createModal; component calling lambdaClient directly instead of through a service)src/routes/ must stay thin and delegate to src/features/).agents/skills/project-overview/SKILL.md — layer map: what belongs in apps/packages/src.agents/skills/spa-routes/SKILL.md — roots vs features split.agents/skills/data-fetching-architecture/SKILL.md — the canonical cross-layer route for server data (component → store SWR hook → service → lambdaClient).agents/skills/store-data-structures/SKILL.md, .agents/skills/zustand/SKILL.md — store shape and action patterns when the diff touches storesmodal, trpc-router, builtin-tool, drizzle, ...) — check .agents/skills/ for a skill matching the touched domain; when one exists it is the yardstick, cite it in rule_sourceThree passes — precedent, outward, inward:
Precedent (pattern alignment) — run this first for any new feature/capability:
useFetchXxx / refreshXxx)? same failure-handling shape? A structural deviation is a finding unless the diff or PR states why the precedent does not fit.Outward (dedup + pattern reuse):
rg the repo with action + context keyword combos (e.g. window.open + popup, setInterval + poll, JSON.parse + storage).packages/utils/, src/utils/, src/hooks/, src/lib/, */store/selectors/, sibling directories of the changed files.existing_implementations filled (file:line or file:line-range, ≥ 1 entry).Inward (extensibility): judge the diff's own design — parameter sprawl, leaky abstractions, hardcoded literals with existing constants (rg to confirm the constant exists).
Fix placement (for bug fixes on long pipelines): many bugs can be patched at several points of the chain they live on (e.g. user message → agent runtime → provider → render); correct placement is decided by problem ownership, not by where the patch is easiest:
packages/model-runtime/src/providers/deepseek/, not in the shared core/openaiCompatibleFactory/ where it would branch for every provider. Class-wide → the fix belongs in the shared layer, not replicated at one call site.if (variant === ...) branch to shared code when a seam exists is the violation.Large-repo fallback: if a single rg exceeds ~30s, restrict to the changed files' top-level directories plus the default reuse sources.
nature: "introduced" even when the existing copy is old — adding the duplicate is new).existing_implementations points at the precedent (and cite the category pattern skill when one exists).