# Pythonic Code

Write, refactor, and review Python for clarity, explicit behavior, local reasoning...

- Repository: https://github.com/basicmachines-co/basic-memory (4440 stars)
- Category: Writing
- License: AGPL-3.0
- Last updated: 2026-11-01
- Runs scripts: yes, review before use

## Install

Claude Code: `npx skills add basicmachines-co/basic-memory --skill pythonic-code -g -a claude-code -y`
Codex: `npx skills add basicmachines-co/basic-memory --skill pythonic-code -g -a codex -y`
Cursor: `npx skills add basicmachines-co/basic-memory --skill pythonic-code -g -a cursor -y`
Gemini CLI: `npx skills add basicmachines-co/basic-memory --skill pythonic-code -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add basicmachines-co/basic-memory`

## Description

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.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

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

The rest: https://github.com/basicmachines-co/basic-memory/blob/HEAD/.agents/skills/pythonic-code/SKILL.md
