Cleanup NUL Files
Find and remove
files that are accidentally created by some tools (like Claude Code) on Windows.
Background
On Windows,
is a reserved device name (like
on Unix). Some tools may accidentally create actual files named
, which can cause issues. This skill helps locate and remove them.
Strict Execution Flow
Do NOT use any scripts. Do NOT skip or merge phases. Execute each phase in order.
Phase 1: Environment Detection (MANDATORY — must display results before proceeding)
Detect and explicitly display the following before doing anything else:
- Operating System: Run a command to detect the OS.
- Windows:
[System.Environment]::OSVersion
or
- macOS/Linux:
- Shell environment: Identify the current shell.
- PowerShell:
$PSVersionTable.PSVersion
- bash/zsh: and or
- Agent identity: Identify which agent is running this skill (Claude Code, GitHub Copilot CLI, Cursor, etc.) based on the agent's own context/identity.
Display the detection results clearly, for example:
Environment Detection:
OS: Windows 11 (10.0.22631)
Shell: PowerShell 7.4
Agent: GitHub Copilot CLI
All subsequent phases MUST use ONLY commands appropriate for the detected OS and shell. Never mix platform commands.
Phase 2: Plan (generate environment-specific steps)
Based on Phase 1 results, generate the concrete execution plan:
For PowerShell (Windows):
- Find:
Get-ChildItem -Path <target> -Recurse -Filter "nul" -File -Force -ErrorAction SilentlyContinue
- Delete:
Remove-Item -LiteralPath <file> -Force
(use prefix if deletion fails due to reserved name)
For bash/zsh (macOS/Linux):
- Find:
find <target> -name "nul" -type f 2>/dev/null
- Delete:
For Git Bash on Windows:
- Find:
find <target> -name "nul" -type f 2>/dev/null
- Delete: (if fails, note that PowerShell may be needed for reserved name handling)
Target path: user-specified or default to current working directory.
If scanning multiple separate root paths, plan them as parallel operations.
Phase 3: Execute
- Run the find command from the plan
- List all found files with their full paths
- Report the total count
- Ask the user for confirmation before deleting
- Delete the confirmed files
- Report results (deleted count, any failures)
Phase 4: Report & Recommendations
Summarize what was done and provide environment-specific recommendations:
- Windows PowerShell: Recommend checking IDE/tool settings that may create files. Suggest using
Remove-Item -LiteralPath "\\?\..."
for stubborn files.
- macOS/Linux bash: Note that files are uncommon on Unix — check if Windows-origin tools created them.
- NEVER recommend commands from a different platform (e.g., do NOT suggest on Windows, do NOT suggest on Linux).