[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M72T5959SAJ15TBS1XS3RGCF":3,"skill-same:01M72T5959SAJ15TBS1XS3RGCF":61},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":35,"commitSha":36,"skillDirectory":37,"forksCount":14,"repositoryHtmlUrl":38,"repositoryHomepageUrl":38,"ownerHtmlUrl":39,"ownerBlogUrl":6,"ownerDescription":40,"updatedAt":41,"install":42,"resources":54},"01M72T5959SAJ15TBS1XS3RGCF","monorepo-build-diagnostics",null,"Diagnose build failures in pnpm\u002FSvelte\u002FVite monorepos — stash-comparison to isolate pre-existing breakage from your changes, workspace dependency resolution pitfalls, untracked-file missing deps.","iberi22\u002Fskills","iberi22","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F10615454?v=4","01M72SQ2NXAA3GW0FSH053A5ES","Brahyan Belalcazar","01M72SQ2PYCH0SSA1K61NGEHDV",0,"MIT","https:\u002F\u002Fgithub.com\u002Fiberi22\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fgeneral\u002Fmonorepo-build-diagnostics\u002FSKILL.md",[],[],"2026-11-10 22:39:42",false,"---\nname: monorepo-build-diagnostics\ndescription: \"Diagnose build failures in pnpm\u002FSvelte\u002FVite monorepos — stash-comparison to isolate pre-existing breakage from your changes, workspace dependency resolution pitfalls, untracked-file missing deps.\"\nversion: 1.0.0\nauthor: Hermes Agent\ntags: [monorepo, pnpm, svelte, vite, build, diagnostics, workspace]\ncategory: software-development\n---\n\n# Monorepo Build Diagnostics\n\n## When to Use\n\n- A `pnpm build` fails after you added or modified files in a Svelte\u002FVite monorepo\n- You need to determine if the breakage is **yours** or **pre-existing** in the working tree\n- A shared workspace package (`@scope\u002Fpkg`) was modified and consuming apps break\n- Untracked `.svelte` files import npm packages that pass dev but fail build\n\n## Stash-Comparison Workflow\n\n**Core technique:** stash your changes, build from clean committed state, compare.\n\n```bash\n# 1. Stash your changes\ncd \u003Crepo-root> && git stash\n\n# 2. Build from clean committed state\ncd apps\u002F\u003Capp> && pnpm build\n\n# 3. Restore your changes\ncd \u003Crepo-root> && git stash pop\n\n# 4. Build again — now the failure is attributable\npnpm build\n```\n\n**Interpretation:**\n- Step 2 **passes** → breakage is yours → debug your code\n- Step 2 **fails** → breakage is pre-existing → fix pre-existing issue first\n\n## Common Pre-Existing Breakage Patterns\n\n### 1. Shared package export mismatch\n\n**Signal:** error says `\"X is not exported by ..\u002F..\u002Fpackages\u002F\u003Cpkg>\u002Fsrc\u002Fcomponents\u002Findex.js\"`\n\nIn pnpm monorepos, `@scope\u002Fpkg` resolves via the workspace `package.json` `\"exports\"` or `\"svelte\"` field. If someone modifies a shared package's `package.json` (e.g. changes `\"exports\": { \".\": \".\u002Fsrc\u002Findex.ts\" }` to `\"svelte\": \".\u002Fsrc\u002Fcomponents\u002Findex.js\"`), **every consuming app breaks** even though neither changed their imports. The `vite-plugin-svelte` resolver follows the `\"svelte\"` field first.\n\n**Fix:**\n```bash\ngit checkout HEAD -- packages\u002F\u003Cbroken-package>\u002Fpackage.json\npnpm install   # re-resolve workspace links\n```\n\n### 2. Missing npm dependencies for untracked files\n\n**Signal:** `Rollup failed to resolve import \"\u003Cpkg>\" from \"\u003Cpath>\u002FUntrackedFile.svelte\"`\n\nUntracked `.svelte` files that import npm packages pass `pnpm dev` (Vite resolves on-the-fly) but **fail `pnpm build`** (Rollup requires all imports resolvable at build time).\n\n**Fix:**\n```bash\npnpm add \u003Cpkg>              # runtime dependency\npnpm add -D @types\u002F\u003Cpkg>    # types (if TypeScript)\n```\n\n### 3. Stale lockfile after workspace change\n\n**Signal:** random build failures, modules not found, version mismatches\n\n**Fix:**\n```bash\npnpm install                # re-resolve workspace links\n# Nuclear option:\nrm -rf node_modules && pnpm install\n```\n\n## Decision Tree\n\n```\nBuild fails after you changed files\n├─ git stash → build passes without your changes?\n│  ├─ YES → breakage is yours → debug your code\n│  └─ NO  → breakage is pre-existing\n│     ├─ Shared package export mismatch? → restore package.json\n│     ├─ Missing dep for untracked file? → pnpm add\n│     └─ Other? → systematic-debugging Phase 1\n└─ git stash → build fails without your changes too?\n   └─ Confirm: is the committed build broken? (CI vs local)\n```\n\n### 4. A write \"succeeds\" (2xx) but nothing lands in the store\n\nThis and the two sections below share one failure shape: **every local gate is\ngreen and the artifact is still wrong.** When you hit one of them, stop\nre-running the build — the build is not the thing that is lying; the artifact\nor the gate's scope is.\n\n**Symptom:** the write endpoint returns success and echoes the record back, the\nparent entity appears updated, but a fresh read returns empty and the backing\nstore has zero rows for that entity.\n\nThis is a distinct failure class from the build errors above, because every\nlocal gate stays green: typecheck, unit tests, and build all pass.\n\n**Two mechanisms cause it, and they compose:**\n\n1. **A NOT NULL column is missing from the built record.** Adapters that write\n   a metadata row (e.g. `sealed_meta(id, appId, instance_id, entity,\n   content_hash, r2_key, created_at)`) require a `created_at`. A factory that\n   emits only a domain-specific timestamp (`recorded_at`, `paid_at`) omits it,\n   the INSERT fails, and the write silently degrades to an in-process cache\n   map. Because the same request reads back from that cache, the handler can\n   honestly report the record it just wrote — and lose it on the next request\n   when the isolate is cold.\n\n2. **`.catch(() => {})` on the insert.** Swallowed errors make a failed write\n   indistinguishable from a successful one. Every `.catch(() => {})` on a\n   persistence path should log the entity and id.\n\n**Diagnostic sequence:**\n```bash\n# 1. Is the row actually there? (count by entity)\nwrangler d1 execute \u003Cdatabase_id> --remote --json \\\n  --command \"SELECT entity, COUNT(*) n FROM \u003Cmeta_table> GROUP BY entity\"\n\n# 2. Compare against a sibling entity that works\nwrangler d1 execute \u003Cdatabase_id> --remote --json \\\n  --command \"SELECT entity,id,r2_key,created_at FROM \u003Cmeta_table> WHERE entity='\u003Cworking>' LIMIT 2\"\n```\nIf your new entity has **no rows at all** while a sibling written by the same\nadapter has rows, the write path is at fault — not the read path. Diff the two\nrecords field by field against the table's NOT NULL columns.\n\n**Fix:** emit every required column from the record factory, and make the catch\nlog. Add a regression test asserting the factory output carries the NOT NULL\nfields (assert presence and parseability, not just truthiness of one field).\n\n**Rule:** a 2xx from a write is a claim, not proof. Confirm in this order:\nresponse body → fresh GET on a new request → direct store count. The store\ncount is the only one that cannot lie.\n\n### 5. The build exits 0 and leaves a deploy bundle that would break production\n\n**Symptom:** `pnpm run build` exits 0 and the whole suite passes, but the\nartifact the deploy command reads back is wrong. Same epistemic shape as the\nwrite case above: every local gate is green, and the defect only appears\nagainst the real system.\n\n**Mechanism.** When the build script wraps a framework build (`astro build`,\netc.), that framework **regenerates its own config artifact** from scratch at\nthe end of the run. Any normalization step placed *before* it is silently\noverwritten, and the incomplete file is exactly what ships.\n\n**Two independent failure modes, both silently green:**\n\n1. **Ordering.** The normalization runs before the framework build, so the\n   framework build overwrites it. The build directory keeps only the\n   framework's bare output — missing bindings, wrong name, missing env vars.\n   Fix: run normalization as the **last** step of the build script, and make\n   the build **exit non-zero** when it fails, so a half-normalized artifact\n   can never be deployed.\n2. **Calendar-derived config.** A config field stamped with `new Date()`\n   drifts by itself. It works until the installed runtime stops supporting\n   that date, at which point the runtime refuses to boot while the build still\n   exits 0 — the failure is at startup, so no compile-time gate can see it.\n   Fix: inherit the field from the declarative config source (the real\n   config file), never from the current date; add a test asserting the value\n   equals the declared one and is not today.\n\n**Diagnostic sequence:**\n```bash\n# 1. Inspect the artifact the deploy command actually reads, after a fresh build\npython3 -c \"import json;j=json.load(open('dist\u002Fserver\u002Fwrangler.json'));print(j['name'],j.get('vars'),len(j.get('d1_databases',[])))\"\n\n# 2. Prove the ordering from the build script itself\ngrep -n \"\u003Cframework-build>\\|\u003Cnormalize-script>\" \u003Cbuild-script>\n\n# 3. For the startup-only class, read the runtime's own error, not the exit code\n\u003Cruntime> dev --config dist\u002Fserver\u002Fwrangler.json\n```\n\n**Rule:** a build artifact is not correct because the build was green. Assert\nthe artifact's fields directly — name, bindings with real identifiers, env,\nroute config, and the inherited-not-dated config fields — as a test that reads\nthe file the build emitted.\n\n### 6. A gate you reported green was never actually run over your files\n\n**Symptom:** a delivery report says \"lint clean\" while the linter, run\nproperly, reports violations in a file you edited.\n\nMechanism, one of two: lint was never invoked separately (a green build and a\ngreen suite are different gates, and reporting one while implying the other is\na false claim), or the linter ran from a directory \u002F over a path list that did\nnot include the edited file, so its scope silently excluded the code in\nquestion. A passing gate only certifies what it actually covered.\n\n**Diagnostic sequence:**\n```bash\n# 1. Run the linter explicitly on the edited files, from the project root\nnpx biome check \u003Cedited-files>; echo \"EXIT=$?\"\n\n# 2. Attribute each violation before reporting\ngit show \u003Ccommit> -- \u003Cfile> | grep -E '^[-+]'   # what your diff changed\ngit log -L \u003Ca>,\u003Cb>:\u003Cfile>                        # who introduced the line\n```\n\n**Rule:** report your violations and the pre-existing ones as two distinct\nfacts, and never fold the second into the first to make a report look\ncleaner. Leave unrelated pre-existing violations out of a focused fix.\n\n### 5. A seed\u002Ffixture script runs twice and duplicates the world\n\n**Symptom:** a public listing renders every record twice. Each duplicate has the\nsame business fields but a **different id**, so deduplicating by id does\nnothing. The adapter's `list()` faithfully returns both rows; nothing is broken\ndownstream — the data itself is wrong.\n\n**Why:** seed scripts that POST blindly create a second set on re-run. Because\nthey are idempotent-ish at the user level (409 → login) the second run looks\nsuccessful in the log while multiplying everything below that point.\n\n**Fix, two layers:**\n\n1. Make the seed idempotent on the business key, not just on auth:\n   ```js\n   const existing = (await api('\u002Fapi\u002F\u003Citems>?instance_id=' + INSTANCE)).data;\n   const names = new Set((Array.isArray(existing) ? existing : []).map((r) => String(r?.name ?? '')));\n   for (const item of items) {\n     if (names.has(item.name)) { created.push(`${item.name} -> ya existia (skip)`); continue; }\n     await api('\u002Fapi\u002F\u003Citems>', { method: 'POST', body: item });\n   }\n   ```\n2. Dedupe defensively in the **reader**, keyed on business identity\n   (restaurant + normalized name + price) rather than id. Keep entries whose\n   same name carries a **different price** — that is real menu variation, and a\n   dedupe that deletes it destroys actual data.\n\nClean up the existing duplicates afterwards through the app's own DELETE\nendpoint, then confirm the store count matches the API response and the DOM.\n\n**Verification rule for UI lists:** assert on the **rendered DOM**, not on the\nserialized HTML. SSR frameworks often serialize the same data twice (props as\n`[0, value]` tuples, preloaded JSON plus the markup), so counting occurrences in\nraw HTML reports numbers the user never sees. Count the actual rendered\ncontrols instead:\n```js\n[...document.querySelectorAll('button')].filter(b => b.innerText.trim() === 'Añadir').length\n```\n\n### 6. A router rejects two files that resolve to the same path — and tests stay green\n\n**Symptom:** the build warns\n`The route \"\u002Fapi\u002Fx\u002F[id]\" is defined in both \"[id]\u002Findex.ts\" and \"[id].ts\"`\nfollowed by \"a collision will result in a hard error in following versions\".\n**Unit tests, typecheck and vitest all pass** — the warning only appears when\ncompiling, so a test-only gate reports green on a tree that will not deploy.\n\n**Rule:** before adding an endpoint under a dynamic segment directory, check\nwhether the flat file already exists:\n```bash\nfind src\u002Fpages -name \"index.ts\" -path \"*\\[[a-zA-Z]*\\]*\" | while read f; do\n  [ -f \"${f%index.ts}.ts\" ] && echo \"COLISION: ${f%index.ts}.ts \u003C-> $f\"\ndone\n```\n\n**Which one to keep:** the pre-existing flat file usually carries more\nconvention than the new one. Compare them — if the old one soft-deletes (marks\n`deleted_at` and the listing filters it) while the new one hard-deletes\n(`adapter.del`, wiping the store), keep the old: soft delete preserves history\nand is the project's convention. Deleting the wrong one destroys the data model.\n\n**Pitfall when cleaning up:** delete **only the offending file**. Removing the\nwhole directory takes sibling routes with it (e.g. `[id]\u002Ftransactions.ts`\nimported by a test), and the resulting `ts2307 Cannot find module` is a\nself-inflicted wound. Restore siblings from git rather than recreating them.\nNote that a directory `[id]\u002F` holding `payment.ts`\u002F`transition.ts` alongside a\nflat `[id].ts` is **not** a collision — only a competing `index.ts` is.\n\n## Reference\n\n> 📎 `references\u002Ferror-fix-reference.md` — condensed error → fix mapping, stash comparison script, and pnpm workspace resolution order.\n","# Monorepo Build Diagnostics\n\n## When to Use\n\n- A `pnpm build` fails after you added or modified files in a Svelte\u002FVite monorepo\n- You need to determine if the breakage is **yours** or **pre-existing** in the working tree\n- A shared workspace package (`@scope\u002Fpkg`) was modified and consuming apps break\n- Untracked `.svelte` files import npm packages that pass dev but fail build\n\n## Stash-Comparison Workflow\n\n**Core technique:** stash your changes, build from clean committed state, compare.\n\n```bash\n# 1. Stash your changes\ncd \u003Crepo-root> && git stash\n\n# 2. Build from clean committed state\ncd apps\u002F\u003Capp> && pnpm build\n\n# 3. Restore your changes\ncd \u003Crepo-root> && git stash pop\n\n# 4. Build again — now the failure is attributable\npnpm build\n```\n\n**Interpretation:**\n- Step 2 **passes** → breakage is yours → debug your code\n- Step 2 **fails** → breakage is pre-existing → fix pre-existing issue first\n\n## Common Pre-Existing Breakage Patterns\n\n### 1. Shared package export mismatch\n\n**Signal:** error says `\"X is not exported by ..\u002F..\u002Fpackages\u002F\u003Cpkg>\u002Fsrc\u002Fcomponents\u002Findex.js\"`\n\nIn pnpm monorepos, `@scope\u002Fpkg` resolves via the workspace `package.json` `\"exports\"` or `\"svelte\"` field. If someone modifies a shared package's `package.json` (e.g. changes `\"exports\": { \".\": \".\u002Fsrc\u002Findex.ts\" }` to `\"svelte\": \".\u002Fsrc\u002Fcomponents\u002Findex.js\"`), **every consuming app breaks** even though neither changed their imports. The `vite-plugin-svelte` resolver follows the `\"svelte\"` field first.\n\n**Fix:**\n```bash\ngit checkout HEAD -- packages\u002F\u003Cbroken-package>\u002Fpackage.json\npnpm install   # re-resolve workspace links\n```\n\n### 2. Missing npm dependencies for untracked files\n\n**Signal:** `Rollup failed to resolve import \"\u003Cpkg>\" from \"\u003Cpath>\u002FUntrackedFile.svelte\"`\n\nUntracked `.svelte` files that import npm packages pass `pnpm dev` (Vite resolves on-the-fly) but **fail `pnpm build`** (Rollup requires all imports resolvable at build time).\n\n**Fix:**\n```bash\npnpm add \u003Cpkg>              # runtime dependency\npnpm add -D @types\u002F\u003Cpkg>    # types (if TypeScript)\n```\n\n### 3. Stale lockfile after workspace change\n\n**Signal:** random build failures, modules not found, version mismatches\n\n**Fix:**\n```bash\npnpm install                # re-resolve workspace links\n# Nuclear option:\nrm -rf node_modules && pnpm install\n```\n\n## Decision Tree\n\n```\nBuild fails after you changed files\n├─ git stash → build passes without your changes?\n│  ├─ YES → breakage is yours → debug your code\n│  └─ NO  → breakage is pre-existing\n│     ├─ Shared package export mismatch? → restore package.json\n│     ├─ Missing dep for untracked file? → pnpm add\n│     └─ Other? → systematic-debugging Phase 1\n└─ git stash → build fails without your changes too?\n   └─ Confirm: is the committed build broken? (CI vs local)\n```\n\n### 4. A write \"succeeds\" (2xx) but nothing lands in the store\n\nThis and the two sections below share one failure shape: **every local gate is\ngreen and the artifact is still wrong.** When you hit one of them, stop\nre-running the build — the build is not the thing that is lying; the artifact\nor the gate's scope is.\n\n**Symptom:** the write endpoint returns success and echoes the record back, the\nparent entity appears updated, but a fresh read returns empty and the backing\nstore has zero rows for that entity.\n\nThis is a distinct failure class from the build errors above, because every\nlocal gate stays green: typecheck, unit tests, and build all pass.\n\n**Two mechanisms cause it, and they compose:**\n\n1. **A NOT NULL column is missing from the built record.** Adapters that write\n   a metadata row (e.g. `sealed_meta(id, appId, instance_id, entity,\n   content_hash, r2_key, created_at)`) require a `created_at`. A factory that\n   emits only a domain-specific timestamp (`recorded_at`, `paid_at`) omits it,\n   the INSERT fails, and the write silently degrades to an in-process cache\n   map. Because the same request reads back from that cache, the handler can\n   honestly report the record it just wrote — and lose it on the next request\n   when the isolate is cold.\n\n2. **`.catch(() => {})` on the insert.** Swallowed errors make a failed write\n   indistinguishable from a successful one. Every `.catch(() => {})` on a\n   persistence path should log the entity and id.\n\n**Diagnostic sequence:**\n```bash\n# 1. Is the row actually there? (count by entity)\nwrangler d1 execute \u003Cdatabase_id> --remote --json \\\n  --command \"SELECT entity, COUNT(*) n FROM \u003Cmeta_table> GROUP BY entity\"\n\n# 2. Compare against a sibling entity that works\nwrangler d1 execute \u003Cdatabase_id> --remote --json \\\n  --command \"SELECT entity,id,r2_key,created_at FROM \u003Cmeta_table> WHERE entity='\u003Cworking>' LIMIT 2\"\n```\nIf your new entity has **no rows at all** while a sibling written by the same\nadapter has rows, the write path is at fault — not the read path. Diff the two\nrecords field by field against the table's NOT NULL columns.\n\n**Fix:** emit every required column from the record factory, and make the catch\nlog. Add a regression test asserting the factory output carries the NOT NULL\nfields (assert presence and parseability, not just truthiness of one field).\n\n**Rule:** a 2xx from a write is a claim, not proof. Confirm in this order:\nresponse body → fresh GET on a new request → direct store count. The store\ncount is the only one that cannot lie.\n\n### 5. The build exits 0 and leaves a deploy bundle that would break production\n\n**Symptom:** `pnpm run build` exits 0 and the whole suite passes, but the\nartifact the deploy command reads back is wrong. Same epistemic shape as the\nwrite case above: every local gate is green, and the defect only appears\nagainst the real system.\n\n**Mechanism.** When the build script wraps a framework build (`astro build`,\netc.), that framework **regenerates its own config artifact** from scratch at\nthe end of the run. Any normalization step placed *before* it is silently\noverwritten, and the incomplete file is exactly what ships.\n\n**Two independent failure modes, both silently green:**\n\n1. **Ordering.** The normalization runs before the framework build, so the\n   framework build overwrites it. The build directory keeps only the\n   framework's bare output — missing bindings, wrong name, missing env vars.\n   Fix: run normalization as the **last** step of the build script, and make\n   the build **exit non-zero** when it fails, so a half-normalized artifact\n   can never be deployed.\n2. **Calendar-derived config.** A config field stamped with `new Date()`\n   drifts by itself. It works until the installed runtime stops supporting\n   that date, at which point the runtime refuses to boot while the build still\n   exits 0 — the failure is at startup, so no compile-time gate can see it.\n   Fix: inherit the field from the declarative config source (the real\n   config file), never from the current date; add a test asserting the value\n   equals the declared one and is not today.\n\n**Diagnostic sequence:**\n```bash\n# 1. Inspect the artifact the deploy command actually reads, after a fresh build\npython3 -c \"import json;j=json.load(open('dist\u002Fserver\u002Fwrangler.json'));print(j['name'],j.get('vars'),len(j.get('d1_databases',[])))\"\n\n# 2. Prove the ordering from the build script itself\ngrep -n \"\u003Cframework-build>\\|\u003Cnormalize-script>\" \u003Cbuild-script>\n\n# 3. For the startup-only class, read the runtime's own error, not the exit code\n\u003Cruntime> dev --config dist\u002Fserver\u002Fwrangler.json\n```\n\n**Rule:** a build artifact is not correct because the build was green. Assert\nthe artifact's fields directly — name, bindings with real identifiers, env,\nroute config, and the inherited-not-dated config fields — as a test that reads\nthe file the build emitted.\n\n### 6. A gate you reported green was never actually run over your files\n\n**Symptom:** a delivery report says \"lint clean\" while the linter, run\nproperly, reports violations in a file you edited.\n\nMechanism, one of two: lint was never invoked separately (a green build and a\ngreen suite are different gates, and reporting one while implying the other is\na false claim), or the linter ran from a directory \u002F over a path list that did\nnot include the edited file, so its scope silently excluded the code in\nquestion. A passing gate only certifies what it actually covered.\n\n**Diagnostic sequence:**\n```bash\n# 1. Run the linter explicitly on the edited files, from the project root\nnpx biome check \u003Cedited-files>; echo \"EXIT=$?\"\n\n# 2. Attribute each violation before reporting\ngit show \u003Ccommit> -- \u003Cfile> | grep -E '^[-+]'   # what your diff changed\ngit log -L \u003Ca>,\u003Cb>:\u003Cfile>                        # who introduced the line\n```\n\n**Rule:** report your violations and the pre-existing ones as two distinct\nfacts, and never fold the second into the first to make a report look\ncleaner. Leave unrelated pre-existing violations out of a focused fix.\n\n### 5. A seed\u002Ffixture script runs twice and duplicates the world\n\n**Symptom:** a public listing renders every record twice. Each duplicate has the\nsame business fields but a **different id**, so deduplicating by id does\nnothing. The adapter's `list()` faithfully returns both rows; nothing is broken\ndownstream — the data itself is wrong.\n\n**Why:** seed scripts that POST blindly create a second set on re-run. Because\nthey are idempotent-ish at the user level (409 → login) the second run looks\nsuccessful in the log while multiplying everything below that point.\n\n**Fix, two layers:**\n\n1. Make the seed idempotent on the business key, not just on auth:\n   ```js\n   const existing = (await api('\u002Fapi\u002F\u003Citems>?instance_id=' + INSTANCE)).data;\n   const names = new Set((Array.isArray(existing) ? existing : []).map((r) => String(r?.name ?? '')));\n   for (const item of items) {\n     if (names.has(item.name)) { created.push(`${item.name} -> ya existia (skip)`); continue; }\n     await api('\u002Fapi\u002F\u003Citems>', { method: 'POST', body: item });\n   }\n   ```\n2. Dedupe defensively in the **reader**, keyed on business identity\n   (restaurant + normalized name + price) rather than id. Keep entries whose\n   same name carries a **different price** — that is real menu variation, and a\n   dedupe that deletes it destroys actual data.\n\nClean up the existing duplicates afterwards through the app's own DELETE\nendpoint, then confirm the store count matches the API response and the DOM.\n\n**Verification rule for UI lists:** assert on the **rendered DOM**, not on the\nserialized HTML. SSR frameworks often serialize the same data twice (props as\n`[0, value]` tuples, preloaded JSON plus the markup), so counting occurrences in\nraw HTML reports numbers the user never sees. Count the actual rendered\ncontrols instead:\n```js\n[...document.querySelectorAll('button')].filter(b => b.innerText.trim() === 'Añadir').length\n```\n\n### 6. A router rejects two files that resolve to the same path — and tests stay green\n\n**Symptom:** the build warns\n`The route \"\u002Fapi\u002Fx\u002F[id]\" is defined in both \"[id]\u002Findex.ts\" and \"[id].ts\"`\nfollowed by \"a collision will result in a hard error in following versions\".\n**Unit tests, typecheck and vitest all pass** — the warning only appears when\ncompiling, so a test-only gate reports green on a tree that will not deploy.\n\n**Rule:** before adding an endpoint under a dynamic segment directory, check\nwhether the flat file already exists:\n```bash\nfind src\u002Fpages -name \"index.ts\" -path \"*\\[[a-zA-Z]*\\]*\" | while read f; do\n  [ -f \"${f%index.ts}.ts\" ] && echo \"COLISION: ${f%index.ts}.ts \u003C-> $f\"\ndone\n```\n\n**Which one to keep:** the pre-existing flat file usually carries more\nconvention than the new one. Compare them — if the old one soft-deletes (marks\n`deleted_at` and the listing filters it) while the new one hard-deletes\n(`adapter.del`, wiping the store), keep the old: soft delete preserves history\nand is the project's convention. Deleting the wrong one destroys the data model.\n\n**Pitfall when cleaning up:** delete **only the offending file**. Removing the\nwhole directory takes sibling routes with it (e.g. `[id]\u002Ftransactions.ts`\nimported by a test), and the resulting `ts2307 Cannot find module` is a\nself-inflicted wound. Restore siblings from git rather than recreating them.\nNote that a directory `[id]\u002F` holding `payment.ts`\u002F`transition.ts` alongside a\nflat `[id].ts` is **not** a collision — only a competing `index.ts` is.\n\n## Reference\n\n> 📎 `references\u002Ferror-fix-reference.md` — condensed error → fix mapping, stash comparison script, and pnpm workspace resolution order.\n",{"name":5,"tags":24,"author":32,"version":33,"category":34,"description":7},[25,26,27,28,29,30,31],"monorepo","pnpm","svelte","vite","build","diagnostics","workspace","Hermes Agent","1.0.0","software-development","main","688810f2886d212632acf81e532b24e483dd8b98","skills\u002Fgeneral\u002Fmonorepo-build-diagnostics","https:\u002F\u002Fgithub.com\u002Fiberi22\u002Fskills","https:\u002F\u002Fgithub.com\u002Fiberi22","Senior WEB Full-Stack","2026-10-12 02:46:21",{"source":8,"skillName":5,"commands":43,"prompt":52,"zipAvailable":53},[44,47,50],{"tool":45,"command":46},"npx","npx skills add iberi22\u002Fskills --skill monorepo-build-diagnostics",{"tool":48,"command":49},"bunx","bunx skills add iberi22\u002Fskills --skill monorepo-build-diagnostics",{"tool":26,"command":51},"pnpm dlx skills add iberi22\u002Fskills --skill monorepo-build-diagnostics","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fiberi22\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fgeneral\u002Fmonorepo-build-diagnostics\u002FSKILL.md",true,[55],{"path":56,"resourceType":57,"resourceTypeDesc":58,"sizeBytes":59,"sourceHtmlUrl":60},"references\u002Ferror-fix-reference.md","REFERENCE","参考文档",2582,"https:\u002F\u002Fgithub.com\u002Fiberi22\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fgeneral\u002Fmonorepo-build-diagnostics\u002Freferences\u002Ferror-fix-reference.md",[62,68,75,81,87,93],{"skillNo":63,"name":64,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":65,"categories":66,"keywords":67,"publishedAt":19},"01M72TWQEQD46ZC9TRBAABF78P","web-design-guidelines","https:\u002F\u002Fgithub.com\u002Fiberi22\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fweb\u002Fweb-design-guidelines\u002FSKILL.md",[],[],{"skillNo":69,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":19},"01M72TWMQFTYD08DGXVAXRPPEB","blocked-page-recovery","Use when a fetch fails: 403\u002F429, paywall, WAF, bot wall. Recovers the page via archives and provenance-checked fallbacks.","https:\u002F\u002Fgithub.com\u002Fiberi22\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fweb\u002Fblocked-page-recovery\u002FSKILL.md",[],[],{"skillNo":76,"name":77,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":19},"01M72TVQMS3HCTX18C8T97WTQQ","studio-coach","https:\u002F\u002Fgithub.com\u002Fiberi22\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Ftools\u002Fstudio-coach\u002FSKILL.md",[],[],{"skillNo":82,"name":83,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":19},"01M72TVNA2PR9RZW0ZAXYP1G6J","src-generator","https:\u002F\u002Fgithub.com\u002Fiberi22\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Ftools\u002Fsrc-generator\u002FSKILL.md",[],[],{"skillNo":88,"name":89,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":90,"categories":91,"keywords":92,"publishedAt":19},"01M72TVEJHHB6SAT3R3TY9MJKS","sqlite-pro","https:\u002F\u002Fgithub.com\u002Fiberi22\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Ftools\u002Fsqlite-pro\u002FSKILL.md",[],[],{"skillNo":94,"name":95,"nameZh":6,"description":96,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":97,"categories":98,"keywords":99,"publishedAt":19},"01M72TVC2EVBHQHCX96VTTYKB8","rigor-evaluator","Use when you need a quick heuristic rigor score (10 criteria, 0-2 each) for the features in a .gitcore\u002Ffeatures.json file, to decide which features are ready to ship.","https:\u002F\u002Fgithub.com\u002Fiberi22\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Ftools\u002Frigor-evaluator\u002FSKILL.md",[],[]]