Pythonic Code
Write, refactor, and review Python for clarity, explicit behavior, local reasoning...
Install
npx skills add basicmachines-co/basic-memory --skill pythonic-code -g -a claude-code -y- Repository
- basicmachines-co/basic-memory4.4k
- Category
- Writing
- Updated
- 3d ago
- License
- AGPL-3.0
- Context cost
- Mediumabout 1,956 tokens
- Runs scripts
- Yes, review before use
What it does
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
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.
