Skills

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
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

  1. Read the repository's AGENTS.md or CLAUDE.md instructions.
  2. Read docs/ENGINEERING_STYLE.md when present.
  3. Read docs/DOMAIN_MODEL.md when the change touches domain language, ownership, identity, source-of-truth rules, or lifecycle behavior.
  4. Read each target file completely before editing it.
  5. 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

  1. Preserve correctness, domain invariants, and public behavior.
  2. Respect repository conventions and compatibility constraints.
  3. Make data flow, control flow, errors, and side effects obvious.
  4. Choose the smallest abstraction that reduces cognitive load now.
  5. Use Python idioms when they clarify intent rather than merely shorten code.
  6. 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.

Read the whole SKILL.md on GitHub

More in Writing