Agent skill
timeline-cleanup
Delete low-value messages from the web timeline by keyword patterns. Protects messages with user-uploaded images. Optionally vacuums the DB afterward.
Install this agent skill to your Project
npx add-skill https://github.com/rcarmo/piclaw/tree/main/skel/.pi/skills/timeline-cleanup
SKILL.md
Timeline Cleanup
Delete messages from the web chat timeline that match keyword patterns, then optionally vacuum the database to reclaim space.
How It Works
- Query the messages DB (from
PICLAW_STORE/messages.db) for rows matching the given patterns - Resolve the full session scope — for
web:*chats, this includes all session trees and branches - Exclude messages that have media attachments — unless
--include-mediais passed - Delete matching messages via the
/post/{id}?cascade=trueHTTP API - Optionally vacuum the database (requires a brief piclaw restart)
Usage
Run cleanup by importing the helper or using the CLI.
Defaults include a throttled delete loop (1100ms delay) with retries on HTTP 429 responses to avoid server-side rate limits.
Import
import { cleanupTimeline } from "/workspace/.pi/skills/timeline-cleanup/cleanup.ts";
const result = await cleanupTimeline({
patterns: ["reload", "compaction"],
// dryRun: true, // Preview only
// includeMedia: false, // Skip messages with attachments (default)
// vacuum: false, // Vacuum DB after (causes restart)
// beforeRowid: 99999, // Only match messages before this rowid
// chatJid: "web:default", // Target chat
// maxLength: 300, // Only match messages shorter than this
// senderFilter: "web-agent", // Only match this sender
// throttleMs: 1100, // Delay between deletes (avoid rate limits)
// retryOn429: true, // Retry if rate limited
// maxRetries: 2, // Max retries for rate limits
});
CLI
bun run /workspace/.pi/skills/timeline-cleanup/cleanup.ts \
--patterns "reload,compaction,compacting" \
--before 5000 \
--dry-run
Built-in Pattern Groups
The cleanupAll() function runs all standard pattern groups in sequence. Use it for a full housekeeping pass:
import { cleanupAll } from "/workspace/.pi/skills/timeline-cleanup/cleanup.ts";
const results = await cleanupAll({ beforeRowid: 5000, dryRun: true });
Pattern groups
| Group | Patterns | Sender | Max length |
|---|---|---|---|
| Reloads | reload, supervisorctl restart, restart-piclaw, local-install, bun pm pack |
any | 500 |
| Compaction | compaction, compacting, auto-compact |
any | 500 |
| Greetings (user) | exact: hey, hello, hi, Hello?, hey there, etc. |
user | 30 |
| Agent intros | Hey! ..., Hello! ..., good to see you, ready to help |
agent | 300 |
| Slash commands | lines starting with / |
any | 50 |
| Slash responses | Unknown command:, Current model:, Switched...model, Switching...model, Model switched, Cycle model, Cycle thinking, Thinking level, Thinking set, Supports thinking |
agent | 300 |
| One-word acks | exact: yes, ok, go, done, well?, so?, etc. |
any | 30 |
| Transition filler | let me check, let me look, now let me, etc. |
agent | 200 |
| Version bumps | bumped version, tagged v0., bump patch |
any | 300 |
| Build/lint/test | make lint, make test, bun run build, pass...0 fail |
any | 300 |
| Git operations | git add, git commit -m, git push, git status |
any | 200 |
| Package installs | bun install, bun add, bun update, packages installed |
any | 300 |
Vacuum
Vacuuming requires exclusive DB access. The cleanup function can:
- Copy the DB to
/tmp - Vacuum the copy
- Stop piclaw, swap the file, start piclaw
This causes a brief (~5s) interruption. Only use when significant space can be reclaimed.
Environment
PICLAW_STORE— message DB parent directory (default:/workspace/.piclaw/store)PICLAW_WEB_PORT— web server port (default: 8080)PICLAW_INTERNAL_SECRET/PICLAW_WEB_INTERNAL_SECRET— internal API auth
Related
close-of-dayinvokes the same cleanup strategy as an end-of-day sweep.- New end-of-day flow uses the unified
messagestool actions (search,delete) for cleanup semantics where available.
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
autoresearch-create
Set up and run an autonomous experiment loop for any optimization target. Gathers what to optimize, then starts the loop immediately. Use when asked to "run autoresearch", "optimize X in a loop", "set up autoresearch for X", or "start experiments".
portainer-container-compare-chart
Compare two containers using native portainer tool data collection and render SVG/CSV outputs.
proxmox-guest-compare-chart
Compare two Proxmox guests using native proxmox tool data collection and render SVG/CSV outputs.
schedule
Schedule a task to run later or on a recurring basis. Prefer the schedule_task tool; fallback to IPC only if needed.
reload
Reinstall piclaw from workspace source and force-restart the running process. Use after making code changes to piclaw.
send-message
Send a message to the chat immediately without waiting for the current task to finish. Useful for acknowledging requests or sending progress updates while working.
Didn't find tool you were looking for?