python-coding-standards

Python coding rules for import placement, naming, file handling, modern syntax and choosing between synchronous code and background workers. They target Python 3.13 and later.

In plain words
What is it for?
Guiding Python changes, keeping imports at the top of files, using pathlib for file work, applying the project’s naming conventions and deciding when Celery workers are appropriate.
Why use it?
They make coding expectations explicit, especially rules that would otherwise be easy to miss during implementation or review.

Cursor rule for Cursor

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 rules/technickai/claude_telemetry/python-coding-standards
Clone the repo
git clone --depth 1 https://github.com/TechNickAI/claude_telemetry

Made for: Cursor.

Per session 8 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,099 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. 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.00008 $0.01099
Opus 5 $0.00004 $0.00549
Sonnet 5 $0.00002 $0.00220
Haiku 4.5 $0.00001 $0.00110

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

Security

Grade A, and why

python-coding-standards scanned grade A with 1 finding 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.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

response = requests.get(url)
Origin

Copies of this mod

1 near-identical copy found in the catalogue:

.cursor/rules/python/python-coding-standards.mdc · 150 lines

How it starts

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

Python Guidelines

Imports - NON-NEGOTIABLE

ALL imports go at the top of the file. Every single one. If you're even thinking about putting an import inside a function, stop.

Exception: circular import issues (genuinely rare).

Don't abbreviate packages ("pandas" not "pd", "numpy" not "np").

Modern Python

We use python 3.13+ and follow modern best practices:

  • Use Path lib for files instead of open
  • Use var!s instead of str(var)
  • Prefer walrus operator (:=) to reduce repetition in code
  • Use modern union syntax X | Y instead of Union[X, Y]
  • Use underscore separators in large numbers: Decimal(1_000_000) not Decimal("1000000")

Attribute and Method Naming

We make everything public by default. We're all consenting adults here.

Only use underscore prefix (_internal) when accessing something would genuinely break functionality - like thread locks or internal state that must be accessed through methods. This is extremely rare.

Async vs Sync

Default to synchronous code. We use Celery for background jobs with multiple workers, so we don't need async to free up CPU. Synchronous code is simpler, easier to debug, and easier to maintain.

When given a choice between sync and async, we choose sync.

def fetch_data(url: str) -> dict:
    response = requests.get(url)
    return response.json()

If a library only provides async API, we can wrap it with asyncio.run():

import asyncio

def sync_wrapper(param: str) -> dict:
    """Synchronous wrapper for async-only library"""
    return asyncio.run(async_library_call(param))

Async is appropriate for WebSocket connections, async-only libraries that can't be easily wrapped, or specific performance-critical paths where async provides clear, measured benefits. Ask for confirmation before introducing async patterns.

Exception Handling - READ THIS COMPLETELY

DO NOT SWALLOW ERRORS. This is the hill we die on.

Default: let exceptions bubble up. We use Sentry/Honeybadger for centralized error tracking, so exceptions that bubble up get caught and reported automatically - we get alerted and can fix them. Write functions with NO try/except:

Read the full file on GitHub · 150 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 · 150 lines · 8 tokens per session scan A d7b2c0830828

Subscribe to this mod's changes

python-coding-standards is a cursor rule published in the GitHub repository TechNickAI/claude_telemetry (30 stars, last pushed 10mo ago), licensed MIT. It adds 8 tokens to every session and 1,099 once invoked, about $0.0000 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.