# Post-Delegation Audit Pattern After subagents build spq-v2 pages, dispatch a second wave of auditing subagents before considering the work done. ## Why Subagent-generated code consistently has these issues that won't surface until runtime: - Missing `onClick` handlers on buttons (text rendered, no action) - AI function signature mismatches between `src/lib/ai.ts` and page code - Wrong PocketBase collection names (underscore vs camelCase) - `sort: '-created'` on collections lacking system date fields - `useToast` calls without `ToastProvider` wrapping the route tree - Empty state / error state / loading state transitions that swallow errors ## How Dispatch 3 auditing subagents in parallel, each covering 2-3 pages: ``` delegate_task tasks=[ { goal: "Audit Dashboard + QuoteGenerator + Settings against originals", toolsets: ["file","terminal"] }, { goal: "Audit Customers + RepairOrders + Appointments against originals", toolsets: ["file","terminal"] }, { goal: "Audit FinancialDashboard + Invoices + Settings against originals", toolsets: ["file","terminal"] }, ] ``` Each auditor must: 1. READ the original v1 source files 2. READ the spq-v2 page files 3. Test PocketBase API calls at `http://127.0.0.1:8091` (login: demo@shop.com/test1234) 4. Compare every feature, UI element, and API call 5. Fix every bug found (they have `file` toolset to edit code) 6. Verify fixes with actual API calls ## Common Root Causes Found | Symptom | Root Cause | Fix | |---------|-----------|-----| | "Something went wrong" on Dashboard | `sort: '-created'` on quotes collection missing `created` field | Change to `sort: '-id'` | | "Something went wrong" on Financial | Same `-created` issue on repairOrders collection | Change to `sort: '-id'` | | "Something went wrong" on RepairOrders | Querying `repair_orders` but collection is `repairOrders` | Fix collection name | | Custom service add does nothing | Button has no `onClick` handler | Add handler that creates service and calls `handleAdd()` | | AI Write/Generate Priorities fail silently | Function signature mismatch between page code and `ai.ts` | Align call signatures | | White screen on page load | `useToast` called without `ToastProvider` | Wrap `` in `` | ## Verification After auditors finish, rebuild (`npx vite build`), restart the proxy server, and test every page in the browser.