llm-ide-rules python.instructions.md

A set of Python coding rules covering the latest Python version, file paths, documentation, data models, database queries, command-line parsing, logging, and typing.

In plain words
What is it for?
Use it when writing or reviewing Python modules, documenting functions, defining data models, building SQL queries, parsing commands, or adding logs.
Why use it?
It keeps Python code consistent with the project’s preferred libraries, style, and handling of values such as IDs, dates, and paths.

Instructions file for GitHub Copilot

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 instructions/iloveitaly/llm-ide-rules/python
Clone the repo
git clone --depth 1 https://github.com/iloveitaly/llm-ide-rules

Made for: GitHub Copilot.

Per session 756 This file is loaded in full into every session.
When invoked 756 The same file — it is already loaded in full.
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.00756 $0.00756
Opus 5 $0.00378 $0.00378
Sonnet 5 $0.00151 $0.00151
Haiku 4.5 $0.00076 $0.00076

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

Security

Grade A, and why

llm-ide-rules python.instructions.md 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 2d ago.

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.

.github/instructions/python.instructions.md · 73 lines

How it starts

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

Python

When writing Python:

  • Assume the latest python, version 3.13.
  • Prefer Pathlib methods (including read and write methods, like read_text) over os.path, open, write, etc.
  • docstrs and comments:
    • If a docstring needs formatting, use markdown. Use Google Style.
    • Prefer docstr to multi-line comments at the top of a function or file.
    • If a docstr does not span multiple lines, do not use triple-quoted strings.
    • Add a newline after """ when using triple-quoted docstrings.
    • If a comment or docstr is a single line, do not end it in a period.
  • Do not create __init__ files unless specifically instructed
  • Use Pydantic models over dataclass or a typed dict.
  • Use SQLAlchemy for generating any SQL queries.
  • Use click for command line argument parsing.
  • Use log.info("the message", the_variable=the_variable) instead of log.info("The message: %s", the_variable) or print for logging. This object can be found at from app import log.
    • Log messages should be lowercase with no leading or trailing whitespace.
    • No variable interpolation in log messages.
    • Do not coerce database IDs, dates, or Path objects to str
  • Do not fix import ordering or other linting issues.
  • Never edit or create any files in migrations/versions/
  • Place all comments on dedicated lines immediately above the code statements they describe. Avoid inline comments appended to the end of code lines.
  • Do not try/catch raw Exceptions unless explicitly told to. Prefer to let exceptions raise and cause an explicit error.
  • Always make an explicit copy before mutating a dictionary that you did not create in the current narrow scope.
  • Never use from __future__
  • Always use re.compile(pattern, re.VERBOSE) and inline # comments to document the logic of each capture group or condition in any complex regular expression.
  • IMPORTANT never edit app/generated/ files. These are autogenerated.

Package Management

  • Use uv add to add python packages. No need for pip compile, pip install, etc.

Read the full file on GitHub · 73 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. 2d ago First seen · 73 lines · 756 tokens per session scan A dbd7646d523e

Subscribe to this mod's changes

llm-ide-rules python.instructions.md is an instructions file published in the GitHub repository iloveitaly/llm-ide-rules (13 stars, last pushed 2d ago), licensed MIT. It adds 756 tokens to every session, about $0.0038 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-30.