Logo Clean Disk

Clean Disk

Cộng đồng
peterpme
clean-disk

Use when a machine is low on disk space, when worktrees, Rust targets, build folders, Xcode DerivedData or caches should go ("clean up disk", "close out their worktrees"), for the scheduled Disk cleanup run, or to set daily cleanup up on a machine. Runs `disk-clean`. Not for app bundle size, CI runner disk or personal files.

Tổng quan

Nhà phát hànhpeterpme
Kho mãskills
Tên kỹ năngclean-disk
Sao
28
Bản fork
0
Tệp đi kèm
1
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI là Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • 1 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • Mã nguồn mở

    Được peterpme công bố trên GitHub. Hãy đọc nội dung nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Clean Disk trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL thư mục kỹ năng bên dưới và xác nhận.
    https://github.com/peterpme/skills/tree/main/clean-disk
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/peterpme/skills.git /tmp/skills
mkdir -p .claude/skills
cp -r /tmp/skills/clean-disk .claude/skills/clean-disk
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Clean Disk trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự tải Clean Disk ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên Clean Disk không bị giới hạn ở mô hình mà kỹ năng này được viết cho. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên kỹ năng chưa dùng không tốn chi phí.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

Clean disk

Goal: no machine runs out of disk because of agent leftovers, and Peter never has to ask. One run is disk-clean --apply, then a short report.

disk-clean (scripts/disk-clean in this skill, linked onto PATH as disk-clean by npm run sync) holds every deletion rule. Run disk-clean --help for them. Do not delete things by hand that the script would not delete. In particular:

  • Never remove a main checkout, delete a branch, or touch ~/Downloads, ~/Documents, Photos or the Finder trash (~/.Trash).
  • Never rm -rf a worktree. The script uses git worktree remove, saves uncommitted changes first, and keeps the branch.
  • Do not run mo clean (Mole). It stops at its developer-tools step (after Corepack) and never finishes. disk-clean runs mo purge --yes, which finishes in about a minute.
  • ~/Library/Developer/CoreDevice/DeviceFS is a mounted view of a connected iPhone, not local data. Ignore its size.
  • Put gtimeout 120 on any du you run yourself.

Run

A scheduled run uses disk-clean --apply --skip-if-free-over 100G. A machine with more than 100 GB free has nothing to gain, so the daily check ends in one line (disk-clean SKIPPED: ..., exit 0) without scanning or removing anything. A manual run, or any run Peter asks for, leaves the flag off. If the scheduled run prints SKIPPED, report that line and stop.

  1. Run disk-clean --apply. It prints each removal with its reason and size, then the free space before and after. When Peter asks interactively, apply right away too: everything it removes can be regenerated or is backed up.

  2. If anything is FAILED, read the reason. Fix it only if the fix is clearly safe, such as a stale index.lock with no git process running. Otherwise report it.

  3. If free space is still under 100 GB or 15% of the disk, measure the next biggest items with gtimeout 120 du -sh on these, and report the top ones with the exact command that would free each:

    ItemCommand
    node_modules in a main checkout not touched for 30+ daysrm -rf <repo>/node_modules (reinstall later)
    ~/Library/pnpmpnpm store prune already ran; the rest is in use
    ~/Library/Developer/CoreSimulator/Devicesxcrun simctl delete <udid> for simulators no longer needed
    ~/.android/avddelete AVDs no longer needed in Android Studio's Device Manager
    Dockerdocker system prune
    ~/.TrashEmpty Trash in Finder
    ~/.rustup/toolchainsrustup toolchain uninstall <old nightly>

    Do not run these yourself. They are Peter's call.

Worktree rules

The script only touches worktrees under agent paths: ~/.t3/worktrees, <repo>/.claude/worktrees, ~/.codex/worktrees, .codex-worktrees and ~/.cursor/worktrees. Sibling clones such as ~/Projects/x/repo-feature are left alone.

A tree is removed once it has been idle long enough for its kind. Idle time counts from the newest of: a file edit in the tree, a commit, checkout or reset (the last reflog entry), and activity in its T3 thread.

