What it does
Queries the posts, options, and comments tables for counts of post revisions, expired transients, spam and trashed comments, and orphaned postmeta rows, then separates findings into a clearly safe-to-delete bucket and a needs-review bucket. Each bucket comes with an estimated row count and approximate space that would be recovered.
Install
This skill isn't packaged in an installable registry. It's a plain SKILL.md file you can copy directly. Copy it from the SKILL.md tab and save it at the path for your assistant:
Use it in your AI assistant
Claude Code
.claude/skills/database-cleanup-advisor/ (or ~/.claude/skills/database-cleanup-advisor/ for all projects)
GitHub Copilot (VS Code)
.github/skills/database-cleanup-advisor/
OpenAI Codex
.codex/skills/database-cleanup-advisor/
Cursor
.cursor/skills/database-cleanup-advisor/ (or ~/.cursor/skills/database-cleanup-advisor/ globally)
Compatibility
Any WordPress site; requires direct database access or WP-CLI (wp db query) to run the diagnostic queries.
The complete SKILL.md for this skill:
---
name: database-cleanup-advisor
description: Use when a user says the database feels bloated, wants to clean up revisions or transients, or asks what's safe to delete before optimizing the database.
---
# Database Cleanup Advisor
## When to use
The database has grown large or slow and the user wants to know what can be safely cleaned up (revisions, expired transients, spam comments) without risking data they actually need.
## Procedure
1. Query post revision counts per post and flag posts with an unusually high number (for example, more than 20 revisions).
2. Query the options table for transients whose expiration timestamp has already passed, and separate those from transients with no expiration set (which need manual judgment, not auto-deletion).
3. Query comment counts by status (spam, trash, unapproved) and note how long items have sat in each status.
4. Check for orphaned postmeta or commentmeta rows that reference post/comment IDs no longer present in their parent tables.
5. Report each category as a separate line item with a row count and an estimated space recovered, ranked by size.
6. Provide the exact cleanup query for each category so the user (or their host) runs it deliberately, rather than running any deletion automatically.
## Guardrails
- Never execute a DELETE, DROP, or TRUNCATE query directly, only report findings and provide the query text for the user to run themselves after a backup.
- Always recommend a fresh backup before any cleanup step that touches the options or postmeta tables, since transients and meta can be depended on in non-obvious ways.