prune-discussions
npx machina-cli add skill brennacodes/brenna-plugs/prune-discussions --openclaw<load-config>
<action>Resolve the user's home directory.</action>
<command language="bash" output="home" tool="Bash">echo $HOME</command>
<constraint>Never pass `~` to the Read tool.</constraint>
<read path="<home>/.things/config.json" output="config" />
<if condition="config-missing">Tell the user: "Run `/things:setup-things` first." Then stop.<exit /></if>
<read path="<home>/.things/for-the-record/preferences.json" output="preferences" />
<if condition="preferences-missing">Tell the user: "Run `/setup-ftr` first." Then stop.<exit /></if>
</load-config>
</step>
<step id="determine-mode" number="2">
<description>Determine Pruning Mode</description>
<action>Parse `$ARGUMENTS` for:</action>
- **--older-than <days>**: Delete discussions older than N days
- **--interactive**: Show all discussions for manual selection
<if condition="--interactive">
<action>Use interactive mode (step 4).</action>
</if>
<if condition="--older-than provided">
<action>Use the explicit days value.</action>
</if>
<if condition="no flags">
<action>Use `preferences.discussion_retention_days`.</action>
<if condition="discussion_retention_days is null or missing">
<action>Tell the user: "No retention policy configured and no `--older-than` flag provided. Either run `/setup-ftr reconfigure` to set `discussion_retention_days`, or use `--older-than <days>` or `--interactive`." Then stop.</action>
<exit />
</if>
</if>
</step>
<step id="find-candidates" number="3">
<description>Find Deletion Candidates (age-based)</description>
<if condition="age-based mode">
<action>List all `.md` files in `<home>/.things/for-the-record/discussions/`. Parse the date from each filename (YYYY-MM-DD prefix) or from frontmatter. Calculate age in days from today.</action>
<action>Filter to files older than the threshold.</action>
<if condition="no candidates">
<action>Tell the user: "No discussions older than <N> days found." Then stop.</action>
<exit />
</if>
<output>
Discussions older than <N> days:
1. <filename> (<date>, <age> days old)
2. <filename> (<date>, <age> days old)
...
Total: <count> files to delete
</output>
<ask-user-question>
<question>Delete these <count> discussions?</question>
<option label="Yes">Delete all listed discussions</option>
<option label="No">Cancel -- keep everything</option>
</ask-user-question>
</if>
</step>
<step id="interactive-selection" number="4">
<description>Interactive Selection</description>
<if condition="interactive mode">
<action>List all `.md` files in `<home>/.things/for-the-record/discussions/` with date and title from frontmatter.</action>
<if condition="no discussions">
<action>Tell the user: "No discussions found." Then stop.</action>
<exit />
</if>
<output>
Discussions:
1. <filename> -- "<title>" (<date>)
2. <filename> -- "<title>" (<date>)
...
</output>
<ask-user-question>
<question>Which discussions would you like to delete? Enter numbers (e.g., "1,3"), a range (e.g., "1-5"), or "all".</question>
</ask-user-question>
<ask-user-question>
<question>Confirm: delete <count> selected discussions?</question>
<option label="Yes">Delete selected discussions</option>
<option label="No">Cancel</option>
</ask-user-question>
</if>
</step>
<step id="delete-files" number="5">
<description>Delete Files</description>
<action>Delete each confirmed file from `<home>/.things/for-the-record/discussions/`.</action>
<command language="bash" tool="Bash">rm "<home>/.things/for-the-record/discussions/<filename>"</command>
</step>
<step id="rebuild" number="6">
<description>Trigger Rebuild</description>
<action>Read `<home>/.things/registry.json` to find the rebuild command for `for-the-record/discussions`. Execute it.</action>
<constraint>If the rebuild command is not found, fall back to: `python3 <cached-path>/scripts/rebuild-index.py <home>/.things`</constraint>
</step>
<step id="git-workflow" number="7">
<description>Handle Git Workflow</description>
<git-workflow>
<action>Pull latest before committing.</action>
<command language="bash" tool="Bash">git -C <home>/.things pull --rebase 2>/dev/null || true</command>
<action>Read git workflow from `config.json` (`git.workflow`).</action>
<if condition="workflow-auto">Automatically `git add`, `git commit -m "prune: <count> discussions"`, and `git push`.</if>
<if condition="workflow-ask">
<ask-user-question>
<question>Commit and push the pruned discussions?</question>
<option>Yes -- commit and push</option>
<option>Commit only</option>
<option>No -- I'll handle git myself</option>
</ask-user-question>
</if>
<if condition="workflow-manual">Tell the user the pruning is complete.</if>
</git-workflow>
</step>
<step id="confirm" number="8">
<description>Confirm</description>
<completion-message>
Pruned <count> discussions.
Remaining: <remaining-count> discussions in `for-the-record/discussions/`
</completion-message>
</step>
</steps>Source
git clone https://github.com/brennacodes/brenna-plugs/blob/main/plugins/for-the-record/skills/prune-discussions/SKILL.mdView on GitHub Overview
The prune-discussions skill deletes old Markdown discussion files from ~/.things/for-the-record/discussions/. It supports three modes: respect a configured retention (discussion_retention_days), apply an explicit --older-than <days> value, or run in interactive mode to pick files. Deletions are confirmed before proceeding to protect data.
How This Skill Works
It loads the user’s home directory, reads config.json and preferences.json, and validates presence of a retention policy. It then chooses a pruning mode based on --older-than, --interactive, or the default discussion_retention_days. Finally, it scans the discussions directory for .md files, computes ages from filenames or frontmatter, and prompts for confirmation before deleting.
When to Use It
- Use the default retention policy from discussion_retention_days to prune automatically.
- Specify --older-than <days> to delete discussions older than a fixed age.
- Use --interactive to review and selectively delete files.
- No retention policy configured and no flags; you’re prompted to configure or provide --older-than.
- Maintain storage hygiene when disk space is limited or old discussions are no longer relevant.
Quick Start
- Step 1: Ensure config and preferences exist; if missing, run the setup commands referenced by prompts.
- Step 2: Choose a mode: use --older-than <days>, or --interactive, or rely on the configured discussion_retention_days.
- Step 3: Review the candidate files and confirm deletion to complete the prune.
Best Practices
- Always confirm before deleting to prevent accidental data loss.
- Prefer --interactive for careful selection of files.
- Provide an explicit --older-than <days> to avoid unintended deletions.
- Verify that you have a valid retention policy configured before pruning.
- Check the candidate list after aging calculations and before confirming deletion.
Example Use Cases
- Retention configured for 90 days; prune older discussions automatically.
- Run prune-discussions --older-than 60 to remove discussions older than 60 days.
- Run in --interactive mode to review and delete a handful of discussions manually.
- Preferences missing; you’re prompted to run /setup-ftr or configure a value.
- No eligible files older than the threshold; user is informed and no deletion occurs.