cc-win-kit — Run Claude Code unattended on Windows without silent breakage
If you run Claude Code on Windows 11 with Windows PowerShell 5.1 — from Task Scheduler, from scripts, overnight — some things break without an error. Exit code 2 becomes 1. Non-ASCII prompts arrive as ??. An em dash in a script turns into a syntax error. A prompt placed after --allowedTools is silently swallowed. A log you are writing shows 0 bytes. You only find out from the wrong result.
cc-win-kit is the set of parts I built so I would stop stepping on these. Every part was run and tested before it went in.
What you get
- Write guard — a PreToolUse hook that blocks Claude Code from writing outside the folders you allow. Fails closed — also when the hook itself times out, crashes or cannot start ("onFailure": "block"; by default Claude Code lets the write through in those cases, which I reproduced three times). Tested with the real claude -p: the allowed file was written, the outside file was blocked.
- Unattended queue runner — runs one task per line through claude -p, with six stop conditions (deadline, job count, total minutes, consecutive errors/timeouts, leftover processes, empty queue), a state file, a morning report, and a dry run.
- Doctor — a read-only health check that finds BOM-less non-ASCII .ps1 files, LF-only .cmd files, default encodings, scheduled tasks that call a .ps1 through -Command, and how fast the write guard really answers. It also reads your Claude Code settings and flags hooks that let a tool call through when they fail: no "onFailure", a matcher that covers Write but not Edit, or a .ps1 hook run through -Command (its deny, exit 2, comes back as 1, and I reproduced the write going through).
- Trap reproducers — deliberately trigger each trap on your machine and tell you which ones apply there (they use your own code pages), plus a script that shows the hook-timeout hole and that the kit's settings close it.
- Safe-invoke helpers for PowerShell 5.1, CLAUDE.md templates (English and Japanese), README in both languages, and the full test suite.
Proof
The full suite passes (ALL PASSED) on Windows PowerShell 5.1.26100 / Python 3.13.7 / Claude Code 2.1.304, including from a fresh extract.
Limits, up front
- The guard stops Claude Code's file-writing tools, not writes made through a shell — the README shows how to run without shell tools.
- Built and tested on one Japanese Windows 11 machine. Behaviour under English code pages (1252 / 437) was checked by simulation, not on an English machine: one trap (LF .cmd) does not occur there. Run tests\run-all.ps1 first.
- The guard's onFailure setting needs Claude Code 2.1.295 or later (the doctor warns on older versions).
- Not for macOS, Linux, or PowerShell 7 only.
License: use and modify it for yourself and inside your own organization. No redistribution or resale. No warranty.