python-coding-rules

Applies canonical Python coding rules for typing, exceptions, resources, async code, tests, and coverage.

Updated Oct 15, 2019
One-click install
npx skills add https://github.com/kkkaoru/dotfiles --skill python-coding-rules-kkkaoru
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: python-coding-rules
Source: https://github.com/kkkaoru/dotfiles/tree/main/.agents/skills/python-coding-rules
Command: npx skills add https://github.com/kkkaoru/dotfiles --skill python-coding-rules-kkkaoru

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Python codebases often accumulate inconsistent style, unsafe typing, weak exception handling, and low-quality tests because rules are scattered or duplicated. This Skill provides a single deduplicated, normative rule set (PY01-PY34) that agents apply whenever planning, writing, editing, testing, or reviewing Python code. ## Core Features & Use Cases - Canonical Rule Set: 34 uniquely identified rules covering repository setup, typing, data models, control flow, exceptions, resources, imports, diagnostics, tests, and coverage, each stated exactly once to avoid contradictions. - Bilingual References: The English references/python.md is the normative source for agents, while references/python.ja.mdx is a Japanese translation for human readers. - Use Case: When asked to refactor a Python module, the agent loads the rule set, plans the implementation (PY30), applies typing and exception rules, updates related tests (PY25), meets coverage thresholds (PY26), and self-reviews against the rules before finishing (PY34). ## Quick Start Apply the python-coding-rules skill to review and refactor my Python module so it follows the canonical typing, exception, and testing rules.

Frequently Asked Questions about python-coding-rules

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I enforce consistent Python coding standards with an AI agent?

Load a single normative rule set like this one, which defines 34 deduplicated rules (PY01-PY34) covering typing, exceptions, resources, tests, and coverage. The agent reads the reference file completely and applies it whenever planning, writing, or reviewing Python code.

What Python typing rules should AI-generated code follow?

The rules require avoiding Any and unchecked casts, narrowing with TypeGuard or protocols, typing all public functions and return values, using dataclasses or TypedDict for structured data, and never using mutable objects as function defaults.

Does this rule set cover Python test and coverage requirements?

Yes. Rules PY25-PY29 require updating tests with any behavior change, meeting configured per-file coverage thresholds or 90% by default, isolating filesystem and network dependencies, and writing explicit non-DRY test cases without loops.

Can I use these Python rules with Ruff and existing lint workflows?

Yes. Rule PY02 requires running the repository's complete configured toolchain, such as Ruff check and Ruff format together, plus type-check and tests. The rules never introduce a second linter, formatter, or package manager.

When should I not load both language versions of the rules?

The English python.md is the only normative version for agents. The Japanese python.ja.mdx is a human translation and should only be loaded when the user explicitly requests Japanese, never alongside the English version by default.