standards-python
Skill0 starsChanged 4 months agoMITView on GitHub
Use this skill whenever you write, review, or design Python code, including type annotations, error handling, naming, docstrings, packaging, and API design, even when the user only asks for a short script. Based on the Google Python Style Guide. Load standards-code for the language-neutral baseline.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- axrmxv/claude-configtheir own version, first seen Oct 13, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- axrmxv/claude-config★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository34 other files it gives its agents.
- AGENTS.mdAGENTS.md
- mcpSkill
- pattern-orchestration-complexSkill
- pattern-task-breakdownSkill
- role-architectSkill
- role-code-reviewSkill
- role-data-engineerSkill
- role-developerSkill
- role-orchestratorSkill
- role-product-engineerSkill
- role-qa-engineerSkill
- role-security-auditorSkill
- role-site-reliability-engineerSkill
- role-technical-writerSkill
- standards-analysisSkill
- standards-api-designSkill
- standards-codeSkill
- standards-databaseSkill
- standards-documentationSkill
- standards-go-concurrencySkill
- standards-go-performanceSkill
- standards-goSkill
- standards-go-testingSkill
- standards-markdownSkill
- standards-observabilitySkill
- standards-pulumi-typescriptSkill
- standards-securitySkill
- standards-shellSkill
- standards-skill-authoringSkill
- standards-testingSkill
- standards-typescriptSkill
- tool-storeSkill
- workflow-debuggingSkill
- workflow-pi-extensionSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
77 rules. About 0 are common, 20 are distinctive, and 57 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈20
Distinctive · estimate
This author's own choices. Worth a look.
57
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 18
Run pylint and a type checker (pytype or mypy) on all code
- Distinctive: line 19
Use 4-space indentation; never tabs
- Very specific: line 20
Keep lines ≤ 80 characters.
- Very specific: line 22
Use """triple-double-quote""" for all docstrings
- Very specific: line 23
Use f-strings for string formatting.
- Very specific: line 24
Use with statements for all file/socket/resource management
- Very specific: line 25
Use default iterators (for key in dict:) over explicit method calls
- Distinctive: line 26
Keep functions focused; aim for ≤ 40 lines
- Very specific: line 31
Use mutable default arguments (def f(x=[])): use None sentinel instead
- Very specific: line 32
Use bare except: or catch Exception/BaseException without re-raising
- Very specific: line 33
Use assert for application logic: only for tests or truly optional checks
- Distinctive: line 34
Use mutable global state: prefer dependency injection or module constants
- Very specific: line 35
Use __double_leading_underscore__ dunder names for your own identifiers
- Very specific: line 36
Use staticmethod unless forced by an existing API: use module-level functions
- Very specific: line 37
Use map()/filter() with lambda: prefer generator expressions
- Very specific: line 38
Use backslash \ for line continuation: use implicit joining inside brackets
- Very specific: line 40
Use typing.Text, typing.List, typing.Dict, etc.
- Very specific: line 57
pylint: Run on all code; suppress only with symbolic names and a comment explaining why.
- Distinctive: line 58
Auto-formatter: Use Black or Pyink to avoid formatting debates.
- Very specific: line 59
Type checker: Use pytype (Google) or mypy.
- Very specific: line 60
Import sorting: Use isort with Black-compatible settings.
- Distinctive: line 62
Keep suppressions rare and always explain them inline.
- Very specific: line 68
Use import x for packages and modules.
- Very specific: line 69
Use from x import y as z only when y is ambiguous, conflicts, or inconveniently long.
- Very specific: line 70
Use import y as z only when z is a standard abbreviation (import numpy as np).
- Distinctive: line 71
Always use the full package name: no relative imports.
- Distinctive: line 74
Prefer explicit absolute imports.
- Very specific: line 87
Use stable import grouping: __future__, stdlib, third-party, internal.
- Distinctive: line 104
Use trailing commas when the closing bracket is on its own line.
- Very specific: line 108
No spaces inside brackets: spam(ham[1], {'eggs': 2}) not spam( ham[ 1 ] ).
- Distinctive: line 109
No space before a comma, semicolon, or colon.
- Very specific: line 110
No space before ( starting an argument list or indexing.
- Distinctive: line 113
Do not vertically align tokens across lines.
- Distinctive: line 117
Never use semicolons to terminate lines or put two statements on one line.
- Very specific: line 121
Use sparingly. Don't wrap return or conditional expressions in unnecessary parentheses.
- Very specific: line 127
No blank line immediately after a def line.
- Very specific: line 135
Always use """triple-double-quotes""".
- Distinctive: line 139
Every file should have a license header and a module docstring describing contents and usage.
- Distinctive: line 144
Keep docstring examples concise.
- Very specific: line 146
Use Yields: instead of Returns: for generator functions.
- Very specific: line 151
Place below the class line.
- Very specific: line 155
Start with # (at least one space after #).
- Distinctive: line 158
Use proper capitalization and punctuation.
- Distinctive: line 160
Prefer comments that explain intent/trade-offs, not mechanical behavior.
- Very specific: line 196
Use a single leading _ for internal/protected module attributes, functions, and class members.
- Very specific: line 208
Use X | None (3.10+) over Optional[X].
- Very specific: line 209
Do not annotate self or cls (except when using Self for return types).
- Very specific: line 210
Use Any when a type truly cannot be expressed.
- Very specific: line 211
Import symbols from typing and collections.abc directly.
- Distinctive: line 213
Prefer concise type-hint examples and avoid verbose templates.
- Very specific: line 221
Use explicit X | None unions.
- Very specific: line 225
Use TypeAlias for complex reusable types.
- Distinctive: line 229
Always specify type parameters.
- Very specific: line 233
Use from __future__ import annotations or string literals for forward references.
- Very specific: line 237
Use TYPE_CHECKING blocks for type-only imports.
- Very specific: line 249
Prefer specific exceptions and small try blocks.
- Very specific: line 251
Never use assert for application logic: only in tests or as truly optional checks.
- Very specific: line 253
Use finally for cleanup regardless of exception outcome.
- Very specific: line 257
Never use mutable default arguments.
- Distinctive: line 263
Use comprehensions for simple transforms.
- Distinctive: line 267
Prefer default iterators over methods that return lists or explicit key/value access.
- Very specific: line 271
Prefer implicit boolean evaluation.
- Very specific: line 275
Prefer f-strings for formatting.
- Very specific: line 277
Use """ for multi-line strings.
- Very specific: line 278
Don't use + to build strings in loops: use a list and ''.join().
- Very specific: line 280
Prefer f-strings and ''.join() for loop-based string building.
- Very specific: line 288
Always use with statements for files, sockets, and similar resources.
- Very specific: line 292
Use @property for simple attribute access with light computation.
- Very specific: line 296
Use judiciously. Write unit tests for decorators.
- Very specific: line 298
Avoid @staticmethod: use module-level functions instead.
- Very specific: line 299
Use @classmethod only for named constructors or class-specific routines.
- Very specific: line 307
Don't rely on the atomicity of built-in types.
- Very specific: line 311
Avoid: custom metaclasses, bytecode access, on-the-fly compilation, __del__, heavy getattr() reflection, dynamic inheritance.
- Very specific: line 315
Avoid. If necessary, declare at module level with a leading _ and provide access via functions.
- Distinctive: line 327
Every executable file must guard its main logic:
- Very specific: line 351
Use getter/setter functions only when getting or setting involves meaningful computation or side effects.
- Very specific: line 353
Follow naming: get_foo(), set_foo(): or @property for simple computed attributes.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Python Standards
Provides: Idiomatic Python patterns, type annotations, imports, error handling, naming conventions, docstrings, and resource management. Based on the Google Python Style Guide.
Primary reference: Google Python Style Guide.
Quick Reference
Golden Rule: Be consistent. Optimize for readability, not cleverness.
Do (✅):
- Run
pylintand a type checker (pytypeormypy) on all code - Use 4-space indentation; never tabs
- Keep lines ≤ 80 characters; use implicit continuation inside
(),[],{} - Annotate all public APIs with type hints; prefer
X | NoneoverOptional[X] - Use
"""triple-double-quote"""for all docstrings - Use f-strings for string formatting; avoid
+concatenation in loops - Use
withstatements for all file/socket/resource management - Use default iterators (
for key in dict:) over explicit method calls - Keep functions focused; aim for ≤ 40 lines
- Guard executables with
if __name__ == '__main__':
Don't (❌):
- Use mutable default arguments (
def f(x=[])): useNonesentinel instead - Use bare
except:or catchException/BaseExceptionwithout re-raising - Use
assertfor application logic: only for tests or truly optional checks - Use mutable global state: prefer dependency injection or module constants
- Use
__double_leading_underscore__dunder names for your own identifiers - Use
staticmethodunless forced by an existing API: use module-level functions - Use
map()/filter()withlambda: prefer generator expressions - Use backslash
\for line continuation: use implicit joining inside brackets - Include type names in variable names (
id_to_name_dict) - Use
typing.Text,typing.List,typing.Dict, etc. in new code: use built-ins
Key commands:
pylint --rcfile=.pylintrc <file> # lint check
pytype . # type check (Google's tool)
mypy . # type check (community standard)
black . # auto-format (or pyink for Google style)
isort . # sort imports
python -m pytest # run testsTooling & Lint
- pylint: Run on all code; suppress only with symbolic names and a comment explaining why. Prefer
pylint: disable=<name>over disabling by ID. - Auto-formatter: Use Black or Pyink to avoid formatting debates. Black is opinionated and largely compatible with this style guide.
- Type checker: Use
pytype(Google) ormypy; enable in CI. - Import sorting: Use
isortwith Black-compatible settings.
Keep suppressions rare and always explain them inline.
Imports
- Use
import xfor packages and modules;from x import ywhereyis a module. - Use
from x import y as zonly whenyis ambiguous, conflicts, or inconveniently long. - Use
import y as zonly whenzis a standard abbreviation (import numpy as np). - Always use the full package name: no relative imports.
- Exemptions:
typing,collections.abc,typing_extensions: import symbols directly.
Prefer explicit absolute imports; avoid relative imports in shared code.
Import Order
Group imports from most generic to least generic, separated by blank lines:
from __future__ import ...- Standard library
- Third-party packages
- Internal / repository sub-packages
Within each group, sort lexicographically by full package path.
Use stable import grouping: __future__, stdlib, third-party, internal.
Formatting
Line Length
Max 80 characters. Use implicit line continuation inside (), [], {}. Never use backslash \ for continuation (except inside string literals).
Indentation
- 4 spaces per level; never tabs.
- Align continuation with the opening delimiter, or use a 4-space hanging indent with nothing on the first line.
Trailing Commas
Use trailing commas when the closing bracket is on its own line. This signals Black/Pyink to keep items one-per-line.
Whitespace
- No spaces inside brackets:
spam(ham[1], {'eggs': 2})notspam( ham[ 1 ] ). - No space before a comma, semicolon, or colon.
- No space before
(starting an argument list or indexing. - No trailing whitespace.
- Spaces around
=for annotated defaults:def f(x: int = 0): but not for unannotated:def f(x=0). - Do not vertically align tokens across lines.
Semicolons
Never use semicolons to terminate lines or put two statements on one line.
Parentheses
Use sparingly. Don't wrap return or conditional expressions in unnecessary parentheses.
Blank Lines
- 2 blank lines between top-level definitions (functions, classes).
- 1 blank line between methods and between a class docstring and the first method.
- No blank line immediately after a
defline.
Comments & Docstrings
Docstring Format
Always use """triple-double-quotes""". The summary line must be ≤ 80 characters and end with a period, ?, or !. If more is needed, follow with a blank line then the body.
Module Docstrings
Every file should have a license header and a module docstring describing contents and usage.
Function & Method Docstrings
Required for all public functions. Use sections: Args, Returns, Yields (for generators), Raises.
Keep docstring examples concise; prefer one compact example over long narrative samples.
- Use
Yields:instead ofReturns:for generator functions. - Overriding methods may use
"""See base class."""if behavior is unchanged.
Class Docstrings
Place below the class line. Describe what the class instance represents. Document public attributes in an Attributes: section (same format as Args:).
Block & Inline Comments
- Start with
#(at least one space after#). - Inline comments: at least 2 spaces from code.
- Comment the why, not the what. Don't describe what the code obviously does.
- Use proper capitalization and punctuation.
Prefer comments that explain intent/trade-offs, not mechanical behavior.
TODO Comments
# TODO: crbug.com/192795 - Investigate cpufreq optimizations.Include a bug/issue reference, not a personal name.
Naming
| Type | Public | Internal |
| Packages | lower_with_under | |
| Modules | lower_with_under | _lower_with_under |
| Classes | CapWords | _CapWords |
| Exceptions | CapWords | |
| Functions/Methods | lower_with_under() | _lower_with_under() |
| Constants (Global/Class) | CAPS_WITH_UNDER | _CAPS_WITH_UNDER |
| Global/Class Variables | lower_with_under | _lower_with_under |
| Instance Variables | lower_with_under | _lower_with_under (protected) |
| Parameters | lower_with_under | |
| Local Variables | lower_with_under |
Names to Avoid
- Single-character names outside common local conventions
- Dashes in module/package names (use underscores)
__double_leading_and_trailing_underscore__for custom symbols- Names that encode type (
id_to_name_dict)
Naming Conventions
- Use a single leading
_for internal/protected module attributes, functions, and class members. Avoid__double_underscore(name mangling hurts testability). - File names must use
.pyextension; never use dashes. CapWordsfor classes;lower_with_under.pyfor module files.- Exception names end in
Errorand should not repeat their module:foo.Errornotfoo.FooError.
Type Annotations
General Rules
- Annotate all public APIs (function signatures, class attributes).
- Use
X | None(3.10+) overOptional[X]; always be explicit: no implicitNonedefaults. - Do not annotate
selforcls(except when usingSelffor return types). - Use
Anywhen a type truly cannot be expressed; preferTypeVarfor generic functions. - Import symbols from
typingandcollections.abcdirectly.
Prefer concise type-hint examples and avoid verbose templates.
Prefer Abstract Types in Signatures
Accept abstract container types from collections.abc in parameters; return concrete types.
NoneType / Optional
Use explicit X | None unions; avoid implicit-optional defaults.
Type Aliases
Use TypeAlias for complex reusable types; name with CapWords.
Generics
Always specify type parameters; never leave generics bare.
Forward Declarations
Use from __future__ import annotations or string literals for forward references.
Conditional Imports (TYPE_CHECKING)
Use TYPE_CHECKING blocks for type-only imports.
TypeVar Naming
Descriptive names unless the variable is unconstrained and private.
Language Features
Exceptions
Prefer specific exceptions and small try blocks; never silently catch broad exceptions.
- Never use
assertfor application logic: only in tests or as truly optional checks. - Custom exception names end in
Error; don't repeat the module name. - Use
finallyfor cleanup regardless of exception outcome.
Mutable Default Arguments
Never use mutable default arguments; use None sentinels or immutable defaults.
Comprehensions & Generators
Allowed for simple cases. No multiple for clauses or complex filter chains. Optimize for readability.
Use comprehensions for simple transforms; switch to explicit loops when readability drops.
Default Iterators
Prefer default iterators over methods that return lists or explicit key/value access.
True/False Evaluations
Prefer implicit boolean evaluation. Use is None / is not None for None checks.
Strings
- Prefer f-strings for formatting;
%operator or.format()are also acceptable. - Stay consistent with quote style (
'or") within a file. - Use
"""for multi-line strings; avoid manual+concatenation across lines. - Don't use
+to build strings in loops: use a list and''.join().
Prefer f-strings and ''.join() for loop-based string building.
Logging
Pass a pattern string and arguments separately to loggers: never an f-string as the first argument.
Files & Resources
Always use with statements for files, sockets, and similar resources.
Properties
Use @property for simple attribute access with light computation. Don't use for pure get/set with no logic: make the attribute public instead. Don't use for expensive operations.
Decorators
Use judiciously. Write unit tests for decorators. Avoid external dependencies (file/network/DB) in decorator code: it runs at import time.
- Avoid
@staticmethod: use module-level functions instead. - Use
@classmethodonly for named constructors or class-specific routines.
Lambda Functions
Acceptable for one-liners. For multi-line or >60–80 char lambdas, use a named nested function. Prefer operator.mul over lambda x, y: x * y.
Threading
Don't rely on the atomicity of built-in types. Use queue.Queue for inter-thread communication. Use threading.Condition over raw locks.
Power Features
Avoid: custom metaclasses, bytecode access, on-the-fly compilation, __del__, heavy getattr() reflection, dynamic inheritance. Standard library uses (e.g., abc.ABCMeta, dataclasses, enum) are fine.
Mutable Global State
Avoid. If necessary, declare at module level with a leading _ and provide access via functions. Module-level constants are fine and encouraged (MAX_SIZE = 100, _INTERNAL_LIMIT = 50).
Functions
Function Length
Aim for ≤ 40 lines. If a function exceeds this, consider decomposing it. Long functions are harder to understand, test, and modify safely.
Main Guard
Every executable file must guard its main logic:
def main() -> None:
...
if __name__ == '__main__':
main()For absl-based tools:
from absl import app
def main(argv: Sequence[str]) -> None:
...
if __name__ == '__main__':
app.run(main)Getters & Setters
Use getter/setter functions only when getting or setting involves meaningful computation or side effects. For simple attribute access, use a public attribute or @property instead.
Follow naming: get_foo(), set_foo(): or @property for simple computed attributes.
Checklist
When Writing Code
- All public functions/methods have docstrings with
Args/Returns/Raises - Type annotations on all public APIs; explicit
X | Nonefor optional types - No mutable default arguments
- No bare
except:or silentexcept Exception - Resources managed with
withstatements - No
+string concatenation in loops - Imports ordered:
__future__→ stdlib → third-party → internal - No relative imports
if __name__ == '__main__':guard on executables- Logging uses
%pattern strings, not f-strings
When Reviewing Code
- Naming follows conventions (snake_case functions/vars, CapWords classes, CAPS_WITH_UNDER constants)
- No type names encoded in variable names
- Functions ≤ ~40 lines; focused and testable
- No mutable global state (constants are fine)
- No
staticmethodwithout compelling reason - Type annotations are specific (no bare
Sequencewithout type parameter) - Exception classes end in
Error; noassertfor application logic
Skill Loading Triggers
| Situation | Also load |
| Writing or reviewing Python tests | standards-testing |
| Auth, secrets, user input, crypto | standards-security |
| Implementing features/fixes (TDD) | role-developer |
| Python API/package/service design | role-architect |
| Python PR review | role-code-review |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

