skill
windows-compatibility
Cross-platform path handling and command patterns
github/gh-aw/.squad/templates/skills/windows-compatibilityofficiallistedunreviewednot running here yet
Set up
Skills are installed by placing their folder where your agent loads skills.
Part of the collection github/gh-aw.
npx skills add github/gh-aw --skill windows-compatibility
Or by hand: Copy the folder .squad/templates/skills/windows-compatibility from github.com/github/gh-aw into ~/.claude/skills/windows-compatibility/ (Claude Code) or your agent's skills folder. Check the collection's own README for other agents.
README
synced Oct 14, 2026Context
Squad runs on Windows, macOS, and Linux. Several bugs have been traced to platform-specific assumptions: ISO timestamps with colons (illegal on Windows), git -C with Windows paths (unreliable), forward-slash paths in Node.js on Windows.
Patterns
Filenames & Timestamps
- Never use colons in filenames: ISO 8601 format
2026-03-15T05:30:00Zis illegal on Windows - Use
safeTimestamp()utility: Replaces colons with hyphens →2026-03-15T05-30-00Z - Centralize formatting: Don't inline
.toISOString().replace(/:/g, '-')— use the utility
Git Commands
- Never use
git -C {path}: Unreliable with Windows paths (backslashes, spaces, drive letters) - Always
cdfirst: Change directory, then run git commands - Check for changes before commit:
git diff --cached --quiet(exit 0 = no changes)
Commit Messages
- Never embed newlines in
-mflag: Backtick-n (\n) fails silently in PowerShell - Use temp file +
-Fflag: Write message to file, commit withgit commit -F $msgFile
Paths
- Never assume CWD is repo root: Always use
TEAM ROOTfrom spawn prompt or rungit rev-parse --show-toplevel - Use path.join() or path.resolve(): Don't manually concatenate with
/or\
Path Comparison (Case Sensitivity)
- Never use case-sensitive
startsWithor===for path comparison on Windows or macOS: These filesystems are case-insensitive —C:\Users\andc:\users\refer to the same location - Use platform-aware comparison: Check
process.platform === 'win32' || process.platform === 'darwin'and lowercase both sides before comparing - Pattern:
const CASE_INSENSITIVE = process.platform === 'win32' || process.platform === 'darwin'; function pathStartsWith(fullPath: string, prefix: string): boolean { if (CASE_INSENSITIVE) { return fullPath.toLowerCase().startsWith(prefix.toLowerCase()); } return fullPath.startsWith(prefix); } - Where it matters: Security checks (path traversal prevention), rootDir confinement, any path-contains-path validation
- Linux is case-sensitive: Do NOT lowercase on Linux —
/Home/and/home/are different directories
Examples
✓ Correct:
// Timestamp utility
const safeTimestamp = () => new Date().toISOString().replace(/:/g, '-').split('.')[0] + 'Z';
// Git workflow (PowerShell)
cd $teamRoot
git add .squad/
if ($LASTEXITCODE -eq 0) {
$msg = @"
docs(ai-team): session log
Changes:
- Added decisions
"@
$msgFile = [System.IO.Path]::GetTempFileName()
Set-Content -Path $msgFile -Value $msg -Encoding utf8
git commit -F $msgFile
Remove-Item $msgFile
}
✗ Incorrect:
// Colon in filename
const logPath = `.squad/log/${new Date().toISOString()}.md`; // ILLEGAL on Windows
// git -C with Windows path
exec('git -C C:\\src\\squad add .squad/'); // UNRELIABLE
// Inline newlines in commit message
exec('git commit -m "First line\nSecond line"'); // FAILS silently in PowerShell
Anti-Patterns
- Testing only on one platform (bugs ship to other platforms)
- Assuming Unix-style paths work everywhere
- Using
git -Cbecause it "looks cleaner" (it doesn't work) - Skipping
git diff --cached --quietcheck (creates empty commits) - Wrong — case-sensitive path check on Windows and macOS:
if (!resolved.startsWith(rootDir + path.sep)) { throw new Error('Path traversal blocked'); } // Fails: 'c:\\Users\\temp\\file'.startsWith('C:\\Users\\temp\\') → false