disk-cleaner by gccszs/disk-cleaner
npx skills add https://github.com/gccszs/disk-cleaner --skill disk-cleaner[OK]、[X]、[!]、[*]、[i]、[DIR]、[FILE]、[PKG]、[x]广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
✅ (成功) - 完成的操作,成功的扫描❌ (错误) - 失败的操作,严重错误⚠️ (警告) - 警告,需要注意的问题🔍 (扫描) - 搜索/扫描操作📊 (统计) - 分析结果,统计数据📁 (目录) - 目录相关信息📦 (包) - 包/模块信息🎉 (成功) - 成功完成时的庆祝消息🚨 (严重) - 严重警告💡 (提示) - 建议,推荐📋 (列表) - 检查清单,摘要🔧 (工具) - 工具,实用程序🌐 (全局) - 跨平台,通用功能🛡️ (安全) - 安全相关信息⚡ (性能) - 性能改进📝 (文档) - 文档🎓 (学习) - 教育内容📞 (支持) - 帮助,支持信息📈 (增长) - 改进,收益🎯 (目标) - 目标,目的🚀 (启动) - 快速开始,快速操作🛠️ (工具) - 工具相关功能示例:
Script output (ASCII): [OK] Scan completed: 50,000 files in 30 seconds
Your report to human: ✅ Scan completed successfully! Found 50,000 files in 30 seconds
[ ] 步骤 1:检查 Python 可用性
[ ] 步骤 2:查找技能包(自动检测20多个位置)
[ ] 步骤 3:运行诊断:python scripts/check_skill.py
[ ] 步骤 4:运行快速采样:--sample(强制要求 - 首先执行此步骤)
[ ] 步骤 5:根据估算选择扫描模式
[ ] 步骤 6:告知用户预期时间
[ ] 步骤 7:使用适当的限制执行扫描
[ ] 步骤 8:显示结果并提供后续步骤
[ ] 步骤 1-3:同上
[ ] 步骤 4:始终先使用 --dry-run(强制要求)
[ ] 步骤 5:显示预览结果
[ ] 步骤 6:在 --force 之前询问用户确认
[ ] 步骤 7:如果确认则执行实际清理
import subprocess
result = subprocess.run(['python', '--version'], capture_output=True, text=True)
# 如果成功,您可以使用此技能
问题:大磁盘(500GB+)的完整磁盘扫描可能需要数小时。用户会失去耐心。
解决方案:使用渐进式扫描 - 在几秒钟内获得结果,而不是数小时!
何时使用:即时估算目录大小和扫描时间
python scripts/analyze_disk.py --sample
# 或
python scripts/analyze_progressive.py --sample
输出:
{
"sample_file_count": 7591,
"sample_size_gb": 17.62,
"files_per_second": 7501.0,
"estimated_time_seconds": 2.0
}
智能体决策逻辑:
# 对于未知磁盘大小,始终先运行快速采样
result = subprocess.run(
['python', 'scripts/analyze_disk.py', '--sample', '--json'],
capture_output=True,
text=True,
timeout=10,
cwd=skill_path
)
import json
sample = json.loads(result.stdout)
estimated_time = sample.get('estimated_time_seconds', 0)
# 根据估算选择下一步操作
if estimated_time < 30:
mode = 'full' # 完整扫描没问题
elif estimated_time < 120:
mode = 'time_limited' # 使用时间限制
else:
mode = 'progressive' # 必须使用渐进式模式
何时使用:30秒内获取大磁盘的部分结果
python scripts/analyze_progressive.py --max-seconds 30
功能:
智能体用法:
def analyze_large_disk_safely(path, max_seconds=30):
"""安全地分析大磁盘,带时间限制"""
result = subprocess.run(
['python', 'scripts/analyze_progressive.py',
'--max-seconds', str(max_seconds),
'--path', str(path)],
capture_output=True,
text=True,
timeout=max_seconds + 10,
cwd=skill_path
)
return result.stdout
何时使用:使用文件/时间限制快速获取结果
# 按文件计数限制(快速)
python scripts/analyze_disk.py --file-limit 10000
# 按时间限制(安全)
python scripts/analyze_disk.py --time-limit 30
# 双重限制(非常快)
python scripts/analyze_disk.py --file-limit 10000 --time-limit 30
USER REQUEST: "Analyze my disk"
↓
┌─────────────────────────────────────────┐
│ STEP 1: Quick Sample (MANDATORY) │
│ python scripts/analyze_disk.py --sample │
└─────────────────────────────────────────┘
↓
Get estimated_time from sample
↓
├─ estimated_time < 30 seconds
│ ↓
│ ✅ Use FULL SCAN
│ python scripts/analyze_disk.py
│
├─ estimated_time 30-120 seconds
│ ↓
│ ⚠️ Use TIME LIMIT
│ python scripts/analyze_disk.py --time-limit 60
│ Tell user: "This will take ~X minutes"
│
└─ estimated_time > 120 seconds
↓
🚨 MUST USE PROGRESSIVE MODE
python scripts/analyze_progressive.py --max-seconds 30
Tell user: "Large disk detected - using progressive scan (30 seconds)"
✅ 磁盘分析将耗时约 2 秒
开始完整扫描...
⚠️ 磁盘分析将耗时约 3 分钟
使用时间限制扫描以获取更快结果...
🚨 检测到大磁盘!完整扫描将耗时约 5 分钟
使用渐进式扫描模式在 30 秒内获取结果...
(这可以快速为您提供部分结果 - 您以后随时可以进行完整扫描)
import subprocess
import json
from pathlib import Path
def smart_disk_analysis(disk_path, python_cmd='python'):
"""
SMART disk analysis - automatically chooses best method
THIS IS THE RECOMMENDED WAY for all agents
"""
# Find skill package
skill_path = find_skill_package() # Use your find function
if not skill_path:
return False, "Skill package not found"
# STEP 1: Quick sample (MANDATORY - do this first!)
print("🔍 Quick sampling disk...")
sample_result = subprocess.run(
[python_cmd, 'scripts/analyze_disk.py', '--sample',
'--path', str(disk_path), '--json'],
capture_output=True,
text=True,
timeout=10,
cwd=str(skill_path)
)
if sample_result.returncode != 0:
return False, "Sample failed"
try:
sample = json.loads(sample_result.stdout)
estimated_time = sample.get('estimated_time_seconds', 0)
except:
estimated_time = 0
print(f" Estimated scan time: {estimated_time:.0f} seconds")
# STEP 2: Choose scanning method based on estimate
if estimated_time < 30:
# Small disk - full scan
print("✅ Using full scan (small disk)")
result = subprocess.run(
[python_cmd, 'scripts/analyze_disk.py',
'--path', str(disk_path)],
capture_output=True,
text=True,
timeout=60,
cwd=str(skill_path)
)
elif estimated_time < 120:
# Medium disk - time limited
minutes = estimated_time / 60
print(f"⚠️ Using time-limited scan (~{minutes:.1f} minutes)")
result = subprocess.run(
[python_cmd, 'scripts/analyze_disk.py',
'--path', str(disk_path),
'--time-limit', '60'], # 1 minute max
capture_output=True,
text=True,
timeout=70,
cwd=str(skill_path)
)
else:
# Large disk - PROGRESSIVE MODE (MANDATORY)
print(f"🚨 Large disk detected! Using progressive scan (30 seconds)")
result = subprocess.run(
[python_cmd, 'scripts/analyze_progressive.py',
'--path', str(disk_path),
'--max-seconds', '30',
'--json'],
capture_output=True,
text=True,
timeout=40,
cwd=str(skill_path)
)
if result.returncode != 0:
return False, result.stderr
print(result.stdout)
return True, result.stdout
# USAGE - Just call this function:
success, output = smart_disk_analysis("C:\\")
success, output = smart_disk_analysis("/home/user")
success, output = smart_disk_analysis("D:\\Projects")
❌ 不要:不检查磁盘大小就始终运行完整扫描 ✅ 要:始终先运行 --sample 进行估算
❌ 不要:让用户等待大磁盘扫描数小时 ✅ 要:对大磁盘使用 --max-seconds 30
❌ 不要:忽略采样的估算时间 ✅ 要:使用估算选择适当的扫描模式
❌ 不要:在 1TB 磁盘上无限制地运行 analyze_disk.py ✅ 要:使用带 --max-seconds 的 analyze_progressive.py
| 情况 | 命令 | 时间 | 结果 |
|---|---|---|---|
| 未知大小 | --sample | 1s | 估算 + 推荐 |
| < 30 秒 | analyze_disk.py | <30s | 完整结果 |
| 30-120 秒 | --time-limit 60 | 60s | 大部分结果 |
120 秒 |
analyze_progressive.py --max-seconds 30| 30s | 部分结果
非常大的磁盘 |analyze_progressive.py --max-seconds 60| 60s | 更多结果
快速采样(1 秒)
渐进式扫描(N 秒)
智能停止
--sample此工作流程适用于任何平台、任何 AI IDE、任何位置。
import subprocess
import sys
def verify_python():
"""Check if Python 3.7+ is available - PLATFORM AGNOSTIC"""
try:
# Try 'python' first (Windows, some Unix)
result = subprocess.run(
['python', '--version'],
capture_output=True,
text=True,
timeout=5
)
if result.returncode == 0:
return True, result.stderr.strip() or result.stdout.strip()
except FileNotFoundError:
pass
try:
# Try 'python3' (macOS, Linux)
result = subprocess.run(
['python3', '--version'],
capture_output=True,
text=True,
timeout=5
)
if result.returncode == 0:
return True, result.stderr.strip() or result.stdout.strip()
except FileNotFoundError:
pass
return False, "Python not found"
# EXECUTE
python_available, version_info = verify_python()
if not python_available:
print("❌ Python 3.7+ required but not found")
print("Install from: https://www.python.org/downloads/")
print("See: NO_PYTHON_GUIDE.md for platform-specific instructions")
sys.exit(1)
print(f"✅ Python available: {version_info}")
from pathlib import Path
import os
def find_skill_package():
"""
Find disk-cleaner skill package - LOCATION INDEPENDENT
Searches in order of priority:
1. Current working directory
2. Project-level: ./skills/, ./.skills/, ./agent-skills/
3. User-level: ~/.skills/, ~/.agent-skills/, ~/skill-packages/
4. Common AI IDE locations
5. Parent directories
"""
# Get python command (python or python3)
python_cmd = 'python' if os.name == 'nt' else 'python3'
# Search locations - PLATFORM & IDE AGNOSTIC
search_locations = []
# 1. Current directory
cwd = Path.cwd()
search_locations.extend([
cwd / 'disk-cleaner',
cwd / 'skills' / 'disk-cleaner',
cwd / '.skills' / 'disk-cleaner',
cwd / 'agent-skills' / 'disk-cleaner',
cwd / '.agent-skills' / 'disk-cleaner',
])
# 2. Parent directories (project root)
for parent in [cwd, *cwd.parents]:
search_locations.extend([
parent / 'skills' / 'disk-cleaner',
parent / '.skills' / 'disk-cleaner',
parent / 'agent-skills' / 'disk-cleaner',
])
# Limit search depth
if len(parent.parts) <= 3:
break
# 3. User home directory
home = Path.home()
search_locations.extend([
home / 'skills' / 'disk-cleaner',
home / '.skills' / 'disk-cleaner',
home / 'agent-skills' / 'disk-cleaner',
home / '.agent-skills' / 'disk-cleaner',
home / 'skill-packages' / 'disk-cleaner',
])
# 4. Platform-specific user directories
if os.name == 'nt': # Windows
appdata = os.environ.get('APPDATA', '')
if appdata:
search_locations.append(Path(appdata) / 'skills' / 'disk-cleaner')
localappdata = os.environ.get('LOCALAPPDATA', '')
if localappdata:
search_locations.append(Path(localappdata) / 'skills' / 'disk-cleaner')
else: # Unix-like (macOS, Linux)
search_locations.extend([
home / '.local' / 'share' / 'skills' / 'disk-cleaner',
home / '.config' / 'skills' / 'disk-cleaner',
Path('/usr/local/share/skills/disk-cleaner'),
])
# 5. AI IDE specific directories (IDE-AGNOSTIC)
# Note: These are examples - actual locations vary
ide_specific = [
# Cursor
home / '.cursor' / 'skills' / 'disk-cleaner',
home / '.cursor' / 'user' / 'skills' / 'disk-cleaner',
# Windsurf
home / '.windsurf' / 'skills' / 'disk-cleaner',
# Continue
home / '.continue' / 'skills' / 'disk-cleaner',
# Generic
home / '.ai-ide' / 'skills' / 'disk-cleaner',
]
search_locations.extend(ide_specific)
# 6. sys.path entries (Python module style)
for path_entry in sys.path:
if path_entry and path_entry not in ['', '.']:
test_path = Path(path_entry) / 'disk-cleaner'
search_locations.append(test_path)
# Remove duplicates and non-existent
search_locations = list(set(search_locations))
# Search for valid skill package
for location in search_locations:
if not location:
continue
try:
# Check for key indicator files
if (location / 'scripts' / 'analyze_disk.py').exists():
return location, f"Found at: {location}"
if (location / 'SKILL.md').exists():
return location, f"Found at: {location}"
except PermissionError:
continue
except Exception:
continue
# Not found - provide helpful message
print("❌ Skill package not found")
print("\nSearched locations:")
for loc in search_locations[:10]: # Show first 10
print(f" - {loc}")
print("\nSolutions:")
print("1. Extract skill package to one of the locations above")
print("2. Or set environment variable: DISK_CLEANER_SKILL_PATH")
print("3. Or provide explicit path when calling functions")
return None, "Not found"
# EXECUTE
skill_path, message = find_skill_package()
if not skill_path:
print(message)
sys.exit(1)
print(f"✅ {message}")
def verify_skill_package(skill_path, python_cmd='python'):
"""Verify skill package integrity - LOCATION INDEPENDENT"""
check_script = skill_path / 'scripts' / 'check_skill.py'
if not check_script.exists():
print(f"❌ Check script not found: {check_script}")
return False
try:
result = subprocess.run(
[python_cmd, str(check_script)],
capture_output=True,
text=True,
timeout=30,
cwd=str(skill_path)
)
# Show verification output
if result.stdout:
print(result.stdout)
if result.returncode == 0:
print("✅ Skill package verified successfully")
return True
else:
print("❌ Skill package verification failed")
if result.stderr:
print(result.stderr)
return False
except subprocess.TimeoutExpired:
print("❌ Verification timed out")
return False
except Exception as e:
print(f"❌ Verification error: {e}")
return False
# Determine python command
python_cmd = 'python' if os.name == 'nt' else 'python3'
# EXECUTE
if not verify_skill_package(skill_path, python_cmd):
sys.exit(1)
def execute_operation(skill_path, operation, python_cmd='python', **kwargs):
"""
Execute disk cleaner operation - PLATFORM & IDE AGNOSTIC
Args:
skill_path: Path to skill package
operation: 'analyze', 'clean', 'monitor'
python_cmd: 'python' or 'python3'
**kwargs: Operation-specific arguments
"""
operation_map = {
'analyze': 'analyze_disk.py',
'clean': 'clean_disk.py',
'monitor': 'monitor_disk.py',
}
if operation not in operation_map:
print(f"❌ Unknown operation: {operation}")
print(f"Valid operations: {list(operation_map.keys())}")
return False, None
script = skill_path / 'scripts' / operation_map[operation]
cmd = [python_cmd, str(script)]
# Add operation-specific arguments
if operation == 'analyze':
if kwargs.get('path'):
cmd.extend(['--path', str(kwargs['path'])])
if kwargs.get('top'):
cmd.extend(['--top', str(kwargs['top'])])
if kwargs.get('json'):
cmd.append('--json')
elif operation == 'clean':
# ALWAYS use dry-run for safety
if not kwargs.get('force'):
cmd.append('--dry-run')
else:
cmd.append('--force')
if kwargs.get('temp'):
cmd.append('--temp')
if kwargs.get('cache'):
cmd.append('--cache')
if kwargs.get('logs'):
cmd.append('--logs')
elif operation == 'monitor':
if kwargs.get('watch'):
cmd.append('--watch')
if kwargs.get('json'):
cmd.append('--json')
try:
print(f"🔧 Executing: {' '.join(cmd)}")
result = subprocess.run(
cmd,
capture_output=True,
text=True,
timeout=kwargs.get('timeout', 300),
cwd=str(skill_path)
)
# Show output
if result.stdout:
print(result.stdout)
if result.returncode != 0:
if result.stderr:
print(f"❌ Error: {result.stderr}")
return False, None
return True, result.stdout
except subprocess.TimeoutExpired:
print("⚠️ Operation timed out")
return False, None
except Exception as e:
print(f"❌ Execution error: {e}")
return False, None
# EXECUTE
success, output = execute_operation(
skill_path,
operation='analyze',
python_cmd=python_cmd,
path='C:\\Users' if os.name == 'nt' else '/home',
json=True
)
if success:
print("✅ Operation completed successfully")
在任何磁盘分析之前:
--sample 估算扫描时间快速参考:
# STEP 1: ALWAYS DO THIS FIRST (1 second)
python scripts/analyze_disk.py --sample
# STEP 2: Choose based on estimate
# < 30s: python scripts/analyze_disk.py
# 30-120s: python scripts/analyze_disk.py --time-limit 60
# > 120s: python scripts/analyze_progressive.py --max-seconds 30
| 用户说 | 操作 | 命令模板 |
|---|---|---|
| "analyze disk" | analyze | python scripts/analyze_disk.py |
| "check disk space" | analyze | python scripts/analyze_disk.py --top 50 |
| "quick scan" | analyze | python scripts/analyze_disk.py --sample |
| "large disk analysis" | analyze | python scripts/analyze_progressive.py --max-seconds 30 |
| "clean temp files" | clean | python scripts/clean_disk.py --temp --dry-run |
| "preview cleanup" | clean | python scripts/clean_disk.py --dry-run |
| "monitor disk" | monitor | python scripts/monitor_disk.py |
| "disk usage" | monitor | python scripts/monitor_disk.py --json |
问题:大磁盘(1TB+)的完整磁盘扫描可能需要数小时
解决方案:使用带时间/文件限制的渐进式扫描
# Quick sample (1 second) - Get instant estimate
subprocess.run(['python', 'scripts/analyze_disk.py', '--sample'])
# Progressive scan (30 seconds) - Get partial results quickly
subprocess.run(['python', 'scripts/analyze_progressive.py',
'--max-seconds', '30'])
# Limited file count (fast)
subprocess.run(['python', 'scripts/analyze_disk.py',
'--file-limit', '10000'])
# Full scan with time limit
subprocess.run(['python', 'scripts/analyze_disk.py',
'--time-limit', '120'])
大磁盘推荐工作流程:
--sample 获取估算(1 秒)--max-seconds 或 --file-limitanalyze_progressive.py 获取实时反馈| 平台 | Python 命令 | 检查命令 |
|---|---|---|
| Windows | python | python --version |
| macOS | python3 | python3 --version |
| Linux | python3 | python3 --version |
# Works on ALL platforms
import os
import subprocess
python_cmd = 'python' if os.name == 'nt' else 'python3'
result = subprocess.run([python_cmd, '--version'], capture_output=True, text=True)
此技能包适用于所有支持以下功能的 AI IDE:
your-project/
├── skills/
│ └── disk-cleaner/ ← Extract here
├── src/
└── README.md
~/.skills/disk-cleaner/ ← Unix-like
~/agent-skills/disk-cleaner/ ← Alternative
C:\Users\You\skills\disk-cleaner\ ← Windows
/usr/local/share/skills/disk-cleaner/ ← Linux (system-wide)
C:\ProgramData\skills\disk-cleaner\ ← Windows (system-wide)
# Cursor automatically searches for skills in:
# - .cursor/skills/
# - project/skills/
# - ~/.skills/
# No special configuration needed
# Windsurf supports skills at:
# - .windsurf/skills/
# - project/skills/
# Skill works via subprocess, no special setup
# Continue configuration (if needed):
# {
# "skills": ["./skills/disk-cleaner"]
# }
# But auto-detection works in most cases
# Use as a tool via subprocess:
# !python skills/disk-cleaner/scripts/analyze_disk.py
# The skill includes intelligent auto-detection
# Just extract and use - no configuration needed
"""
Universal Disk Cleaner Skill Usage
Works with ALL AI IDEs, on ALL platforms, at ANY location
"""
import subprocess
import sys
import os
from pathlib import Path
def use_disk_cleaner(operation='analyze', **kwargs):
"""
Use disk cleaner skill - UNIVERSAL FUNCTION
Works on:
- All platforms (Windows, macOS, Linux)
- All AI IDEs (Cursor, Windsurf, Continue, etc.)
- All installation levels (global, project, user)
Args:
operation: 'analyze', 'clean', 'monitor'
**kwargs: Operation-specific arguments
Returns:
(success: bool, output: str)
"""
# 1. Determine Python command
python_cmd = 'python' if os.name == 'nt' else 'python3'
# 2. Verify Python
try:
result = subprocess.run(
[python_cmd, '--version'],
capture_output=True,
text=True,
timeout=5
)
if result.returncode != 0:
print("❌ Python not found")
return False, "Python 3.7+ required"
except Exception as e:
print(f"❌ Python check
[OK], [X], [!], [*], [i], [DIR], [FILE], [PKG], [x]✅ (Success) - Completed operations, successful scans❌ (Error) - Failed operations, critical errors⚠️ (Warning) - Warnings, issues that need attention🔍 (Scanning) - Search/scan operations📊 (Statistics) - Analysis results, statistics📁 (Directory) - Directory-related information📦 (Package) - Package/module information🎉 (Success) - Celebratory messages for successful completion🚨 (Critical) - Critical warningsExample:
Script output (ASCII): [OK] Scan completed: 50,000 files in 30 seconds
Your report to human: ✅ Scan completed successfully! Found 50,000 files in 30 seconds
[ ] STEP 1: Check Python availability
[ ] STEP 2: Find skill package (auto-detects 20+ locations)
[ ] STEP 3: Run diagnostics: python scripts/check_skill.py
[ ] STEP 4: Run quick sample: --sample (MANDATORY - do this FIRST)
[ ] STEP 5: Choose scan mode based on estimate
[ ] STEP 6: Inform user of expected time
[ ] STEP 7: Execute scan with appropriate limits
[ ] STEP 8: Show results and offer next steps
[ ] STEP 1-3: Same as above
[ ] STEP 4: ALWAYS use --dry-run first (MANDATORY)
[ ] STEP 5: Show preview results
[ ] STEP 6: Ask user confirmation before --force
[ ] STEP 7: Execute actual cleaning if confirmed
import subprocess
result = subprocess.run(['python', '--version'], capture_output=True, text=True)
# If this succeeds, you can use this skill
Problem : Full disk scan on large disks (500GB+) can take HOURS. Users will lose patience.
Solution : Use progressive scanning - get results in seconds, not hours!
When to use : Get instant estimate of directory size and scan time
python scripts/analyze_disk.py --sample
# OR
python scripts/analyze_progressive.py --sample
Output :
{
"sample_file_count": 7591,
"sample_size_gb": 17.62,
"files_per_second": 7501.0,
"estimated_time_seconds": 2.0
}
Agent Decision Logic :
# ALWAYS run quick sample first for unknown disk sizes
result = subprocess.run(
['python', 'scripts/analyze_disk.py', '--sample', '--json'],
capture_output=True,
text=True,
timeout=10,
cwd=skill_path
)
import json
sample = json.loads(result.stdout)
estimated_time = sample.get('estimated_time_seconds', 0)
# Choose next action based on estimate
if estimated_time < 30:
mode = 'full' # Full scan is fine
elif estimated_time < 120:
mode = 'time_limited' # Use time limit
else:
mode = 'progressive' # MUST use progressive mode
When to use : Get partial results in 30 seconds for large disks
python scripts/analyze_progressive.py --max-seconds 30
Features :
Agent Usage :
def analyze_large_disk_safely(path, max_seconds=30):
"""Safely analyze large disk with time limit"""
result = subprocess.run(
['python', 'scripts/analyze_progressive.py',
'--max-seconds', str(max_seconds),
'--path', str(path)],
capture_output=True,
text=True,
timeout=max_seconds + 10,
cwd=skill_path
)
return result.stdout
When to use : Get results quickly with file/time limits
# Limit by file count (fast)
python scripts/analyze_disk.py --file-limit 10000
# Limit by time (safe)
python scripts/analyze_disk.py --time-limit 30
# Both limits (very fast)
python scripts/analyze_disk.py --file-limit 10000 --time-limit 30
USER REQUEST: "Analyze my disk"
↓
┌─────────────────────────────────────────┐
│ STEP 1: Quick Sample (MANDATORY) │
│ python scripts/analyze_disk.py --sample │
└─────────────────────────────────────────┘
↓
Get estimated_time from sample
↓
├─ estimated_time < 30 seconds
│ ↓
│ ✅ Use FULL SCAN
│ python scripts/analyze_disk.py
│
├─ estimated_time 30-120 seconds
│ ↓
│ ⚠️ Use TIME LIMIT
│ python scripts/analyze_disk.py --time-limit 60
│ Tell user: "This will take ~X minutes"
│
└─ estimated_time > 120 seconds
↓
🚨 MUST USE PROGRESSIVE MODE
python scripts/analyze_progressive.py --max-seconds 30
Tell user: "Large disk detected - using progressive scan (30 seconds)"
✅ Disk analysis will take approximately 2 seconds
Starting full scan...
⚠️ Disk analysis will take approximately 3 minutes
Using time-limited scan for faster results...
🚨 Large disk detected! Full scan would take approximately 5 minutes
Using progressive scan mode to get results in 30 seconds...
(This gives you partial results quickly - you can always do a full scan later)
import subprocess
import json
from pathlib import Path
def smart_disk_analysis(disk_path, python_cmd='python'):
"""
SMART disk analysis - automatically chooses best method
THIS IS THE RECOMMENDED WAY for all agents
"""
# Find skill package
skill_path = find_skill_package() # Use your find function
if not skill_path:
return False, "Skill package not found"
# STEP 1: Quick sample (MANDATORY - do this first!)
print("🔍 Quick sampling disk...")
sample_result = subprocess.run(
[python_cmd, 'scripts/analyze_disk.py', '--sample',
'--path', str(disk_path), '--json'],
capture_output=True,
text=True,
timeout=10,
cwd=str(skill_path)
)
if sample_result.returncode != 0:
return False, "Sample failed"
try:
sample = json.loads(sample_result.stdout)
estimated_time = sample.get('estimated_time_seconds', 0)
except:
estimated_time = 0
print(f" Estimated scan time: {estimated_time:.0f} seconds")
# STEP 2: Choose scanning method based on estimate
if estimated_time < 30:
# Small disk - full scan
print("✅ Using full scan (small disk)")
result = subprocess.run(
[python_cmd, 'scripts/analyze_disk.py',
'--path', str(disk_path)],
capture_output=True,
text=True,
timeout=60,
cwd=str(skill_path)
)
elif estimated_time < 120:
# Medium disk - time limited
minutes = estimated_time / 60
print(f"⚠️ Using time-limited scan (~{minutes:.1f} minutes)")
result = subprocess.run(
[python_cmd, 'scripts/analyze_disk.py',
'--path', str(disk_path),
'--time-limit', '60'], # 1 minute max
capture_output=True,
text=True,
timeout=70,
cwd=str(skill_path)
)
else:
# Large disk - PROGRESSIVE MODE (MANDATORY)
print(f"🚨 Large disk detected! Using progressive scan (30 seconds)")
result = subprocess.run(
[python_cmd, 'scripts/analyze_progressive.py',
'--path', str(disk_path),
'--max-seconds', '30',
'--json'],
capture_output=True,
text=True,
timeout=40,
cwd=str(skill_path)
)
if result.returncode != 0:
return False, result.stderr
print(result.stdout)
return True, result.stdout
# USAGE - Just call this function:
success, output = smart_disk_analysis("C:\\")
success, output = smart_disk_analysis("/home/user")
success, output = smart_disk_analysis("D:\\Projects")
❌ DON'T : Always run full scan without checking disk size first ✅ DO : Always run --sample first to estimate
❌ DON'T : Let users wait hours for large disk scan ✅ DO : Use --max-seconds 30 for large disks
❌ DON'T : Ignore estimated time from sample ✅ DO : Use estimate to choose appropriate scan mode
❌ DON'T : Run analyze_disk.py on 1TB disk without limits ✅ DO : Use analyze_progressive.py with --max-seconds
| Situation | Command | Time | Result |
|---|---|---|---|
| Unknown size | --sample | 1s | Estimate + recommendation |
| < 30 seconds | analyze_disk.py | <30s | Full results |
| 30-120 seconds | --time-limit 60 | 60s | Most results |
120 seconds |
analyze_progressive.py --max-seconds 30| 30s | Partial results
Very large disk |analyze_progressive.py --max-seconds 60| 60s | More results
Quick Sample (1 second)
Progressive Scan (N seconds)
Smart Stopping
--sample firstThis workflow works on ANY platform, in ANY AI IDE, at ANY location.
import subprocess
import sys
def verify_python():
"""Check if Python 3.7+ is available - PLATFORM AGNOSTIC"""
try:
# Try 'python' first (Windows, some Unix)
result = subprocess.run(
['python', '--version'],
capture_output=True,
text=True,
timeout=5
)
if result.returncode == 0:
return True, result.stderr.strip() or result.stdout.strip()
except FileNotFoundError:
pass
try:
# Try 'python3' (macOS, Linux)
result = subprocess.run(
['python3', '--version'],
capture_output=True,
text=True,
timeout=5
)
if result.returncode == 0:
return True, result.stderr.strip() or result.stdout.strip()
except FileNotFoundError:
pass
return False, "Python not found"
# EXECUTE
python_available, version_info = verify_python()
if not python_available:
print("❌ Python 3.7+ required but not found")
print("Install from: https://www.python.org/downloads/")
print("See: NO_PYTHON_GUIDE.md for platform-specific instructions")
sys.exit(1)
print(f"✅ Python available: {version_info}")
from pathlib import Path
import os
def find_skill_package():
"""
Find disk-cleaner skill package - LOCATION INDEPENDENT
Searches in order of priority:
1. Current working directory
2. Project-level: ./skills/, ./.skills/, ./agent-skills/
3. User-level: ~/.skills/, ~/.agent-skills/, ~/skill-packages/
4. Common AI IDE locations
5. Parent directories
"""
# Get python command (python or python3)
python_cmd = 'python' if os.name == 'nt' else 'python3'
# Search locations - PLATFORM & IDE AGNOSTIC
search_locations = []
# 1. Current directory
cwd = Path.cwd()
search_locations.extend([
cwd / 'disk-cleaner',
cwd / 'skills' / 'disk-cleaner',
cwd / '.skills' / 'disk-cleaner',
cwd / 'agent-skills' / 'disk-cleaner',
cwd / '.agent-skills' / 'disk-cleaner',
])
# 2. Parent directories (project root)
for parent in [cwd, *cwd.parents]:
search_locations.extend([
parent / 'skills' / 'disk-cleaner',
parent / '.skills' / 'disk-cleaner',
parent / 'agent-skills' / 'disk-cleaner',
])
# Limit search depth
if len(parent.parts) <= 3:
break
# 3. User home directory
home = Path.home()
search_locations.extend([
home / 'skills' / 'disk-cleaner',
home / '.skills' / 'disk-cleaner',
home / 'agent-skills' / 'disk-cleaner',
home / '.agent-skills' / 'disk-cleaner',
home / 'skill-packages' / 'disk-cleaner',
])
# 4. Platform-specific user directories
if os.name == 'nt': # Windows
appdata = os.environ.get('APPDATA', '')
if appdata:
search_locations.append(Path(appdata) / 'skills' / 'disk-cleaner')
localappdata = os.environ.get('LOCALAPPDATA', '')
if localappdata:
search_locations.append(Path(localappdata) / 'skills' / 'disk-cleaner')
else: # Unix-like (macOS, Linux)
search_locations.extend([
home / '.local' / 'share' / 'skills' / 'disk-cleaner',
home / '.config' / 'skills' / 'disk-cleaner',
Path('/usr/local/share/skills/disk-cleaner'),
])
# 5. AI IDE specific directories (IDE-AGNOSTIC)
# Note: These are examples - actual locations vary
ide_specific = [
# Cursor
home / '.cursor' / 'skills' / 'disk-cleaner',
home / '.cursor' / 'user' / 'skills' / 'disk-cleaner',
# Windsurf
home / '.windsurf' / 'skills' / 'disk-cleaner',
# Continue
home / '.continue' / 'skills' / 'disk-cleaner',
# Generic
home / '.ai-ide' / 'skills' / 'disk-cleaner',
]
search_locations.extend(ide_specific)
# 6. sys.path entries (Python module style)
for path_entry in sys.path:
if path_entry and path_entry not in ['', '.']:
test_path = Path(path_entry) / 'disk-cleaner'
search_locations.append(test_path)
# Remove duplicates and non-existent
search_locations = list(set(search_locations))
# Search for valid skill package
for location in search_locations:
if not location:
continue
try:
# Check for key indicator files
if (location / 'scripts' / 'analyze_disk.py').exists():
return location, f"Found at: {location}"
if (location / 'SKILL.md').exists():
return location, f"Found at: {location}"
except PermissionError:
continue
except Exception:
continue
# Not found - provide helpful message
print("❌ Skill package not found")
print("\nSearched locations:")
for loc in search_locations[:10]: # Show first 10
print(f" - {loc}")
print("\nSolutions:")
print("1. Extract skill package to one of the locations above")
print("2. Or set environment variable: DISK_CLEANER_SKILL_PATH")
print("3. Or provide explicit path when calling functions")
return None, "Not found"
# EXECUTE
skill_path, message = find_skill_package()
if not skill_path:
print(message)
sys.exit(1)
print(f"✅ {message}")
def verify_skill_package(skill_path, python_cmd='python'):
"""Verify skill package integrity - LOCATION INDEPENDENT"""
check_script = skill_path / 'scripts' / 'check_skill.py'
if not check_script.exists():
print(f"❌ Check script not found: {check_script}")
return False
try:
result = subprocess.run(
[python_cmd, str(check_script)],
capture_output=True,
text=True,
timeout=30,
cwd=str(skill_path)
)
# Show verification output
if result.stdout:
print(result.stdout)
if result.returncode == 0:
print("✅ Skill package verified successfully")
return True
else:
print("❌ Skill package verification failed")
if result.stderr:
print(result.stderr)
return False
except subprocess.TimeoutExpired:
print("❌ Verification timed out")
return False
except Exception as e:
print(f"❌ Verification error: {e}")
return False
# Determine python command
python_cmd = 'python' if os.name == 'nt' else 'python3'
# EXECUTE
if not verify_skill_package(skill_path, python_cmd):
sys.exit(1)
def execute_operation(skill_path, operation, python_cmd='python', **kwargs):
"""
Execute disk cleaner operation - PLATFORM & IDE AGNOSTIC
Args:
skill_path: Path to skill package
operation: 'analyze', 'clean', 'monitor'
python_cmd: 'python' or 'python3'
**kwargs: Operation-specific arguments
"""
operation_map = {
'analyze': 'analyze_disk.py',
'clean': 'clean_disk.py',
'monitor': 'monitor_disk.py',
}
if operation not in operation_map:
print(f"❌ Unknown operation: {operation}")
print(f"Valid operations: {list(operation_map.keys())}")
return False, None
script = skill_path / 'scripts' / operation_map[operation]
cmd = [python_cmd, str(script)]
# Add operation-specific arguments
if operation == 'analyze':
if kwargs.get('path'):
cmd.extend(['--path', str(kwargs['path'])])
if kwargs.get('top'):
cmd.extend(['--top', str(kwargs['top'])])
if kwargs.get('json'):
cmd.append('--json')
elif operation == 'clean':
# ALWAYS use dry-run for safety
if not kwargs.get('force'):
cmd.append('--dry-run')
else:
cmd.append('--force')
if kwargs.get('temp'):
cmd.append('--temp')
if kwargs.get('cache'):
cmd.append('--cache')
if kwargs.get('logs'):
cmd.append('--logs')
elif operation == 'monitor':
if kwargs.get('watch'):
cmd.append('--watch')
if kwargs.get('json'):
cmd.append('--json')
try:
print(f"🔧 Executing: {' '.join(cmd)}")
result = subprocess.run(
cmd,
capture_output=True,
text=True,
timeout=kwargs.get('timeout', 300),
cwd=str(skill_path)
)
# Show output
if result.stdout:
print(result.stdout)
if result.returncode != 0:
if result.stderr:
print(f"❌ Error: {result.stderr}")
return False, None
return True, result.stdout
except subprocess.TimeoutExpired:
print("⚠️ Operation timed out")
return False, None
except Exception as e:
print(f"❌ Execution error: {e}")
return False, None
# EXECUTE
success, output = execute_operation(
skill_path,
operation='analyze',
python_cmd=python_cmd,
path='C:\\Users' if os.name == 'nt' else '/home',
json=True
)
if success:
print("✅ Operation completed successfully")
BEFORE ANY DISK ANALYSIS :
--sample first to estimate scan timeQuick Reference :
# STEP 1: ALWAYS DO THIS FIRST (1 second)
python scripts/analyze_disk.py --sample
# STEP 2: Choose based on estimate
# < 30s: python scripts/analyze_disk.py
# 30-120s: python scripts/analyze_disk.py --time-limit 60
# > 120s: python scripts/analyze_progressive.py --max-seconds 30
| User Says | Operation | Command Template |
|---|---|---|
| "analyze disk" | analyze | python scripts/analyze_disk.py |
| "check disk space" | analyze | python scripts/analyze_disk.py --top 50 |
| "quick scan" | analyze | python scripts/analyze_disk.py --sample |
| "large disk analysis" | analyze | python scripts/analyze_progressive.py --max-seconds 30 |
| "clean temp files" | clean |
Problem : Full disk scan can take hours on large disks (1TB+)
Solution : Use progressive scanning with time/file limits
# Quick sample (1 second) - Get instant estimate
subprocess.run(['python', 'scripts/analyze_disk.py', '--sample'])
# Progressive scan (30 seconds) - Get partial results quickly
subprocess.run(['python', 'scripts/analyze_progressive.py',
'--max-seconds', '30'])
# Limited file count (fast)
subprocess.run(['python', 'scripts/analyze_disk.py',
'--file-limit', '10000'])
# Full scan with time limit
subprocess.run(['python', 'scripts/analyze_disk.py',
'--time-limit', '120'])
Recommended workflow for large disks :
--sample to get estimate (1 second)--max-seconds or --file-limitanalyze_progressive.py for real-time feedback| Platform | Python Command | Check Command |
|---|---|---|
| Windows | python | python --version |
| macOS | python3 | python3 --version |
| Linux | python3 | python3 --version |
# Works on ALL platforms
import os
import subprocess
python_cmd = 'python' if os.name == 'nt' else 'python3'
result = subprocess.run([python_cmd, '--version'], capture_output=True, text=True)
This skill package works with ALL AI IDEs that support:
your-project/
├── skills/
│ └── disk-cleaner/ ← Extract here
├── src/
└── README.md
~/.skills/disk-cleaner/ ← Unix-like
~/agent-skills/disk-cleaner/ ← Alternative
C:\Users\You\skills\disk-cleaner\ ← Windows
/usr/local/share/skills/disk-cleaner/ ← Linux (system-wide)
C:\ProgramData\skills\disk-cleaner\ ← Windows (system-wide)
# Cursor automatically searches for skills in:
# - .cursor/skills/
# - project/skills/
# - ~/.skills/
# No special configuration needed
# Windsurf supports skills at:
# - .windsurf/skills/
# - project/skills/
# Skill works via subprocess, no special setup
# Continue configuration (if needed):
# {
# "skills": ["./skills/disk-cleaner"]
# }
# But auto-detection works in most cases
# Use as a tool via subprocess:
# !python skills/disk-cleaner/scripts/analyze_disk.py
# The skill includes intelligent auto-detection
# Just extract and use - no configuration needed
"""
Universal Disk Cleaner Skill Usage
Works with ALL AI IDEs, on ALL platforms, at ANY location
"""
import subprocess
import sys
import os
from pathlib import Path
def use_disk_cleaner(operation='analyze', **kwargs):
"""
Use disk cleaner skill - UNIVERSAL FUNCTION
Works on:
- All platforms (Windows, macOS, Linux)
- All AI IDEs (Cursor, Windsurf, Continue, etc.)
- All installation levels (global, project, user)
Args:
operation: 'analyze', 'clean', 'monitor'
**kwargs: Operation-specific arguments
Returns:
(success: bool, output: str)
"""
# 1. Determine Python command
python_cmd = 'python' if os.name == 'nt' else 'python3'
# 2. Verify Python
try:
result = subprocess.run(
[python_cmd, '--version'],
capture_output=True,
text=True,
timeout=5
)
if result.returncode != 0:
print("❌ Python not found")
return False, "Python 3.7+ required"
except Exception as e:
print(f"❌ Python check failed: {e}")
return False, str(e)
# 3. Find skill package (intelligent search)
def find_skill():
search_paths = [
# Current directory
Path.cwd() / 'disk-cleaner',
Path.cwd() / 'skills' / 'disk-cleaner',
Path.cwd() / '.skills' / 'disk-cleaner',
# Project root
*[(p / 'skills' / 'disk-cleaner') for p in [Path.cwd(), *Path.cwd().parents][:3]],
# User home
Path.home() / 'skills' / 'disk-cleaner',
Path.home() / '.skills' / 'disk-cleaner',
]
for path in search_paths:
if (path / 'scripts' / 'analyze_disk.py').exists():
return path
return None
skill_path = find_skill()
if not skill_path:
print("❌ Skill package not found")
print("Extract to: skills/disk-cleaner/ or ~/.skills/disk-cleaner/")
return False, "Skill package not found"
# 4. Execute operation
scripts = {
'analyze': 'analyze_disk.py',
'clean': 'clean_disk.py',
'monitor': 'monitor_disk.py',
}
if operation not in scripts:
return False, f"Unknown operation: {operation}"
script = skill_path / 'scripts' / scripts[operation]
cmd = [python_cmd, str(script)]
# Add arguments
if operation == 'analyze':
if kwargs.get('path'):
cmd.extend(['--path', str(kwargs['path'])])
elif operation == 'clean':
cmd.append('--dry-run') # Always safe
elif operation == 'monitor':
if kwargs.get('json'):
cmd.append('--json')
# Run
try:
result = subprocess.run(
cmd,
capture_output=True,
text=True,
timeout=300,
cwd=str(skill_path)
)
return result.returncode == 0, result.stdout
except Exception as e:
return False, str(e)
# USAGE EXAMPLES:
# success, output = use_disk_cleaner('analyze', path='.')
# success, output = use_disk_cleaner('clean')
# success, output = use_disk_cleaner('monitor', json=True)
if __name__ == "__main__":
# Quick test
success, output = use_disk_cleaner('analyze')
print(output)
[ ] Did you run --sample FIRST to estimate scan time?
[ ] Did you inform user about expected scan time?
[ ] Did you choose appropriate mode based on estimate?
[ ] Did you use progressive mode for >2 minute estimates?
[ ] Did you provide feedback during long scans?
Small Disk ( < 30 seconds estimated):
Medium Disk (30-120 seconds estimated) :
Large Disk ( > 120 seconds estimated):
# THIS IS THE REQUIRED PATTERN for all disk analysis:
def safe_disk_analysis(disk_path):
# Step 1: ALWAYS sample first
sample = subprocess.run(
['python', 'scripts/analyze_disk.py', '--sample', '--json'],
capture_output=True,
text=True,
cwd=skill_path
)
import json
data = json.loads(sample.stdout)
estimate = data.get('estimated_time_seconds', 0)
# Step 2: Inform user
if estimate > 120:
print(f"Large disk detected! Estimated: {estimate/60:.1f} minutes")
print("Using progressive scan (30 seconds) for quick results...")
# Step 3: Choose mode
if estimate < 30:
# Full scan
return subprocess.run(['python', 'scripts/analyze_disk.py'])
elif estimate < 120:
# Time limited
return subprocess.run(['python', 'scripts/analyze_disk.py', '--time-limit', '60'])
else:
# Progressive (MANDATORY for large disks)
return subprocess.run(['python', 'scripts/analyze_progressive.py', '--max-seconds', '30'])
# SOLUTION - Platform-independent guidance
import platform
system = platform.system()
if system == "Windows":
print("Install from: https://www.python.org/downloads/")
print("Check 'Add Python to PATH' during installation")
elif system == "Darwin": # macOS
print("Install: brew install python@3.11")
print("Or: https://www.python.org/downloads/macos/")
else: # Linux
print("Install: sudo apt install python3 # Debian/Ubuntu")
print("Or: sudo dnf install python3 # Fedora")
# SOLUTION - Show all searched locations
print("Skill package not found.")
print("Extract to ONE of these locations:")
print(" - ./skills/disk-cleaner/")
print(" - ./disk-cleaner/")
print(" - ~/.skills/disk-cleaner/")
print(" - project/skills/disk-cleaner/")
print("\nOr set: DISK_CLEANER_SKILL_PATH=/path/to/skill")
# SOLUTION - Platform-specific advice
if os.name == 'nt':
print("Run as Administrator if needed")
else:
print("Some directories may require: sudo")
print("Or adjust: chmod +x scripts/*.py")
You can optionally set these to help with auto-detection:
# Set skill package location (overrides auto-detection)
export DISK_CLEANER_SKILL_PATH=/path/to/skills/disk-cleaner
# Set Python command (overrides auto-detection)
export DISK_CLEANER_PYTHON_CMD=python3
# Enable debug output
export DISK_CLEANER_DEBUG=true
Solution : The skill is IDE-agnostic. Check:
Solution : The skill handles platform differences. Check:
python vs python3)chmod +x)Solution : Run diagnostic:
python skills/disk-cleaner/scripts/check_skill.py
# Or
python3 skills/disk-cleaner/scripts/check_skill.py
disk-cleaner/
├── SKILL.md # This file
├── AGENT_QUICK_REF.txt # Quick reference
├── NO_PYTHON_GUIDE.md # Help for users without Python
├── INSTALL.md # Installation guide
├── FIXES.md # What's fixed in v2.0
├── scripts/ # All scripts (universal)
├── diskcleaner/ # Core modules (self-contained)
└── references/ # Platform information
Before using this skill in ANY AI IDE:
python --version (or python3 --version)This skill package works EVERYWHERE - just Python 3.7+ required!
No IDE-specific configuration needed. No platform-specific setup. No installation level restrictions.
Just extract and use!
Weekly Installs
213
Repository
GitHub Stars
16
First Seen
Jan 22, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode195
cursor186
gemini-cli183
codex183
github-copilot182
kimi-cli159
通过 LiteLLM 代理让 Claude Code 对接 GitHub Copilot 运行 | 高级变通方案指南
31,600 周安装
💡 (Tip) - Suggestions, recommendations📋 (List) - Checklists, summaries🔧 (Tool) - Tools, utilities🌐 (Global) - Cross-platform, universal features🛡️ (Safety) - Safety-related information⚡ (Performance) - Performance improvements📝 (Document) - Documentation🎓 (Learning) - Educational content📞 (Support) - Help, support information📈 (Growth) - Improvements, gains🎯 (Target) - Goals, objectives🚀 (Launch) - Quick start, fast operations🛠️ (Tools) - Tool-related featurespython scripts/clean_disk.py --temp --dry-run| "preview cleanup" | clean | python scripts/clean_disk.py --dry-run |
| "monitor disk" | monitor | python scripts/monitor_disk.py |
| "disk usage" | monitor | python scripts/monitor_disk.py --json |