Intelligent file write error handler: diagnoses permissions, disk space, path length, file locks before retrying. Auto-activates on 'Error writing file', 'Permission denied', 'Access denied', 'No space left', file write failures.
Automatically diagnoses and resolves file write errors through systematic investigation rather than blind retries. Prevents common write failures proactively.
Auto-activates when any of these occurs:
This skill does NOT:
Required inputs:
1. Path Validation
import os
# Check path length (Windows: 260 char limit)
if len(filepath) > 260 and os.name == 'nt':
print(f"Path too long: {len(filepath)} chars")
# Check parent directory exists
parent = os.path.dirname(filepath)
if not os.path.exists(parent):
print(f"Parent directory missing: {parent}")
2. Permission Check
import os
# Check directory write permission
parent = os.path.dirname(filepath) or '.'
if not os.access(parent, os.W_OK):
print(f"No write permission: {parent}")
# Check file permissions if exists
if os.path.exists(filepath):
if not os.access(filepath, os.W_OK):
print(f"File not writable: {filepath}")
3. Disk Space Check
import shutil
# Check available disk space
stat = shutil.disk_usage(os.path.dirname(filepath) or '.')
free_gb = stat.free / (1024**3)
if free_gb < 0.1: # Less than 100MB
print(f"Low disk space: {free_gb:.2f} GB free")
4. File Lock Detection
import os
# Try to open with exclusive access