pythonic-code
БесплатноЗапускает вложенные скриптыНе проверенWrite, refactor, and review Python for clarity, explicit behavior, local reasoning, strong types, constructive domain modeling, and minimal abstraction. Use…
от basicmachines-co★ 4 799 звёзд на GitHubОб этом скилле
Pythonic Code
Write Python that makes domain behavior obvious to human and AI readers. Apply a WWGD lens: choose the simplest correct design that feels native to Python and is easy to verify.
The preferred design method is Constructive Domain Modeling: define the valid values and outcomes a program can construct, then let their types carry obligations to the code that consumes them.
Orient Before Coding
- Read the repository's
AGENTS.mdorCLAUDE.mdinstructions. - Read
docs/ENGINEERING_STYLE.mdwhen present. - Read
docs/DOMAIN_MODEL.mdwhen the change touches domain language, ownership, identity, source-of-truth rules, or lifecycle behavior. - Read each target file completely before editing it.
- Identify the supported Python version, configured tools, surrounding patterns, and behavior that must remain stable.
Let local project rules override generic style advice.
Make Decisions In This Order
- Preserve correctness, domain invariants, and public behavior.
- Respect repository conventions and compatibility constraints.
- Make data flow, control flow, errors, and side effects obvious.
- Choose the smallest abstraction that reduces cognitive load now.
- Use Python idioms when they clarify intent rather than merely shorten code.
- Prove the result with types, tests, and repository tooling.
Model The Positive Space
Constructive Domain Modeling describes what the program supports instead of starting with a broad representation and a growing list of invalid combinations.
- Represent one valid state with a product of required fields, usually a frozen dataclass.
- Represent meaningful alternatives with a closed union using a Python 3.12
typealias. - Use Pydantic models and discriminated unions at API, CLI, MCP, configuration, and persistence boundaries where untrusted values require runtime validation or serialization.
- Parse or classify a broad boundary shape once, then pass the narrower domain value internally. Do not make every consumer rediscover the invariant through checks and casts.
- Consume a closed union with explicit
matchcases. Usetyping.assert_neverwhen it proves exhaustive handling, and avoid catch-all cases that hide a newly added variant. - Prefer a total function over a partial one. When a case is expected, either narrow the input so the case is impossible or widen the return union so the caller must handle it.
- Return explicit variants for recoverable domain outcomes when callers can respond differently. Keep exceptions for broken invariants, cancellation, and unpredictable filesystem, network, queue, or database failures.
- Choose the simplest model that rules out a real error. Do not add wrapper-only IDs, Result types around every operation, or maximum-precision unions that cost more than they clarify.
Before narrowing an ORM model or compatibility schema, trace its writers and serialized forms. Storage may remain broad while a parser constructs a safer domain value for the core workflow.
Prefer Functions Before Hierarchies
- Start with an ordinary, fully typed function.
- Pair functions with a dataclass when related state or an operation result needs a name.
- Use callbacks, closures, or
functools.partialwhen binding behavior is clearer than creating another object. - Use
functools.singledispatchonly when behavior genuinely varies by the first argument's runtime type and open registration is an intentional extension point. - Use a narrow
Protocolfor genuine replaceable behavior. Do not use property-only protocols to describe internal result data; return a concrete frozen dataclass unless callers truly require structural interoperability. - Use a concrete class when identity, cohesive mutable state, lifecycle, or resource ownership requires one.
- Use an abstract base class only when runtime-enforced subclassing or shared skeletal behavior is part of the current design.
Do not replace one class hierarchy with clever functional machinery. Prefer the form with the fewest concepts, hidden rules, and call hops.
Keep Reasoning Local
- Keep a straightforward workflow together when top-to-bottom reading is clearest.
- Extract a helper only when its name captures a domain operation, it isolates a side effect or constraint, it removes meaningful duplication, or it forms a cohesive testable computation.
- Do not extract helpers merely to shorten a function.
- Treat a class dominated by private methods as a signal that behavior may belong in explicit module-level functions operating on typed values.
- Treat long chains of
_prepare_*,_resolve_*,_apply_*, and_build_*calls as a prompt to reconsider the data flow or name one meaningful phase object. - Avoid manager, factory, base, adapter, strategy, and registry abstractions with only one real implementation.
- Avoid dynamic registration, metaprogramming, and decorator-driven control flow unless the product currently needs that ex
Установить pythonic-code в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл pythonic-code?
Write, refactor, and review Python for clarity, explicit behavior, local reasoning, strong types, constructive domain modeling, and minimal abstraction. Use when creating or changing nontrivial Python, simplifying object-heavy, helper-heavy, or overly procedural code, evaluating whether code is Pythonic, or reviewing Python maintainability in Basic Memory repositories.
Как установить скилл pythonic-code?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл pythonic-code запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic