TsukiNi22/ai-utils / skills/python/python-class
python-class
UnverifiedScaffold Python files and class architectures in Tsukini's style - the Python equivalent of cpp-class - class (one per file, attributes with their defaults in __init__), abstract class (abc, abstract methods), tool (one function per file, MAGIC tool/), module of free functions, exception (subclass of the project error with its code), const category (frozen dataclass + instance), pytest test file, with the Xartania header, the
Python files in Tsukini's style
SKILL_DIR = the directory of this file. Load python-style (code) and python-comments (comments) first; a project
layout comes from python-project. Generator (--help for every option):
python3 SKILL_DIR/scripts/new_file.py <kind> <Name> --dir <folder> [--desc "..."] [--base Parent] \
[--attributes "name: type = default # comment; ..."] [--methods "name(params) -> type # what it does; ..."] \
[--relative] [--export] [--banner xartania|none|<text>]
Architecture only: never write the logic of a function. Every body is
pass(no return value), the smallest return of its type (return 0,"",False,[],{},NoneforX | None),...(abstract method) orraise NotImplementedError(any other type), even if the user describes the behavior: the description goes in the docstring of a public method or the trailing comment of thedef. The user writes the logic. Allowed: attributes with their defaults in__init__,super().__init__(), the constants of aconst.pycategory.
1. Understand the request
| Kind | File | Content |
|---|---|---|
class | <folder>/<snake_name>.py (Class/ of an application, src/<pkg>/ of a package) | class PascalCase, docstring, __init__ with the typed attributes (self._x: int = 0 # meaning), the methods |
abstract | same | class X(ABC) + @abstractmethod methods with ... (the I / A of cpp-class: the interface of a family) |
tool | tool/<function>.py (MAGIC) | one function named like the file under ##### Program ##### |
module | <folder>/<name>.py | free functions under ##### Tools ##### |
exception | appended to exception.py | class XError(ProjectError) with its ERROR.* code |
const | appended to const.py | a frozen dataclass category + its instance in ##### Declaration ##### (aligned) |
test | tests/test_<name>.py | one test_<function> per listed name (bodies written with tests / pytest) |
--relative: file of a package (from .const import ..., no__main__guard); without it: application / script (from const import ..., checked imports,if __name__ == "__main__"guard: the module can only be imported).--base: parent class; imported automatically when it is in the same folder, else add the import by hand.--export: adds the class to__all__and the imports of the package__init__.py(public API).- Types used in a signature that are not builtins (another class of the project) are imported by hand in the
# Import that can be checkedblock with their# Used forcomment.
2. Decide before generating
- Names:
snake_casefile / function / method / attribute,PascalCaseclass,_namefor the private ones (methods only used by the class, attributes not part of its API),UPPER_SNAKEconstants. One class per file. - Where: application (MAGIC)
src/Class/,src/tool/, feature folders (src/window_build/); packagesrc/<pkg>/with sub-packages per concern. Show the tree in the AskUserQuestion when a place is ambiguous. - Signatures fully typed (
-> Noneincluded), defaults on the parameters of a mode (failsafe: bool = False).
3. After
xstyle --rtk <files> (python-style rules), python3 -c "import <module>" (or PYTHONPATH=src for a package) to check that
the skeleton imports; tests created with --kind test are filled with the tests skill.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the work | Stars: 318k | Updated | Claude CodeCodex | Unverified | Install |
| systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes | Stars: 318k | Updated | Claude CodeCodex | Unverified | Install |
| test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation code | Stars: 318k | Updated | Claude CodeCodex | Unverified | Install |
| skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |