Agent skill

Pythonic Code

by basicmachines-co in basicmachines-co/basic-memory

Write, refactor, and review Python for clarity, explicit behavior, local reasoning, strong types, constructive domain modeling, and minimal abstraction.

AGPL-3.0Auto-check passedDevelopment

Install Pythonic Code

skills CLI
$ npx skills add basicmachines-co/basic-memory --skill pythonic-code -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install basicmachines-co/basic-memory pythonic-code --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/basicmachines-co/basic-memory.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/pythonic-code .claude/skills/pythonic-code && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
pythonic-code
GitHub stars
4.1k
Token cost
~2.1k tokens
SKILL.md length
1,102 words
Files
12 (incl. scripts)
Skills in repo
49
Repo updated
First seen
Licence
AGPL-3.0

At a glance

Write, refactor, and review Python for clarity, explicit behavior, local reasoning, strong types, constructive domain modeling, and minimal abstraction.

  • Works in 5 steps: Read the repository's AGENTS.md or… → Read docs/ENGINEERING_STYLE.md when… → Read docs/DOMAIN_MODEL.md when the… → …
  • Changing nontrivial Python
  • SKILL.md covers Orient Before Coding, Make Decisions In This Order, Model The Positive Space and Prefer Functions Before…, plus 4 more sections
  • Runs Python scripts from its folder

What it does

Pythonic Code is an agent skill from basicmachines-co/basic-memory. 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.

Its SKILL.md is about 2.1k tokens, which your agent loads only when the skill is triggered. The skill folder holds 16 other files, including scripts (for example `agents/openai.yaml`, `evals/context/AGENTS.md` and `evals/evals.json`).

It sits in Development, covering Domain-driven design and Refactoring. It works with Python. The repository describes itself as: AI conversations that actually remember. Never re-explain your project to your AI again. Join our Discord: https://discord.gg/tyvKNccgqN. The licence is AGPL-3.0.

When your agent uses it

  • Changing nontrivial Python
  • Simplifying object-heavy
  • Overly procedural code
  • Evaluating whether code is Pythonic

Example prompts

  • “/pythonic-code”

Requirements

  • Python 3

Workflow steps

5 steps, taken from the first numbered list in SKILL.md.

  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,
  4. Read each target file completely before editing it.
  5. Identify the supported Python version, configured tools, surrounding patterns, and behavior

What it can do on your machine

Read from SKILL.md and the folder at commit 6982cfc. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 1 file in scripts/ (Python), which the agent can run.

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Pythonic Code loads about 2.1k tokens when it runs. Until then it costs about 96 tokens; SKILL.md has 1,102 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~96
When it runs · the whole SKILL.md, loaded when a task matches
~2.1k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from basicmachines-co/basic-memory at commit 6982cfc, republished under its AGPL-3.0 licence (© basicmachines-co). 1,102 words, ~2,063 tokens.

