Minimalny kod: drabina dla agenta AI
Agent pyta, czy kod w ogóle musi powstać, zanim go napisze, i nie dotyka niczego poza zadaniem.
Jakość, dla początkujących. Opublikowano
Co robi
Agent AI chętnie dopisuje: nowy helper obok istniejącego, nową zależność do formatowania daty, poprawki stylu w pliku, który miał zmienić w jednej linii. Ten skill zakłada ograniczenie w chwili pisania. Agent najpierw czyta kod i śledzi przepływ, potem wspina się po drabinie siedmiu szczebli: czy to w ogóle potrzebne, czy już jest w repozytorium, czy robi to biblioteka standardowa, funkcja platformy, zainstalowana zależność, jedna linia, i dopiero na końcu minimum kodu. Błąd naprawia u źródła, po sprawdzeniu wszystkich wywołań. Każdy świadomy skrót oznacza komentarzem minimal: z sufitem i ścieżką rozbudowy. Twarde minimum zostaje nietknięte: walidacja na granicach zaufania, obsługa błędów chroniąca dane, bezpieczeństwo, dostępność i jeden uruchamialny test.
Kiedy używać
Kiedy używać
- Twój agent pisze, poprawia albo refaktoryzuje kod w istniejącym repozytorium.
- Diffy od agenta są dłuższe, niż wymaga zadanie, i trudno je przejrzeć.
- Agent dodaje zależności albo helpery, które już masz.
- Chcesz listę świadomych skrótów, którą da się wyciągnąć jednym grepem.
Kiedy nie używać
- Zlecasz research, audyt, raport albo plan. Skill dotyczy tylko kodu, nie tekstu.
- Prosisz wprost o pełną, rozbudowaną wersję. Twoje polecenie ma pierwszeństwo.
- Budujesz prototyp do wyrzucenia i nie zależy Ci na przeglądzie diffu.
Tabela decyzyjna
| Sytuacja | Co robi agent |
|---|---|
| Potrzebny helper do formatowania ceny | Szuka istniejącego w repozytorium i bibliotece standardowej, zanim napisze nowy. |
| Zgłoszony błąd w jednym widoku | Szuka wszystkich wywołań wadliwej funkcji i poprawia ją raz, w miejscu wspólnym. |
| Poprawka jednej linii w dużym pliku | Zmienia tylko tę linię; formatowanie i importy obok zostają. |
| Świadomy skrót, np. globalna blokada | Dodaje komentarz minimal: z sufitem i ścieżką rozbudowy. |
| Nowy endpoint przyjmujący dane | Zostawia walidację i jeden test, bo to twarde minimum. |
| Design system każe użyć własnego komponentu | Stosuje design system zamiast natywnego elementu. |
Szablon
Drabina siedmiu szczebli, zakres chirurgiczny, komentarz minimal:, twarde minimum i kolejność pierwszeństwa.
---
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.
Pozostałe pliki
CONTEXT.template.mdSzablon kontekstu: gdzie leżą helpery, polecenie testów, granice zaufania, system designu, środowisko testowe.
# 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.mdInformacja o źródle adaptacji i pełny tekst licencji MIT.
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.
Czego potrzebujesz
An AI coding agent that reads a markdown instruction file (Claude Code, Codex CLI or Cursor) (otwiera się w nowej karcie)
Skill to plik instrukcji, który agent czyta przed pisaniem kodu. Wystarczy dowolny agent, który ładuje takie pliki.
- Claude Code: zainstaluj według strony podlinkowanej wyżej, skille opisuje https://code.claude.com/docs/en/skills (otwiera się w nowej karcie).
- Codex CLI: zainstaluj według https://developers.openai.com/codex/cli (otwiera się w nowej karcie), plik AGENTS.md opisuje https://developers.openai.com/codex/guides/agents-md (otwiera się w nowej karcie).
- Cursor: zainstaluj z https://cursor.com/downloads (otwiera się w nowej karcie), reguły opisuje https://cursor.com/docs/context/rules (otwiera się w nowej karcie).
Git (otwiera się w nowej karcie)
Zakres chirurgiczny i samokontrolę przed commitem sprawdzasz na diffie.
- Zainstaluj Git ze strony podlinkowanej wyżej.
- Przed commitem przeczytaj git diff i sprawdź, że każda linia wynika z zadania.
ponytail, the upstream skill this template adapts (optional) (otwiera się w nowej karcie)
Oryginał drabiny. Nie jest potrzebny do działania tego szablonu, ale możesz go użyć zamiast niego albo porównać sformułowania.
- Instrukcję instalacji znajdziesz w README repozytorium podlinkowanego wyżej.
- Niezależnie od wyboru trzymaj THIRD-PARTY-NOTICE.md obok tego szablonu.
Instalacja
- Pobierz folder files/ i zmień nazwę CONTEXT.template.md na CONTEXT.md.
- Uzupełnij CONTEXT.md: gdzie leżą helpery, polecenie testów, granice zaufania, system designu i środowisko testowe.
- Claude Code: umieść SKILL.md i CONTEXT.md w .claude/skills/code-minimalism/ w projekcie albo w ~/.claude/skills/code-minimalism/ dla wszystkich projektów. Claude wczyta skill, gdy opis pasuje, albo gdy wpiszesz /code-minimalism.
- Codex: wklej treść SKILL.md do AGENTS.md w katalogu głównym repozytorium albo do ~/.codex/AGENTS.md, a CONTEXT.md trzymaj obok.
- Cursor: dodaj SKILL.md jako regułę projektu w .cursor/rules/ albo wklej go do AGENTS.md, a CONTEXT.md połóż w katalogu głównym repozytorium, żeby reguła mogła go odczytać.
- Inny agent: wklej SKILL.md do pliku instrukcji projektu lub promptu systemowego i trzymaj CONTEXT.md obok.
- Zachowaj THIRD-PARTY-NOTICE.md w tym samym folderze. Licencja MIT tego wymaga.
Działa, jeśli
- Przy prośbie o nowy helper agent najpierw podaje wynik wyszukiwania w repozytorium, a dopiero potem pisze kod.
- Przy poprawce błędu raport agenta wymienia sprawdzone wywołania naprawianej funkcji.
- Diff poprawki jednej linii nie zawiera zmian formatowania ani importów poza tą linią.
- grep -rn "minimal:" . zwraca komentarze z sufitem i ścieżką rozbudowy przy każdym świadomym skrócie.
- Przed commitem agent pisze jedną linię samokontroli: każda linia diffu wynika z zadania, a agent przeszedł po drabinie.
- Nowy kod z rozgałęzieniem albo parserem przychodzi z jednym uruchamialnym testem.
Wymagania
- Agent AI, który czyta plik instrukcji w markdown (Claude Code, Codex, Cursor lub inny).
- Repozytorium z kodem, które agent może przeszukiwać.
- Jedno polecenie uruchamiające testy lub sprawdzenie typów, wpisane do CONTEXT.md.
Pytania
Czy minimalizm nie skończy się kodem bez testów i walidacji?
Nie. Skill ma twarde minimum, którego agent nie tnie: zrozumienie kodu, walidację na granicach zaufania, obsługę błędów chroniącą dane, bezpieczeństwo, dostępność i jeden uruchamialny test za każdą nietrywialną logiką.
Co jeśli chcę pełnej, rozbudowanej wersji?
Powiedz to wprost. Polecenie użytkownika stoi najwyżej w kolejności pierwszeństwa i agent buduje pełną wersję bez dyskusji.
Czy skill ogranicza design interfejsu?
Nie. Dotyczy struktury kodu: abstrakcji, zależności, liczby plików i linii. Jakość wizualna i ruch podlegają Twojemu design systemowi, który wygrywa z zasadą użycia natywnego elementu.
Po co komentarz minimal:?
Oznacza świadomy skrót razem z jego sufitem i ścieżką rozbudowy. Jeden grep daje listę odłożonej pracy, a skrót bez komentarza traktujesz jak nieudokumentowany błąd.
Skąd pochodzi drabina?
Zaadaptowane z projektu ponytail autorstwa DietrichGebert (MIT): drabina, czytanie przed pisaniem, naprawa u źródła, stałe zasady, twarde minimum, konwencja komentarza minimal: (dawniej ponytail:) z listą grep, zasada krótkiej prozy przy kodzie, granica „rządzi tym, co budujesz, nie tym, co mówisz” i pierwszeństwo polecenia użytkownika. Dodane w tym szablonie: chirurgiczny zakres, poziomy pierwszeństwa od 2 do 5, punkt o testowaniu na kopii, samokontrola przed commitem i lista błędów. Autora, link i pełny tekst licencji znajdziesz w pliku z informacją o licencji, dołączonym do szablonu.
Gdzie to pasuje
Ten skill działa w chwili pisania kodu, więc łączy się z każdym workflow, który zleca agentowi implementację. Szablon równoległych agentów dzieli pracę na sekcje, a ten skill pilnuje, żeby każda sekcja wróciła z krótkim, czytelnym diffem. Szablon przeglądu adwersarialnego sprawdza gotową zmianę; ten skill zmniejsza to, co trzeba sprawdzić. Na ścieżkach płatności, logowania i danych klientów pierwszeństwo mają niezmienniki i ich testy. Zaadaptowane z projektu ponytail autorstwa DietrichGebert (MIT): drabina, czytanie przed pisaniem, naprawa u źródła, stałe zasady, twarde minimum, konwencja komentarza minimal: (dawniej ponytail:) z listą grep, zasada krótkiej prozy przy kodzie, granica „rządzi tym, co budujesz, nie tym, co mówisz” i pierwszeństwo polecenia użytkownika. Dodane w tym szablonie: chirurgiczny zakres, poziomy pierwszeństwa od 2 do 5, punkt o testowaniu na kopii, samokontrola przed commitem i lista błędów.
Wszystkie skilleŹródła
Źródło adaptacji
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. Licencja: MIT
- ponytail (DietrichGebert), MIT (dostęp 2026-09-22)
- Claude Code docs: skills (dostęp 2026-09-22)
- Codex docs: AGENTS.md (dostęp 2026-09-22)
- Cursor docs: rules (dostęp 2026-09-22)
Pytania o wdrożenie zadajesz na Discordzie.Dołącz za darmo