Writing Portable Python

Use when writing or reviewing ANY Python that could run on an operating system other than the one you are on — harness scripts, skill scripts, hooks, installers, CLIs. Covers the failures that are invisible on the machine that wrote them, in the order they actually bite - platform-exclusive imports that fail at IMPORT and take down every caller, text I/O and console output that die on a cp1252 Windows console, path rendering for a TARGET os rather than the host, os.replace and file-locking semantics that differ on Windows, the missing exec bit, absent system binaries (jq/host/dig), and subprocess spawn cost that inverts the bash-is-lighter intuition. Enforced by `_meta/portability_lint.py`; this skill is the reasoning, the lint is the regression guard. Trigger on - writing a script, cross-platform, Windows, macOS, portability, "works on my machine", UnicodeEncodeError, ModuleNotFoundError fcntl, cp1252, charmap codec, file locking, atomic write, shebang.

joogy06 be2c88a 11.8 KB Updated

File contents

joogy06/agent-foundry/tree/main/skills/writing-portable-python commit be2c88a6c5

Frequently asked questions

npx skillmds@latest add joogy06/writing-portable-python