python-script-developer
Skill1 starsChanged 4 months agoMITView on GitHub
Write production-ready Python CLI tools, automation scripts, and batch file processors with type hints, structured `logging` (never `print` for diagnostics), `argparse` interfaces, `pathlib` for filesystem work, specific exception handling, and cross-platform support (Linux, macOS, Windows). Use this skill whenever the user asks to create a Python script, `.py` utility, CLI tool, automation, batch processor, or data pipeline — including casual phrasings like "write a python script that ...", "automate this in python", "I need a small tool", or "give me a one-off processor". Also use when reviewing or hardening an existing Python script.
In this repository24 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- architecture-auditSkill
- autodreamSkill
- deep-discoverySkill
- generic-by-designSkill
- gitops-cd-developerSkill
- gitops-pipeline-developerSkill
- golang-script-developerSkill
- humanizerSkill
- information-architectureSkill
- interactive-deck-builderSkill
- javascript-script-developerSkill
- linux-script-developerSkill
- makefile-script-developerSkill
- plan-interviewSkill
- pre-commit-setupSkill
- qaSkill
- skill-builderSkill
- teacher-modeSkill
- terraform-module-developerSkill
- typescript-script-developerSkill
- ui-deslopSkill
- xquik-x-dataSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
16 rules. About 0 are common, 2 are distinctive, and 14 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
14
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 40
Every script you write starts from this skeleton.
- Very specific: line 100
Validate the result: Run python3 scripts/validate-script.py <your-script.py> — it AST-parses the script and checks shebang, docstrings, …
- Very specific: line 120
No bare
except:: Always catch a specific exception. - Very specific: line 125
Atomic writes: write to tmp.with_suffix(".tmp") then Path.replace(target) so partial writes can't corrupt the destination.
- Very specific: line 129
Start every script from assets/templates/.
- Distinctive: line 130
Add type hints to every function (args and return).
- Very specific: line 131
Use argparse with explicit type=Path for file/directory args.
- Very specific: line 132
Use logging at module scope.
- Very specific: line 133
Use pathlib.Path for all filesystem work.
- Distinctive: line 135
Use Google-style or NumPy-style docstrings on public functions.
- Very specific: line 136
Use context managers (with) for files, locks, sockets, temp files.
- Very specific: line 138
Run scripts/validate-script.py on the result.
- Very specific: line 143
Use os.path, os.system, os.popen, or string-concatenated paths.
- Very specific: line 144
Use bare except: or swallow exceptions with pass.
- Very specific: line 147
Write top-level execution code without a __main__ guard.
- Very specific: line 149
Use deprecated stdlib (optparse, imp) or unpinned third-party deps.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Python Script Developer
Production-ready Python. Type-hinted + logged + argparsed + pathlib + specific exceptions.
When to use
- The user asks for any
.pyscript, CLI tool, automation, or batch processor. - The user wants to harden, refactor, or review an existing Python script.
- A task chain ends in "and put it in a python script".
Required structure
Every script you write starts from this skeleton. Do not omit type hints, the if __name__ == '__main__' guard, or the sys.exit(main()) pattern.
#!/usr/bin/env python3
"""<one-line description>.
<longer description if needed>
"""
from __future__ import annotations
import argparse
import logging
import sys
from pathlib import Path
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s %(levelname)s %(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
)
logger = logging.getLogger(__name__)
SCRIPT_DIR = Path(__file__).resolve().parent
def parse_args() -> argparse.Namespace:
p = argparse.ArgumentParser(description=__doc__)
p.add_argument("input", type=Path, help="Input file path")
p.add_argument("-o", "--output", type=Path, help="Output file path")
p.add_argument("-v", "--verbose", action="store_true", help="Enable debug logging")
return p.parse_args()
def main() -> int:
args = parse_args()
if args.verbose:
logger.setLevel(logging.DEBUG)
try:
# logic here
return 0
except FileNotFoundError as e:
logger.error("File not found: %s", e)
return 1
except Exception:
logger.exception("Unexpected error")
return 2
if __name__ == "__main__":
sys.exit(main())Workflow
- Confirm the package manager. If the script imports anything outside the standard library, install commands must use the user's preferred manager. See
references/package-managers.md— read it on the first run to capture the preference, then save it to user memory so future runs skip the question. - Pick a starting template from
assets/templates/:script.template.py— basic single-purpose script.cli-tool.template.py— multi-subcommand CLI.file-processor.template.py— batch processing.
- Apply patterns from
references/patterns.mdfor any non-obvious case (custom exceptions, dataclass validation, subcommands, structured logging, progress bars). - Validate the result. Run
python3 scripts/validate-script.py <your-script.py>— it AST-parses the script and checks shebang, docstrings, type hints, main guard, logging, pathlib, argparse, and error handling. Aim for 100%. - Cross-check
references/anti-patterns.md— especiallyos.pathvspathlib, bareexcept, missing__main__guard, and hardcoded values. - For cross-platform scripts, load
references/cross-platform.mdand apply the rules (signals, paths, console colors, executable suffixes). - Generate man-page-style docs using the template in
references/documentation.md— either inline or as<script>.mdnext to the file.
Available resources
assets/templates/{script,cli-tool,file-processor}.template.py— starting points.assets/examples/csv-analyzer.py— full-featured reference implementation.scripts/validate-script.py— score a script against the checklist (run after writing).references/patterns.md— load when implementing argparse/logging/error/file/dataclass patterns.references/anti-patterns.md— load when reviewing or rewriting an existing script.references/cross-platform.md— load when targeting macOS or Windows alongside Linux.references/documentation.md— load when generating script reference docs.references/package-managers.md— load on first run to capture the user's preferred installer.
Top gotchas (always inline — do not skip)
pathlib.Path, neveros.path.Path(__file__).resolve().parent / "config.yaml", notos.path.join(...).logging, neverprintfor diagnostics.printis only for the script's structured output.- No bare
except:. Always catch a specific exception. Useexcept Exception:only at the very top ofmain()withlogger.exception(...). argparse, never rawsys.argvparsing.if __name__ == "__main__": sys.exit(main())— return exit codes frommain()instead of callingsys.exitfrom anywhere inside.- Always add type hints to function signatures (
def f(x: int) -> str:). They double as documentation and letmypyfind bugs. withfor every file/lock/socket — no manualf.close().- Atomic writes: write to
tmp.with_suffix(".tmp")thenPath.replace(target)so partial writes can't corrupt the destination.
What you DO
- Start every script from
assets/templates/. - Add type hints to every function (args and return).
- Use
argparsewith explicittype=Pathfor file/directory args. - Use
loggingat module scope; let--verboseflip the level toDEBUG. - Use
pathlib.Pathfor all filesystem work. - Catch specific exceptions and map them to distinct exit codes (1 = generic, 2 = bad input, 3 = permission, 130 = SIGINT, etc.).
- Use Google-style or NumPy-style docstrings on public functions.
- Use context managers (
with) for files, locks, sockets, temp files. - Show progress with
tqdmfor any loop that may take more than a couple of seconds. - Run
scripts/validate-script.pyon the result; iterate until ≥ 90%. - Generate man-page-style reference docs (
references/documentation.md).
What you do NOT do
- Use
os.path,os.system,os.popen, or string-concatenated paths. - Use bare
except:or swallow exceptions withpass. - Print debug info — use
logger.debug(...). - Hardcode values that should come from env vars, config, or args.
- Write top-level execution code without a
__main__guard. - Skip docstrings on public functions.
- Use deprecated stdlib (
optparse,imp) or unpinned third-party deps.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

