Use before running shell commands on the Windows machine (Git Bash or PowerShell), checking line endings, capturing test output, or removing worktrees and branches. Covers silent PowerShell and Git Bash traps that produce wrong or stray results, and the worktree and gate rules workers break by accident.
Install
npx skillscat add josiahallard/agentic-project-manager-kit/shell-and-worktree-traps Install via the SkillsCat registry.
SKILL.md
Shell and worktree traps
- Use absolute paths and your assigned worktree. Never leave a shell inside a worktree about to be removed:
cdholds a Windows handle on the folder, and a latergit worktree removefails "Permission denied". - Line endings: check the committed blob,
git show <rev>:<path>. In Git Bashgrep -c $'\r'matches every line, an always-true CRLF test;.gitattributesnormalises on commit. - Any script with Windows paths, regexes or escapes: write it to a file with your file-write tool and run it by absolute path. A Bash heredoc mangles backslash paths (a worktree path once ended up mangled and was force-removed), collapses
\\to\in regexes, and can turn\nor\0into real newline or NUL characters inside a Python file. - PowerShell file APIs:
[IO.File]::ReadAllText/WriteAllTextresolve a relative path against the PROCESS cwd (often the main checkout), not$PWD: a failed read gives$null, thenWriteAllTextcreates an empty stray there. Use your file-edit tool, or an absolute path. python - @'...'@passes the here-string as an argument, not stdin: Python opens a REPL that can loop and fill the disk. Write the script to a file, or pipe the here-string to Python.- A PowerShell function or pipeline returning exactly ONE object gives a bare scalar with no
.Count($null), so$x.Count -gt 0passes silently: wrap in@()before counting. - Subprocesses: pass arguments as an array with the shell disabled.
- Test output: tee the whole output to a file (or
dotnet test --logger trx), then read the file; never grep it live (a case-sensitive filter once matched the pass banner but not the failure text). Never pipe a gate or locked run through a truncating reader. - One foreground gate per worktree, on its assigned ports; never background one with a stray
&(two at once fought over the same build). - Cleanup goes through the kit's tools (
python <kit>/tools/worktree_remove.py -C <main checkout> <worktree>), only for a worktree that is yours to remove; otherwise report it to the lander or coordinator.
Never
git worktree remove --force,git branch -D, deleting another session's branch, or taking over another session's run.[IO.File]or[System.IO]with a relative path.- Kill a process by name.
- Move an assigned worktree to another folder: the configured worktree location holds unless the owner assigns another.
Details: <kit>/docs/worktree-remove.md; <kit>/docs/new-worktree.md.