Download SKILL.mdSave it as .claude/skills/pythonic-code/SKILL.md (or your agent's skills folder). This skill also uses 11 other files; get the full folder from GitHub.
name
pythonic-code
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.

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.

  • 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 type alias.
  • 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 match cases. Use typing.assert_never when 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.partial when binding behavior is clearer than creating another object.
  • Use functools.singledispatch only when behavior genuinely varies by the first argument's runtime type and open registration is an intentional extension point.
  • Use a narrow Protocol for 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 extension mechanism.

If extracting a helper makes the reader navigate more but understand no less, keep the logic local.

Show full SKILL.md (375 more words)Show less

Write Explicit Python

  • Name values after the domain concept they carry.
  • Use full annotations and narrow types. Do not hide uncertainty with Any, broad casts, speculative getattr, or unstructured dictionaries.
  • Use frozen dataclasses for internal domain values and Pydantic at validation and serialization boundaries. A Pydantic model is not automatically the best internal state representation.
  • Prefer direct iteration, context managers, standard-library building blocks, and simple comprehensions where their meaning is immediate.
  • Distinguish absence from falsiness; use truth-value testing only when empty values share the intended meaning.
  • Keep async work, resource ownership, cancellation, and cleanup visible.
  • Fail fast with specific errors when an invariant or external operation fails. Do not use exceptions for ordinary domain branching, or add silent fallbacks and broad exception handling.
  • Comment decisions and constraints, not mechanics.
  • Optimize measured hot paths; do not trade readability for hypothetical performance.

Match The Requested Mode

Write

Establish the valid states, outcomes, and boundary parser first. Implement the direct path, make closed variants exhaustive, then add only the abstractions required by real variation, state, or boundaries.

Refactor

Preserve observable behavior, keep the diff focused, and add or update a regression test when the behavior is risky. Look for status strings coupled to optional fields, repeated validation, "should never happen" branches, and expected outcomes carried by exceptions. Replace them only when a smaller constructive model removes a real unsupported state. Do not mechanically rewrite already-clear code, convert I/O failures to Result types, or reshape persisted data before tracing its writers.

Review

Report concrete readability, abstraction, typing, lifecycle, and domain-model risks. Explain the smallest practical improvement. Ask which invalid state or unhandled obligation a proposed type actually removes; stronger-looking types without a concrete payoff are not an improvement. Do not edit unless the user asks for fixes.

Verify The Result

Run the narrowest command that proves the change, then widen according to risk:

  1. Focused tests for the changed behavior.
  2. Formatter, linter, and type checker configured by the project. Use the type checker to prove exhaustive consumers where the domain is a closed union.
  3. Repository health, package, integration, or full gates when boundaries are affected.

Lead the final response with the outcome and verification. Explain design choices only when they are non-obvious or materially affect future work.

© basicmachines-co, AGPL-3.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 11 other files (scripts) in .agents/skills/pythonic-code of basicmachines-co/basic-memory.

  • SKILL.md
  • agents/openai.yaml
  • evals/context/AGENTS.md
  • evals/context/pyproject.toml
  • evals/evals.json
  • evals/files/accepted_preparation.py
  • evals/files/accepted_snapshot.py
  • evals/files/shared_runtime_ownership.md
  • evals/files/test_accepted_preparation.py
  • evals/files/test_accepted_snapshot.py
  • justfile
  • scripts/run_evals.py

Open the folder on GitHubat commit 6982cfc

Compare with similar skills

Pythonic Code next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Pythonic Code compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Pythonic Code this skillbasicmachines-co/basic-memory4.1k—~2.1kAutomated safety check: PassAGPL-3.0
Dignified Python Standardsdocling-project/docling68k—~1.5kAutomated safety check: PassApache-2.0
Readable Pycrazyguitar/pysheeet8.2k—~2.4kAutomated safety check: PassMIT
Nexus MapperHaaaiawd/Nexus-skills1661 repos~2.5kAutomated safety check: NotesNone
Refactor OpCVCUDA/CV-CUDA2.7k—~1.5kAutomated safety check: PassCustom licence
Readable Verilog GeneratorEriemon/verilog-generator308—~5.4kAutomated safety check: PassApache-2.0

Similar skills

  • Dignified Python Standards

    docling-project/docling

    Applies opinionated production Python conventions chosen by the project's Python version: modern type syntax, pathlib, explicit checks and interface guidance.

    68k GitHub stars~1.5k tokensUpdated today
    DevelopmentAuto-check passed
  • Readable Py

    crazyguitar/pysheeet

    Readable Python code rules inspired by The Art of Readable Code.

    8.2k GitHub stars~2.4k tokensUpdated today
    DevelopmentAuto-check passed
  • Nexus Mapper

    Haaaiawd/Nexus-skills

    Generate a persistent .nexus-map/ knowledge base that lets any AI session instantly understand a codebase's architecture, systems, dependencies, and change hotspots.

    166 GitHub starsUsed in 1 repo~2.5k tokens
    DevelopmentAuto-check: notes
  • Refactor Op

    CVCUDA/CV-CUDA

    Find and safely apply per-operator refactoring / redundancy-reduction opportunities in a CV-CUDA operator (near-duplicate Tensor/VarShape kernels, reinvented shared utilities, dead code).

    2.7k GitHub stars~1.5k tokensUpdated 20 days ago
    DevelopmentAuto-check passed
  • Readable Verilog Generator

    Eriemon/verilog-generator

    A skill your agent uses when creating, writing, reviewing, annotating, repairing, refactoring, or validating readable Verilog RTL, including synthesizable Verilog-2001 .v files, existing-RTL…

    308 GitHub stars~5.4k tokensUpdated 1 mo ago
    DevelopmentAuto-check passed
  • Python Design

    mindfold-ai/Trellis

    Python design patterns for CLI scripts and utilities — type-first development, deep modules, complexity management, and red flags.

    15k GitHub stars~4k tokensUpdated 8 days ago
    DevelopmentAuto-check passed

More from basicmachines-co/basic-memory

All 49 skills in this repo
  • cmux Settings Editor

    basicmachines-co/basic-memory

    Views, sets, unsets and validates cmux settings in ~/.config/cmux/cmux.json with a helper script that checks keys against the schema.

    4.1k GitHub starsUsed in 1 repo~1.3k tokens
    Auto-check passed
  • cmux Window and Pane Control

    basicmachines-co/basic-memory

    End-user control of cmux topology and routing (windows, workspaces, panes/surfaces, focus, moves, reorder, identify, trigger flash). Use when automation needs…

    4.1k GitHub starsUsed in 2 repos~842 tokens
    Auto-check passed
  • Cmux Markdown Viewer Panel

    basicmachines-co/basic-memory

    Opens markdown files in a formatted cmux panel beside the terminal that re-renders on every change, handy for plans and task lists.

    4.1k GitHub starsUsed in 2 repos~527 tokens
    Auto-check passed
  • cmux Workspace Scoping

    basicmachines-co/basic-memory

    Keeps agent actions scoped to the cmux workspace and terminal that invoked it, and lays out pane and surface commands that avoid disrupting the user's own focus.

    4.1k GitHub starsUsed in 2 repos~1.7k tokens
    Auto-check passed
  • Basic Memory Repo Images

    basicmachines-co/basic-memory

    Produces PR, changelog and two-week retro images for the Basic Memory repository from evidence in PR bodies, saved to fixed paths under docs/assets/infographics.

    4.1k GitHub stars~2.7k tokensUpdated today
    Auto-check passed
  • Logfire Instrumentation

    basicmachines-co/basic-memory

    Adds Pydantic Logfire tracing, logging and metrics to Python, JavaScript or TypeScript and Rust projects, with the correct setup order and library extras.

    4.1k GitHub stars~2.3k tokensUpdated today
    Auto-check passed

Works with

Categories

Questions about Pythonic Code

What does Pythonic Code do?

Write, refactor, and review Python for clarity, explicit behavior, local reasoning, strong types, constructive domain modeling, and minimal abstraction. Pythonic Code is an agent skill from basicmachines-co/basic-memory. Write, refactor, and review Python for clarity, explicit behavior, local reasoning, strong types, constructive domain modeling, and minimal abstraction.

When should I use Pythonic Code?

Pythonic Code fits situations like: changing nontrivial Python; simplifying object-heavy; overly procedural code; evaluating whether code is Pythonic.

How do I install Pythonic Code in Claude Code?

Run `npx skills add basicmachines-co/basic-memory --skill pythonic-code -a claude-code`. Or copy the skill folder (.agents/skills/pythonic-code in basicmachines-co/basic-memory) into .claude/skills/pythonic-code in your project. Claude Code loads it when a task matches its description.

How do I install Pythonic Code in Codex?

Run `npx skills add basicmachines-co/basic-memory --skill pythonic-code -a codex`. Or copy the skill folder (.agents/skills/pythonic-code in basicmachines-co/basic-memory) into .agents/skills/pythonic-code in your project. Codex loads it when a task matches its description.

Can I use Pythonic Code in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add basicmachines-co/basic-memory --skill pythonic-code -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/pythonic-code, .gemini/skills/pythonic-code, .github/skills/pythonic-code and .opencode/skills/pythonic-code in your project.

What does Pythonic Code need to run?

Going by SKILL.md and its folder, Pythonic Code needs Python for the scripts in its folder. Our summary lists: Python 3.

Does Pythonic Code access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Pythonic Code safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Pythonic Code use?

Pythonic Code is published under the AGPL-3.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Pythonic Code use?

About 2.1k tokens (SKILL.md is roughly 8.3k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Pythonic Code?

Skills that share tags, products or a category with Pythonic Code: Dignified Python Standards (docling-project/docling, 68k stars), Readable Py (crazyguitar/pysheeet, 8.2k stars), Nexus Mapper (Haaaiawd/Nexus-skills, 166 stars) and Refactor Op (CVCUDA/CV-CUDA, 2.7k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Pythonic Code?

basicmachines-co (a GitHub organization) maintains it in basicmachines-co/basic-memory, which has 4,107 GitHub stars. The repository holds 49 skills in this directory. The repository was last updated on October 7, 2026.

Source: basicmachines-co/basic-memory on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.