Back to skills
SkillHub ClubShip Full StackFull Stack

mac-cleanup

Cleans up system caches, trash, and old downloads on macOS.

Packaged view

This page reorganizes the original catalog entry around fit, installability, and workflow context first. The original raw source lives below.

Stars
3,125
Hot score
99
Updated
March 20, 2026
Overall rating
C4.0
Composite score
4.0
Best-practice grade
B81.2

Install command

npx @skill-hub/cli install openclaw-skills-mac-clean-skill

Repository

openclaw/skills

Skill path: skills/aadipapp/mac-clean-skill

Cleans up system caches, trash, and old downloads on macOS.

Open repository

Best for

Primary workflow: Ship Full Stack.

Technical facets: Full Stack.

Target audience: everyone.

License: MIT.

Original source

Catalog source: SkillHub Club.

Repository owner: openclaw.

This is still a mirrored public skill entry. Review the repository before installing into production workflows.

What it helps with

  • Install mac-cleanup into Claude Code, Codex CLI, Gemini CLI, or OpenCode workflows
  • Review https://github.com/openclaw/skills before adding mac-cleanup to shared team environments
  • Use mac-cleanup for development workflows

Works across

Claude CodeCodex CLIGemini CLIOpenCode

Favorites: 0.

Sub-skills: 0.

Aggregator: No.

Original source / Raw SKILL.md

---
name: mac-cleanup
description: Cleans up system caches, trash, and old downloads on macOS.
author: tempguest
version: 0.1.0
license: MIT
---

# Mac Cleanup Skill

This skill helps you reclaim disk space on your MacBook Pro by cleaning up:
- **System Caches**: Clears the user cache directory (`~/Library/Caches`).
- **Trash**: Empties the Trash (`~/.Trash`).
- **Old Downloads**: Deletes files in `~/Downloads` that are older than 30 days.

## Commands

- `cleanup`: standardized command to run the cleanup script.


---

## Skill Companion Files

> Additional files collected from the skill directory layout.

### README.md

```markdown
# Mac Cleanup Skill for OpenClaw

This skill allows your OpenClaw agent to perform system maintenance on your MacBook Pro.

## Features

- **Empty Trash**: Permanently deletes files in `~/.Trash`.
- **Clear Caches**: Removes files in `~/Library/Caches` older than 7 days.
- **Clean Downloads**: Deletes files in `~/Downloads` older than 30 days.

## Installation

Since this is a local skill, you need to point OpenClaw to this directory or publish it to ClawHub.

### Local Install (Development)
If you have the OpenClaw CLI installed:
```bash
openclaw skill install ./mac-cleanup-skill
```

## Usage

Once installed, you can ask OpenClaw:
> "Clean up my mac"
> "Run the cleanup skill"

By default, the script runs in **DRY RUN** mode to prevent accidental data loss. To actually delete files, you need to modify the command execution to pass the `--force` flag or run the script manually.

## Publishing to ClawHub

To share this skill with the community (or yourself on other devices):

1.  **Login to ClawHub**:
    ```bash
    clawhub login
    ```

2.  **Publish the Skill**:
    Navigate to the skill directory and run:
    ```bash
    clawhub publish
    ```

## Security Note

This skill deletes files. Review `scripts/cleanup.py` before running with `--force`.

```

### _meta.json

```json
{
  "owner": "aadipapp",
  "slug": "mac-clean-skill",
  "displayName": "mac-clean-skill",
  "latest": {
    "version": "1.0.0",
    "publishedAt": 1770785297696,
    "commit": "https://github.com/openclaw/skills/commit/fa9ff7754655360560dd39494b902b8bef7d585c"
  },
  "history": []
}

```

### scripts/cleanup.py

```python
#!/usr/bin/env python3
import os
import shutil
import time
import argparse
from datetime import datetime, timedelta

def get_file_age_days(filepath):
    """Returns the age of the file in days."""
    return (time.time() - os.path.getmtime(filepath)) / (24 * 3600)

def cleanup_directory(directory, max_age_days=0, dry_run=True):
    """
    Cleans up files in a directory.
    If max_age_days > 0, only deletes files older than that.
    """
    if not os.path.exists(directory):
        print(f"Directory not found: {directory}")
        return

    print(f"Scanning {directory}...")
    count = 0
    size_freed = 0

    try:
        for item in os.listdir(directory):
            item_path = os.path.join(directory, item)
            
            try:
                if os.path.isfile(item_path):
                    age = get_file_age_days(item_path)
                    if max_age_days > 0 and age < max_age_days:
                        continue
                    
                    size_freed += os.path.getsize(item_path)
                    if dry_run:
                        print(f"[DRY RUN] Would delete file: {item_path} (Age: {age:.1f} days)")
                    else:
                        os.remove(item_path)
                        print(f"Deleted file: {item_path}")
                    count += 1
                
                elif os.path.isdir(item_path):
                    # For directories like caches, we might want to delete the whole folder if it's safe
                    # For Downloads, we usually just delete files within it, stepping into subdirs is risky without clear rules
                    # Here we implemented a simple safe approach: only delete files in the top level of the target dir
                    # except for Trash where we nuke everything
                    if directory.endswith(".Trash"):
                         # In trash, delete directories too
                        if dry_run:
                            print(f"[DRY RUN] Would delete directory: {item_path}")
                        else:
                            shutil.rmtree(item_path)
                            print(f"Deleted directory: {item_path}")
                        count += 1
                    
            except Exception as e:
                print(f"Error processing {item_path}: {e}")

    except PermissionError:
        print(f"Permission denied accessing {directory}")

    print(f"Found {count} items to clean in {directory}. Est. space: {size_freed / (1024*1024):.2f} MB")


def main():
    parser = argparse.ArgumentParser(description="Mac Cleanup Skill")
    parser.add_argument("--dry-run", action="store_true", help="Print actions without deleting files", default=True)
    parser.add_argument("--force", action="store_false", dest="dry_run", help="Actually delete files")
    args = parser.parse_args()

    print(f"Starting Cleanup (Dry Run: {args.dry_run})")

    # 1. Clean Trash
    trash_dir = os.path.expanduser("~/.Trash")
    cleanup_directory(trash_dir, dry_run=args.dry_run)

    # 2. Clean Caches
    caches_dir = os.path.expanduser("~/Library/Caches")
    # For caches, we are careful. Deleting currently used caches can crash apps.
    # A safer approach for a skill is to warn or only delete specific known heavy caches.
    # For this generic skill, we will list them but maybe NOT delete indiscriminately in a background task without user prompt.
    # However, the user asked for a cleanup skill. We will stick to the plan but be verbose.
    # Let's target specific subfolders to be safer if this was production, but for now we scan the root.
    # Actually, deleting ~/Library/Caches files is generally safe on macOS as they are regenerated, but doing it while apps are open is the risk.
    print(f"\n[WARNING] excessive cache cleaning can slow down system temporarily.")
    cleanup_directory(caches_dir, max_age_days=7, dry_run=args.dry_run) # Only delete old caches > 7 days

    # 3. Clean Downloads
    downloads_dir = os.path.expanduser("~/Downloads")
    cleanup_directory(downloads_dir, max_age_days=30, dry_run=args.dry_run)

    print("\nCleanup Complete.")

if __name__ == "__main__":
    main()

```

mac-cleanup | SkillHub