agentleFS
MesteriisMesteriis/Engineering-Bible-AI/skills/python/SKILL.md

python

Skill0 starsChanged 4 months agoMITView on GitHub

Applies senior Python rules for typing, async, APIs, persistence, tests, packaging, and architecture.

We split this skill into the rules it gives an agent

40 rules. 0 are common, 32 are distinctive, and 8 are very specific to this project.

  • 0

    Common

    Most of the 40 edited versions we read keep these.

  • 32

    Distinctive

    This author's own choices. Worth a look.

  • 8

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Before changing Python code, inspect relevant files when present:

    line 14
  2. Distinctive:

    Do not assume framework, ORM, validator, or test runner without evidence.

    line 39
  3. Very specific:

    Use uv for environment, dependency, lock, and command execution workflows when the project already uses uv or the user approves adopting it.

    line 43
  4. Very specific:

    Use ruff for linting and formatting when configured or available locally.

    line 45
  5. Very specific:

    Use ty for type checking when configured, requested, or clearly the strongest available local type checker.

    line 46
  6. Very specific:

    Do not introduce uv, ruff, or ty as project requirements solely because this skill prefers them.

    line 48
  7. Distinctive:

    Follow existing project style first.

    line 53
  8. Distinctive:

    Prefer explicit functions and small modules.

    line 54
  9. Very specific:

    Avoid dumping code into utils.py, helpers.py, or common.py unless the repository already uses that pattern and the addition is cohesive.

    line 55
  10. Distinctive:

    Keep imports clean and localize optional/heavy imports only when justified.

    line 56
  11. Distinctive:

    Avoid import-time side effects.

    line 57
  12. Distinctive:

    Avoid mutable global state.

    line 58
  13. Distinctive:

    Use the configured Python version.

    line 62
  14. Distinctive:

    If the project version cannot be confirmed, avoid syntax and stdlib features newer than Python 3.10 unless the user approves.

    line 64
  15. Distinctive:

    Do not assume Python 3.12+ without confirmation.

    line 66
  16. Distinctive:

    Use type hints for new or modified public functions and methods unless this conflicts with project style.

    line 70
  17. Very specific:

    If new Any is used, justify it briefly.

    line 87
  18. Distinctive:

    Do not mass-retrofit typing outside task scope.

    line 89
  19. Distinctive:

    Avoid boolean flags that radically change behavior.

    line 94
  20. Distinctive:

    Prefer returning values over mutating shared state.

    line 95
  21. Distinctive:

    Use classes when they represent state, lifecycle, interface implementation, dependency grouping, or polymorphic behavior.

    line 96
  22. Distinctive:

    Do not create classes just to wrap one function.

    line 97
  23. Distinctive:

    Use the established project model approach:

    line 101
  24. Distinctive:

    Do not introduce a modeling library unless already used or explicitly requested.

    line 110
  25. Very specific:

    Do not use bare except.

    line 114
  26. Distinctive:

    Do not log and re-raise unless there is a clear reason.

    line 129
  27. Distinctive:

    never block the event loop with sync I/O.

    line 137
  28. Distinctive:

    use timeouts for external calls where appropriate.

    line 138
  29. Very specific:

    do not ignore asyncio.CancelledError.

    line 141
  30. Distinctive:

    Before changing persistence code, inspect:

    line 147
  31. Distinctive:

    do not invent table or column names.

    line 159
  32. Distinctive:

    do not bury business logic in persistence code unless the project intentionally does so.

    line 162
  33. Distinctive:

    add migrations when schema changes require them.

    line 163
  34. Distinctive:

    Do not assume a framework.

    line 167
  35. Distinctive:

    If a framework is present:

    line 169
  36. Distinctive:

    keep handlers/controllers thin.

    line 171
  37. Distinctive:

    use existing dependency injection style.

    line 173
  38. Distinctive:

    keep business logic out of transport layer.

    line 174
  39. Distinctive:

    avoid leaking internals in public errors.

    line 176
  40. Distinctive:

    Use the existing test setup.

    line 180

“Common” is measured: kept by at least 6 in 10 of the 40 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Skill: python

Purpose

Apply the shared engineering style to Python projects while respecting existing repository conventions.

Inspect First

