02 — Skills and refactoring
Commandments I and X: automate what repeats; refactor so the code reads like its neighbor.
Skills (slash-commands)
- Build a skill when a procedure repeats (≥3 times), its order is easy to get wrong (Migration (database) — A controlled change to the database layout — adding a column, a table or moving data — step by step. Like a renovation to plan: rebuilding data in a set order so nothing “collapses”. more in the glossary →:
number → SQL — The query language for a database — the way you “ask” the database for data or change it. The universal standard for talking to a database. A badly written query can bog down the whole app. more in the glossary → → apply → AI_README — A map file in every code directory: what’s here, what it’s for and what to watch out for — written for search. The assistant finds the right file with one search instead of reading the whole directory. more in the glossary → → Commit — A saved, labelled point in the project’s history — a confirmation of a specific batch of changes. Small, described commits make a history you can return to any working state from. more in the glossary →), or it carries a project-specific gotcha
(
PYTHONIOENCODING=utf-8on Windows,--runInBandwhile a server runs). - A skill has an output contract (exit 0 = green, otherwise what failed) and prints anything destructive it does.
- A skill is a recipe for the agent; a Hook — Automation in the tool’s configuration that always fires on a specific event (e.g. after a file edit). Anything that must happen “always after something” shouldn’t depend on the assistant remembering. more in the glossary → is automation run by the harness. “Always do X after Y” = a hook in config, not a skill and not a memory.
- Starter set:
/run(server + smoke),/run-tests,/update-ai-readme,/add-migration(relational DB).
Refactoring
- Search for prior art first (
git log -S,git blame) — an “ugly” shape often has a reason. - Refactor separately from a behavior change — one commit is either cleanup or a feature.
- Reuse before rewrite — check whether the helper already exists.
- Keep old entry points working on structural moves (re-exporting shims), or update every caller in the same change.
- Small verified steps: refactor → tests green → commit.
- Apply SOLID — Five code design principles (single responsibility, open for extension, substitutability, narrow interfaces, dependency inversion). They help keep the next change cheap — applied in proportion, not as a cult. more in the glossary → proportionally: one reason to change per module; extend behind a flag rather than editing a hot path (→ 12); no abstraction before the second concrete case.
- Two review modes, never mixed: simplification (reuse, clarity) vs correctness (adversarial bug-hunt).
Anti-patterns
- 🚫 A skill for something done once.
- 🚫 A skill that silently runs something destructive.
- 🚫 A big-bang rewrite after which nobody can say what broke.
- 🚫 Five layers and a factory for a three-field CRUD.