python-rules

python-rules is a skill for Claude Code from softspark/ai-toolkit. It costs 55 tokens per session (2,758 once invoked), scanned A, original, Apache-2.0.

A set of rules for writing and reviewing Python code, including style, type hints, common frameworks, security, and tests.

In plain words
What is it for?
Use it when creating or reviewing Python files and projects that use tools such as FastAPI, Django, Flask, pytest, or SQLAlchemy.
Why use it?
It keeps Python code consistent and helps catch errors and security problems early.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Part of the ai-toolkit plugin — 115 skills, 44 agents, 14 hooks shipped together

Good fit Use it when creating or reviewing Python files and projects that use tools such as FastAPI, Django, Flask, pytest, or SQLAlchemy.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/softspark/ai-toolkit/python-rules
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.

Any agent
npx skills add softspark/ai-toolkit --skill python-rules
Clone the repo
git clone --depth 1 https://github.com/softspark/ai-toolkit

Made for: Claude Code.

Or install ai-toolkit, the plugin that ships this one along with the rest of its 115 skills, 44 agents, 14 hooks.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for python-rules

README.md
[![agentmods](https://agentmods.dev/badge/skills/softspark/ai-toolkit/python-rules/github.svg)](https://agentmods.dev/skills/softspark/ai-toolkit/python-rules)
Your own site
<a href="https://agentmods.dev/skills/softspark/ai-toolkit/python-rules"><img src="https://agentmods.dev/badge/skills/softspark/ai-toolkit/python-rules/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for python-rules

Your own site · 80×15
<a href="https://agentmods.dev/skills/softspark/ai-toolkit/python-rules"><img src="https://agentmods.dev/badge/skills/softspark/ai-toolkit/python-rules.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 55 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,758 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 1 finding, up to high

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • high Tool Misuse · line 179
    Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).
    Fix: Validate all tool parameters against an allowlist. Reject dangerous parameter values (shell=True, --force, -rf /) and use safe defaults.
How audits are shown
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.1 $0.00055 $0.02758
Opus 5 $0.00028 $0.01379
Sonnet 5 $0.00011 $0.00552
Haiku 4.5 $0.00006 $0.00276

Measured 6d ago against content hash 0baaab7cc1e7, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

python-rules 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 6d 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.

Runs shell commandslowCapability

Expected in a hook, worth knowing in a rule or an instructions file.

- Never use `os.system()` or `subprocess.run(shell=True)` with user input.
app/skills/python-rules/SKILL.md · 258 lines

How it starts

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

Python Rules

These rules come from app/rules/python/ in ai-toolkit. They cover the project's standards for coding style, frameworks, patterns, security, and testing in Python. Apply them when writing or reviewing Python code.

Python Coding Style

Type Hints

  • Type all public function signatures (parameters + return).
  • Use str | None (PEP 604) over Optional[str] on Python 3.10+.
  • Use from __future__ import annotations for forward references.
  • Use TypeAlias or type (3.12+) for complex type aliases.
  • Use Protocol for structural subtyping instead of ABCs where possible.

Naming

  • snake_case: variables, functions, methods, modules.
  • PascalCase: classes, type aliases, Protocols.
  • UPPER_SNAKE: module-level constants.
  • Prefix private: _internal_helper. No double underscore unless name mangling needed.
  • Prefix unused: _ for intentionally unused variables.

Functions

  • Prefer keyword arguments for functions with >2 params.
  • Use * to force keyword-only: def fetch(*, limit: int, offset: int).
  • Return early to reduce nesting. Avoid deep if/else chains.
  • Use @staticmethod only for pure utility. Prefer module-level functions.

Imports

  • Group: stdlib, third-party, local. Separated by blank lines.
  • Use absolute imports. Relative imports only within packages.
  • Never from module import *. Be explicit.
  • Use if TYPE_CHECKING: for import-only-for-types to avoid circular imports.

Data Structures

  • Use dataclasses for plain data containers.
  • Use Pydantic BaseModel for validated data / API schemas.
  • Use NamedTuple for lightweight immutable records.
  • Use Enum for fixed sets of values. Prefer StrEnum on 3.11+.
  • Prefer dict / list literals over dict() / list() constructors.

Modern Python

  • Use f-strings for formatting. Never .format() or % for new code.
  • Use pathlib.Path over os.path for file operations.
  • Use contextlib.suppress(KeyError) over bare try/except for simple cases.
  • Use walrus operator := when it genuinely improves readability.
  • Use match/case (3.10+) for complex conditionals on structured data.

Read the full file on GitHub · 258 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. 6d ago First seen · 258 lines · 55 tokens per session scan A 0baaab7cc1e7

Subscribe to this mod's changes

python-rules is a skill published in the GitHub repository softspark/ai-toolkit (170 stars, last pushed yesterday), licensed Apache-2.0. It adds 55 tokens to every session and 2,758 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 1 finding (runs shell commands). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.