senior-python-engineering
Skill119 starsChanged 5 months agoMITView on GitHub
The standard for writing Python here — small, typed, explicit, testable modules with side effects pushed to the edges. Use when implementing or designing any Python code.
In this repository16 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- architecture-reviewSkill
- code-reviewSkill
- documentationSkill
- git-workflowSkill
- mcp-toolsSkill
- project-architectureSkill
- prompt-renderingSkill
- refactoringSkill
- runtime-engineSkill
- sidecar-auth-contextSkill
- skill-authoringSkill
- testingSkill
- vercel-react-best-practicesSkill
- yaml-schemaSkill
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 5 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 10
Do not edit this file directly.
- Distinctive: line 41
Use Pydantic for data crossing a boundary that needs validation/parsing (YAML spec models, plugin/API payloads).
- Distinctive: line 43
Use dataclasses (often frozen) for internal domain models that don't need runtime validation (e.g.
- Distinctive: line 46
Separate domain models from transport/API models: Don't reuse a FastAPI request model as your internal domain object.
- Distinctive: line 58
Clear async boundaries: Don't mix blocking I/O into async paths.
- Distinctive: line 64
Avoid clever code and premature abstraction: Write the simple version; abstract only when a second real case appears.
- Very specific: line 69
Locate the layer: Put code in the correct src/agentplatform/<layer> package per AGENTS.md.
- Very specific: line 78
Type and lint: run make format then make lint (ruff + mypy).
≈ “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
<!--
This file is generated by tools/skills.
Do not edit this file directly.
Edit .ai/skills/senior-python-engineering.md and run `make generate-ai`.
-->Skill: Senior Python Engineering
Purpose
Set the standard for writing Python in this repository: small, typed, explicit, testable modules with side effects pushed to the edges — code that future agents can safely modify without fear.
When to Use This Skill
- Implementing any Python code in
src/agentplatform/(tasks0001+). - Designing a new module, model, or adapter.
- Deciding between dataclass vs. Pydantic, sync vs. async, or where to put a dependency.
Files to Read First
AGENTS.md(architecture rules and planned package layout).docs/ARCHITECTURE.md(layer responsibilities)..ai/skills/architecture-review.md(invariants you must not break).pyproject.toml(configured tools: ruff, mypy, pytest).
Core Principles
- Small modules, single responsibility. One layer concern per module; no giant files.
- Explicit typed models. Type everything;
mypyruns strict.- Use Pydantic for data crossing a boundary that needs validation/parsing (YAML spec models, plugin/API payloads).
- Use dataclasses (often frozen) for internal domain models that don't need runtime validation (e.g. compiled graph nodes). Choose intentionally, not at random.
- Separate domain models from transport/API models. Don't reuse a FastAPI request model as your internal domain object.
- Keep side effects at boundaries. I/O, network, time, and randomness live in adapters at the edges; core logic stays pure and testable.
- Dependency injection over hidden globals. Pass collaborators in; no module-level mutable singletons, and never mutable global request state.
- Adapters via explicit interfaces. External integrations (LLM, MCP, DB,
plugins) sit behind ABCs so implementations are navigable and can be faked in
tests. Reach for
typing.Protocolwhere the typing is structural rather than nominal:runtime_checkableProtocols for optional capabilities detected withisinstance(seeagent_engine/engine/), plain Protocols for the minimal shape a function needs of its argument. - Clear async boundaries. Don't mix blocking I/O into async paths; keep async at the edges and be consistent within a module.
- Typed, actionable errors. Define specific exception types; messages name
the offending thing (key, id, variable). Avoid bare
except. - Small, intent-named functions. A function name should describe what it does; if you need "and" in the name, split it.
- Avoid clever code and premature abstraction. Write the simple version; abstract only when a second real case appears.
Process
- Locate the layer. Put code in the correct
src/agentplatform/<layer>package perAGENTS.md. - Model the data. Decide Pydantic (boundary/validated) vs. dataclass (internal/domain); make domain models immutable where possible.
- Define the interface first. Sketch the public function/class signatures
and any ABC for external dependencies — or a
runtime_checkableProtocol when the capability is optional and detected structurally at runtime. - Implement the core pure logic, keeping I/O behind injected adapters.
- Wire dependencies explicitly (constructor/params), not via globals.
- Type and lint: run
make formatthenmake lint(ruff + mypy). - Add tests per
.ai/skills/testing.md; runmake check.
Expected tools
pytest— tests.ruff— formatting + linting.mypy(orpyrightif later configured) — static typing.pydantic— boundary/validated models.fastapi— when the API layer is implemented (task0009).typer— when the CLI is implemented (task0008).
Checklist Before Finishing
- Code is in the correct layer; modules are small and single-purpose.
- Everything is typed;
mypyis clean. - Pydantic vs. dataclass chosen intentionally and justified.
- Domain models separated from transport/API models.
- Side effects isolated at adapters; core logic is pure.
- Dependencies injected; no hidden/mutable globals; no global request state.
- External integrations sit behind explicit ABCs; optional capabilities
behind
runtime_checkableProtocols. - Errors are typed and actionable.
- No premature abstraction or clever code.
make checkpasses.
Common Mistakes to Avoid
- One big module that spans several layers.
- Untyped code or
Anyused to silencemypy. - Reusing transport models as domain models (or vice versa).
- Hidden global state / module-level singletons holding request data.
- Concrete external clients hardwired in core logic (untestable).
- Building frameworks/abstractions before there's a second use case.
Expected Final Report
State: which modules were added/changed and the layer each belongs to; the
model choices (Pydantic vs. dataclass) and why; how external dependencies are
injected and faked; confirmation that side effects are at the edges; and the
make check result.
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.

