cleanup-nul

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Cleanup NUL Files

清理NUL文件

Find and remove
nul
files that are accidentally created by some tools (like Claude Code) on Windows.
查找并移除Windows系统中部分工具(如Claude Code)意外创建的
nul
文件。

Background

背景信息

On Windows,
nul
is a reserved device name (like
/dev/null
on Unix). Some tools may accidentally create actual files named
nul
, which can cause issues. This skill helps locate and remove them.
在Windows系统中,
nul
是一个保留的设备名(类似Unix系统中的
/dev/null
)。部分工具可能会意外创建名为
nul
的实际文件,这可能引发问题。本skill可帮助定位并移除这些文件。

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)

阶段1:环境检测(必填 — 必须先显示结果再继续)

Detect and explicitly display the following before doing anything else:
  1. Operating System: Run a command to detect the OS.
    • Windows:
      [System.Environment]::OSVersion
      or
      $env:OS
    • macOS/Linux:
      uname -s
  2. Shell environment: Identify the current shell.
    • PowerShell:
      $PSVersionTable.PSVersion
    • bash/zsh:
      echo $SHELL
      and
      echo $BASH_VERSION
      or
      echo $ZSH_VERSION
  3. 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.

在执行任何操作前,检测并明确显示以下信息:
  1. 操作系统:运行命令检测系统。
    • Windows:
      [System.Environment]::OSVersion
      $env:OS
    • macOS/Linux:
      uname -s
  2. Shell环境:识别当前使用的Shell。
    • PowerShell:
      $PSVersionTable.PSVersion
    • bash/zsh:
      echo $SHELL
      以及
      echo $BASH_VERSION
      echo $ZSH_VERSION
  3. 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:
    Remove-Item -LiteralPath <file> -Force
    (use
    \\?\<full-path>
    prefix if deletion fails due to reserved name)
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:
    rm -f <file>
    (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.

基于阶段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
  • 删除:
    rm -f <file>
    (如果失败,说明可能需要使用PowerShell处理保留名称)
目标路径:用户指定路径或默认当前工作目录。
如果扫描多个独立的根路径,将其规划为并行操作。

Phase 3: Execute

阶段3:执行操作

  1. Run the find command from the plan
  2. List all found
    nul
    files with their full paths
  3. Report the total count
  4. Ask the user for confirmation before deleting
  5. Delete the confirmed files
  6. Report results (deleted count, any failures)

  1. 运行计划中的查找命令
  2. 列出所有找到的
    nul
    文件及其完整路径
  3. 报告找到的文件总数
  4. 删除前需向用户确认
  5. 删除用户确认的文件
  6. 报告执行结果(已删除文件数、任何失败情况)

Phase 4: Report & Recommendations

阶段4:报告与建议

Summarize what was done and provide environment-specific recommendations:
  • Windows PowerShell: Recommend checking IDE/tool settings that may create
    nul
    files. Suggest using
    Remove-Item -LiteralPath "\\?\..."
    for stubborn files.
  • macOS/Linux bash: Note that
    nul
    files are uncommon on Unix — check if Windows-origin tools created them.
  • NEVER recommend commands from a different platform (e.g., do NOT suggest
    chmod
    on Windows, do NOT suggest
    Get-Acl
    on Linux).
总结已执行的操作,并提供适配当前环境的建议:
  • Windows PowerShell:建议检查可能创建
    nul
    文件的IDE/工具设置。对于难以删除的文件,建议使用
    Remove-Item -LiteralPath "\\?\..."
    命令。
  • macOS/Linux bash:注意Unix系统中
    nul
    文件并不常见,检查是否是Windows来源的工具创建了这些文件。
  • 绝对不推荐使用其他平台的命令(例如:不要在Windows系统中建议使用
    chmod
    ,不要在Linux系统中建议使用
    Get-Acl
    )。