agentleFS
eliransueliransu/digital-brain/skills/wiki-prune/SKILL.md

wiki-prune

Skill1 starsChanged 7 months agoMITView on GitHub

Weekly janitor for the Obsidian wiki. Archives `wiki/daily/YYYY-MM-DD/` folders older than 7 days into `wiki/.archive/YYYY-WW/`, keeping the rolled-up summaries that `wiki-fold` produced. Dry-run by default; `--commit` moves the folders; `--hard` deletes archive entries older than 30 days. Suggested cadence: every Monday morning. Triggers on: "/digital-brain:wiki-prune", "/prune", "prune wiki", "clean old dailies", "weekly cleanup", "garbage collect wiki".

  • Deletes or force-pushes

The file

We split this skill into the rules it gives an agent

8 rules. About 0 are common, 2 are distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Fold before prune (recommended): If wiki-fold hasn't run in the last 7 days, warn before pruning so context isn't lost.

    line 22
  2. Very specific:

    Skip non-date folders: Only YYYY-MM-DD/ entries are candidates.

    line 24
  3. Very specific:

    Ensure wiki/.archive/<iso_week>/ exists (mkdir -p).

    line 61
  4. Very specific:

    Never delete anything in the original wiki/daily/ — only mv to archive.

    line 126
  5. Very specific:

    Never archive folders that aren't named in YYYY-MM-DD format (skip + warn).

    line 127
  6. Distinctive:

    Never archive folders inside the live retention window.

    line 128
  7. Very specific:

    If mv fails (permissions, target exists), abort the run and print the error — don't keep going.

    line 130
  8. Distinctive:

    Default to printing first, mutating second.

    line 131

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

wiki-prune: Weekly Daily-Folder Janitor

/digital-brain:sync writes a folder per day under wiki/daily/. Left alone, those pile up forever and /sup slows down. wiki-prune is the janitor: every Monday it archives folders older than 7 days into a per-ISO-week directory under wiki/.archive/, so the live wiki/daily/ directory only ever holds the current week.

Rules of engagement:

  • Dry run by default. Print what would happen. Move nothing until --commit.
  • Archive, don't delete. Move folders into wiki/.archive/YYYY-WW/, preserving structure. Originals stay recoverable via mv back.
  • Hard delete only on explicit opt-in. With --hard, delete archive entries older than 30 days from the archive root. Use sparingly.
  • Fold before prune (recommended). If wiki-fold hasn't run in the last 7 days, warn before pruning so context isn't lost.
  • Never touch the live week. Anything dated within the last retention days stays in place.
  • Skip non-date folders. Only YYYY-MM-DD/ entries are candidates. _config.json and anything else is left alone.

Inputs / flags

FlagEffect
(none)Dry run. List candidates, suggest next run. No filesystem changes.
--commitMove matching folders into wiki/.archive/YYYY-WW/.
--hardAfter archiving, delete archive entries older than 30 days. Requires Y/N in chat.
--retention=NOverride the 7-day window. Rare — default is 7.
--skip-fold-checkDon't warn about stale wiki-fold.

