Python Unix Philosophy
Overview
Use this skill to translate broad Unix philosophy into concrete Python decisions. Favor small parts, explicit interfaces, unsurprising behavior, and data-driven design over clever abstractions or speculative frameworks.
Read references/unix-python-principles.md when you need the full principle index, review checklist, or examples for a specific rule.
Workflow
- Classify the request.
- Architecture/design: choose module boundaries, ownership, and interfaces.
- Refactor: split large units and remove accidental complexity.
- Code review: identify where the code violates Unix-style constraints.
- Script/tooling: decide whether a one-off task belongs in the app or a standalone script.
- Map the problem to the smallest relevant principle set.
- Reach first for modularity, clarity, separation, simplicity, robustness, and least surprise.
- Pull in economy, optimization, diversity, or extensibility only when they materially affect the decision.
- Prefer local, concrete improvements.
- Replace giant functions with small collaborators.
- Replace inheritance-heavy seams with
Protocol, simple functions, or composition.
- Replace hardcoded branches with tables or config maps.
- Replace hidden side effects with explicit names and explicit state changes.
- Explain tradeoffs in plain language.
- Say which principle is being honored or violated.
- Say why the proposed change improves maintenance, testing, or debugging.
- Prefer one clear recommendation over many equally plausible options.
Default Heuristics
- Keep modules and classes narrow in purpose.
- Program to consumer-facing interfaces; in Python this usually means
Protocol, callables, or small objects.
- Prefer
dataclass, Enum/StrEnum, and typed dictionaries/models over clever flags or magic state.
- Separate policy from mechanism: business rules should not depend on vendor SDK details.
- Use standalone scripts for one-off maintenance work instead of adding permanent app endpoints.
- Make failures explicit with precise exceptions and
raise ... from ....
- Keep library code quiet: return values or raise errors; do not
print().
- Fold changing knowledge into configuration or data tables instead of long
if/elif chains.
- Avoid surprising APIs: no mutable default arguments, no hidden writes in getters, no silent retries unless the contract says so.
- Optimize only after profiling or clear evidence.
Design Guidance
Architecture
- Start from the smallest useful interface.
- Prefer composition over inheritance.
- Add abstraction only after duplication or test seams prove the need.
- Choose boring, standard tools first; justify extra frameworks with concrete payoff.
Refactoring
- Find the unit doing more than one job.
- Split mechanism from policy before introducing patterns.
- Preserve behavior first, then simplify names, signatures, and dependency flow.
- If a task is operational and temporary, move it into
scripts/ instead of the main runtime path.
Code Review
- Review for maintenance risk, not stylistic novelty.
- Flag tight coupling, implicit behavior, giant interfaces, silent failure, and premature optimization.
- Tie each finding to a principle so the feedback is teachable and reusable.
- If multiple fixes are possible, recommend the smallest change that restores clarity and safety.
Principle Priority
When principles compete, use this bias order:
- Clarity over cleverness.
- Simplicity over speculative extensibility.
- Transparency over hidden convenience.
- Robustness over silent recovery.
- Developer time over marginal machine-time wins, unless profiling says otherwise.
Reference Usage
- Read only the sections you need from references/unix-python-principles.md.
- Use the review checklist in that file when auditing a change set or proposing a refactor plan.
- Reuse the anti-patterns and preferred patterns there when you need short, teachable rationale.
1---2name: python-unix-philosophy3description: Apply Unix philosophy to Python architecture, refactoring, and code review. Use when Codex needs to design or review Python modules, services, scripts, dependency boundaries, error handling, configuration-driven logic, or API surfaces; especially when the goal is to reduce coupling, improve clarity, split oversized components, prefer simple mechanisms, or make future extension safer without over-engineering.4---56# Python Unix Philosophy78## Overview910Use this skill to translate broad Unix philosophy into concrete Python decisions. Favor small parts, explicit interfaces, unsurprising behavior, and data-driven design over clever abstractions or speculative frameworks.1112Read [references/unix-python-principles.md](references/unix-python-principles.md) when you need the full principle index, review checklist, or examples for a specific rule.1314## Workflow15161. Classify the request.17 - Architecture/design: choose module boundaries, ownership, and interfaces.18 - Refactor: split large units and remove accidental complexity.19 - Code review: identify where the code violates Unix-style constraints.20 - Script/tooling: decide whether a one-off task belongs in the app or a standalone script.212. Map the problem to the smallest relevant principle set.22 - Reach first for modularity, clarity, separation, simplicity, robustness, and least surprise.23 - Pull in economy, optimization, diversity, or extensibility only when they materially affect the decision.243. Prefer local, concrete improvements.25 - Replace giant functions with small collaborators.26 - Replace inheritance-heavy seams with `Protocol`, simple functions, or composition.27 - Replace hardcoded branches with tables or config maps.28 - Replace hidden side effects with explicit names and explicit state changes.294. Explain tradeoffs in plain language.30 - Say which principle is being honored or violated.31 - Say why the proposed change improves maintenance, testing, or debugging.32 - Prefer one clear recommendation over many equally plausible options.3334## Default Heuristics3536- Keep modules and classes narrow in purpose.37- Program to consumer-facing interfaces; in Python this usually means `Protocol`, callables, or small objects.38- Prefer `dataclass`, `Enum`/`StrEnum`, and typed dictionaries/models over clever flags or magic state.39- Separate policy from mechanism: business rules should not depend on vendor SDK details.40- Use standalone scripts for one-off maintenance work instead of adding permanent app endpoints.41- Make failures explicit with precise exceptions and `raise ... from ...`.42- Keep library code quiet: return values or raise errors; do not `print()`.43- Fold changing knowledge into configuration or data tables instead of long `if/elif` chains.44- Avoid surprising APIs: no mutable default arguments, no hidden writes in getters, no silent retries unless the contract says so.45- Optimize only after profiling or clear evidence.4647## Design Guidance4849### Architecture5051- Start from the smallest useful interface.52- Prefer composition over inheritance.53- Add abstraction only after duplication or test seams prove the need.54- Choose boring, standard tools first; justify extra frameworks with concrete payoff.5556### Refactoring5758- Find the unit doing more than one job.59- Split mechanism from policy before introducing patterns.60- Preserve behavior first, then simplify names, signatures, and dependency flow.61- If a task is operational and temporary, move it into `scripts/` instead of the main runtime path.6263### Code Review6465- Review for maintenance risk, not stylistic novelty.66- Flag tight coupling, implicit behavior, giant interfaces, silent failure, and premature optimization.67- Tie each finding to a principle so the feedback is teachable and reusable.68- If multiple fixes are possible, recommend the smallest change that restores clarity and safety.6970## Principle Priority7172When principles compete, use this bias order:73741. Clarity over cleverness.752. Simplicity over speculative extensibility.763. Transparency over hidden convenience.774. Robustness over silent recovery.785. Developer time over marginal machine-time wins, unless profiling says otherwise.7980## Reference Usage8182- Read only the sections you need from [references/unix-python-principles.md](references/unix-python-principles.md).83- Use the review checklist in that file when auditing a change set or proposing a refactor plan.84- Reuse the anti-patterns and preferred patterns there when you need short, teachable rationale.