Windows 系统上使用 Claude code 时,遇到 “Stop hook error: Failed with non-blocking status code: No stderr output” 错误的解决方案。

原因

遇到这个错大概率就是使用官方的 Ralph loop 插件导致,因为官方的插件的钩子写法只有sh脚本,只是适配类Unix系统(不带win玩

在wsl上也会出错

不过在WSL上也会出错

解决方案

https://github.com/anthropics/claude-plugins-official/pull/305

这位大佬直接写了一个powershell脚本,用node启动判断平台,然后执行对应的脚本,直接下载代码替换 .claude/plugins/ralph-loop 的文件就行了。最好就启动cc 重新安装一下插件。/plugins 命令重装

测试

1
/ralph-loop:ralph-loop "Append the current iteration number to test-iterations.txt. Read the file first, then append the next number. Output <promise>DONE</promise> when it contains 1 through 5." --max-iterations 5 --completion-promise "DONE"

测试结果

能看到 claude 在尝试退出的时候,执行了钩子函数,重写入了文件

最后输出也是这样的

1
2
3
4
5
1
2
3
4
5

完美! good fix