macos-python-scripting

Write zero-setup macOS utilities using Apple's Python 3.9 standard library.

1|Updated Feb 25, 2026
One-click install
npx skills add https://github.com/cjthompson/claude-code-config --skill macos-python-scripting-cjthompson
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: macos-python-scripting
Source: https://github.com/cjthompson/claude-code-config/tree/main/plugins/python-scripting/skills/macos-python-scripting
Command: npx skills add https://github.com/cjthompson/claude-code-config --skill macos-python-scripting-cjthompson

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing small macOS utilities often pulls in Homebrew, pip, or virtual environments that break on clean machines. This Skill constrains scripts to Apple's /usr/bin/python3 and the Python 3.9 standard library so they run on any Mac with Command Line Tools installed. ## Core Features & Use Cases - Zero-dependency scripting: Enforces the #!/usr/bin/python3 shebang, Python 3.9 syntax (Optional/Union instead of T | None), and standard-library-only imports such as argparse, json, plistlib, pathlib, and subprocess. - Safe macOS integration: Invokes stable system programs via absolute paths and argument arrays, never shell=True, with typed functions and isinstance narrowing of decoded plist/JSON data. - Isolated verification: Validates scripts with /usr/bin/python3 -E -s -S and runs tests via unittest discover without environment leakage. - Use Case: Build a CLI tool that reads a plist preference file, opens a URL with /usr/bin/open, and exits with a clean error message — all without installing anything on the target Mac. ## Quick Start Write a macOS utility script that runs on Apple's /usr/bin/python3 using only the standard library to parse a plist file and print selected keys.

Frequently Asked Questions about macos-python-scripting

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write a Python script that runs on any Mac without installing anything?

Start the file with #!/usr/bin/python3 and import only the Python 3.9 standard library, such as argparse, json, plistlib, and subprocess. This interpreter ships with Apple's Command Line Tools, so no Homebrew, pip, or virtual environment is needed.

What Python version does macOS /usr/bin/python3 support?

Apple's /usr/bin/python3 from Command Line Tools runs Python 3.9. Use Optional[T] and Union[A, B] instead of T | None, and avoid match statements, tomllib, typing.Self, and other newer APIs.

Can I use pip packages with Apple's system Python?

No, scripts targeting /usr/bin/python3 should rely only on the standard library. Do not depend on Apple-bundled or user site-packages including pip, setuptools, six, or future, since these are not guaranteed on a clean machine.

How do I safely run macOS commands from a Python script?

Use subprocess with absolute paths and argument arrays, for example subprocess.run(["/usr/bin/open", url], check=True). Never use shell=True for data-derived arguments, and catch CalledProcessError at the CLI boundary.

How do I test a standalone Python script without environment interference?

Run it with /usr/bin/python3 -E -s -S to ignore environment variables, user site-packages, and the site module. For tests, use unittest discovery with -s for the start directory and -p for the file pattern.

What if /usr/bin/python3 is missing on a Mac?

Report that Apple Command Line Tools are required and stop. Do not attempt to install or modify the interpreter, since the script's guarantee is zero-setup execution on the system-provided Python.