Skip to content
Back to skills

Tmp Cleanup

BSecurity

Free memory by deleting stale artefacts from the temp dir (/tmp is often tmpfs, so it lives in RAM). Use when the user asks to free memory or clean up, when temp cleanup is requested, or when you notice memory pressure (low MemAvailable, swapping, OOM, large tmpfs usage).

  • 2 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added October 17, 2026
ai-agentsgobash

Works with

  • claude code

Security analysis

B85/100
  • highPerforms destructive filesystem operations

Pro scans all 2 files and shows the line behind each finding

Scanned October 17, 2026

npx -y skills add fabienjuif/agentic-skills --skill tmp-cleanup --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Tmp Cleanup?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Tmp Cleanup
[![Security: B — Skills Directory](https://www.skillsdirectory.com/api/skills/fabienjuif-tmp-cleanup/badge)](https://www.skillsdirectory.com/skills/fabienjuif-tmp-cleanup)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: tmp-cleanup
description: Free memory by deleting stale artefacts from the temp dir (/tmp is often tmpfs, so it lives in RAM). Use when the user asks to free memory or clean up, when temp cleanup is requested, or when you notice memory pressure (low MemAvailable, swapping, OOM, large tmpfs usage).
---

# tmp-cleanup

On many Linux systems `/tmp` is tmpfs, so everything in it consumes RAM. The bundled
script `tmp-cleanup.sh` (next to this file) deletes stale top-level entries. It is a
script, rather than inline `rm -rf`, so the deletion rules (age, ownership, protected
names) are fixed and reviewable instead of improvised per call.

Works on Linux and macOS (bash 3.2+). Same skill format for Claude Code
(`~/.claude/skills/`) and Codex (`~/.codex/skills/` or `~/.agents/skills/`).

## Steps

1. Dry run first and show the count and size to the user:
   `<skill dir>/tmp-cleanup.sh`
2. Delete: `<skill dir>/tmp-cleanup.sh --apply`
   - Default age threshold is 3h; use `--hours N` if the user asks for another.
   - `--dir PATH` targets another directory (default `/tmp` on Linux, `$TMPDIR` on macOS).
   - On an explicit "free memory" / "cleanup" request, go straight to `--apply`.
   - On self-noticed memory pressure, dry-run, then ask before `--apply`.
3. Report only the before/after `df` lines. If memory is still tight, look at
   `du -sh /tmp/* 2>/dev/null | sort -h | tail` and tell the user about recent big
   offenders; don't delete entries newer than the threshold unasked.

## Safety

- Only top-level entries owned by the current user are touched.
- Protected by default: X/Qt locks and sockets, tmux, zellij, ssh, systemd-private,
  `*.lock`, `com.apple.*`, and the agents' own session dirs (`claude-*`, `cc-daemon-*`,
  `codex-*`).
- Protect more with `TMP_CLEANUP_KEEP="pattern1 pattern2"` or by editing the `keep` array.
- If the target isn't tmpfs (always the case on macOS) the script says deleting won't
  free RAM; tell the user instead of insisting.
- If your environment blocks recursive deletes (e.g. a hook), that's intentional: get
  the user's explicit OK before running `--apply` through the script.

Files in this skill

  • SKILL.md2.1 KB
  • tmp-cleanup.sh2 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.