/claude-aai:coding-patternsfrom claude-aai
Applies Jeremy's coding style and conventions (fastai style guide) across all projects. Covers naming, layout, imports, TDD with pytest, docments, versioning, and fastcore/fasthtml ecosystem preference. Auto-activates before file read/write/search operations.
Ships in claude-aai. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Based on the fastai style guide and Jeremy's 3 decades of coding experience, and used across all of his projects, not only fastai ones.
Use the fastcore/fasthtml ecosystem (fastcore, fasthtml, fastlite, ...) when picking libraries - these are Jeremy's own, editable-installed as siblings, and preferred over heavier third-party alternatives.
Readers assume everything present is necessary. When they see str(x) on something that's already a str, they stop and wonder what subtle thing it's guarding against; when the answer is "nothing", they paid for a mystery with no payoff. The same goes for defensive copies (list(x) that's never mutated), "just in case" try/excepts, redundant type coercions, and unused parameters. Before adding any construct, know why it's needed; if you can't say, leave it out. The cost doubles in nbdev projects, where tests are documentation.
The same applies to prose in code: almost never add comments (only when the code is truly unclear), and don't add type hints, docstrings, or boilerplate that pull no weight. Prefer concise, readable code over verbose "enterprise" style.
Docments are trailing comments on function parameters that fastcore uses for documentation. A signature with docments (or any long signature) uses this layout: ( stays on the def line, each parameter on its own line indented 4, and ): alone on its own line at def indent:
@delegates(start_kernel)
async def run_kernel(
kernel_name='python3', # Kernelspec name to launch
manager_cls=KernelManager, # Manager class, e.g. a subclass customizing launch
**kwargs
):
NEVER remove docments when refactoring - they're essential documentation.
When **kwargs passes through to a known callee, decorate with @delegates(callee) so the signature shows the real options - and delegates REQUIRES the collector to be named kwargs, not kw etc. Skip the decorator when the callee's own signature is just **kwargs (nothing to delegate).
Write any non-trivial string literal as a raw string (r"..." / r"""..."""): regexes, payload text for tools, code or markup inside strings, anything multi-line or containing backslashes. In plain strings a stray \n or \d either errors or silently corrupts, and each miss costs a round trip to diagnose plus another to fix. Raw strings are WYSIWYG, so the first attempt matches what you meant. The r costs nothing when no escapes are present, so make it the default, not the exception.
Run chkstyle {path} to check fastai style (only include path if needed). But use judgment - chkstyle is a hint, not gospel.
In nbdev projects, point it at the notebooks (chkstyle nbs/00_core.ipynb), not the exported .py: the notebook run also checks example and test cells, which never reach the module.
Read from standard locations rather than duplicating config:
.github/release.ymlpyproject.toml under [tool.yourpkg][project].name)importlib.resourcesVersions are bumped immediately after release, so the tree always carries the next release's version. Hence a sibling dep pin can be written before it ships (foo>=<foo's local version>), releasing means shipping what's there (no suffix machinery, no bump step to forget), and bumping is part of releasing - Jeremy's step, never part of a change.
This convention is for Python projects. Other artifact types version at change time instead: for example, the Claude Code plugins in skill-plugins bump automatically when ./build.py regenerates a changed output.
Prefer flat layout over src/:
myproject/
├── mypkg/
│ └── __init__.py
├── tests/
├── pyproject.toml
└── README.md
All code has writing, maintenance, and readability costs - especially tests: every test must be kept passing forever, gets read by every future contributor, and must be revised whenever the behavior it pins changes. So never write a test as a reflex, and don't aim for anywhere near 100% coverage. A test earns its place only when:
Wiring and orchestration get zero tests: re-exports, delegations, one-line glue, functions that just sequence calls to other tools. A test there only asserts that Python works, and pins down internals we may want to change. Strong tell: if a test needs recording fakes or mock collaborators to reach the code, it's testing a transcript of the implementation, not logic - extract the logic into a small pure function and test that, or don't test at all.
IF you add a test, ALWAYS work red-green: write it FIRST, run it to see it fail, THEN make the change, then run it again to see it pass.
pytest -q (not python -m pytest, which prompts for permission); nbdev projects use nbdev-test (see the nbdev-editing skill)# Conditionals
if not x: return default
if x and y: do_thing()
# Try/except
try: return run("cmd").strip() or default
except Exception: return default
# Loops
for i in range(n): result[i] = 0
while len(items) < 3: items.append(0)
Combine imports on single lines:
import os, re, sys, shutil
from pathlib import Path
from fastcore.utils import *
from fastcore.utils import * already provides os, Path, and much of the stdlib - don't re-import those alongside it.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
coding-style, fastai, fastcore, fasthtml, python-conventions, tdd
Other plugins' skills for the same job
5 skills in this plugin
/claude-code-docsUse when answering questions about current Claude Code behavior, configuration, CLI features, hooks, skills, plugins, sessions, compaction, permissions, or other Claude Code-specific interfaces from official documentation./nbdev-editingWorkflow and gotchas for nbdev projects, where notebooks in nbs/ are the source of truth. TRIGGER — read BEFORE touching code, tests, or docs in ANY nbdev repo (has a [tool.nbdev] section in pyproject.toml): before the first cell edit, not after. Don't edit the autogenerated .py files (projects often also mix in plain hand-written .py modules - check the per-file marker). Routes to the pyskill docs that carry the substance, and holds the nbdev v3 delta and environment specifics. Assumes and pulls in the persistent-python and coding-patterns skills./persistent-pythonThe persistent clikernel Python session — Jeremy's preferred single tool for nearly ALL Python work. TRIGGER — read and bootstrap as step zero of EVERY session where clikernel is available, before the first tool call: even tasks that only read a file or search a directory, plus stateful inspection, editing code or notebooks, debugging, experiments, API probes, data transforms, pyskills discovery, notebook-style work, local tool orchestration. If it could go through Python, it goes here — never python -c, Bash heredocs, or ad hoc scripts./write-proseHow to write prose that doesn't read as AI slop. TRIGGER — read BEFORE writing or editing ANY prose meant for a human to read: READMEs, docs, articles, PR/commit text, emails, announcements, release notes, or comments longer than a line. Not for code. Covers a marked good/sloppy sample pair, the numbered tells they illustrate, banned words, and the em-dash and hard-wrap bans.npx claudepluginhub answerdotai/skill-plugins --plugin claude-aai