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.
npx agentmods add rules/nedcodes-ok/cursorrules-collection/pythongit clone --depth 1 https://github.com/nedcodes-ok/cursorrules-collectionWhat 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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00643 | $0.00643 |
| Opus 5 | $0.00321 | $0.00321 |
| Sonnet 5 | $0.00129 | $0.00129 |
| Haiku 4.5 | $0.00064 | $0.00064 |
Grade A, and why
python 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.
Copies of this mod
1 near-identical copy found in the catalogue:
- python — 100% identical, 0 lines differ
How it starts
The opening of the file, as written. The whole thing — 57 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Python Rules
Style & Structure
- Use type hints for all function signatures, return types, and class attributes
- Prefer f-strings over .format() or % formatting
- Use pathlib instead of os.path for all file operations
- Prefer list/dict/set comprehensions over map/filter when the expression fits one line
- Use dataclasses for plain data containers. Pydantic BaseModel for validated/serialized data
- Use Enum for fixed sets of values, StrEnum for string enums (Python 3.11+)
- Use
__slots__on data-heavy classes to reduce memory - Prefer
collections.abctypes for type hints:Sequence,Mapping,Iterableover concrete types
Error Handling
- Use specific exception types, never bare
except:orexcept Exception: - Use
contextlib.suppress()for expected, recoverable exceptions - Return early to avoid deep nesting. Max 3 levels of indentation
- Custom exceptions inherit from a project-level base exception
- Never silence exceptions in production. Log at minimum
- Use
elseclause on try/except for code that should run only when no exception occurred
Imports
- Group imports: stdlib, third-party, local (separated by blank lines)
- Use absolute imports over relative imports
- Never use wildcard imports (
from x import *) - Sort with isort or ruff. One import per line for third-party packages
- Lazy imports for heavy dependencies only needed in specific code paths
Functions & Classes
- Keep functions under 30 lines. Extract helpers aggressively
- Use
*argsand**kwargssparingly. Document types when used - Prefer returning values over modifying mutable arguments
- Use generators (
yield) for large sequences instead of building full lists - Keyword-only arguments after
*for functions with 3+ params - Use
@staticmethodonly when the method truly needs no instance/class access - Prefer composition over inheritance. Use protocols (typing.Protocol) for interfaces
- Use
@propertyfor computed attributes, not for hiding method calls
Testing
- Use pytest over unittest. No test classes unless sharing fixtures
- Name tests:
test_<function>_<scenario>_<expected> - Use fixtures for shared setup,
@pytest.mark.parametrizefor multiple cases - Use
tmp_pathfixture for file operations, not manual temp directories - Mock at boundaries (HTTP, DB, filesystem), not internal functions
- Use
pytest.raises(ExactError, match="message")for exception testing
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.
- yesterday First seen · 57 lines · 643 tokens per session scan A d51f9f11306c
python is a cursor rule published in the GitHub repository nedcodes-ok/cursorrules-collection (37 stars, last pushed 6mo ago), licensed MIT. It adds 643 tokens to every session, about $0.0032 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.