Workflow

  1. Compute cutoff. today = date +%Y-%m-%d (local time). cutoff = today - retention (default 7 days). Anything strictly older than the cutoff is a candidate.
  2. Scan wiki/daily/. For each entry, check whether its name matches ^[0-9]{4}-[0-9]{2}-[0-9]{2}$. Skip everything else (e.g. _config.json). Compare the date against the cutoff.
  3. Fold-freshness check. Find the newest mtime under wiki/folds/. If older than 7 days (or the folds directory does not exist), print: ⚠️ wiki-fold last ran <N> days ago — run /digital-brain:wiki-fold first to preserve context, or pass --skip-fold-check. Continue, do NOT abort — the user may consciously want to prune without folding.
  4. Group candidates by ISO week. For each candidate folder, compute:
    • iso_week = date -j -f "%Y-%m-%d" "<folder-date>" "+%G-W%V" (macOS) — yields e.g. 2026-W19.
    • archive_dir = wiki/.archive/<iso_week>/<folder-date>/.
  5. Always print a report. Table with: folder name, file count, total size, archive target, ISO week. Plus the list of folders being kept (live week).
  6. If --commit:
    • Ensure wiki/.archive/<iso_week>/ exists (mkdir -p).
    • For each candidate, mv wiki/daily/<date> wiki/.archive/<iso_week>/<date>. Idempotent: if the target already exists, abort with an error — never overwrite.
    • Print the new paths.
  7. If --hard:
    • List archive subdirectories under wiki/.archive/ whose mtime is > 30 days old.
    • Print them and ask in chat: Delete <N> archive entries permanently? (y/N).
    • On y, rm -rf them. On anything else, abort.
  8. Print next-run suggestion. Compute the next Monday strictly after today. Print: Suggested next run: Mon <YYYY-MM-DD> 09:00 — automate via /digital-brain:schedule "every Monday 09:00" /digital-brain:wiki-prune --commit.

Output shapes

Dry run

## wiki-prune — <today HH:MM>  (dry run)

Retention: 7 days · cutoff: <YYYY-MM-DD>

Would archive (<N> folders → wiki/.archive/):
  wiki/daily/2026-05-04/   3 files   18 KB   →  wiki/.archive/2026-W18/2026-05-04/
  wiki/daily/2026-05-03/   3 files   12 KB   →  wiki/.archive/2026-W18/2026-05-03/
  wiki/daily/2026-05-02/   3 files   14 KB   →  wiki/.archive/2026-W18/2026-05-02/

Live week kept (within retention):
  wiki/daily/2026-05-12/  wiki/daily/2026-05-11/  wiki/daily/2026-05-09/

⚠️ wiki-fold last ran 12 days ago — consider running /digital-brain:wiki-fold first.

No changes made. Re-run with --commit to archive.

Suggested next run: Mon 2026-05-18 09:00.

Commit

## wiki-prune — <today HH:MM>  (committed)

Archived 3 folders into wiki/.archive/2026-W18/.
Live wiki/daily/ now holds 3 days (2026-05-09 → 2026-05-12).

Suggested next run: Mon 2026-05-18 09:00.

Hard delete (with confirmation prompt)

## wiki-prune — <today HH:MM>  (hard delete preview)

Archive entries older than 30 days:
  wiki/.archive/2026-W14/    (mtime 2026-04-08, 32 days old)
  wiki/.archive/2026-W13/    (mtime 2026-04-01, 39 days old)

Delete 2 archive entries permanently? (y/N)

Safety rules

  • Never delete anything in the original wiki/daily/ — only mv to archive.
  • Never archive folders that aren't named in YYYY-MM-DD format (skip + warn).
  • Never archive folders inside the live retention window.
  • --hard requires explicit chat confirmation. No silent deletes.
  • If mv fails (permissions, target exists), abort the run and print the error — don't keep going.
  • Default to printing first, mutating second. The user reviews the dry run, then commits.

Cadence

Suggested: every Monday at 09:00. Monday morning is the natural week boundary — the previous week's signal has either been captured by wiki-fold or is no longer load-bearing, and starting fresh keeps /sup snappy because there's only one current week of daily files to scan.

To automate:

/digital-brain:schedule "every Monday 09:00" /digital-brain:wiki-prune --commit

Or wire a SessionStart hook to run the dry-run version every Monday so you see candidates the first time you open Claude that week and decide whether to commit. The dry run is the safe default to schedule — it never mutates.


Relationship to other skills

  • /digital-brain:sync writes the daily folders that this skill prunes.
  • /digital-brain:wiki-fold preserves long-term signal before prune drops the raw daily files.
  • /digital-brain:wiki-lint may reference items from old daily folders — run lint before prune to flag anything load-bearing.

Typical Monday routine:

  1. /digital-brain:wiki-fold — roll up last week.
  2. /digital-brain:wiki-lint — audit for orphans/dead refs.
  3. /digital-brain:wiki-prune (dry run) → review → --commit.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.