Minimal code: a ladder for AI agents
Your agent asks whether code needs to exist before writing it, and touches nothing outside the task.
Quality, beginner. Published
What it does
AI agents like to add: a new helper next to an existing one, a new dependency to format a date, style fixes in a file they came to change in one line. This skill puts a constraint on the moment of writing. The agent reads the code and traces the flow first, then climbs a seven-rung ladder: does this need to exist, is it already in the repository, does the standard library do it, a native platform feature, an installed dependency, one line, and only then the minimum code. It fixes bugs at the root after checking every caller. It marks each deliberate shortcut with a minimal: comment naming the ceiling and the upgrade path. The hard floor stays untouched: validation at trust boundaries, error handling that prevents data loss, security, accessibility and one runnable check.
When to use it
When to use it
- Your agent writes, fixes or refactors code in an existing repository.
- Diffs from your agent run longer than the task needs and are hard to review.
- Your agent adds dependencies or helpers you already have.
- You want a list of deliberate shortcuts you can pull with one grep.
When not to use it
- You are asking for research, an audit, a report or a plan. The skill covers code only, not prose.
- You explicitly ask for the full, elaborate version. Your direction comes first.
- You are building a throwaway prototype and do not care about reviewing the diff.
Decision table
| Situation | What the agent does |
|---|---|
| Needs a helper to format a price | Searches the repository and the standard library before writing a new one. |
| A bug reported in one view | Finds every caller of the faulty function and fixes it once, in the shared place. |
| A one-line fix in a large file | Changes that line only; nearby formatting and imports stay as they are. |
| A deliberate shortcut, such as a global lock | Adds a minimal: comment naming the ceiling and the upgrade path. |
| A new endpoint that accepts input | Keeps validation and one check, because they are the hard floor. |
| The design system requires a custom component | Follows the design system instead of the native element. |
Template
The seven-rung ladder, surgical scope, the minimal: comment, the hard floor and the precedence order.
---
name: code-minimalism
description: A write-time constraint for any agent that writes code. Before adding a line, climb a seven-rung ladder (need it at all, already in the codebase, stdlib, native platform feature, installed dependency, one line, only then the minimum), keep edits surgical, and never cut the hard floor of comprehension, validation, security and one runnable check. Use it whenever you write, fix or refactor code.
---
# Code minimalism
Adapted from ponytail by DietrichGebert (MIT): the ladder, comprehension-first, root-cause fixes, the standing rules, the hard floor, the `minimal:` comment convention (renamed from `ponytail:`) and its grep ledger, the output rule for prose, the build-not-talk boundary and the user-direction override. Added in this template: surgical scope, precedence levels 2 to 5, the scratch-copy floor item, the commit self-check and the failure-modes list. See THIRD-PARTY-NOTICE.md.
Read CONTEXT.md next to this file before you write code. It names the project's precedence overrides, its design system, its conventions and the command that runs its checks.
If CONTEXT.md is missing, or a field you need is blank, ask the user for it in the user's language before you write code, one field at a time, for example: EN "Add the command that runs your checks (tests, type check, lint):", PL „Podaj polecenie, które uruchamia Twoje testy (testy, sprawdzenie typów, lint):”. Write the answer into CONTEXT.md so you do not ask again.
## Before you start / What you need
- **An AI coding agent that reads a markdown instruction file** (required): Claude Code (https://code.claude.com/docs/en/setup, skills at https://code.claude.com/docs/en/skills), Codex CLI (https://developers.openai.com/codex/cli, AGENTS.md at https://developers.openai.com/codex/guides/agents-md) or Cursor (https://cursor.com/downloads, rules at https://cursor.com/docs/context/rules).
- **Git** (required, https://git-scm.com/downloads): surgical scope and the commit self-check are checked against `git diff`.
- **One command that runs your checks**, written into CONTEXT.md.
- **ponytail** (optional, https://github.com/DietrichGebert/ponytail, MIT): the upstream skill this template adapts. You do not need it for this template to work. Whichever you use, keep THIRD-PARTY-NOTICE.md next to this file.
This skill governs what you build. It does not govern what you say: research, reviews, audits, plans and reports keep their full depth.
## 1. Comprehend first
The ladder runs after comprehension, never instead of it.
1. Read the task in full.
2. Read every file the change touches.
3. Trace the real flow end to end: where the input comes from, what calls the code, where the output goes.
4. Only then climb the ladder.
A small diff you do not understand ships a confident wrong fix. Read fully, then be minimal.
## 2. The ladder
Before writing any code, stop at the first rung that holds:
1. **Does this need to exist at all?** If the need is speculative, skip it and say so in one line.
2. **Is it already in this codebase?** A helper, util, type or pattern a few files over: reuse it. Re-implementing what already exists is the most common kind of bloat.
3. **Does the standard library do it?** Use it.
4. **Does a native platform feature cover it?** Use it: CSS over JavaScript, a database constraint over application code, a built-in form control over a custom widget.
5. **Does an already-installed dependency solve it?** Use it. Never add a dependency for what a few lines can do.
6. **Can it be one line?** Write one line.
7. **Only then:** write the minimum code that works.
To check rung 2, search the codebase for the verb and the noun of what you are about to write (for example `format` and `price`) before writing it.
## 3. Bug fixes: root cause, not symptom
1. Reproduce the failure and read the real output before you edit.
2. Find the function where the fault lives.
3. Search for every caller of that function.
4. Fix it once, in the shared function. One guard there is a smaller diff than a guard in every caller.
5. Patching only the path the ticket names leaves every sibling caller broken. Say in your report which callers you checked.
## 4. Standing rules
- No unrequested abstractions: no interface with one implementation, no factory for one product, no config for a value that never changes.
- No boilerplate or scaffolding "for later". Later can scaffold for itself.
- Prefer deletion over addition.
- Prefer boring over clever. Clever code is what someone decodes at 3am.
- Touch the fewest files possible. Once you understand the problem, the shortest working diff wins.
- Given two options of the same size, take the one that is correct on edge cases. Minimal means less code, not a flimsier algorithm.
- For a large request, ship the minimal version and question the rest in the same reply. Never stall.
## 5. Surgical scope
When you edit existing code, touch only the lines you can trace to the request.
Blocked:
- reformatting whitespace, quotes or commas outside the change
- adding type hints or docstrings to functions you are not modifying
- "cleaning up" unrelated imports
- refactoring adjacent helpers
- rewriting style in a file you came to touch for one line
- speculative abstraction
Allowed:
- deleting a helper whose last caller your change removed
- updating an import line for a symbol you added or removed
- adjacent edits the main change requires to compile or pass the type checker
**The trace test:** can you explain every changed line in one sentence that ends in the request? "It looked cleaner" is not a trace. Revert that line.
Unscoped edits hide the real change from reviewers and create merge conflicts with unrelated work.
## 6. The `minimal:` comment
When you cut a real corner on purpose (a global lock, a quadratic scan, a naive heuristic, an in-memory cache), mark it with a comment that names the ceiling and the upgrade path:
```python
# minimal: global lock, switch to per-account locks if throughput matters
```
```js
// minimal: linear scan over the list, index by id once it passes a few thousand rows
```
Use the comment syntax of the language, keep the literal `minimal:` prefix, and keep it on one line. The comments form a deferred-work ledger anyone can list with:
```
grep -rn "minimal:" .
```
A shortcut without this comment is not a deliberate simplification. It is an undocumented defect.
## 7. The hard floor: never minimise these away
- **Comprehension:** reading the code the change touches and tracing the real flow.
- **Input validation at trust boundaries:** anything that arrives from a user, a network call, a file or another service.
- **Error handling that prevents data loss.**
- **Security measures:** authentication, authorisation, escaping, permission checks.
- **Accessibility basics:** labels, focus order, keyboard access, contrast.
- **Anything the user explicitly asked to keep.**
- **Testing a destructive operation on a scratch copy**, never on the live, actively used repository, database or environment. This holds under time pressure too.
- **One runnable check behind non-trivial logic** (a branch, a loop, a parser, a money or security path): the smallest thing that fails if the logic breaks. No test framework, fixtures or per-function suites unless asked. Trivial one-liners need no check.
## 8. Precedence
Highest first. Where this skill conflicts with anything above it on this list, this skill yields.
1. **Explicit user direction.** If the user asks for the full version, build it without re-arguing.
2. **Security, money and tenant-boundary invariants and their tests.** Guards, idempotency keys, invariant checks and property tests on these paths are never "unrequested boilerplate".
3. **Review and audit deliverables.** Coverage maps, review reports and audit documents are the product; their length is the point.
4. **The project's design system.** Visual and motion quality in a user interface is a requirement, not over-engineering. Where the ladder says "use the native element" and the design system says otherwise, the design system wins. This skill governs code structure (abstractions, dependencies, file count, line count), not visual craft.
5. **The existing conventions of the repository.** Matching the surrounding code beats a shorter diff that does not.
6. This skill.
CONTEXT.md may name project-specific entries for levels 2 to 5. Apply them.
## 9. Prose inside a code deliverable
Code first, then at most three short lines: what you skipped and when to add it. If the explanation is longer than the code, delete the explanation. Explanation the user explicitly asked for is not bloat.
## 10. Commit self-check
Before every commit or pull request, answer in one line:
> Every line in this diff traces to the request, and the ladder was climbed.
If you cannot say that honestly, read the diff again before committing. Write the line in your reply so the user sees it.
## Failure modes to catch in yourself
- You wrote a helper, then found an equivalent one two folders away. Delete yours, use theirs.
- You fixed the caller named in the bug report and never searched for the other callers.
- Your diff for a one-line fix also renamed variables and reordered imports.
- You added a dependency to format a date the standard library already formats.
- You skipped validation on a new endpoint "to keep it minimal". The floor is not negotiable.
- You wrote a clever one-liner nobody can read. One line is rung 6, not a licence for obscurity; if the one-liner is unreadable, take rung 7.
- You left a known shortcut without a `minimal:` comment.
Other files
CONTEXT.template.mdContext template: where helpers live, the check command, trust boundaries, design system, scratch environment.
# Code minimalism: project context
Copy this file to CONTEXT.md next to SKILL.md and fill in every blank. Never put passwords, access keys or card numbers here.
## Project and stack
(Languages, frameworks and runtime the agent writes code in.)
Example: a TypeScript web shop with a relational database.
## Where shared helpers live
(Folders the agent searches before writing a new helper, util or type. This makes rung 2 of the ladder fast.)
Example: src/lib/, src/utils/, src/types/
## Installed dependencies worth reaching for
(Libraries already in the project that cover common needs, so the agent uses them instead of adding new ones.)
Example: date-fns for dates, zod for input validation, the query builder for database access.
## Dependency policy
(When may the agent add a new dependency, and who approves it?)
Example: never without asking first; propose it in one line with the reason.
## Command that runs the checks
(The one command the agent runs before reporting a change as done: tests, type check, lint.)
Example: npm test && npm run typecheck
## Trust boundaries
(Where untrusted input enters the system. Validation here is never minimised away.)
Example: API route handlers, webhook receivers, CSV import, file uploads.
## Money, security and tenant paths
(Code paths where invariants and their tests always outrank minimalism: precedence level 2.)
Example: checkout and refunds, login and session handling, anything scoped by account id.
## Design system
(Where the design rules live, if any. Precedence level 4: in the user interface they beat "use the native element".)
Example: docs/DESIGN.md and the components in src/ui/
## Repository conventions that beat a shorter diff
(Patterns the agent must match even when a shorter version exists: precedence level 5.)
Example: every service function returns a result object instead of throwing.
## Scratch environment for destructive operations
(Where the agent tests resets, deletes, migrations and force operations. Never the live environment.)
Example: a fresh clone in a temporary folder; the staging database, never production.
## Explicit keep-list
(Anything the user wants kept even if the ladder would cut it.)
Example: keep the verbose logging in the payment worker.
THIRD-PARTY-NOTICE.mdWhich parts are adapted, from where, and the full MIT licence text.
Adapted from ponytail by DietrichGebert (MIT): the ladder, comprehension-first, root-cause fixes, the standing rules, the hard floor, the `minimal:` comment convention (renamed from `ponytail:`) and its grep ledger, the output rule for prose, the build-not-talk boundary and the user-direction override. Added in this template: surgical scope, precedence levels 2 to 5, the scratch-copy floor item, the commit self-check and the failure-modes list. Source: https://github.com/DietrichGebert/ponytail, used under the MIT licence reproduced below.
MIT License
Copyright (c) 2026 DietrichGebert
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
What you need
An AI coding agent that reads a markdown instruction file (Claude Code, Codex CLI or Cursor) (opens in new tab)
The skill is an instruction file the agent reads before it writes code. Any agent that loads such files works.
- Claude Code: install it from the page linked above; skills are documented at https://code.claude.com/docs/en/skills (opens in new tab).
- Codex CLI: install it from https://developers.openai.com/codex/cli (opens in new tab); AGENTS.md is documented at https://developers.openai.com/codex/guides/agents-md (opens in new tab).
- Cursor: install it from https://cursor.com/downloads (opens in new tab); rules are documented at https://cursor.com/docs/context/rules (opens in new tab).
Git (opens in new tab)
You check surgical scope and the commit self-check against the diff.
- Install Git from the page linked above.
- Before a commit, read git diff and check that every line traces to the request.
ponytail, the upstream skill this template adapts (optional) (opens in new tab)
The original of the ladder. This template does not need it to work, but you can use it instead or compare the wording.
- The install steps are in the README of the repository linked above.
- Whichever you use, keep THIRD-PARTY-NOTICE.md next to this template.
Install
- Download the files/ folder and rename CONTEXT.template.md to CONTEXT.md.
- Fill in CONTEXT.md: where helpers live, the check command, trust boundaries, the design system and the scratch environment.
- Claude Code: put SKILL.md and CONTEXT.md in .claude/skills/code-minimalism/ in the project, or in ~/.claude/skills/code-minimalism/ for every project. Claude loads the skill when the description matches, or when you type /code-minimalism.
- Codex: paste SKILL.md into AGENTS.md at the repository root or into ~/.codex/AGENTS.md, and keep CONTEXT.md next to it.
- Cursor: add SKILL.md as a project rule in .cursor/rules/ or paste it into AGENTS.md, and put CONTEXT.md in the repository root so the rule can read it.
- Any other agent: paste SKILL.md into the project instruction file or system prompt, and keep CONTEXT.md next to it.
- Keep THIRD-PARTY-NOTICE.md in the same folder. The MIT licence requires it.
It's working if
- Asked for a new helper, the agent first reports what its repository search found, then writes code.
- On a bug fix, the agent's report lists the callers of the fixed function it checked.
- The diff for a one-line fix contains no formatting or import changes outside that line.
- grep -rn "minimal:" . returns comments naming a ceiling and an upgrade path at every deliberate shortcut.
- Before a commit, the agent writes the one-line self-check: every line in the diff traces to the request and the ladder was climbed.
- New code with a branch or a parser arrives with one runnable check.
Requirements
- An AI agent that reads a markdown instruction file (Claude Code, Codex, Cursor or another).
- A code repository the agent can search.
- One command that runs tests or a type check, written into CONTEXT.md.
Questions
Will minimalism end in code without tests and validation?
No. The skill has a hard floor the agent never cuts: comprehension of the code, validation at trust boundaries, error handling that prevents data loss, security, accessibility and one runnable check behind non-trivial logic.
What if I want the full, elaborate version?
Say so. User direction sits at the top of the precedence order, and the agent builds the full version without re-arguing.
Does the skill limit interface design?
No. It governs code structure: abstractions, dependencies, file count and line count. Visual and motion quality follow your design system, which beats the use-the-native-element rung.
Why the minimal: comment?
It marks a deliberate shortcut together with its ceiling and upgrade path. One grep gives you the deferred-work list, and a shortcut without the comment counts as an undocumented defect.
Where does the ladder come from?
Adapted from ponytail by DietrichGebert (MIT): the ladder, comprehension-first, root-cause fixes, the standing rules, the hard floor, the minimal: comment convention (renamed from ponytail:) and its grep ledger, the output rule for prose, the build-not-talk boundary and the user-direction override. Added in this template: surgical scope, precedence levels 2 to 5, the scratch-copy floor item, the commit self-check and the failure-modes list. The author, the link and the full licence text are in the licence notice file shipped with the template.
Where it fits
This skill acts at the moment code gets written, so it pairs with any workflow that hands implementation to an agent. The parallel agents template (sectioned-fan-out) splits work into sections, and this skill keeps each section's diff short and readable. The adversarial review template checks a finished change; this skill shrinks what there is to check. On payment, login and customer-data paths, invariants and their tests take precedence. Adapted from ponytail by DietrichGebert (MIT): the ladder, comprehension-first, root-cause fixes, the standing rules, the hard floor, the minimal: comment convention (renamed from ponytail:) and its grep ledger, the output rule for prose, the build-not-talk boundary and the user-direction override. Added in this template: surgical scope, precedence levels 2 to 5, the scratch-copy floor item, the commit self-check and the failure-modes list.
All skillsSources
Adapted from
Adapted from ponytail by DietrichGebert (MIT): the ladder, comprehension-first, root-cause fixes, the standing rules, the hard floor, the minimal: comment convention (renamed from ponytail:) and its grep ledger, the output rule for prose, the build-not-talk boundary and the user-direction override. Added in this template: surgical scope, precedence levels 2 to 5, the scratch-copy floor item, the commit self-check and the failure-modes list.
https://github.com/DietrichGebert/ponytail. License: MIT
- ponytail (DietrichGebert), MIT (accessed 2026-09-22)
- Claude Code docs: skills (accessed 2026-09-22)
- Codex docs: AGENTS.md (accessed 2026-09-22)
- Cursor docs: rules (accessed 2026-09-22)
Questions about setting these up go in the Discord.Join free