python-script-conventions

Enforces Python 3.12+ script layout, typing, logging, and dataclass conventions for standalone scripts.

Updated Jul 8, 2026
One-click install
npx skills add https://github.com/Sotdo/personal_skills --skill python-script-conventions-sotdo
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: python-script-conventions
Source: https://github.com/Sotdo/personal_skills/tree/main/skills/python-script-conventions
Command: npx skills add https://github.com/Sotdo/personal_skills --skill python-script-conventions-sotdo

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires pandas, loguru, and includes references (resource) components.

What problem does it solve? Python scripts written or edited by AI agents often drift in structure, import placement, logging style, and documentation format, making a codebase inconsistent and hard to review. This Skill codifies a single set of conventions so every generated or modified .py file follows the same section layout, modern Python 3.12+ idioms, and documentation standards. ## Core Features & Use Cases - Standardized 7-section layout: IMPORTS, DECORATORS, CONSTANTS, CONFIG, LOGGING, CORE LOGIC, and MAIN sections with a ready-to-use template file (templates/agent_script_template.py) as the starting point for new scripts. - Modern Python 3.12+ rules: native generics, X | None unions, type aliases, frozen slotted dataclasses, StrEnum markers, match-case branching, loguru logging, and pathlib-only path handling. - Documentation and review standards: module-level docstring format, single-line function docstrings, three-column change-summary tables, plus a verification checklist and a catalog of common pitfalls. - Use Case: When asked to write a new bioinformatics data-processing script, load this Skill first, open the bundled template, and produce a script that passes the full verification checklist on the first pass. ## Quick Start Load the python-script-conventions skill and use its template to write a new Python script that filters a CSV by p-value threshold.

Frequently Asked Questions about python-script-conventions

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

FAQPage Schema
How do I structure a standalone Python script for data processing?▼

Follow the 7-section layout: IMPORTS, DECORATORS, GLOBAL CONSTANTS & ENUMS, CONFIGURATION & DATACLASSES, LOGGING SETUP, CORE LOGIC, and MAIN EXECUTION. Start from the bundled agent_script_template.py, which includes parse_args(), a main() returning an exit code, and loguru setup.

What Python 3.12 typing features should I use in new scripts?▼

Use native list and dict generics, X | None instead of Optional, the type keyword for aliases, and def func[T](...) for generics. Configuration objects should use @dataclass(kw_only=True, slots=True, frozen=True), and grouped string markers should use enum.StrEnum.

Should I use print or logging in Python CLI scripts?▼

Use loguru, never print, for all runtime output. Expose a --verbose CLI flag for debug-level logging and apply @logger.catch on core functions to capture exceptions instead of scattering try/except blocks.

When should I not apply these script conventions?▼

Do not apply them to multi-module libraries or packages, which follow their own structure, or to Jupyter notebooks. The conventions target standalone single-file scripts; library modules omit the LOGGING, CONFIG, and MAIN sections entirely.

How do I replace long if-elif chains for text classification in Python?▼

Use a declarative signal table of frozen dataclass instances plus a resolution function that detects all matches independently, then deduplicates and suppresses contextually dependent signals. For keyword-profile analysis, use exact-match sets with a stem-prefix fallback of 3+ character stems.