Community生产力与协作github.com

smart-file-organizer

Safely scan, deduplicate, preview, organize, and undo local folder organization with zero regular-file deletion, plus strictly-scoped, consent-gated cleanup of temp files/folders, truly empty folders, and corresponding stale Windows HKCU registry entries. Use when the user asks to clean up, sort, organize, classify, deduplicate, remove temp/empty junk, clean matching stale registry entries, or undo organization/cleanup on Downloads, Desktop, or any local directory.

smart-file-organizer 是什么?

smart-file-organizer is a Claude Code agent skill that safely scan, deduplicate, preview, organize, and undo local folder organization with zero regular-file deletion, plus strictly-scoped, consent-gated cleanup of temp files/folders, truly empty folders, and corresponding stale Windows HKCU registry entries. Use when the user asks to clean up, sort, organize, classify, deduplicate, remove temp/empty junk, clean matching stale registry entries, or undo organization/cleanup on Downloads, Desktop, or any local directory.

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/adrian147258/kkskill/tree/HEAD/smart-file-organizer

Installed? Explore more 生产力与协作 skills: steipete/gemini, steipete/gh-issues, steipete/skill-creator · View all 6 →

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

Smart File Organizer

Organize cluttered local folders (such as Downloads or Desktop) safely using organize.py and cleanup.py. Built with Python 3.8+ standard library only—no third-party packages required.

Golden Safety Rules

  1. NEVER skip the dry-run preview. Always run plan (or clean-scan) and show the user a clear summary before changing anything.
  2. NEVER pass --yes before explicit user approval. Only run apply --yes or clean-apply --yes after the user confirms the exact previewed items.
  3. NEVER delete any regular user file.
    • plan / apply never deletes any file (duplicates are only quarantined into _Duplicates / _重复文件 when requested).
    • clean-scan / clean-apply is strictly locked to a hardcoded whitelist: ONLY .tmp / .temp files, temp / tmp folders (plus opt-in %TEMP% via --include-user-temp), truly empty folders (os.rmdir), and corresponding stale Windows HKCU registry entries. It will NEVER touch .txt, .log, .bak, documents, or existing files.
  4. Always provide the exact rollback command (undo or clean-undo) after running apply or clean-apply.

Workflow A: Organize Files

Step 1: Confirm Target & Preferences

Confirm the target directory path and infer or ask for:

  • Mode: by-type (default), by-date, by-type-date, or by-extension
  • Folder language: --lang zh (when user speaks Chinese or prefers Chinese folder names) or --lang en
  • Scope: top-level only (default) or --recursive
  • Duplicates: whether to isolate exact duplicates (--quarantine-duplicates)

For full rules, extension mappings, and custom JSON rule schema, see rules-and-safety.md and custom-rules.example.json.

Step 2: Scan the Folder

python scripts/organize.py scan "<target_dir>" --lang zh

Step 3: Generate & Present a Dry-Run Plan

python scripts/organize.py plan "<target_dir>" --mode by-type --lang zh --quarantine-duplicates --plan-out "<temp_dir>/organize-plan.json"

Present the destination folder summary and sample moves. Wait for explicit user confirmation.

Step 4: Apply & Verify

python scripts/organize.py apply "<target_dir>" --plan "<temp_dir>/organize-plan.json" --yes

Give the user the exact undo command printed by apply.


Workflow B: Optional Cleanup (Temp + Empty Folders + Corresponding Registry)

This workflow can be offered after organizing a folder or run standalone when requested.

Step 1: Ask Whether the User Wants Cleanup & Confirm Scope

Ask the user:

  1. Whether they want to scan for temp files/folders (.tmp/.temp, temp/tmp), truly empty folders, and corresponding stale Windows HKCU registry entries inside <target_dir>.
  2. Whether to also scan their user OS %TEMP% folder (--include-user-temp, opt-in only; never touches C:\Windows\Temp).

Step 2: Run clean-scan (Dry-Run Preview)

python scripts/organize.py clean-scan "<target_dir>" --plan-out "<temp_dir>/cleanup-plan.json"

Add --recursive to scan nested temp items, or --include-user-temp if explicitly requested. Use --temp, --empty-dirs, or --registry to limit to specific categories.

Present the full categorized preview to the user:

  • [1] Temp files & temp folders (names, counts, total size)
  • [2] Truly empty folders
  • [3] Matching stale HKCU registry entries (key label, value name, stale path)

Step 3: Ask for Explicit User Consent

STOP and ask the user for approval. They may approve all three categories, approve only some (e.g. temp + empty folders without registry, or vice versa), or cancel.

Step 4: Execute Approved Cleanup (clean-apply --yes)

If the user approves the full saved plan:

python scripts/organize.py clean-apply "<target_dir>" --plan "<temp_dir>/cleanup-plan.json" --yes

If the user deselected any category, re-run with only the approved flags (e.g. --temp --empty-dirs) and --yes.

Step 5: Report Results & Rollback Command

Report:

  • Counts of removed temp files/dirs, empty folders, and registry entries (plus any skipped busy/locked items)
  • The .reg backup file location inside <target_dir>/.organizer-logs/
  • The exact clean-undo command to restore removed empty folders and backed-up registry entries:
python scripts/organize.py clean-undo "<target_dir>" --run-id <run_id>

Additional Commands

  • Find exact duplicates only: python scripts/organize.py duplicates "<target_dir>" --recursive
  • Check organize & cleanup history: python scripts/organize.py history "<target_dir>"
  • Undo organization: python scripts/organize.py undo "<target_dir>"
  • Undo cleanup (empty folders + registry): python scripts/organize.py clean-undo "<target_dir>"

相关技能