cleanup-nul
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCleanup NUL Files
清理NUL文件
Find and remove files that are accidentally created by some tools (like Claude Code) on Windows.
nul查找并移除Windows系统中部分工具(如Claude Code)意外创建的文件。
nulBackground
背景信息
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.
nul/dev/nullnul在Windows系统中,是一个保留的设备名(类似Unix系统中的)。部分工具可能会意外创建名为的实际文件,这可能引发问题。本skill可帮助定位并移除这些文件。
nul/dev/nullnulStrict 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)
阶段1:环境检测(必填 — 必须先显示结果再继续)
Detect and explicitly display the following before doing anything else:
- Operating System: Run a command to detect the OS.
- Windows: or
[System.Environment]::OSVersion$env:OS - macOS/Linux:
uname -s
- Windows:
- Shell environment: Identify the current shell.
- PowerShell:
$PSVersionTable.PSVersion - bash/zsh: and
echo $SHELLorecho $BASH_VERSIONecho $ZSH_VERSION
- PowerShell:
- 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 CLIAll subsequent phases MUST use ONLY commands appropriate for the detected OS and shell. Never mix platform commands.
在执行任何操作前,检测并明确显示以下信息:
- 操作系统:运行命令检测系统。
- Windows:或
[System.Environment]::OSVersion$env:OS - macOS/Linux:
uname -s
- Windows:
- Shell环境:识别当前使用的Shell。
- PowerShell:
$PSVersionTable.PSVersion - bash/zsh:以及
echo $SHELL或echo $BASH_VERSIONecho $ZSH_VERSION
- PowerShell:
- Agent身份:根据Agent自身的上下文/身份,识别运行本skill的Agent(如Claude Code、GitHub Copilot CLI、Cursor等)。
清晰显示检测结果,例如:
环境检测结果:
操作系统:Windows 11 (10.0.22631)
Shell:PowerShell 7.4
Agent:GitHub Copilot CLI后续所有阶段必须仅使用与检测到的操作系统和Shell匹配的命令。绝对不能混合跨平台命令。
Phase 2: Plan (generate environment-specific steps)
阶段2:制定计划(生成适配环境的步骤)
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: (use
Remove-Item -LiteralPath <file> -Forceprefix if deletion fails due to reserved name)\\?\<full-path>
For bash/zsh (macOS/Linux):
- Find:
find <target> -name "nul" -type f 2>/dev/null - Delete:
rm -f <file>
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)
rm -f <file>
Target path: user-specified or default to current working directory.
If scanning multiple separate root paths, plan them as parallel operations.
基于阶段1的检测结果,生成具体的执行计划:
PowerShell(Windows)环境:
- 查找:
Get-ChildItem -Path <target> -Recurse -Filter "nul" -File -Force -ErrorAction SilentlyContinue - 删除:(如果因保留名称导致删除失败,使用
Remove-Item -LiteralPath <file> -Force前缀)\\?\<full-path>
bash/zsh(macOS/Linux)环境:
- 查找:
find <target> -name "nul" -type f 2>/dev/null - 删除:
rm -f <file>
Windows下的Git Bash环境:
- 查找:
find <target> -name "nul" -type f 2>/dev/null - 删除:(如果失败,说明可能需要使用PowerShell处理保留名称)
rm -f <file>
目标路径:用户指定路径或默认当前工作目录。
如果扫描多个独立的根路径,将其规划为并行操作。
Phase 3: Execute
阶段3:执行操作
- Run the find command from the plan
- List all found files with their full paths
nul - Report the total count
- Ask the user for confirmation before deleting
- Delete the confirmed files
- Report results (deleted count, any failures)
- 运行计划中的查找命令
- 列出所有找到的文件及其完整路径
nul - 报告找到的文件总数
- 删除前需向用户确认
- 删除用户确认的文件
- 报告执行结果(已删除文件数、任何失败情况)
Phase 4: Report & Recommendations
阶段4:报告与建议
Summarize what was done and provide environment-specific recommendations:
- Windows PowerShell: Recommend checking IDE/tool settings that may create files. Suggest using
nulfor stubborn files.Remove-Item -LiteralPath "\\?\..." - macOS/Linux bash: Note that files are uncommon on Unix — check if Windows-origin tools created them.
nul - NEVER recommend commands from a different platform (e.g., do NOT suggest on Windows, do NOT suggest
chmodon Linux).Get-Acl
总结已执行的操作,并提供适配当前环境的建议:
- Windows PowerShell:建议检查可能创建文件的IDE/工具设置。对于难以删除的文件,建议使用
nul命令。Remove-Item -LiteralPath "\\?\..." - macOS/Linux bash:注意Unix系统中文件并不常见,检查是否是Windows来源的工具创建了这些文件。
nul - 绝对不推荐使用其他平台的命令(例如:不要在Windows系统中建议使用,不要在Linux系统中建议使用
chmod)。Get-Acl