# Wiki Prune

> >

- **Type:** Skill
- **Install:** `agentstack add skill-eliransu-digital-brain-wiki-prune`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [eliransu](https://agentstack.voostack.com/s/eliransu)
- **Installs:** 0
- **Category:** [AI & ML](https://agentstack.voostack.com/c/ai-and-ml)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [eliransu](https://github.com/eliransu)
- **Source:** https://github.com/eliransu/digital-brain/tree/main/skills/wiki-prune
- **Website:** https://github.com/eliransu/digital-brain

## Install

```sh
agentstack add skill-eliransu-digital-brain-wiki-prune
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# 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

| Flag                | Effect                                                                            |
| ------------------- | --------------------------------------------------------------------------------- |
| _(none)_            | Dry run. List candidates, suggest next run. No filesystem changes.                |
| `--commit`          | Move matching folders into `wiki/.archive/YYYY-WW/`.                              |
| `--hard`            | After archiving, delete archive entries older than 30 days. Requires Y/N in chat. |
| `--retention=N`     | Override the 7-day window. Rare — default is 7.                                   |
| `--skip-fold-check` | Don'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  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" "" "+%G-W%V"` (macOS) — yields e.g. `2026-W19`.
   - `archive_dir = wiki/.archive///`.

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//` exists (`mkdir -p`).
   - For each candidate, `mv wiki/daily/ wiki/.archive//`. 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  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  09:00 — automate via /digital-brain:schedule "every Monday 09:00" /digital-brain:wiki-prune --commit`.

---

## Output shapes

### Dry run

```
## wiki-prune —   (dry run)

Retention: 7 days · cutoff: 

Would archive ( 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 —   (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 —   (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`.

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [eliransu](https://github.com/eliransu)
- **Source:** [eliransu/digital-brain](https://github.com/eliransu/digital-brain)
- **License:** MIT
- **Homepage:** https://github.com/eliransu/digital-brain

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-eliransu-digital-brain-wiki-prune
- Seller: https://agentstack.voostack.com/s/eliransu
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
