skills/python-class-and-filename/exports/claude/SKILL.md
Create focused Python classes and choose matching snake_case module filenames when adding or refactoring class-based code.
npx skillsauth add balandongiv/agent-skillbook python-class-and-filenameInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill defines a practical standard for creating Python classes and naming the .py file that contains them. Use it when you are adding a new class, refactoring a generic module into a clearer one, or deciding whether a file should center around a class at all.
The goal is to make Python code easy to find, easy to import, easy to debug, and consistent across the repository. The core rule is simple: the filename should describe the module responsibility, and the class name should describe the object responsibility.
snake_case filenames and PascalCase class namesPair module names and class names predictably.
# file: path_resolver.py
class PathResolver:
pass
If a file contains one important class, name the file after that class converted to snake_case.
Examples:
PathResolver → path_resolver.pyBlinkAnnotationLoader → blink_annotation_loader.pyEARSignalProcessor → ear_signal_processor.pyExperimentConfig → experiment_config.pyAvoid vague filenames like utils.py, helpers.py, common.py, or misc.py when the file really has one clear responsibility.
The safest default is one main class per file, with the filename matching that class concept. This improves IDE navigation, imports, stack traces, and code search.
Small helper dataclasses, enums, or tightly coupled private helpers may live in the same file when they only support the main class.
The filename should tell a reader what the module is for.
ear_data_loader.pypath_resolver.pyblink_signal_processor.pyexperiment_config.pyblink_evaluator.pyChoose names that reflect the real job of the class instead of broad placeholder names.
Use a class when state must be stored across methods, configuration belongs to the object, or multiple related operations act on the same object. Use a function module when the logic is stateless, small, and reusable.
# file: path_utils.py
def normalize_path(path: str) -> str:
...
def ensure_dir(path: str) -> None:
...
A file like this should stay function-oriented unless there is a real object abstraction to model.
Constructors should only receive the dependencies the class needs. If __init__ takes many unrelated arguments, the class may have too many responsibilities.
from pathlib import Path
class EARDataLoader:
def __init__(self, data_root: Path) -> None:
self.data_root = Path(data_root)
When creating or reviewing a Python class and its filename:
PascalCase using a noun or noun phrase that describes the object.snake_case.py filename.A good import should feel obvious:
from src.preprocessing.path_resolver import PathResolver
from src.annotation.blink_annotation_loader import BlinkAnnotationLoader
from src.experiments.experiment_runner import ExperimentRunner
If the import feels awkward or overly generic, rename the file or class.
PascalCase for Python class names.snake_case.py for Python filenames.csv_annotation_loader.py is better than csvloader.py.utils.py, stuff.py, temp.py, common.py. These make search and debugging harder.processing.py that only contains PathResolver is misleading.PathResolver, BlinkEvaluator, and SubjectRouter in one module hides responsibility.earsigproc.py is much harder to read than ear_signal_processor.py.Use this minimal pattern as a default for new class files:
"""Short module description."""
from __future__ import annotations
from pathlib import Path
class PathResolver:
"""Resolve important project paths from a base directory."""
def __init__(self, root_dir: Path) -> None:
self.root_dir = Path(root_dir)
def get_data_dir(self) -> Path:
return self.root_dir / "data"
Suggested filename: path_resolver.py
Before finalizing a class and filename, ask:
tools
One-sentence description of what this skill does and when to use it.
tools
One-sentence description of what this skill does and when to use it.
documentation
Review per-subject performance to identify likely outliers, distinguish bad data from difficult but valid cases, and document whether subject exclusion is justified before any filtered rerun.
documentation
Review per-subject performance to identify likely outliers, distinguish bad data from difficult but valid cases, and document whether subject exclusion is justified before any filtered rerun.