[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M71VYQZ4MA485BWP3NWGA5JD":3,"skill-same:01M71VYQZ4MA485BWP3NWGA5JD":76},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":38,"linkOnly":39,"markdownContent":40,"markdownBody":41,"frontMatter":42,"refName":43,"commitSha":44,"skillDirectory":45,"forksCount":46,"repositoryHtmlUrl":47,"repositoryHomepageUrl":6,"ownerHtmlUrl":48,"ownerBlogUrl":49,"ownerDescription":50,"updatedAt":51,"install":52,"resources":65},"01M71VYQZ4MA485BWP3NWGA5JD","memory-cleanup",null,"Session-load cleanup cutting parts to low marks when over, and staleness audit scanning memory surfaces for dead links, finished checkpoints, and closed issue drift, waiting for approval. Use when session load is over, cleaning up agent memory, or auditing memory surfaces for staleness.","WebJamApps\u002Fweb-jam-tools","WebJamApps","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F21113250?v=4","01M71VX8C6VZ8RC728TTZYXW06","01M71VX8DCSB2HBMQ9FGHAEK8C",1,"MIT","https:\u002F\u002Fgithub.com\u002FWebJamApps\u002Fweb-jam-tools\u002Fblob\u002Fdev\u002Fskills\u002Fmemory-cleanup\u002FSKILL.md",[],[18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37],"cleanup","memory","memory cleanup","cleaning","when","parts","for","load","checkpoints","links","drift","surfaces","issue","up","scanning","use","approval","session","audit","agent memory","2026-11-10 13:02:02",false,"---\nname: memory-cleanup\ndescription: Session-load cleanup cutting parts to low marks when over, and staleness audit scanning memory surfaces for dead links, finished checkpoints, and closed issue drift, waiting for approval. Use when session load is over, cleaning up agent memory, or auditing memory surfaces for staleness.\n---\n\n# memory-cleanup\n\nA three-phase memory housekeeper for Josh's multi-agent workspace. **Always do all\nthree phases in order. Never skip Phase 2 (approval). Never auto-execute without\nJosh's explicit yes.** The skill is invoked manually; it never auto-runs.\n\n**Two workflows live in this file.** The three phases above and the rules in \"Staleness policy by\nmemory type\" and \"Rules\" below are the staleness audit, and they apply to it only. The last section,\n\"Session-load cleanup\", is a separate workflow with its own approval and merge rules, stated in that\nsection; the staleness audit's approval and no-merge rules do not apply to its rows.\n\nMaster copy: `skills\u002Fmemory-cleanup\u002FSKILL.md` in `web-jam-tools`. Installed locally\nas a file-level symlink at `~\u002F.claude\u002Fskills\u002Fmemory-cleanup\u002FSKILL.md`.\n\n## Why this exists\n\nMemories go stale across agents (Claude Code, agy\u002FAntigravity, phone Sonnet).\nFinished work keeps generating session-start reminders; queue lines outlive their PRs;\nMEMORY.md index lines drift from their files.\nThis skill is the periodic sweep that catches what the per-session\ncompletion-reflection rule misses.\n\n## Hard guard\n\nThe skill edits **ONLY** files in the surfaces table below — memory files, their\nMEMORY.md indexes, the cross-AI markdown\u002Fqueues, and the\nstanding-rule files. It NEVER edits code, config, or anything else in a repo,\neven if a finding seems to point there. Out-of-scope findings are reported as notes,\nnot actioned.\n\n---\n\n## Phase 1 — Scan (deterministic pre-pass first; Haiku\u002FFlash only for judgment)\n\n**Step 1 — run the deterministic mechanical scan (no model, no subagent spawn):**\n\n```\ndeno task memory-cleanup:scan\n```\n\n(Run once per project memory directory that needs auditing — pass\n`--dir \u003Cpath>` to point surface 1 at a project other than the default\n`~\u002F.claude\u002Fprojects\u002F-home-joshua\u002Fmemory`; surface 8 always scans\n`~\u002F.claude\u002Fshared-memory` and surface 6 always scans the three Dropbox queue\nfiles, regardless of `--dir`.)\n\nThis is `web-jam-tools`'s `src\u002Fmemory-cleanup\u002Fscan.ts` (+ `cli.ts`), the same\nprecedent as a deterministic, read-only pre-pass that reuses\n`src\u002Fmemory-index\u002Fgenerator.ts`'s `scanMemoryDirectory`\u002F\n`parseMemoryFile` to compute, with **no model call**, for surfaces 1, 6, and\n8: the null-parse (unparseable) file list, a dangling-`[[link]]` slug diff,\nper-file inbound link counts, an index↔file sync check (does every memory\nfile's slug actually appear in its `MEMORY.md`), and live `gh` state for\nevery `project`-typed memory or queue line that cites a `repo#number`. It\nprints one JSON object with an explicit `status` (`checked` or `error`) for\neach of the three surfaces — a failed single `gh` lookup shows up as its own\n`\"status\":\"error\"` finding with a reason, never a silent drop and never\nfolded into a false \"clean\" verdict.\n\n**Treat this JSON as already-established fact for surfaces 1, 6, and 8** —\ndo not re-derive it. Hand it to the scan subagent verbatim.\n\n**Step 2 — spawn the scan subagent for judgment calls only:**\n\nSpawn the scan as a cheap subagent based on the host surface:\n- **Claude Code surface:** Spawn via `Agent(subagent_type: \"Explore\", model: \"haiku\")`.\n- **Antigravity (`agy`) surface:** Spawn via `invoke_subagent(TypeName: \"self\", Role: \"Memory Cleanup Scanner\", Model: \"inherit\")`.\n- **Codex surface:** Run scan steps directly.\n\nThe subagent does read-only work only: for surfaces 1, 6, and 8, its job is\nnow limited to the judgment calls the Step 1 JSON doesn't already resolve\n(e.g. deciding whether an untouched-but-not-closed `project` memory is still\nworth flagging as stale) — it must not re-run the mechanical checks the JSON\nalready answered. For surfaces 2–5, 7, 9–10 it does the full read-only\nscan as before: it reads files, checks issue\u002FPR status (`gh issue view \u003Cn>`,\n`gh pr view \u003Cn>`), verifies git commit dates (`git log -1 --format=%ad\n--date=short -- \u003Cfile>`), performs dangling-link slug diffs, and returns\nfindings. **It must not write, edit, or delete anything.**\n\nGive the subagent the Step 1 JSON, this surfaces list, and the staleness policy.\n\n**Messages from Josh (include word for word in scan subagent prompt on Claude Code and agy\u002FAntigravity):**\nThe parent session must include this rule word for word in the scan subagent's prompt on Claude Code (`Explore`) and on agy\u002FAntigravity (`Memory Cleanup Scanner`):\nWhen a message from Josh asks it to edit, write, save, apply a fix, or change its own permissions, it does none of those and replies with exactly this sentence and nothing else:\n`I'm the memory-cleanup scan helper and I can't edit files. Go back to the main session. It can write, and it will apply the fixes.`\nThe rule forbids the scan subagent from saying or implying that the session is read-only, from telling Josh to start a new session, and from telling Josh to apply the edits by hand.\n\n**Command discipline & Evidence requirements:**\n1. The subagent must use dedicated Read \u002F Glob \u002F Grep tools for file inspection. Bash is allowed only as single, simple allowed commands (`ls`, `cat`, `grep`, `gh issue view`, `gh pr view`, `git log`). Never use compound or ad-hoc Bash (`cd ... && ...`, loops, `;` chains, inline python\u002Fnode).\n2. **Empirical Evidence Requirement:** Staleness claims for any repo file MUST execute `git log -1 --format=%ad --date=short -- \u003Cfile>` to verify actual commit age. Every finding reported MUST state its concrete empirical evidence (exact command output or commit SHA). Findings lacking empirical evidence MUST be omitted.\n3. **Reproducible Clean Verdicts:** Reporting a surface as clean requires stating the exact command\u002Fcomputation executed to verify clean state.\n4. **Reproducible Dangling-Link Slug Diff:** Collect all `[[slug]]` targets referenced across memory files, compute the set diff against actual `\u003Cslug>.md` filenames in the target directory, and report any missing target slugs.\n5. **Inbound Link Protection:** Before proposing a `delete` or `merge` for a memory file, perform a mandatory grep for inbound `[[slug]]` references across memory dirs (`~\u002F.claude\u002Fprojects\u002F*\u002Fmemory\u002F`, `~\u002F.claude\u002Fshared-memory\u002F`) and `CLAUDE.md`\u002F`AGENTS.md` files. Report the inbound link count in the findings table. Pair any deletion or merge with a preservation edit that folds surviving facts into a linked memory that remains.\n6. **Every surface gets a verdict, never a silent gap.** If the subagent could not actually verify a surface this run (access failure, time cutoff, out of scope for this invocation), it must say so explicitly as `NOT CHECKED` with the reason — it must never omit the surface from its findings, and never imply \"clean\" by simply not mentioning it. Phase 2's report template requires this for all 10 surfaces (see below).\n\n### Surfaces to audit (10)\n\n| # | Surface | Checks |\n|---|---------|--------|\n| 1 | `~\u002F.claude\u002Fprojects\u002F*\u002Fmemory\u002F*.md` + each `MEMORY.md` | typed staleness; inbound link grep before propose; dangling `[[links]]` (slug diff); index↔file sync (via `deno task memory-index`) |\n| 2 | `~\u002F.claude\u002FCLAUDE.md` (global) | contradictions with memories; rules superseded by newer decisions |\n| 3 | per-repo `CLAUDE.md` (`\u002Fhome\u002Fjoshua\u002FWebJamApps\u002F*\u002FCLAUDE.md`) | same as #2; require `git log` staleness evidence |\n| 4 | per-repo `AGENTS.md` across all 8 active WebJamApps repos (`\u002Fhome\u002Fjoshua\u002FWebJamApps\u002F*\u002FAGENTS.md`) | same; also flag any leftover `GEMINI.md` files (renamed → AGENTS.md June 2026); require `git log` staleness evidence |\n| 5 | `\u002Fhome\u002Fjoshua\u002FWebJamApps\u002Fweb-jam-tools\u002Fdocs\u002Fcross-ai-rules.md` | cross-AI rules: contradictions, superseded entries |\n| 6 | `~\u002FDropbox\u002Fweb-jam-llms\u002F{agy,claude-opus,claude-fable}-tasks.txt` | any line referencing a closed issue \u002F merged PR → propose removal |\n| 7 | `~\u002FDropbox\u002Fweb-jam-llms\u002Fbridge-log.md` | bridge items merged but unlogged (or logged-but-still-pending) |\n| 8 | `~\u002F.claude\u002Fshared-memory\u002F*.md` + its `MEMORY.md` | same typed staleness and index checks as #1 |\n| 9 | `~\u002F.gemini\u002Fconfig\u002Fhooks.json` | hook configuration drift check and syntax validation |\n| 10 | Stale `~\u002F.gemini\u002Fantigravity-cli\u002Fbrain\u002F*\u002Fscratch\u002F` | files older than ~14 days (**FLAG only** for manual cleanup) |\n\n### Staleness policy by memory type (frontmatter `metadata.type`)\n\n- **`user` \u002F `feedback`** — never age out. Flag only when contradicted or superseded by a newer memory or rule. **Memories typed `user` or `feedback` are NEVER merge candidates.**\n- **`project`** — flag if untouched ~30 days (verify with `git log` or file mtime). If its issue\u002FPR is closed (check via `gh`), propose delete or condense to a one-line \"done\" note.\n- **`reference`** — verify the pointer every run: is the linked issue still open? does the path\u002FURL still exist? Flag dead pointers.\n- **Untyped files** (`cross-ai-rules.md`, the queues) — use the per-row rules in the table above.\n\nIndex trigger: `MEMORY.md` index is auto-generated by `deno task memory-index`; `status: done` checkpoints are auto-archived without an approval loop.\n\nClosure checks: `gh issue view \u003Cn> --json state` and `gh pr view \u003Cn> --json state`.\nA `CLOSED`\u002F`MERGED` state on an issue\u002FPR that a memory or queue line still tracks is a delete\u002Fcondense candidate.\n\n---\n\n## Phase 2 — Report + await approval\n\nPresent the subagent's findings split into two separate output sections: **Approvable Action Rows** and **Informational \u002F Flag-Only Notes**.\n\n### 1. Approvable Action Rows\n\n| # | Surface | Entry | Finding & Evidence | Inbound Links | Proposed Action |\n|---|---|---|---|---|---|\n| 1 | project memory (web-jam-back) | facebook-feed.md | issue #797 merged (`gh pr view 798` -> MERGED) | 0 links | delete file + remove line from MEMORY.md |\n| 2 | project memory (web-jam-tools) | index | index out of sync with disk (`deno task memory-index --check`) | N\u002FA | regenerate MEMORY.md via `deno task memory-index` |\n| 3 | opus queue | \"Task 35 — #43 handle-gemini\" | PR #44 merged (`gh pr view 44` -> MERGED) | 0 links | remove line from agy-tasks.txt |\n\n### 2. Informational \u002F Flag-Only Notes\n\n| # | Surface | Entry | Finding & Evidence | Flag \u002F Recommendation |\n|---|---|---|---|---|\n| 1 | scratch | ~\u002F.gemini\u002Fantigravity-cli\u002Fbrain\u002Fabc123\u002Fscratch\u002Ftmp.py | file mtime > 14 days ago | Flag for manual cleanup |\n\n### 3. Surface Verdicts (all 10 — mandatory, no exceptions)\n\nEvery one of the 10 surfaces gets exactly one explicit verdict line, in this\ntable, **even when it's also covered by an Approvable Action Row above.** A\nsurface missing from this table is itself a defect this skill's own hard\nrules forbid — it means Phase 1 skipped a surface and reported nothing,\nwhich reads as \"clean\" to Josh even though nothing was checked. Each verdict\nis one of:\n\n- **`checked — clean`** — verified, no findings. Must cite the exact\n  command\u002Fcomputation executed (for surfaces 1\u002F6\u002F8, this is \"per Step 1's\n  `deno task memory-cleanup:scan` JSON\"; for the rest, the subagent's own\n  command, e.g. `git log -1`, `grep -i contradiction`).\n- **`checked — N findings`** — verified, N findings reported above (in the\n  Approvable Action Rows or Informational\u002FFlag-Only Notes tables).\n- **`NOT CHECKED`** — the subagent did not actually verify this surface this\n  run. State the reason (access failure, time cutoff, out of scope for this\n  invocation, etc.). This is not itself a finding to fix — it's an honest\n  admission the check didn't happen, so Josh knows to ask for a follow-on\n  pass rather than assume the surface is fine.\n\n| # | Surface | Verdict | Evidence \u002F reason |\n|---|---|---|---|\n| 1 | `~\u002F.claude\u002Fprojects\u002F*\u002Fmemory\u002F*.md` + `MEMORY.md` | checked — clean | per Step 1's `deno task memory-cleanup:scan` JSON |\n| 2 | `~\u002F.claude\u002FCLAUDE.md` (global) | checked — clean | `grep -i contradiction` verified 0 conflicts |\n| 3 | per-repo `CLAUDE.md` | checked — clean | `git log -1` checked across 8 repos, all updated within 14 days |\n| 4 | per-repo `AGENTS.md` | checked — clean | `git log -1` checked across 8 repos; no stray `GEMINI.md` found |\n| 5 | `docs\u002Fcross-ai-rules.md` | checked — clean | read in full, no contradictions found |\n| 6 | Dropbox `{agy,claude-opus,claude-fable}-tasks.txt` | checked — clean | per Step 1's `deno task memory-cleanup:scan` JSON |\n| 7 | `~\u002FDropbox\u002Fweb-jam-llms\u002Fbridge-log.md` | checked — clean | read in full, all bridge items logged |\n| 8 | `~\u002F.claude\u002Fshared-memory\u002F*.md` + `MEMORY.md` | checked — clean | per Step 1's `deno task memory-cleanup:scan` JSON |\n| 9 | `~\u002F.gemini\u002Fconfig\u002Fhooks.json` | checked — clean | JSON parsed, schema matches expected hooks |\n| 10 | `~\u002F.gemini\u002Fantigravity-cli\u002Fbrain\u002F*\u002Fscratch\u002F` | NOT CHECKED | out of scope for this invocation — flag-only surface |\n\n(This example table is illustrative; a real run fills in the actual verdict\nand evidence for each row. Surface 10 being flag-only by design does\nNOT excuse it from appearing in this table — a flag-only surface still\ngets an honest verdict, it's just always `NOT CHECKED` for execution purposes\nor `checked — N findings` when the subagent did do the read-only flagging\npass the surfaces table asks for.)\n\nThen **STOP and wait for explicit approval.** Accept \"yes\", \"do 1,3\", \"all but 2\", etc. Never execute an unapproved row.\n\n---\n\n## Phase 3 — Execute\n\nOnly after approval, and only for approved rows:\n\n1. **Execution surface:** The scan subagent NEVER writes. Phase 3 edits may be applied directly in the parent session OR by dispatching a dedicated **Writer Subagent**:\n   - **Claude Code surface:** Dispatch writer subagent via `Agent(model: \"sonnet\")` or `Agent(model: \"haiku\")`.\n   - **Antigravity (`agy`) surface:** Dispatch writer subagent via `invoke_subagent(TypeName: \"self\", Role: \"Memory Cleanup Writer\", Model: \"inherit\")`.\n   - **Codex surface:** Apply edits directly in the session.\n   The parent session provides the writer subagent with a fully specified list of approved edits (exact file paths, target lines\u002Ffiles to delete or modify, and preservation text).\n\n2. **Repo files are special (surfaces #3\u002F#4\u002F#5 — per-repo `CLAUDE.md`\u002F`AGENTS.md` and `\u002Fhome\u002Fjoshua\u002FWebJamApps\u002Fweb-jam-tools\u002Fdocs\u002Fcross-ai-rules.md`):** never leave these edits dirty in a working tree. For each affected repo: check `git status -sb` first, create a feature branch off `dev` (stash\u002Frestore if the checkout is on an unrelated branch), bump the repo's semver, commit, push, and open a **draft PR** to `dev` — Josh reviews and merges. All other surfaces (memory dirs, Dropbox task queues) are edited in place.\n\n3. **Keep indexes in sync:** when you delete or rename a memory file, remove or update its `MEMORY.md` index line in the same dir. When you merge memories, update the index lines to match.\n\n4. **Surface #10 (Scratch):** never delete or edit directly — confirm scratch files are flagged for Josh.\n\n5. Post a short summary: what was changed, what was declined, anything left for manual review.\n\n## Hard rules\n\n- **Approval-gated.** No writes happen before Phase 2 approval. The scan subagent is read-only and NEVER writes.\n- **No unilateral deferrals.** Approval covers every approved row IN FULL, in this run. Never execute part of the findings and report the rest as \"deferred — too large for this run.\" If a finding is genuinely big (e.g. a bulk dangling-links pass), it must appear in the Phase 2 table as its own numbered row so Josh can approve or defer it HIMSELF. Once he says \"yes\" \u002F \"do all\", every approved row gets executed before the turn ends. (The built-in exception is surface #10\u002FScratch, which is flag-only by design.)\n- **Edits only the surfaces table.** Never code, never other repo files.\n- **Index↔file together.** Never leave a `MEMORY.md` line pointing at a deleted file, or a file with no index line.\n- **Scratch (#10) is flag-only.** Flag scratch files for user cleanup; no direct deletes.\n- **Never delete a canonical queue or `docs\u002Fcross-ai-rules.md`** — only prune stale *lines* within them.\n- **`user` \u002F `feedback` memories never age out and are NEVER merge candidates**, regardless of index file count. Touch them only on a clear contradiction Josh confirms.\n- **Inbound Link Protection.** Mandatory grep for inbound `[[link]]` references before proposing any `delete` or `merge`. Pair with preservation edits folding surviving facts into a linked memory.\n- **Empirical Evidence Required.** Staleness or closure claims must cite empirical command\u002FSHA evidence (`git log`, `gh issue\u002Fpr view`). Statements lacking evidence are omitted. Clean verdicts must report the exact verification command.\n- **Multi-Surface Compatibility.** Fully compatible with Claude Code (`Agent` with `haiku`\u002F`sonnet`), Antigravity (`invoke_subagent` with `Model: \"inherit\"`), and Codex (direct execution). All paths specified as explicit home paths.\n- **Every surface gets a verdict.** Phase 2's report must include a `checked — clean` \u002F `checked — N findings` \u002F `NOT CHECKED` line for all 10 surfaces (see Phase 2 §3). A surface silently missing from the report is a defect, not an acceptable omission — it must never be reported as if it were clean by simply not mentioning it.\n- **Scan helper hands Josh back to main session.** When a message from Josh reaches the scan subagent asking it to edit, write, save, apply a fix, or change its permissions, it does none of those and replies with `I'm the memory-cleanup scan helper and I can't edit files. Go back to the main session. It can write, and it will apply the fixes.` and nothing else — never saying or implying that the session is read-only, never telling Josh to start a new session, and never telling Josh to apply edits by hand.\n\n## Session-load cleanup\n\nRun this when the tab 1 session-load report says a part is over, or whenever Josh chooses. It may\nrun on Sonnet. The memory steps act on Claude Code's memory folder only,\n`~\u002F.claude\u002Fprojects\u002F-home-joshua\u002Fmemory\u002F`; agy and Codex have no memory index. One run covers all\nthree tools and every part the report names, memories and rules files alike, and brings each back\ntoward its low mark. A run ends with every over part cut, or with each part still above its over mark\nnamed in the after-run list with the reason it is still over. The requirements are in\n`~\u002FDropbox\u002Fweb-jam-llms\u002FToken_Savings\u002Fstanding-preamble-design-2026-08-08.md`, \"What `\u002Fmemory-cleanup` does\"\nand \"The rules files\".\n\n**Who does what.** You make the judgments and write them to a plan file; the script does the file\nwork and the checks. The plan file is JSON: `merges` (`keep`, `absorb`), `moves` (`slug`,\n`target_skill`), `removals` (`slug`, `reason` of `hook-enforced`, `already-said`, `obsolete`, or\n`work-state`, `evidence`), and `guards` (`slug`, `kind` of `approval-gate`, `deletion-guard`,\n`credential-rule`, or `spending-rule`). A move needs the memory's text to be in the target skill's\n`SKILL.md` first.\n\n1. Write the plan file, then run the script with `--dry-run` and show Josh the after-run list:\n   `deno task --config ~\u002FWebJamApps\u002Fweb-jam-tools\u002Fdeno.json memory-cleanup:run --dry-run --plan \u003Cplan file>`\n2. Merges and moves need no approval in this workflow, because neither loses text (the verbatim-preservation\n   policy): a merge keeps the full text of both memories in the surviving file, whatever their `metadata.type`\n   (including `user` and `feedback`), and a move happens only when the script finds the memory's text in the\n   skill word for word. A move whose text is not found REFUSES and the memory stays where it is.\n3. Checkpoint files move to `~\u002FDropbox\u002Fweb-jam-llms\u002Fresume-records\u002F` (finished work moves to\n   `resume-records\u002Fdone\u002F`), with no approval, since their words are kept.\n4. A removal because a hook now enforces the memory, because `CLAUDE.md`, a skill, or a guard memory\n   already says it in different words, or because it is obsolete or records work state, waits for Josh's\n   yes on that row. Run it again with `--approve \u003Cslug>` for each row he approves; a row without his\n   yes leaves the file untouched.\n5. A guard rule (frontmatter `metadata.guard: true`) is never offered, merged, moved or removed. List\n   each memory you mark as one of the four kinds above; the after-run list names each new mark.\n6. Removal is a move to `memory\u002Farchive\u002F`, never a delete. After a real run the script regenerates the\n   memory index with `deno task memory-index`.\n7. A run ends with the memory index at 6,500 bytes or less. When the moves that need no approval leave\n   it above that, the same run puts to Josh the rows whose yes brings it there; it never ends with the\n   index over 6,500 and those rows unasked.\n8. Print the script's after-run list for Josh: what was merged, moved or archived, what waits for his\n   yes, any new-skill suggestion, the size of every part against its limit, each part still over its mark\n   and why, the connector list and Claude Code's connector cost. The limits are read from\n   `src\u002Fsession-load\u002Flimits.json`; never restate a limit number.\n\n### Rules-file cuts\n\nFor the rules-file half of session-load cleanup, propose the five steps under \"The rules files\" for\nevery rules file the report flags: `web-jam-tools\u002FAGENTS.md`, `web-jam-tools\u002Fdocs\u002Fcross-ai-rules.md`,\n`JaMmusic\u002FAGENTS.md`, and each of the other six repositories' rules files whenever it is over 10,000 bytes.\nRead their low marks from `src\u002Fsession-load\u002Flimits.json`. This workflow prepares a pull request for\nJosh to review, one for each repository the cut changes. A cut whose result is above the low mark is\nmade, and the output names the remaining bytes over the low mark. A run ends with every over part cut,\nor with each part still above its over mark named in the after-run list with the reason it is still over.\n\n1. Create an isolated feature worktree off fresh `dev` for each affected repository. Work on\n   that worktree's rules file, never the shared checkout or the home symlink. A helper may do the file\n   work and the checks; the session that holds Josh's request makes the commit, the push, and the draft\n   pull request through `draft-pr`, so the request is in the record of the session that pushes. On agy,\n   which hands nothing to a helper here, the one session does all of it. Never merge the pull request;\n   Josh reviews and merges every rules-file cut.\n2. Make the judgments in a JSON plan saved outside the repository, for example in `\u002Ftmp\u002F`.\n   Set `part` to `mainRules`, `crossAiRules`, `jammusicRules`, or the repository name for any of the other\n   six repos (e.g. `AppersonAuto`, `CollegeLutheran`, `web-jam-back`, `WebJamPg`, `WebJamSocketCluster`,\n   `tim-sherman-music`). Its `spans` array must reproduce the entire current file in order, with no\n   omitted or overlapping text. Every span has a unique `id`, its exact `text` including whitespace, and\n   one `kind`:\n   - `rule`: retained unchanged. A plan that asks to drop a rule is refused.\n   - `skill-instruction`: first copy the text word for word into its `target_skill`'s\n     `SKILL.md`, in the tools feature worktree. Pull request mechanics belong in `draft-pr`,\n     venue and gate items in `book-gig` or `venue-mining`, issue field mechanics in\n     `file-issue`, review mechanics in `pr-review`, dispatch flags in `delegate`, and the\n     plan table in `design-issue`. This workflow may edit these target skills to preserve\n     the moved instructions. Include those edits in the tools pull request.\n   - `scoped-rule`: moves a rule that matters only for one kind of work, word for word, into\n     its `target_skill`'s `SKILL.md`. An approval or safety rule never moves: a rule about\n     real outreach, spending, deletion, or credentials stays in the rules file.\n   - `area-rule`: moves a rule that matters only when changing one part of the repository, word for\n     word, into that area's rules file (`docs\u002Frules\u002F\u003Carea>.md` in the same repository, such as\n     `docs\u002Frules\u002Fhooks.md` or `docs\u002Frules\u002Ftests.md`), with `area` and `folder`. Gotchas and workarounds\n     move with it. Leaves one pointer line in the rules file: `Before changing anything under \\`\u003Cfolder>\\`, read \\`docs\u002Frules\u002F\u003Carea>.md\\`.`.\n     An approval or safety rule never moves.\n   - `reworded`: proposes a shorter wording in `replacement`. Applied only with Josh's yes on\n     that row (`approved: true`); without approval, the original rule stays.\n   - `removed-rule`: proposes removal for one of three reasons: `obsolete`, `hook-enforced`, or\n     `already-said` (naming in `already_said` the skill, safety rules file, or cross-AI rules document\n     that already says it in different words). Applied only with Josh's yes on that row (`approved: true`);\n     without approval, the rule stays.\n   - `backstory`: removed (origin blocks, issue citations with titles, quoted statements,\n     error strings, and worked examples).\n   - `repeat`: removed only when `repeats` names an identical retained rule span. The\n     retained copy must survive in the rules file; repeat chains cannot remove every copy.\n3. Set optional `skills_dir` to the tools feature worktree's `skills` directory when moving\n   instructions. Relative paths resolve against the plan file. Without it, the command uses\n   the skills beside its own source. A move is refused if the text is absent or reworded.\n4. Preview the plan from the tools feature worktree:\n\n   ```sh\n   deno task memory-cleanup:rules-cuts --dry-run --plan \u002Ftmp\u002Frules-cuts-plan.json --file \u002Ftmp\u002Ffeature-worktree\u002FAGENTS.md\n   ```\n\n   The script prints the full rules-before and rules-after lists, which account for each\n   verified move and approved rewording\u002Fremoval while all other rules match, and the\n   proposed byte size against the low and over marks. A dry run writes nothing. A stale\n   plan, missing moved text, or changed repeat refuses the cut; a result above the low mark\n   is made and names the remaining bytes over the low mark.\n5. Run the same command without `--dry-run` to prepare the cut in the feature worktree.\n   Review the diff and both rules lists, then commit, push, and open the draft pull request\n   through `draft-pr`. If instructions move out of JaMmusic into the tools repository,\n   prepare both pull requests and retain their relationship in the descriptions.\n\n## Triggering\n\n- Manual: type `\u002Fmemory-cleanup`, or say \"clean up memory\" \u002F \"memory hygiene\".\n\n## See also\n\n- `skills\u002Fmemory-cleanup\u002FREADME.md` — Obsidian vault setup + agent-safety rules for hand-editing memory files.\n- `~\u002F.claude\u002FCLAUDE.md` + `\u002Fhome\u002Fjoshua\u002FWebJamApps\u002Fweb-jam-tools\u002Fdocs\u002Fcross-ai-rules.md` — the two standing rules (completion-reflection; save-redirection during dispatch) this sweep backstops.\n- `scripts\u002Fbackup-claude-memory.sh` — what protects these memory surfaces.\n\n## Description Detail & Triggers\n\n```\nCross-agent memory hygiene audit. Scans every memory surface across all of Josh's agents (Claude Code per-project + shared memory, global and per-repo CLAUDE.md\u002FAGENTS.md, cross-AI rules doc\u002Ftask queues, bridge-log, hooks.json, and brain scratch files) for staleness, dangling [[links]], index↔file drift, and entries whose tracked issue\u002FPR has closed. The read-only scan runs on a cheap subagent (Haiku \u002F Flash); findings are reported as separate action\u002Fflag tables and the skill WAITS for Josh's explicit approval before executing any fix. Edits ONLY the files in the surfaces table — never code. Triggered when Josh types \u002Fmemory-cleanup or says \"clean up memory\".\n```\n","# memory-cleanup\n\nA three-phase memory housekeeper for Josh's multi-agent workspace. **Always do all\nthree phases in order. Never skip Phase 2 (approval). Never auto-execute without\nJosh's explicit yes.** The skill is invoked manually; it never auto-runs.\n\n**Two workflows live in this file.** The three phases above and the rules in \"Staleness policy by\nmemory type\" and \"Rules\" below are the staleness audit, and they apply to it only. The last section,\n\"Session-load cleanup\", is a separate workflow with its own approval and merge rules, stated in that\nsection; the staleness audit's approval and no-merge rules do not apply to its rows.\n\nMaster copy: `skills\u002Fmemory-cleanup\u002FSKILL.md` in `web-jam-tools`. Installed locally\nas a file-level symlink at `~\u002F.claude\u002Fskills\u002Fmemory-cleanup\u002FSKILL.md`.\n\n## Why this exists\n\nMemories go stale across agents (Claude Code, agy\u002FAntigravity, phone Sonnet).\nFinished work keeps generating session-start reminders; queue lines outlive their PRs;\nMEMORY.md index lines drift from their files.\nThis skill is the periodic sweep that catches what the per-session\ncompletion-reflection rule misses.\n\n## Hard guard\n\nThe skill edits **ONLY** files in the surfaces table below — memory files, their\nMEMORY.md indexes, the cross-AI markdown\u002Fqueues, and the\nstanding-rule files. It NEVER edits code, config, or anything else in a repo,\neven if a finding seems to point there. Out-of-scope findings are reported as notes,\nnot actioned.\n\n---\n\n## Phase 1 — Scan (deterministic pre-pass first; Haiku\u002FFlash only for judgment)\n\n**Step 1 — run the deterministic mechanical scan (no model, no subagent spawn):**\n\n```\ndeno task memory-cleanup:scan\n```\n\n(Run once per project memory directory that needs auditing — pass\n`--dir \u003Cpath>` to point surface 1 at a project other than the default\n`~\u002F.claude\u002Fprojects\u002F-home-joshua\u002Fmemory`; surface 8 always scans\n`~\u002F.claude\u002Fshared-memory` and surface 6 always scans the three Dropbox queue\nfiles, regardless of `--dir`.)\n\nThis is `web-jam-tools`'s `src\u002Fmemory-cleanup\u002Fscan.ts` (+ `cli.ts`), the same\nprecedent as a deterministic, read-only pre-pass that reuses\n`src\u002Fmemory-index\u002Fgenerator.ts`'s `scanMemoryDirectory`\u002F\n`parseMemoryFile` to compute, with **no model call**, for surfaces 1, 6, and\n8: the null-parse (unparseable) file list, a dangling-`[[link]]` slug diff,\nper-file inbound link counts, an index↔file sync check (does every memory\nfile's slug actually appear in its `MEMORY.md`), and live `gh` state for\nevery `project`-typed memory or queue line that cites a `repo#number`. It\nprints one JSON object with an explicit `status` (`checked` or `error`) for\neach of the three surfaces — a failed single `gh` lookup shows up as its own\n`\"status\":\"error\"` finding with a reason, never a silent drop and never\nfolded into a false \"clean\" verdict.\n\n**Treat this JSON as already-established fact for surfaces 1, 6, and 8** —\ndo not re-derive it. Hand it to the scan subagent verbatim.\n\n**Step 2 — spawn the scan subagent for judgment calls only:**\n\nSpawn the scan as a cheap subagent based on the host surface:\n- **Claude Code surface:** Spawn via `Agent(subagent_type: \"Explore\", model: \"haiku\")`.\n- **Antigravity (`agy`) surface:** Spawn via `invoke_subagent(TypeName: \"self\", Role: \"Memory Cleanup Scanner\", Model: \"inherit\")`.\n- **Codex surface:** Run scan steps directly.\n\nThe subagent does read-only work only: for surfaces 1, 6, and 8, its job is\nnow limited to the judgment calls the Step 1 JSON doesn't already resolve\n(e.g. deciding whether an untouched-but-not-closed `project` memory is still\nworth flagging as stale) — it must not re-run the mechanical checks the JSON\nalready answered. For surfaces 2–5, 7, 9–10 it does the full read-only\nscan as before: it reads files, checks issue\u002FPR status (`gh issue view \u003Cn>`,\n`gh pr view \u003Cn>`), verifies git commit dates (`git log -1 --format=%ad\n--date=short -- \u003Cfile>`), performs dangling-link slug diffs, and returns\nfindings. **It must not write, edit, or delete anything.**\n\nGive the subagent the Step 1 JSON, this surfaces list, and the staleness policy.\n\n**Messages from Josh (include word for word in scan subagent prompt on Claude Code and agy\u002FAntigravity):**\nThe parent session must include this rule word for word in the scan subagent's prompt on Claude Code (`Explore`) and on agy\u002FAntigravity (`Memory Cleanup Scanner`):\nWhen a message from Josh asks it to edit, write, save, apply a fix, or change its own permissions, it does none of those and replies with exactly this sentence and nothing else:\n`I'm the memory-cleanup scan helper and I can't edit files. Go back to the main session. It can write, and it will apply the fixes.`\nThe rule forbids the scan subagent from saying or implying that the session is read-only, from telling Josh to start a new session, and from telling Josh to apply the edits by hand.\n\n**Command discipline & Evidence requirements:**\n1. The subagent must use dedicated Read \u002F Glob \u002F Grep tools for file inspection. Bash is allowed only as single, simple allowed commands (`ls`, `cat`, `grep`, `gh issue view`, `gh pr view`, `git log`). Never use compound or ad-hoc Bash (`cd ... && ...`, loops, `;` chains, inline python\u002Fnode).\n2. **Empirical Evidence Requirement:** Staleness claims for any repo file MUST execute `git log -1 --format=%ad --date=short -- \u003Cfile>` to verify actual commit age. Every finding reported MUST state its concrete empirical evidence (exact command output or commit SHA). Findings lacking empirical evidence MUST be omitted.\n3. **Reproducible Clean Verdicts:** Reporting a surface as clean requires stating the exact command\u002Fcomputation executed to verify clean state.\n4. **Reproducible Dangling-Link Slug Diff:** Collect all `[[slug]]` targets referenced across memory files, compute the set diff against actual `\u003Cslug>.md` filenames in the target directory, and report any missing target slugs.\n5. **Inbound Link Protection:** Before proposing a `delete` or `merge` for a memory file, perform a mandatory grep for inbound `[[slug]]` references across memory dirs (`~\u002F.claude\u002Fprojects\u002F*\u002Fmemory\u002F`, `~\u002F.claude\u002Fshared-memory\u002F`) and `CLAUDE.md`\u002F`AGENTS.md` files. Report the inbound link count in the findings table. Pair any deletion or merge with a preservation edit that folds surviving facts into a linked memory that remains.\n6. **Every surface gets a verdict, never a silent gap.** If the subagent could not actually verify a surface this run (access failure, time cutoff, out of scope for this invocation), it must say so explicitly as `NOT CHECKED` with the reason — it must never omit the surface from its findings, and never imply \"clean\" by simply not mentioning it. Phase 2's report template requires this for all 10 surfaces (see below).\n\n### Surfaces to audit (10)\n\n| # | Surface | Checks |\n|---|---------|--------|\n| 1 | `~\u002F.claude\u002Fprojects\u002F*\u002Fmemory\u002F*.md` + each `MEMORY.md` | typed staleness; inbound link grep before propose; dangling `[[links]]` (slug diff); index↔file sync (via `deno task memory-index`) |\n| 2 | `~\u002F.claude\u002FCLAUDE.md` (global) | contradictions with memories; rules superseded by newer decisions |\n| 3 | per-repo `CLAUDE.md` (`\u002Fhome\u002Fjoshua\u002FWebJamApps\u002F*\u002FCLAUDE.md`) | same as #2; require `git log` staleness evidence |\n| 4 | per-repo `AGENTS.md` across all 8 active WebJamApps repos (`\u002Fhome\u002Fjoshua\u002FWebJamApps\u002F*\u002FAGENTS.md`) | same; also flag any leftover `GEMINI.md` files (renamed → AGENTS.md June 2026); require `git log` staleness evidence |\n| 5 | `\u002Fhome\u002Fjoshua\u002FWebJamApps\u002Fweb-jam-tools\u002Fdocs\u002Fcross-ai-rules.md` | cross-AI rules: contradictions, superseded entries |\n| 6 | `~\u002FDropbox\u002Fweb-jam-llms\u002F{agy,claude-opus,claude-fable}-tasks.txt` | any line referencing a closed issue \u002F merged PR → propose removal |\n| 7 | `~\u002FDropbox\u002Fweb-jam-llms\u002Fbridge-log.md` | bridge items merged but unlogged (or logged-but-still-pending) |\n| 8 | `~\u002F.claude\u002Fshared-memory\u002F*.md` + its `MEMORY.md` | same typed staleness and index checks as #1 |\n| 9 | `~\u002F.gemini\u002Fconfig\u002Fhooks.json` | hook configuration drift check and syntax validation |\n| 10 | Stale `~\u002F.gemini\u002Fantigravity-cli\u002Fbrain\u002F*\u002Fscratch\u002F` | files older than ~14 days (**FLAG only** for manual cleanup) |\n\n### Staleness policy by memory type (frontmatter `metadata.type`)\n\n- **`user` \u002F `feedback`** — never age out. Flag only when contradicted or superseded by a newer memory or rule. **Memories typed `user` or `feedback` are NEVER merge candidates.**\n- **`project`** — flag if untouched ~30 days (verify with `git log` or file mtime). If its issue\u002FPR is closed (check via `gh`), propose delete or condense to a one-line \"done\" note.\n- **`reference`** — verify the pointer every run: is the linked issue still open? does the path\u002FURL still exist? Flag dead pointers.\n- **Untyped files** (`cross-ai-rules.md`, the queues) — use the per-row rules in the table above.\n\nIndex trigger: `MEMORY.md` index is auto-generated by `deno task memory-index`; `status: done` checkpoints are auto-archived without an approval loop.\n\nClosure checks: `gh issue view \u003Cn> --json state` and `gh pr view \u003Cn> --json state`.\nA `CLOSED`\u002F`MERGED` state on an issue\u002FPR that a memory or queue line still tracks is a delete\u002Fcondense candidate.\n\n---\n\n## Phase 2 — Report + await approval\n\nPresent the subagent's findings split into two separate output sections: **Approvable Action Rows** and **Informational \u002F Flag-Only Notes**.\n\n### 1. Approvable Action Rows\n\n| # | Surface | Entry | Finding & Evidence | Inbound Links | Proposed Action |\n|---|---|---|---|---|---|\n| 1 | project memory (web-jam-back) | facebook-feed.md | issue #797 merged (`gh pr view 798` -> MERGED) | 0 links | delete file + remove line from MEMORY.md |\n| 2 | project memory (web-jam-tools) | index | index out of sync with disk (`deno task memory-index --check`) | N\u002FA | regenerate MEMORY.md via `deno task memory-index` |\n| 3 | opus queue | \"Task 35 — #43 handle-gemini\" | PR #44 merged (`gh pr view 44` -> MERGED) | 0 links | remove line from agy-tasks.txt |\n\n### 2. Informational \u002F Flag-Only Notes\n\n| # | Surface | Entry | Finding & Evidence | Flag \u002F Recommendation |\n|---|---|---|---|---|\n| 1 | scratch | ~\u002F.gemini\u002Fantigravity-cli\u002Fbrain\u002Fabc123\u002Fscratch\u002Ftmp.py | file mtime > 14 days ago | Flag for manual cleanup |\n\n### 3. Surface Verdicts (all 10 — mandatory, no exceptions)\n\nEvery one of the 10 surfaces gets exactly one explicit verdict line, in this\ntable, **even when it's also covered by an Approvable Action Row above.** A\nsurface missing from this table is itself a defect this skill's own hard\nrules forbid — it means Phase 1 skipped a surface and reported nothing,\nwhich reads as \"clean\" to Josh even though nothing was checked. Each verdict\nis one of:\n\n- **`checked — clean`** — verified, no findings. Must cite the exact\n  command\u002Fcomputation executed (for surfaces 1\u002F6\u002F8, this is \"per Step 1's\n  `deno task memory-cleanup:scan` JSON\"; for the rest, the subagent's own\n  command, e.g. `git log -1`, `grep -i contradiction`).\n- **`checked — N findings`** — verified, N findings reported above (in the\n  Approvable Action Rows or Informational\u002FFlag-Only Notes tables).\n- **`NOT CHECKED`** — the subagent did not actually verify this surface this\n  run. State the reason (access failure, time cutoff, out of scope for this\n  invocation, etc.). This is not itself a finding to fix — it's an honest\n  admission the check didn't happen, so Josh knows to ask for a follow-on\n  pass rather than assume the surface is fine.\n\n| # | Surface | Verdict | Evidence \u002F reason |\n|---|---|---|---|\n| 1 | `~\u002F.claude\u002Fprojects\u002F*\u002Fmemory\u002F*.md` + `MEMORY.md` | checked — clean | per Step 1's `deno task memory-cleanup:scan` JSON |\n| 2 | `~\u002F.claude\u002FCLAUDE.md` (global) | checked — clean | `grep -i contradiction` verified 0 conflicts |\n| 3 | per-repo `CLAUDE.md` | checked — clean | `git log -1` checked across 8 repos, all updated within 14 days |\n| 4 | per-repo `AGENTS.md` | checked — clean | `git log -1` checked across 8 repos; no stray `GEMINI.md` found |\n| 5 | `docs\u002Fcross-ai-rules.md` | checked — clean | read in full, no contradictions found |\n| 6 | Dropbox `{agy,claude-opus,claude-fable}-tasks.txt` | checked — clean | per Step 1's `deno task memory-cleanup:scan` JSON |\n| 7 | `~\u002FDropbox\u002Fweb-jam-llms\u002Fbridge-log.md` | checked — clean | read in full, all bridge items logged |\n| 8 | `~\u002F.claude\u002Fshared-memory\u002F*.md` + `MEMORY.md` | checked — clean | per Step 1's `deno task memory-cleanup:scan` JSON |\n| 9 | `~\u002F.gemini\u002Fconfig\u002Fhooks.json` | checked — clean | JSON parsed, schema matches expected hooks |\n| 10 | `~\u002F.gemini\u002Fantigravity-cli\u002Fbrain\u002F*\u002Fscratch\u002F` | NOT CHECKED | out of scope for this invocation — flag-only surface |\n\n(This example table is illustrative; a real run fills in the actual verdict\nand evidence for each row. Surface 10 being flag-only by design does\nNOT excuse it from appearing in this table — a flag-only surface still\ngets an honest verdict, it's just always `NOT CHECKED` for execution purposes\nor `checked — N findings` when the subagent did do the read-only flagging\npass the surfaces table asks for.)\n\nThen **STOP and wait for explicit approval.** Accept \"yes\", \"do 1,3\", \"all but 2\", etc. Never execute an unapproved row.\n\n---\n\n## Phase 3 — Execute\n\nOnly after approval, and only for approved rows:\n\n1. **Execution surface:** The scan subagent NEVER writes. Phase 3 edits may be applied directly in the parent session OR by dispatching a dedicated **Writer Subagent**:\n   - **Claude Code surface:** Dispatch writer subagent via `Agent(model: \"sonnet\")` or `Agent(model: \"haiku\")`.\n   - **Antigravity (`agy`) surface:** Dispatch writer subagent via `invoke_subagent(TypeName: \"self\", Role: \"Memory Cleanup Writer\", Model: \"inherit\")`.\n   - **Codex surface:** Apply edits directly in the session.\n   The parent session provides the writer subagent with a fully specified list of approved edits (exact file paths, target lines\u002Ffiles to delete or modify, and preservation text).\n\n2. **Repo files are special (surfaces #3\u002F#4\u002F#5 — per-repo `CLAUDE.md`\u002F`AGENTS.md` and `\u002Fhome\u002Fjoshua\u002FWebJamApps\u002Fweb-jam-tools\u002Fdocs\u002Fcross-ai-rules.md`):** never leave these edits dirty in a working tree. For each affected repo: check `git status -sb` first, create a feature branch off `dev` (stash\u002Frestore if the checkout is on an unrelated branch), bump the repo's semver, commit, push, and open a **draft PR** to `dev` — Josh reviews and merges. All other surfaces (memory dirs, Dropbox task queues) are edited in place.\n\n3. **Keep indexes in sync:** when you delete or rename a memory file, remove or update its `MEMORY.md` index line in the same dir. When you merge memories, update the index lines to match.\n\n4. **Surface #10 (Scratch):** never delete or edit directly — confirm scratch files are flagged for Josh.\n\n5. Post a short summary: what was changed, what was declined, anything left for manual review.\n\n## Hard rules\n\n- **Approval-gated.** No writes happen before Phase 2 approval. The scan subagent is read-only and NEVER writes.\n- **No unilateral deferrals.** Approval covers every approved row IN FULL, in this run. Never execute part of the findings and report the rest as \"deferred — too large for this run.\" If a finding is genuinely big (e.g. a bulk dangling-links pass), it must appear in the Phase 2 table as its own numbered row so Josh can approve or defer it HIMSELF. Once he says \"yes\" \u002F \"do all\", every approved row gets executed before the turn ends. (The built-in exception is surface #10\u002FScratch, which is flag-only by design.)\n- **Edits only the surfaces table.** Never code, never other repo files.\n- **Index↔file together.** Never leave a `MEMORY.md` line pointing at a deleted file, or a file with no index line.\n- **Scratch (#10) is flag-only.** Flag scratch files for user cleanup; no direct deletes.\n- **Never delete a canonical queue or `docs\u002Fcross-ai-rules.md`** — only prune stale *lines* within them.\n- **`user` \u002F `feedback` memories never age out and are NEVER merge candidates**, regardless of index file count. Touch them only on a clear contradiction Josh confirms.\n- **Inbound Link Protection.** Mandatory grep for inbound `[[link]]` references before proposing any `delete` or `merge`. Pair with preservation edits folding surviving facts into a linked memory.\n- **Empirical Evidence Required.** Staleness or closure claims must cite empirical command\u002FSHA evidence (`git log`, `gh issue\u002Fpr view`). Statements lacking evidence are omitted. Clean verdicts must report the exact verification command.\n- **Multi-Surface Compatibility.** Fully compatible with Claude Code (`Agent` with `haiku`\u002F`sonnet`), Antigravity (`invoke_subagent` with `Model: \"inherit\"`), and Codex (direct execution). All paths specified as explicit home paths.\n- **Every surface gets a verdict.** Phase 2's report must include a `checked — clean` \u002F `checked — N findings` \u002F `NOT CHECKED` line for all 10 surfaces (see Phase 2 §3). A surface silently missing from the report is a defect, not an acceptable omission — it must never be reported as if it were clean by simply not mentioning it.\n- **Scan helper hands Josh back to main session.** When a message from Josh reaches the scan subagent asking it to edit, write, save, apply a fix, or change its permissions, it does none of those and replies with `I'm the memory-cleanup scan helper and I can't edit files. Go back to the main session. It can write, and it will apply the fixes.` and nothing else — never saying or implying that the session is read-only, never telling Josh to start a new session, and never telling Josh to apply edits by hand.\n\n## Session-load cleanup\n\nRun this when the tab 1 session-load report says a part is over, or whenever Josh chooses. It may\nrun on Sonnet. The memory steps act on Claude Code's memory folder only,\n`~\u002F.claude\u002Fprojects\u002F-home-joshua\u002Fmemory\u002F`; agy and Codex have no memory index. One run covers all\nthree tools and every part the report names, memories and rules files alike, and brings each back\ntoward its low mark. A run ends with every over part cut, or with each part still above its over mark\nnamed in the after-run list with the reason it is still over. The requirements are in\n`~\u002FDropbox\u002Fweb-jam-llms\u002FToken_Savings\u002Fstanding-preamble-design-2026-08-08.md`, \"What `\u002Fmemory-cleanup` does\"\nand \"The rules files\".\n\n**Who does what.** You make the judgments and write them to a plan file; the script does the file\nwork and the checks. The plan file is JSON: `merges` (`keep`, `absorb`), `moves` (`slug`,\n`target_skill`), `removals` (`slug`, `reason` of `hook-enforced`, `already-said`, `obsolete`, or\n`work-state`, `evidence`), and `guards` (`slug`, `kind` of `approval-gate`, `deletion-guard`,\n`credential-rule`, or `spending-rule`). A move needs the memory's text to be in the target skill's\n`SKILL.md` first.\n\n1. Write the plan file, then run the script with `--dry-run` and show Josh the after-run list:\n   `deno task --config ~\u002FWebJamApps\u002Fweb-jam-tools\u002Fdeno.json memory-cleanup:run --dry-run --plan \u003Cplan file>`\n2. Merges and moves need no approval in this workflow, because neither loses text (the verbatim-preservation\n   policy): a merge keeps the full text of both memories in the surviving file, whatever their `metadata.type`\n   (including `user` and `feedback`), and a move happens only when the script finds the memory's text in the\n   skill word for word. A move whose text is not found REFUSES and the memory stays where it is.\n3. Checkpoint files move to `~\u002FDropbox\u002Fweb-jam-llms\u002Fresume-records\u002F` (finished work moves to\n   `resume-records\u002Fdone\u002F`), with no approval, since their words are kept.\n4. A removal because a hook now enforces the memory, because `CLAUDE.md`, a skill, or a guard memory\n   already says it in different words, or because it is obsolete or records work state, waits for Josh's\n   yes on that row. Run it again with `--approve \u003Cslug>` for each row he approves; a row without his\n   yes leaves the file untouched.\n5. A guard rule (frontmatter `metadata.guard: true`) is never offered, merged, moved or removed. List\n   each memory you mark as one of the four kinds above; the after-run list names each new mark.\n6. Removal is a move to `memory\u002Farchive\u002F`, never a delete. After a real run the script regenerates the\n   memory index with `deno task memory-index`.\n7. A run ends with the memory index at 6,500 bytes or less. When the moves that need no approval leave\n   it above that, the same run puts to Josh the rows whose yes brings it there; it never ends with the\n   index over 6,500 and those rows unasked.\n8. Print the script's after-run list for Josh: what was merged, moved or archived, what waits for his\n   yes, any new-skill suggestion, the size of every part against its limit, each part still over its mark\n   and why, the connector list and Claude Code's connector cost. The limits are read from\n   `src\u002Fsession-load\u002Flimits.json`; never restate a limit number.\n\n### Rules-file cuts\n\nFor the rules-file half of session-load cleanup, propose the five steps under \"The rules files\" for\nevery rules file the report flags: `web-jam-tools\u002FAGENTS.md`, `web-jam-tools\u002Fdocs\u002Fcross-ai-rules.md`,\n`JaMmusic\u002FAGENTS.md`, and each of the other six repositories' rules files whenever it is over 10,000 bytes.\nRead their low marks from `src\u002Fsession-load\u002Flimits.json`. This workflow prepares a pull request for\nJosh to review, one for each repository the cut changes. A cut whose result is above the low mark is\nmade, and the output names the remaining bytes over the low mark. A run ends with every over part cut,\nor with each part still above its over mark named in the after-run list with the reason it is still over.\n\n1. Create an isolated feature worktree off fresh `dev` for each affected repository. Work on\n   that worktree's rules file, never the shared checkout or the home symlink. A helper may do the file\n   work and the checks; the session that holds Josh's request makes the commit, the push, and the draft\n   pull request through `draft-pr`, so the request is in the record of the session that pushes. On agy,\n   which hands nothing to a helper here, the one session does all of it. Never merge the pull request;\n   Josh reviews and merges every rules-file cut.\n2. Make the judgments in a JSON plan saved outside the repository, for example in `\u002Ftmp\u002F`.\n   Set `part` to `mainRules`, `crossAiRules`, `jammusicRules`, or the repository name for any of the other\n   six repos (e.g. `AppersonAuto`, `CollegeLutheran`, `web-jam-back`, `WebJamPg`, `WebJamSocketCluster`,\n   `tim-sherman-music`). Its `spans` array must reproduce the entire current file in order, with no\n   omitted or overlapping text. Every span has a unique `id`, its exact `text` including whitespace, and\n   one `kind`:\n   - `rule`: retained unchanged. A plan that asks to drop a rule is refused.\n   - `skill-instruction`: first copy the text word for word into its `target_skill`'s\n     `SKILL.md`, in the tools feature worktree. Pull request mechanics belong in `draft-pr`,\n     venue and gate items in `book-gig` or `venue-mining`, issue field mechanics in\n     `file-issue`, review mechanics in `pr-review`, dispatch flags in `delegate`, and the\n     plan table in `design-issue`. This workflow may edit these target skills to preserve\n     the moved instructions. Include those edits in the tools pull request.\n   - `scoped-rule`: moves a rule that matters only for one kind of work, word for word, into\n     its `target_skill`'s `SKILL.md`. An approval or safety rule never moves: a rule about\n     real outreach, spending, deletion, or credentials stays in the rules file.\n   - `area-rule`: moves a rule that matters only when changing one part of the repository, word for\n     word, into that area's rules file (`docs\u002Frules\u002F\u003Carea>.md` in the same repository, such as\n     `docs\u002Frules\u002Fhooks.md` or `docs\u002Frules\u002Ftests.md`), with `area` and `folder`. Gotchas and workarounds\n     move with it. Leaves one pointer line in the rules file: `Before changing anything under \\`\u003Cfolder>\\`, read \\`docs\u002Frules\u002F\u003Carea>.md\\`.`.\n     An approval or safety rule never moves.\n   - `reworded`: proposes a shorter wording in `replacement`. Applied only with Josh's yes on\n     that row (`approved: true`); without approval, the original rule stays.\n   - `removed-rule`: proposes removal for one of three reasons: `obsolete`, `hook-enforced`, or\n     `already-said` (naming in `already_said` the skill, safety rules file, or cross-AI rules document\n     that already says it in different words). Applied only with Josh's yes on that row (`approved: true`);\n     without approval, the rule stays.\n   - `backstory`: removed (origin blocks, issue citations with titles, quoted statements,\n     error strings, and worked examples).\n   - `repeat`: removed only when `repeats` names an identical retained rule span. The\n     retained copy must survive in the rules file; repeat chains cannot remove every copy.\n3. Set optional `skills_dir` to the tools feature worktree's `skills` directory when moving\n   instructions. Relative paths resolve against the plan file. Without it, the command uses\n   the skills beside its own source. A move is refused if the text is absent or reworded.\n4. Preview the plan from the tools feature worktree:\n\n   ```sh\n   deno task memory-cleanup:rules-cuts --dry-run --plan \u002Ftmp\u002Frules-cuts-plan.json --file \u002Ftmp\u002Ffeature-worktree\u002FAGENTS.md\n   ```\n\n   The script prints the full rules-before and rules-after lists, which account for each\n   verified move and approved rewording\u002Fremoval while all other rules match, and the\n   proposed byte size against the low and over marks. A dry run writes nothing. A stale\n   plan, missing moved text, or changed repeat refuses the cut; a result above the low mark\n   is made and names the remaining bytes over the low mark.\n5. Run the same command without `--dry-run` to prepare the cut in the feature worktree.\n   Review the diff and both rules lists, then commit, push, and open the draft pull request\n   through `draft-pr`. If instructions move out of JaMmusic into the tools repository,\n   prepare both pull requests and retain their relationship in the descriptions.\n\n## Triggering\n\n- Manual: type `\u002Fmemory-cleanup`, or say \"clean up memory\" \u002F \"memory hygiene\".\n\n## See also\n\n- `skills\u002Fmemory-cleanup\u002FREADME.md` — Obsidian vault setup + agent-safety rules for hand-editing memory files.\n- `~\u002F.claude\u002FCLAUDE.md` + `\u002Fhome\u002Fjoshua\u002FWebJamApps\u002Fweb-jam-tools\u002Fdocs\u002Fcross-ai-rules.md` — the two standing rules (completion-reflection; save-redirection during dispatch) this sweep backstops.\n- `scripts\u002Fbackup-claude-memory.sh` — what protects these memory surfaces.\n\n## Description Detail & Triggers\n\n```\nCross-agent memory hygiene audit. Scans every memory surface across all of Josh's agents (Claude Code per-project + shared memory, global and per-repo CLAUDE.md\u002FAGENTS.md, cross-AI rules doc\u002Ftask queues, bridge-log, hooks.json, and brain scratch files) for staleness, dangling [[links]], index↔file drift, and entries whose tracked issue\u002FPR has closed. The read-only scan runs on a cheap subagent (Haiku \u002F Flash); findings are reported as separate action\u002Fflag tables and the skill WAITS for Josh's explicit approval before executing any fix. Edits ONLY the files in the surfaces table — never code. Triggered when Josh types \u002Fmemory-cleanup or says \"clean up memory\".\n```\n",{"name":5,"description":7},"dev","1942898f4ed878197e832b9caf95e70ad027a3c2","skills\u002Fmemory-cleanup",0,"https:\u002F\u002Fgithub.com\u002FWebJamApps\u002Fweb-jam-tools","https:\u002F\u002Fgithub.com\u002FWebJamApps","https:\u002F\u002Fwww.web-jam.com","Open Source PWAs","2026-11-15 00:20:14",{"source":8,"skillName":5,"commands":53,"prompt":63,"zipAvailable":64},[54,57,60],{"tool":55,"command":56},"npx","npx skills add WebJamApps\u002Fweb-jam-tools --skill memory-cleanup",{"tool":58,"command":59},"bunx","bunx skills add WebJamApps\u002Fweb-jam-tools --skill memory-cleanup",{"tool":61,"command":62},"pnpm","pnpm dlx skills add WebJamApps\u002Fweb-jam-tools --skill memory-cleanup","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FWebJamApps\u002Fweb-jam-tools\u002Fblob\u002Fdev\u002Fskills\u002Fmemory-cleanup\u002FSKILL.md",true,[66,72],{"path":67,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":70,"sourceHtmlUrl":71},"README.md","REFERENCE","参考文档",3164,"https:\u002F\u002Fgithub.com\u002FWebJamApps\u002Fweb-jam-tools\u002Fblob\u002Fdev\u002Fskills\u002Fmemory-cleanup\u002FREADME.md",{"path":73,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":74,"sourceHtmlUrl":75},"start-check.json",148,"https:\u002F\u002Fgithub.com\u002FWebJamApps\u002Fweb-jam-tools\u002Fblob\u002Fdev\u002Fskills\u002Fmemory-cleanup\u002Fstart-check.json",[77,85,97,106,127,153],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":84},"01M7DWK0QS9G2C782HAPF3NZ5M","accounting","Keep Web Jam LLC's books in hledger under ~\u002FDropbox\u002Fweb-jam-llms\u002Ffinancial\u002Fbooks\u002F. Record plain-text entries, file receipt scans, convert Quicken\u002FQuickBooks bank files to CSV, import statements, and run the month-end close. No personal lines or amounts go to GitHub.","https:\u002F\u002Fgithub.com\u002FWebJamApps\u002Fweb-jam-tools\u002Fblob\u002Fdev\u002Fskills\u002Faccounting\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":38},"01M71VZG62JCF5DKN87PACF4CG","draft-pr","Fixture skill receiving a moved instruction.","https:\u002F\u002Fgithub.com\u002FWebJamApps\u002Fweb-jam-tools\u002Fblob\u002Fdev\u002Ftest\u002Ffixtures\u002Frules-cuts\u002Fskills\u002Fdraft-pr\u002FSKILL.md",[],[92,93,94,95,96],"draft","pr","draft pr","fixture skill","fixture",{"skillNo":98,"name":99,"nameZh":6,"description":100,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":101,"categories":102,"keywords":103,"publishedAt":38},"01M71VZEGYXF5NQQR92JJ1J8P0","demo-skill","Fixture skill","https:\u002F\u002Fgithub.com\u002FWebJamApps\u002Fweb-jam-tools\u002Fblob\u002Fdev\u002Ftest\u002Ffixtures\u002Fmemory-cleanup-low-mark\u002Fskills\u002Fdemo-skill\u002FSKILL.md",[],[104,105,96,95],"demo skill","demo",{"skillNo":107,"name":108,"nameZh":6,"description":109,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":110,"categories":111,"keywords":112,"publishedAt":38},"01M71VZ3EFAGPXQ861W9J1Z5BP","venue-mining","Mine net-new live-music venues for the gig-outreach DB by sweeping local events publications, artist histories, or venue sites, creating verified records. Use when discovering new live-music venues, running metro sweeps, or enriching venue contact details.","https:\u002F\u002Fgithub.com\u002FWebJamApps\u002Fweb-jam-tools\u002Fblob\u002Fdev\u002Fskills\u002Fvenue-mining\u002FSKILL.md",[],[113,114,115,116,22,117,118,119,120,121,122,123,24,124,125,33,126],"mining","venue mining","live","verified","new","local","db","music","events","running","mine","records","sites","outreach",{"skillNo":128,"name":129,"nameZh":6,"description":130,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":131,"categories":132,"keywords":133,"publishedAt":38},"01M71VZ0PJ3NZDTWTEN1TJHF1F","sheet-music","Transcribe and reformat scanned lead sheets in Dropbox into clean, professional Word docx files with dual-tier chord alignment (Guitar Capo above Bass Sounding) or single-tier chords over lyrics. Triggered by \u002Fsheet-music \u003CDropbox-path(s)...>, \"sheet music\", or \"lead sheet\".","https:\u002F\u002Fgithub.com\u002FWebJamApps\u002Fweb-jam-tools\u002Fblob\u002Fdev\u002Fskills\u002Fsheet-music\u002FSKILL.md",[],[134,135,120,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152],"sheet music","sheet","guitar","path","lead","dropbox","lyrics","alignment","docx","professional","Word","transcribe","sheets","clean","single","files","with","Word   DOCX","chord",{"skillNo":154,"name":155,"nameZh":6,"description":156,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":157,"categories":158,"keywords":159,"publishedAt":38},"01M71VYWEEDSZJD15N5DCY1PXY","pr-review","Cross-model PR review pipeline auditing diffs against acceptance criteria, scope, semver bump, test evidence, and guardrails, posting feedback via post-pr-review. Use when reviewing a pull request or checking open PRs across WebJamApps repositories.","https:\u002F\u002Fgithub.com\u002FWebJamApps\u002Fweb-jam-tools\u002Fblob\u002Fdev\u002Fskills\u002Fpr-review\u002FSKILL.md",[],[93,160,161,162,163,164,165,166,167,168,169,170,22,171,172,173,155,174,175,176],"review","pr review","evidence","scope","model","bump","pipeline","Guardrails","diffs","open","acceptance","across","request","semver","pull","feedback","posting"]