SKILL.md
Python Coding Standards (PEP 8)
When reviewing or generating Python code, follow these rules:
File Naming
- Source files: Use snakecase (e.g.,
userservice.py,api_client.py) - Package directories: Use snakecase (e.g.,
dataprocessing/,utils/) - Test files: Use
testprefix (e.g.,testuser_service.py) - Config files: Use snakecase (e.g.,
configsettings.py)
Variable Naming
- Variables: snakecase (e.g.,
username,isactive,totalcount) - Constants: UPPERSNAKECASE (e.g.,
MAXRETRIES,APIBASE_URL) - Boolean variables: Prefix with
is,has,can,should(e.g.,isloading,haserror) - Protected variables: Single underscore prefix (e.g.,
internaldata) - Private variables: Double underscore prefix (e.g.,
__private_data)
Function Naming
- Functions: snakecase (e.g.,
calculatetotal(),fetchuserdata()) - Private functions: Prefix with underscore (e.g.,
validateinput(),processdata()) - Dunder methods: Double underscores (e.g.,
init,str,repr)
Class Naming
- Classes: PascalCase (e.g.,
UserService,DataProcessor,ApiClient) - Exception classes: PascalCase with
ErrororExceptionsuffix (e.g.,ValidationError) - Abstract classes: PascalCase, optionally prefix with
BaseorAbstract(e.g.,BaseHandler)
Method Naming
- Instance methods: snakecase (e.g.,
getuser(),process_data()) - Class methods: snake_case with
@classmethoddecorator - Static methods: snake_case with
@staticmethoddecorator - Properties: snake_case with
@propertydecorator
Module Organization
- Imports at the top: standard library, third-party, local imports (separated by blank lines)
- Module-level dunder names after imports (
all,version) - One class per file for large classes; multiple related classes okay for small ones
- Use
allto define public API