python-conventions

A set of conventions for writing clear, typed Python code that follows the repository's style, error-handling, testing, and tooling choices.

In plain words
What is it for?
Add or modify Python modules and tests using type hints, dataclasses or existing validation models, project-specific tools, and pytest.
Why use it?
It reduces inconsistent Python code and catches type, style, and behavior problems early.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/tmj-90/gaffer/python-conventions
Any agent
npx skills add tmj-90/gaffer --skill python-conventions
Clone the repo
git clone --depth 1 https://github.com/tmj-90/gaffer

Made for: Claude Code, Codex.

Per session 84 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,128 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00084 $0.01128
Opus 5 $0.00042 $0.00564
Sonnet 5 $0.00017 $0.00226
Haiku 4.5 $0.00008 $0.00113

Measured yesterday against content hash cadc4c6206c9, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

python-conventions scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

runner/skills/python-conventions/SKILL.md · 77 lines

How it starts

The opening of the file, as written. The whole thing — 77 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Write idiomatic, typed Python

Add Python that reads as pythonic, is fully type-hinted, and matches the repo's existing idioms and tooling — clear and correct, not just runnable.

Steps

  1. Read the lore first. Call search_lore (Memory MCP) for the repo's Python conventions and respect its config: the Python version, pyproject.toml (dependencies, tool config), the formatter/linter (ruff / black), and the type checker (mypy / pyright). Use the project's environment manager (poetry / venv / uv) — never install globally.
  2. Find a sibling module and copy its patterns — package layout, import style, error handling, how data is modelled, and how tests are organised.
  3. Type everything. Add type hints on every function signature and public attribute; prefer precise types (Sequence, Mapping, Protocol, TypedDict, Literal) over bare Any. Justify any Any in a comment. Run the project's type checker and fix the cause of errors rather than # type: ignore-ing them.
  4. Model data with @dataclass (frozen where it should be immutable) or Pydantic when the repo already uses it for validation at boundaries — not loose dicts of stringly-typed keys.
  5. Be pythonic. Comprehensions and generators over manual loops where readable; context managers (with) for resources; pathlib over string paths; f-strings for formatting; enumerate/zip over index juggling.
  6. Handle errors explicitly. Catch the narrowest exception that fits — no bare except: and no blanket except Exception that swallows. Re-raise with context (raise X from err) or handle; never silently pass. Validate external input at the boundary.
  7. Test with pytest. Use fixtures and parametrize for table-style cases; cover happy path, edge cases, and error conditions; assert behaviour, not incidental detail.
  8. Verify + evidence. Run the project's tests + lint + type check, record test_output via the record-evidence skill, and submit for review.

Read the full file on GitHub · 77 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 77 lines · 84 tokens per session scan A cadc4c6206c9

Subscribe to this mod's changes

python-conventions is a skill published in the GitHub repository tmj-90/gaffer (2 stars, last pushed 7d ago), licensed Apache-2.0. It adds 84 tokens to every session and 1,128 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.