Before changing Python code, inspect relevant files when present:

  • pyproject.toml
  • requirements.txt
  • setup.py
  • setup.cfg
  • tox.ini
  • pytest.ini
  • mypy.ini
  • .ruff.toml
  • ruff.toml
  • .pre-commit-config.yaml
  • Docker/CI files
  • existing source and test files

Infer:

  • Python version;
  • dependency manager;
  • formatter/linter;
  • test runner;
  • typing level;
  • package structure;
  • async/sync conventions.

Do not assume framework, ORM, validator, or test runner without evidence.

Tooling Defaults

  • Use uv for environment, dependency, lock, and command execution workflows when the project already uses uv or the user approves adopting it.
  • Use ruff for linting and formatting when configured or available locally.
  • Use ty for type checking when configured, requested, or clearly the strongest available local type checker.
  • Do not introduce uv, ruff, or ty as project requirements solely because this skill prefers them.

Style

  • Follow existing project style first.
  • Prefer explicit functions and small modules.
  • Avoid dumping code into utils.py, helpers.py, or common.py unless the repository already uses that pattern and the addition is cohesive.
  • Keep imports clean and localize optional/heavy imports only when justified.
  • Avoid import-time side effects.
  • Avoid mutable global state.

Python Version

Use the configured Python version.

If the project version cannot be confirmed, avoid syntax and stdlib features newer than Python 3.10 unless the user approves.

Do not assume Python 3.12+ without confirmation.

Typing

Use type hints for new or modified public functions and methods unless this conflicts with project style.

Prefer:

  • concrete types where useful;
  • collections.abc interfaces;
  • Protocol for structural interfaces;
  • TypedDict or existing models for structured dictionaries;
  • Literal for constrained values;
  • precise optionality.

Avoid Any unless:

  • required by a third-party API;
  • the value is genuinely dynamic;
  • narrowing would add false precision.

If new Any is used, justify it briefly.

Do not mass-retrofit typing outside task scope.

Functions and Classes

  • Keep functions cohesive.
  • Avoid boolean flags that radically change behavior.
  • Prefer returning values over mutating shared state.
  • Use classes when they represent state, lifecycle, interface implementation, dependency grouping, or polymorphic behavior.
  • Do not create classes just to wrap one function.

Data Models

Use the established project model approach:

  • dataclasses;
  • Pydantic;
  • attrs;
  • ORM models;
  • plain typed objects;
  • domain entities.

Do not introduce a modeling library unless already used or explicitly requested.

Error Handling

Do not use bare except.

Avoid:

try:
    ...
except Exception:
    pass

Use specific exceptions.

Preserve error context.

Do not log and re-raise unless there is a clear reason.

Domain errors should follow existing project patterns.

Async

For async code:

  • never block the event loop with sync I/O;
  • use timeouts for external calls where appropriate;
  • avoid orphan tasks;
  • handle cancellation correctly;
  • do not ignore asyncio.CancelledError;
  • manage task lifecycle when using asyncio.create_task;
  • protect shared mutable state.

Database / ORM

Before changing persistence code, inspect:

  • models;
  • migrations;
  • repositories;
  • transaction boundaries;
  • indexes;
  • constraints;
  • query style.

Rules:

  • do not invent table or column names;
  • avoid N+1 queries;
  • preserve transactions for multi-step writes;
  • do not bury business logic in persistence code unless the project intentionally does so;
  • add migrations when schema changes require them.

API Frameworks

Do not assume a framework.

If a framework is present:

  • keep handlers/controllers thin;
  • validate inputs;
  • use existing dependency injection style;
  • keep business logic out of transport layer;
  • return consistent response models;
  • avoid leaking internals in public errors.

Tests and Validation

Use the existing test setup.

Common validation commands, only when configured or clearly available:

uv run pytest
pytest
python -m pytest
ruff check .
ruff format --check .
ty check
mypy .
pyright

Report exact commands and results.

Shared Cross-Ecosystem Style

Apply the shared engineering style from:

  • ../../engineering/05_design_principles.md
  • ../../engineering/06_responsibility_model.md
  • ../../engineering/07_complexity_budget.md
  • ../../engineering/12_naming_bible.md

Language-specific idioms control syntax and ecosystem details, but they must not weaken the core rules: small cohesive units, explicit boundaries, honest validation, no dumping grounds, and no fake placeholders.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.