KindRemoved afterMeaning
Merged1 idle dayThe branch's PR is merged or closed, the T3 thread is deleted or archived, or (with no tracked edits) every commit is already in origin's default branch or a production, release/*, stable or <app>-production-<version> branch. Squash and rebase merges count.
Clean3 idle days (--days)No uncommitted or untracked files. Removing it loses nothing because the branch stays, so an open PR or open T3 thread doesn't keep it.
Dirty14 idle daysShown as watch from day 3. Changes are backed up before removal.
  • Never removed: locked trees, and trees a process is running in.
  • Backups: before a tree with uncommitted changes is removed, the changes are saved to ~/.local/state/disk-clean/backups/<date>-<repo>-<tree>/ and kept 60 days. A detached commit that no branch holds is saved on a rescued/<tree>-<sha> branch.

Cache rules

ItemRule
Project build foldersmo purge --yes: Mole's purge of build, dist, Pods, .venv and similar in projects with no file changed in 7 days
Xcode DerivedDataRemoved when its project folder is gone (such as a removed worktree) or it has been idle 7 days
trash-cli trashItems deleted 3+ days ago
Simulator runtimesRemoved when unused for 14 days and a newer runtime of the same family exists (a device-specific runtime such as iOS-27-2-iPhone19-4 is its own family)
Simulatorsxcrun simctl delete unavailable
pnpmpnpm store prune
uvuv cache prune, waiting at most 60 s for uv's lock. A long-running uvx MCP server holds that lock; then archives older than 14 days are removed directly.
Size capsEmptied when over the cap and not in use: uv 10 GB, Gradle 10 GB (skipped while a Gradle daemon runs), Yarn global cache 5 GB, npm 5 GB

To restore one, follow README.txt in its backup folder: git worktree add <dir> <branch>, then git -C <dir> apply --index changes.patch and tar -xzf untracked.tar.gz -C <dir>. To keep a tree out of cleanup, git worktree lock <path>.

If repos live outside ~/Projects, ~/skills and ~/dotfiles, pass each extra directory with --root <dir>, or set DISK_CLEAN_ROOTS (colon-separated).

Report

Lead with the answer:

**Disk cleanup, <machine>, <date>:** freed <N> GB, <free> GB free (<pct>% of disk).

| Removed | Count | Size |
|---|---|---|
| Worktrees (dead or idle) | | |
| Rust target folders | | |
| Build folders (Mole), DerivedData, runtimes, trash, caches | | |

Backed up before removal: <tree → backup folder, or none>
Watch: <trees with tracked edits that will be removed at 14 days, with idle days, or none>
Needs your call: <FAILED items, or the biggest remaining items with commands when free space is low>

Write the Needs your call: line only when something there needs Peter; otherwise leave it out. When nothing was removed and free space is fine, report one line. Where the machine has a cleanup for scheduled-run threads, a run thread is deleted a few minutes after it finishes unless its report has a Needs your call: line. history.log keeps the record.

Set up on a machine

Every machine with T3 Code gets its own daily run, because the cleanup is local.

  1. Confirm disk-clean --help works. If it doesn't, run git -C ~/skills pull --ff-only && npm --prefix ~/skills run sync. If it still doesn't, this skill isn't merged to main yet: stop, because every scheduled run would fail.

  2. Run disk-clean (a dry run) and check that the removals make sense for this machine. Add --root dirs if repos live elsewhere.

  3. Call schedule_task with:

    • projectId: the "No project" (scratch) project from t3_project_list;

    • bindToCurrentThread: false;

    • title: "Disk cleanup";

    • schedule: {type: "fixed_time", timeOfDay: "07:00"};

    • this prompt, with any --root arguments added:

      [t3-sentinel-run] Run the clean-disk skill: one scheduled disk-clean --apply --skip-if-free-over 100G run on this machine, then the report (one line if it prints SKIPPED). If disk-clean is not on PATH, reply in one line starting with "Needs your call:" that the skill isn't installed, and stop.

  4. If ~/.t3/sentinel/config.json exists, add the returned scheduledTaskId to its cleanup_task_ids list, so finished run threads are deleted. The [t3-sentinel-run] tag keeps the watchdog from treating the run as agent work.

  5. Report the next run time.

Tệp đi kèm

Mô hình đọc các tệp này khi cần trong lúc kỹ năng được tải. Các tệp được cung cấp ở dạng có thể đọc và không bao giờ được thực thi.

Câu hỏi thường gặp

Kỹ năng AI Clean Disk làm được gì?

Use when a machine is low on disk space, when worktrees, Rust targets, build folders, Xcode DerivedData or caches should go ("clean up disk", "close out their worktrees"), for the scheduled Disk cleanup run, or to set daily cleanup up on a machine. Runs `disk-clean`. Not for app bundle size, CI runner disk or personal files.

Vì sao nên dùng Clean Disk trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Clean Disk là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Clean Disk trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/peterpme/skills/tree/main/clean-disk. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm và cài đặt thành một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Clean Disk?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Bạn có thể dùng Clean Disk với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Clean Disk với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Clean Disk có miễn phí không?

Kỹ năng này được peterpme phát hành trên GitHub. Hãy xem điều khoản giấy phép trong kho mã. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp cho mô hình các công cụ mới để gọi — mã được chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và tiêu chí của đầu ra tốt. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