cleanup
Cleans up old auto-captured files with configurable retention policy and archive support.
- License 许可
- MIT
- 所属仓库
- goffity/dev-km
- 最近更新
- 2026-11-10
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- cleanup
- description
- Cleans up old auto-captured files with configurable retention policy and archive support.
- argument-hint
- [days]
- user-invocable
- true
02 资源文件 12
- 参考文档references/commands.md15.1 KB
- 参考文档rules/artifact.md1.8 KB
- 参考文档rules/auth.md3.1 KB
- 参考文档rules/context.md2.4 KB
- 参考文档rules/cred.md2.9 KB
- 参考文档rules/job.md7.5 KB
- 参考文档rules/node.md3.0 KB
- 参考文档rules/other.md3.6 KB
- 参考文档rules/plugin.md3.1 KB
- 参考文档rules/queue.md1.5 KB
- 参考文档rules/run.md12.3 KB
- 参考文档rules/test.md1.0 KB
03 SKILL.md 正文
Cleanup - Retention Policy Manager
จัดการไฟล์เก่าด้วย retention policy พร้อม archive และ dry-run mode
Usage
/cleanup # Preview ด้วย default settings (30 days)
/cleanup [days] # Preview with custom retention period
/cleanup [days] --execute # Execute cleanup
/cleanup --archive # Archive before delete
Instructions
Step 1: Parse Arguments and Show Current State
export TZ='Asia/Bangkok'
echo "=== Auto-captured Files ==="
find docs/auto-captured -type f -name "*.md" 2>/dev/null | wc -l | xargs echo "Total files:"
echo ""
echo "=== Learnings Files ==="
find kb/05-ai-reviewed/learnings -type f -name "*.md" 2>/dev/null | wc -l | xargs echo "Total files:"
echo ""
echo "=== Archives ==="
ls -la docs/archives/ 2>/dev/null || echo "No archives yet"
Step 2: Determine Mode
| Argument | Mode |
|---|---|
| (none) | Dry-run, 30 days retention |
[days] |
Dry-run with custom retention |
[days] --execute |
Execute cleanup |
--archive |
Enable archiving |
--all |
Clean all targets |
Step 3: Run Cleanup Script
Dry-run mode (default):
cd "$PROJECT_ROOT"
./scripts/cleanup.sh --days [DAYS] --dry-run [--archive] [--all]
Execute mode:
cd "$PROJECT_ROOT"
./scripts/cleanup.sh --days [DAYS] [--archive] [--all]
Step 4: Show Results
Display the script output showing:
- Files that would be / were deleted
- Total space freed
- Archives created (if enabled)
Step 5: Confirm and Suggest Next Steps
## Cleanup Summary
| Metric | Value |
|--------|-------|
| Retention Period | [days] days |
| Files Processed | [count] |
| Space Freed | [size] |
| Archives Created | [count] |
### Next Steps
1. Review remaining files in `docs/auto-captured/`
2. Run `/distill` to extract patterns from learnings
3. Schedule periodic cleanup (cron job recommendation)
Examples
# Preview what would be deleted (30 days default)
/cleanup
# Preview with 7 days retention
/cleanup 7
# Execute cleanup with archiving
/cleanup 14 --archive --execute
# Clean all targets (auto-captured + draft learnings)
/cleanup --all --execute
Retention Policy
| Target | Policy |
|---|---|
docs/auto-captured/ |
Delete all files older than retention period |
kb/05-ai-reviewed/learnings/ |
Delete only status: draft files older than retention period |
kb/05-ai-reviewed/retrospective/ |
Never auto-delete (permanent records) |
kb/02-patterns/ |
Never auto-delete (distilled knowledge) |
Archive Format
When --archive is enabled:
- Archives stored in
docs/archives/ - Format:
archive_[target]_YYYYMMDD_HHMMSS.tar.gz - Contains all files that will be deleted
Scheduling Recommendation
Add to crontab for automatic cleanup:
# Weekly cleanup, keep 30 days, archive old files
0 0 * * 0 cd /path/to/project && ./scripts/cleanup.sh --days 30 --archive --all
Related Commands
| Command | Purpose |
|---|---|
/distill |
Extract patterns from learnings |
/mem |
Quick knowledge capture |
/td |
Session retrospective |
04 同仓库更多 Skills
wait-what
Stop. That last message did not land: re-pitch it.
tdd
Test-driven development loop (red-green-refactor) with commit-based phase state and Jira traceability. Use when the user wants to build a feature or fix a bug test-first, mentions "tdd", "red-green-refactor", or "test-first". Replaces the tdg plugin — combines its commit/phase discipline with seam-based test quality rules from kb Testing Standards.
td
Creates post-task retrospectives with Before/After context and session documentation.
summary
Generates weekly or monthly session summaries from retrospectives and activity logs.
share
Shares knowledge across projects by copying to shared-knowledge directory with cross-project metadata.
session-analyzer
Analyzes git changes and creates retrospective drafts with Before/After context.