/claude-housekeeping:claude-housekeepingfrom claude-housekeeping
Scan all Claude Code project artifacts (memories, hooks, commands, plans, settings) across global ~/.claude and every project in ~/.claude/projects.json. Produce a numbered list of drift recommendations plus an executable command list, state-visualization table, and mermaid graphs. Never auto-applies — user must approve recommendations explicitly. Use when the user says "housekeeping", "/claude-housekeeping", "audit my claude config", "find drift", or wants a daily/weekly snapshot of their Claude setup health.
Ships in claude-housekeeping. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
User-invoked drift detector + cleanup helper for the user's Claude Code artifacts.
If invoked via /schedule for an unattended cron run, the skill MUST stop after producing the report — surfaces a notification for the user to review on their next prompt. No unattended execution of recommendations, ever.
/claude-housekeeping # interactive: scan, show report, prompt for approvals, apply
/claude-housekeeping --report-only # scan only, write report file, no prompts
/claude-housekeeping --report-only --quiet # report only, no notification if zero recommendations
/claude-housekeeping --diff before=X after=Y # generate delta report comparing two prior snapshots
/claude-housekeeping --threshold-days=N # tune the "orphan plans older than N days" cutoff (default 1)
/claude-housekeeping --include-dormant # scan dormant projects too (default: skip)
/claude-housekeeping --emit-commands=3,7,12 # output only the specified recommendations' command blocks
/claude-housekeeping --report-only --auto-reschedule # report only + reschedule next run 24 h out (used by self-scheduled runs)
When the user types /claude-housekeeping (with any args), run the scanner directly — there is no wrapper script. Invoke it from the plugin dir, which is where this skill actually executes from:
python3 "${CLAUDE_PLUGIN_ROOT}/skills/claude-housekeeping/scanner.py" --report-only [args]
Do not hardcode $HOME/.claude/skills/claude-housekeeping/scanner.py. That path is a pre-XDG-migration location: Claude Code resolves global artifacts from $CLAUDE_CONFIG_DIR, so a copy sitting in ~/.claude/skills/ may be stale, unloaded, or absent. If CLAUDE_PLUGIN_ROOT is unset (running the skill outside a plugin context), fall back to the scanner next to this SKILL.md.
The scanner writes a markdown report to <live_root>/housekeeping/reports/YYYY-MM-DD-HHMM.md (live root = $CLAUDE_CONFIG_DIR, falling back to ~/.claude) and prints the path on stdout. The model should Read the report file and surface a summary + numbered recommendations to the user.
Interactive flow (after reading the report):
Plan mode compatibility: --report-only is safe to run in plan mode — it only writes an audit-output file under ~/.claude/housekeeping/reports/, not actual state changes. Defer applying recommendations until plan mode exits.
After the user approves and the model applies one or more recommendations, the model must create or reset a 24-hour one-shot follow-up run. This is the only scheduling that happens; it does not fire on --report-only runs that were not triggered by the scheduler itself.
State file: ~/.claude/housekeeping/scheduled-run.json
{ "job_id": "<CronCreate id>", "scheduled_for": "<ISO UTC>", "created_at": "<ISO UTC>" }
~/.claude/housekeeping/scheduled-run.json exists, extract job_id.CronDelete(id) — ignore errors (job may have already fired and auto-deleted).date -d '+24 hours' '+%M %H %d %m *'
This produces the local-time cron expression (e.g. "27 14 22 5 *").CronCreate with:
cron: the value from step 3recurring: false (one-shot; auto-deletes after firing)durable: true (persists across session restarts)prompt: "/claude-housekeeping --report-only --auto-reschedule"~/.claude/housekeeping/scheduled-run.json:
SCHED_FOR=$(date -d '+24 hours' -u +%Y-%m-%dT%H:%M:%SZ)
NOW=$(date -u +%Y-%m-%dT%H:%M:%SZ)
printf '{"job_id":"%s","scheduled_for":"%s","created_at":"%s"}\n' \
"$NEW_JOB_ID" "$SCHED_FOR" "$NOW" \
> ~/.claude/housekeeping/scheduled-run.json
"Next housekeeping run scheduled for <human-readable local time>." (e.g. "Thu 22 May 14:27").--auto-reschedule flow (self-scheduled unattended run)When invoked as /claude-housekeeping --report-only --auto-reschedule (i.e., fired by the scheduler):
--report-only takes precedence. The user reviews the report on their next prompt.Legacy config root — global artifacts stranded where Claude Code no longer reads them.
$CLAUDE_CONFIG_DIR (the live root), falling back to ~/.claude. When that root moves — e.g. Claude Code's own ~/.claude → ~/.config/claude/<account>/ XDG migration — an incomplete move leaves skills, commands, the memory master, settings.json keys, and the hook chain behind in the old root, loaded by nothing..claude/ still loads from the repo, so project commands and per-project memory keep working while the entire global chain is silently gone. Everything feels mostly fine.~/.claude), so the fix is to symlink the live root's skills/commands/memory at the tracked originals — not to copy config into an untracked tree, which would silently drop it from version control.settings.json can't be symlinked (Claude Code rewrites it) → merge the missing keys.Orphan plans in ~/.claude/plans/*.md older than --threshold-days (default 1).
screenshots/.docs/plans/ (content-sniffing for project signals), or delete if trivially-small / shipped-duplicate.docs/plans/ under a dated slug; the file left in ~/.claude/plans/ is the orphaned original. Before routing, check the target project's docs/plans/ for an existing canonical (same H1 / topic, possibly a different slug or date). If one exists, delete the orphan — routing it creates a near-duplicate. Only genuinely-unmigrated plans should be routed.Duplicate memories — same-filename feedback_*.md across ≥3 projects.
~/.claude/memory/<name>.md (create global index if absent), delete per-project copies. Show content diff if copies aren't identical.Duplicate commands — *.md in ~/.claude/commands/ that also appear in */.claude/commands/.
.worktrees/ paths.Config drift — per-project settings.json hook lines that are now covered globally.
Missing global hooks — sanity check ~/.claude/settings.json matches the expected baseline.
Uncommitted/untracked .claude/ changes — modified or untracked artifacts (skills, commands, memory, hooks, settings.json, CLAUDE.md) in either the homedir repo (covers global ~/.claude/) or any project repo (covers ~/<project>/.claude/). Skips ephemeral subdirs (sessions, cache, daemon, telemetry, backups, etc.) and .bak/~/.tmp/.swp files. Catches in-flight skill development, untracked auto-memory files, and config edits that never got committed.
Missing global memory cascade (scope-aware) — Claude's auto-memory loader is cwd-siloed: only ~/.claude/projects/{slug}/memory/ loads, so the global memories at ~/.claude/memory/ never reach project sessions. But not every global memory belongs in every project — most are situational (a bangkok_cost_estimates memory is noise in a C++ engine; wayland_keybindings is noise in a web project). So the cascade is scoped, not blanket:
applies-to: [tag, …] in its frontmatter (universal / web / legacy-cpp / desktop / bkk / …). Absent → treated as universal (back-compat).code.tags: [...] in projects.json (namespaced under code — the same key any project-scoped consumer of the registry uses, parallel to e.g. invest for the investor-portal's own project data). A memory cascades into a project iff it's universal or its applies-to intersects the project's code.tags. Untagged project → universal memories only (safe default).apply-cascade.py helper, which symlinks only qualifying memories, prunes out-of-scope ones, merges the global MEMORY.md sections into the project's MEMORY.md between auto-managed markers, and updates .gitignore. Collisions are surfaced but never overwritten..claude/memory/, not in the global dir.Installed skill ≠ git source — a skill under ~/.claude/skills/ that differs from its git-tracked plugin source under ~/biohack-claude/plugins/*/skills/. The live copy was edited in place, or the published plugin is a stale snapshot — the two rot apart.
Broken shared-library references — a python-tui-lib/scripts/ or /hooks/ .sh referenced from a settings.json hook command (global + per-project) or a cmds: entry in ~/Taskfile.yml / ~/*/Taskfile.yml, that no longer exists on disk. Catches drift after a shared script is renamed/removed without updating its callers — e.g. md-to-pdf.sh → md-to-html.sh leaving task md dead with exit 127. Scoped to python-tui-lib/{scripts,hooks}/ paths (resolving {{.ROOT_DIR}} / relative / ~ / $VAR forms) so it stays quiet on project-local scripts and remote /opt/… references.
python-tui-lib listing to suggest the rename (e.g. md-to-pdf.sh → md-to-html.sh) — or delete the dead caller.Per-project memory not stored in its own repo (storage-location drift) — the correct layout: project-specific memory lives in the project's own repo at ~/<proj>/.claude/memory/ (real files, gitignored except !.claude/memory/); generic memory lives in ~/.claude/memory/ (the homedir master, scan #7), symlinked in; and ~/.claude/projects/<slug>/memory (the cwd-siloed dir Claude actually loads) is a symlink to the project's repo dir. Drift = that loader dir is a real directory — the project's memory then sits in the gitignored homedir tree, un-version-controlled in the project repo. The table's last column also flags a project repo whose .gitignore doesn't yet un-ignore .claude/memory/.
cp -a preserves real files and generic cascade symlinks; their relative ../../../../.claude/memory targets still resolve — both locations are 4 levels below ~), wires .gitignore, and replaces the loader dir with a symlink. Then commit in the project repo and register the project in projects.json if missing. Reference migration: llvm-mos-65816 (docs/plans/2026-06-20-memory-organization-two-tier.md). Pairs with scans #2 (promote duplicated generics to the master) and #7 (cascade generics back in).Reports land at ~/.claude/housekeeping/reports/YYYY-MM-DD-HHMM[-before|-after|-diff].md.
Structure (in order):
# Housekeeping report — YYYY-MM-DD HH:MM
## Summary
<sentence: N recommendations across K categories>
## Recommendations
### 1. <category> — <one-line title>
<details>
### 2. ...
[etc.]
## Executable command list
<prelude>
# Recommendation #1
<backup + pre-check + action + post-check + rollback hint>
# Recommendation #2
...
<end summary>
## State visualization
<Unicode-box table — one row per project, columns for artifact types>
## Mermaid graphs
<dependency map, recent migrations (if any), recommendation category pie>
For --diff mode, the structure differs (see "Diff mode" below).
--diff before=X after=Y)Generates a comparison report:
# Housekeeping diff — <before-timestamp> → <after-timestamp>
## Summary
- Resolved: N recommendations
- New: M recommendations (regressions or new drift)
- Unchanged: K recommendations (deferred / dormant)
- Net change: -<N-M>
## Resolved recommendations
<list — these got fixed>
## New recommendations
<list — investigate before declaring success>
## Unchanged recommendations
<list — skipped/dormant>
## State table diff
<side-by-side — what changed per project>
<details>
<summary>Full before report</summary>
<embedded report #1>
</details>
<details>
<summary>Full after report</summary>
<embedded report #2>
</details>
Every recommendation's command block follows this pattern:
cp -a originals into /tmp/housekeeping-backup-<timestamp>/recommendation-N/.sha256sum / diff to confirm the file is in the expected pre-state.mv, rm, etc.).Hash-pinning: the command block embeds sha256s of source files in pre-checks, so a deferred apply (hours later, state shifted) fails fast rather than overwriting unexpected state.
The skill reads the local ~/.claude/projects.json cache for the list of projects to scan; it is a read-only consumer and never writes the registry back. The definitive shared-object contract is ~/docs/projects-json.md. Each entry has name, path, status (active/dormant/not-cloned), optional notes, and a code sub-object (code.tags — memory-cascade scope tags; code.repoURL — the project's GitHub URL, when known). Unknown fields and namespaces are ignored. Entries with path: null (idea-stage projects with no local checkout, or projects not yet cloned) are skipped entirely — nothing to scan. Dormants skipped by default; --include-dormant includes them. Other consumers of the registry namespace their own project-specific data the same way code does here — e.g. the investor portal (invest) uses an invest key — never a shared generic field.
This skill was specified in ~/docs/plans/2026-05-19-globalize-hooks-housekeeping-skill.md (Part B). Refer there for design rationale.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub wbniv/biohack-claude --plugin claude-housekeeping