The Problem
Every coding session with your AI agent leaves things behind: plans, handoff notes, logs, temporary files, build data, and more.
These files are useful while you're working, but once the feature is finished, most are no longer needed. They take up disk space and clutter future sessions with outdated notes and context that your agent could easily get from the latest code.
Over time, all that leftover clutter adds up.
The Solution
Context Cleanup! One command after you finish your work, and your agent cleans up what's no longer needed.
It removes leftover files, trims agent instructions down to what future sessions actually need, and frees up disk space, all while protecting your code and unfinished work.
How to use it
Run the skill once your work is committed or delivered. It only runs when you ask it to.
In Claude Code:
/context-cleanup— Clean up the current project and its leftover session files./context-cleanup docs/— Limit cleanup to a specific folder or path./context-cleanup all— Check leftover disk files across all your projects, while keeping documentation cleanup limited to the current project.
In Codex, use $context-cleanup instead.
How it works
- Checks that your work is committed. If any Git-tracked files have uncommitted changes, the skill stops without deleting anything.
- Reviews what's left behind. A fresh subagent called the Sweeper reads your project as if it's starting a new session. It decides what to delete, rewrite, keep, or ask you about.
- Cleans up safely. Your main agent reviews those decisions, protects important files and active work, and asks your permission when needed.
- Shows you what changed. You get a report of what was cleaned up, what was kept, and how much disk space was freed.
Features
- Remove leftover session files. Clean up outdated plans, handoffs, drafts, logs, and temporary files that are no longer needed.
- Keep agent instructions relevant. Trim
AGENTS.md,CLAUDE.md, and other agent notes to the information future sessions actually need: how to build, run, test, and work with your project. Remove outdated decisions, research, and session history. - Keep documentation up to date. Preserve documentation written for your users while removing outdated history and fixing instructions that no longer match the code.
- Turn rules into automated checks. If a rule in your agent instructions can be enforced by an existing test or check, the skill can add that check with your approval and remove the redundant written rule.
- Free up disk space. Find leftover session folders, transcripts, unused worktrees, obsolete Xcode build data, and simulators created during development.
- Undo changes with Git. Rewrites to agent notes and deletions of tracked files are saved in one commit, so you can undo them with
git revert. The skill never pushes. - Works with Claude Code and Codex. Use the same skill in either agent.
FAQs
Does it delete files without asking?
Only files that Git can restore, or cleanup items that are no longer usable, such as merged branches, clean worktrees, and Xcode build data for projects that no longer exist.
For anything else, the skill shows you what it wants to remove, including file sizes, and asks for your permission first.
Will it touch my code or unfinished work?
No. The skill doesn't modify your product code, except to add an automated check you've approved.
It also protects secrets, active sessions, booted simulators, and files belonging to unfinished work. It skips session files that changed within the last 24 hours and never manually deletes transcripts.
What if I haven't committed my changes?
The skill stops immediately and tells you which tracked file has uncommitted changes. Nothing gets deleted.
Commit your work, then run the command again.
Can I tell it to keep certain files or folders?
Yes! It's a customizable skill. Ask your agent to add them to the skill's keep list, in references/sweeper.md, such as docs/decisions/.
You can also adjust what the skill cleans up to better fit your workflow.
