cleanup
Safe artifact pruning. Audits stale project artifacts — merged git branches, old session/context files, temp dirs and caches, debug screenshots — then cleans only what the user confirms. Use this when the working tree feels cluttered, before archiving a project, or after a long session. Never deletes the main/current branch, env files, secrets, or databases. Side-effecting; run explicitly.
- License 许可
- MIT
- 最近更新
- 2026-06-23
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- cleanup
- description
- Safe artifact pruning. Audits stale project artifacts — merged git branches, old session/context files, temp dirs and caches, debug screenshots — then cleans only what the user confirms. Use this when the working tree feels cluttered, before archiving a project, or after a long session. Never deletes the main/current branch, env files, secrets, or databases. Side-effecting; run explicitly.
- argument-hint
- [category: git | sessions | temp | all]
- disable-model-invocation
- true
03 SKILL.md 正文
cleanup — Project Artifact Audit
Audit and optionally remove stale artifacts. Audit-first, confirm-then-execute.
Usage: /cleanup [category] where category is git | sessions | temp | all (default: all)
Phase 1: Safety Pre-Check
git status --porcelain
git branch --show-current
If uncommitted changes exist, warn:
You have uncommitted changes. Cleanup will NOT touch your current branch or working files, but consider committing or stashing first.
Record the current branch name now — it is on the never-delete list.
Phase 2: Audit (collect, do not delete)
git
# Local branches already merged into the default branch (exclude default + current)
git branch --merged "$(git symbolic-ref --short refs/remotes/origin/HEAD 2>/dev/null | sed 's@origin/@@' || echo main)" \
| grep -vE "main|master" | grep -v "^\*"
# Remote refs that no longer exist upstream
git remote prune origin --dry-run
# Age of each local branch (for the report)
git for-each-ref --sort=-committerdate refs/heads/ --format='%(refname:short) %(committerdate:relative)'
sessions
# Stale session/context handoff files, older than 14 days («adjust path to project convention»)
find .claude/tasks/ -name "context_session_*.md" -mtime +14 2>/dev/null
temp
# Build/test/tool caches and debug artifacts — sizes only
du -sh .playwright-mcp/ test-results/ playwright-report/ node_modules/.cache/ 2>/dev/null
# «PLACEHOLDER: add framework build cache dir, e.g. .next/ dist/ build/»
ls -la *.png *.log *.tmp 2>/dev/null
Phase 3: Report Table
| Category | Item | Age / Size | Action | Safe |
|---|---|---|---|---|
| git | [branch] | merged | delete | yes |
| git | [remote ref] | gone | prune | yes |
| sessions | [file] | N days | delete | yes |
| temp | .playwright-mcp/ | [size] | clear | yes |
| temp | *.png (debug) | [count] | delete | yes |
Mark anything ambiguous as Safe: manual and leave it for the user to decide.
Phase 4: Confirm
Options:
1. Clean all items marked Safe
2. Clean a specific category
3. Select individual items
4. Cancel
Wait for an explicit choice. Do nothing destructive before it.
Phase 5: Execute (only after confirmation)
# git
git remote prune origin
git branch --merged "$(git symbolic-ref --short refs/remotes/origin/HEAD 2>/dev/null | sed 's@origin/@@' || echo main)" \
| grep -vE "main|master" | grep -v "^\*" | xargs -r git branch -d
# temp
rm -rf .playwright-mcp/* 2>/dev/null
rm -f ./*.png 2>/dev/null
Use git branch -d (safe; refuses unmerged), never -D, unless the user explicitly names a branch to force-delete.
HARD RULES — never violate
- Never delete the default branch (main/master) or the current branch.
- Never delete
.env*,*.pem,*.key,credentials*, or any database/backup file. - Never delete without an audit and an explicit confirmation first.
- Never use
rm -rfon paths outside the project working directory. - Prefer
-dover-D; prefer dry-run flags during the audit phase.
04 同仓库更多 Skills
wrap-up
Session-end safe closeout. Updates STATUS, verifies you are on a feature branch (never main), security-greps the diff for secrets, makes a conventional commit (no AI-tool mentions), then asks for approval before pushing and opening a PR. Use this to properly close a development session. Side-effecting and gated on explicit user approval; run explicitly.
wake-up
Session-start context sync. Reads project STATUS, git state, and runs a quick health check, then emits a short (<15 line) announcement of where things stand and the single best next step. Use this at the beginning of a working session to re-establish context fast. Does NOT re-read CLAUDE.md (already in the system prompt). Read-only and fast.
station
End-of-session composition that chains retrospect → document → cleanup → wrap-up into one closeout pipeline. Use this to fully close a working session — capture learnings, sync docs, prune artifacts, then commit and open a PR — without forgetting a step. Side-effecting; honors each sub-skill's confirmation and approval gates. Run explicitly.
retrospect
Post-session learning capture. Mines the current conversation for reusable patterns, pitfalls, architecture decisions, performance and security insights, then appends them to the project knowledge registry. Use this at the end of a working session, after a bug is fixed, or after a non-obvious decision is made — so the next session starts smarter. Writes structured entries to .claude/knowledge/REGISTRY.md.
pre-ship
Mandatory pre-commit quality gates — type-check, lint, test, build — run in order and halting on the first failure. Use this BEFORE committing any change that touches application code, so failures are caught while context is still fresh instead of by CI. Surfaces the failing tool's verbatim error and refuses to proceed until gates pass.
document
Code-is-truth documentation sync. Detects drift between the codebase and project docs (STATUS.md, CLAUDE.md, README), then applies targeted edits so docs describe what the code actually is. Use this after shipping features, before a release, or when docs feel stale. Secret-scans every doc before writing. Makes small surgical edits, never wholesale rewrites.