maintainable-python
БесплатноБез исполняемых скриптовНе проверенUse when writing, refactoring, or reviewing Python code, especially data models, type annotations, input validation, and module design.
от devon-systems★ 250 звёзд на GitHubОб этом скилле
Write maintainable Python
Follow the project's supported Python version, dependencies, and tools.
Reuse existing definitions first
Before adding a type, model, validator, or parser, search by concept, field names, and constraints.
Check shared modules and nearby callers. Read candidate definitions and their validation rules.
Reuse the smallest matching definition, such as an Annotated constraint, enum, value type, or parser.
Share those definitions even when input, domain, persistence, and response models need separate contracts.
Reuse a whole model only when its meaning and rules should change together for all callers.
Similar field names alone do not justify sharing a model.
Write typed functions and models
Annotate all function and method parameters, return values, and model fields, including helpers and -> None.
Specify collection element types and possible None results. Let precise local types use inference.
Validate or narrow Any from integrations before application code uses it.
Use object for unknown values that require inspection before use.
Use built-in collection types, T | None, and generic syntax supported by the project.
Accept Iterable[T], Sequence[T], or Mapping[K, V] when those operations suffice.
Return concrete collections when callers need complete, reusable results.
Use type parameters to preserve input-output relationships, and Protocol for shared required operations.
For decorators, preserve signatures with ParamSpec and a return type parameter, and metadata with functools.wraps.
Fix type errors where they originate. Avoid broad unions that hide incompatible caller expectations. Keep casts and suppressions narrow and explain their assumptions. Annotations, aliases, and casts do not validate runtime values, including dataclass fields.
Choose types that express the data
- Use dataclasses for named records, or
NamedTuplewhen tuple compatibility matters. Use plain classes when behavior or resource management dominates the fields. - Use
Literal["json", "csv"]for fixed choices of ordinary strings. Name reused unions with a type alias. - Use enums for named runtime members, iteration, or lookup by value.
Choose
StrEnumfor string interoperability and plainEnumfor distinct domain members. Define stored or transmitted values explicitly rather than withauto(). - Use unions of records when alternatives require different fields.
Narrow variants with
isinstanceor literal discriminator fields, and check exhaustive handling. - Use the project's validation approach. Choose Pydantic when runtime input validation or schema generation justifies it. Do not add it merely to serialize a simple internal record.
- Use
TypedDictfor fixed dictionary shapes and ordinary dictionaries when keys are data. - Use value types or
NewTypewhen they prevent meaningful mistakes, such as swapping unrelated IDs. - Give
Noneone meaning per API. Distinguish omitted updates from explicit clears with a sentinel or separate alternatives.
Avoid a class for every string or a state union when one optional field expresses the requirement. Read the relevant section of type-choice examples for concrete bad and good cases. Adapt their Python 3.12 syntax to the project's version.
Configure dataclasses deliberately
- Prefer
frozen=Truefor stable values and snapshots. Freezing is shallow, so use immutable contents when needed. - Use
kw_only=Truewhen positional arguments would be easy to confuse. - Use
slots=Truewhen memory savings or attribute restrictions help. Check for dependencies on instance__dict__. - Use
field(default_factory=...)for per-instance mutable defaults. - Keep field-based equality for values. Use
eq=Falseto retain inherited equality, usually object identity. Implement equality by domain ID explicitly when needed. Changes to hashed fields can break set and dictionary lookups. Avoidunsafe_hash=Trueas a workaround for mutable records. - Put value checks and relationships between fields in
__post_init__. - Compute derived values with properties. Store historical values when recalculation would change their meaning.
Validate external input with Pydantic v2
Use built-in field types and Annotated with Field constraints before custom validators.
Use field validators for individual values and model validators for relationships between fields.
Choose validation policies explicitly:
- Use strict validation when accepting another type would hide a mistake. Allow conversion when the format requires it. Check the relevant types because strict Python and JSON validation can differ.
- Use
extra="forbid"when unknown or misspelled fields should fail. - Distinguish nullable fields from defaults.
T | Nonealone does not make a field optional to supply. - Use
TypeAdapterto validate existing types or collections without another model. - Use discriminated unions when parsing tagged va
Установить maintainable-python в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл maintainable-python?
Use when writing, refactoring, or reviewing Python code, especially data models, type annotations, input validation, and module design.
Как установить скилл maintainable-python?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл maintainable-python запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create 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…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic