Artificial Intelligence / AI

Ponytail: Make Your Coding Agent Check the Shelf First – The Skill for Writing Less Code

Ponytail makes your coding agent check the shelf before ordering a new part. The rule is sound and the benchmark is honest but narrow: less code, no more and no less correct. On modern PHP its shelf list sees three of eight definitions.

9 min read

This post is also available in Turkish →
An old repairman's bench with a dismantled brass tap, a single washer lit in an open drawer and a new tap box pushed aside, illustrating Ponytail's check-the-shelf-first rule for coding agents.

Take a dripping tap to the old repairman down the street. He won't sell you a new one. He looks at his shelf, pulls a washer out of a drawer, gives it two turns and you're done. Coding agents often do the opposite: ask for a date picker and they install a library or draw a calendar from scratch.

This week's radar entry, Ponytail, tries to train that habit out of them. It is a single prompt that whispers "check the shelf before you order a new part" into your coding agent's ear, and the repository, opened in June 2026, sits at roughly 197k stars today. I read the source and tested the PHP side separately. Short version: the rule is sound, the numbers are honest but narrow, and the shelf inventory is half blind on modern PHP.

What is Ponytail?#

Ponytail is an MIT-licensed skill and rules file that loads one instruction into every session: write the smallest complete change that solves the task. In its own words, "The best code is the code you never wrote."

At its core is a six-rung ladder. The agent stops at the first rung that works:

  1. Does this need to exist? Features and options nobody asked for are skipped, and named in one line.
  2. Is it already in the codebase (a helper, component, service)?
  3. Does the standard library or platform already do it?
  4. Does an installed dependency do it? No new dependency for a few lines.
  5. Can it be one line a reader understands at a glance?
  6. Otherwise, the minimum code that works.

Next to the ladder sits a "never cut" list: validation at trust boundaries, error handling that prevents data loss, security, accessibility. New logic with a branch, a loop, a parser, money or security has to leave one small test behind. A deliberate shortcut gets a shortcut: <the limit>, <when to upgrade> comment, and /ponytail-debt collects them into a ledger. In the technical debt chapter I argued that interest is charged every time you touch a file; a ledger at least keeps you from forgetting where the debt lives.

Installing it#

In Claude Code, as two separate commands:

Metin
/plugin marketplace add DietrichGebert/ponytail
/plugin install ponytail@ponytail

In Codex:

Bash
codex plugin marketplace add DietrichGebert/ponytail
codex plugin add ponytail@ponytail

In Codex you then trust its two lifecycle hooks under /hooks and start a new thread. GitHub Copilot CLI, Gemini CLI and OpenCode have their own steps in INSTALL.md. Instruction-only tools such as Cursor's rule file, Windsurf and Cline get the repo's AGENTS.md copied into your project; you get the rules but not commands like /ponytail-review or /ponytail-audit. How each tool reads rules files differently is covered in chapter 4.2, and all of that applies here too.

A disclosure: I did not install Ponytail inside an agent and run tasks with it for this post. I read the source at commit ebd8654 (22 November 2026) and tested the PHP behaviour of its code map with a separate script.

Whose numbers, measuring what?#

The top of the README makes a bold claim: 53% less code, 41% less time, 26% lower cost, 45% fewer tokens. The project measured it. The method file (benchmarks/results/2026-10-07-agentic.md) is worth reading, because it states its own limits:

  • One agent, one model: Claude Code 2.1.288 with Opus 5.5. Codex, Cursor and the rest were not measured.
  • Tasks: 12 of the 39 tasks run in a real FastAPI + React repo; the rest are 18 small surgical tasks and "build me a small app" requests. Not a single PHP task.
  • No shell: Bash was disabled in every arm, and sessions ran in temp folders outside any git repo with CLAUDE.md loading switched off. That is not how you work day to day.
  • Correctness: On the 18 tasks with hidden checks, the agent without Ponytail passed 86 of 90 runs and Ponytail 5 passed 87. The file says it plainly: less code did not cost correctness or safety, and did not add any either.

That last sentence is the most useful line in the repository. Ponytail makes code shorter; it does not check it. If you want a security gate, the gates from chapter 5.3 are the place to look.

The shelf list is half blind on PHP#

A lesser-known piece of Ponytail is the code map built at session start. hooks/ponytail-map.js puts the project's class and function names into the agent's context, one line per folder, within a 2,000-character budget. The "is it already in the codebase" rung leans on that list. No model, no dependencies, one regular expression per language.

PHP files share the Java and Kotlin pattern:

JavaScript
/^\s*(?:public\s+)?(?:static\s+)?(?:final\s+)?(?:class|interface|enum|record)\s+(\w+)/gm

There is no abstract, readonly, trait or function in it. I ported the pattern to PCRE as-is and ran it over a small PHP 8.3-style project:

File Definition In the map
src/Domain/Musteri.php final class Musteri yes
src/Domain/Durum.php enum Durum yes
src/Domain/StokDeposu.php interface StokDeposu yes
src/Service/SiparisService.php final readonly class SiparisService no
src/Service/OdemeService.php abstract class OdemeService no
src/Support/Zamanlayici.php trait Zamanlayici no
src/Support/para.php para_bicimle(), slug_uret() no

Three of eight definitions make it in. The painful part is that the misses aren't random: the folders most likely to be reused, Service/ and Support/, vanish entirely. On my older-style Altınkaynak library the same pattern caught six out of six. So the problem isn't PHP, it's modern PHP. In a codebase full of final readonly class, the shelf list is empty exactly where the shelves are fullest, and "does it already exist" falls back on the agent's own searching.

Ponytail lets you switch the map off with PONYTAIL_MAP=0 (it's in the source, not the README). As a replacement I wrote a small script that counts definitions with token_get_all; you can paste its output into a section of your AGENTS.md:

PHP
<?php
declare(strict_types=1);
​
// Usage: php php-harita.php [project-root] [character-budget]
$kok = rtrim($argv[1] ?? getcwd(), '/');
$butce = (int) ($argv[2] ?? 2000);
$atla = '#/(vendor|node_modules|tests?|storage|cache)/#';
​
$klasorler = [];
$dosyalar = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($kok, FilesystemIterator::SKIP_DOTS));
foreach ($dosyalar as $dosya) {
    $yol = substr($dosya->getPathname(), strlen($kok) + 1);
    if ($dosya->getExtension() !== 'php' || preg_match($atla, '/' . $yol)) {
        continue;
    }
    $jetonlar = token_get_all((string) file_get_contents($dosya->getPathname()));
    $derinlik = 0;
    foreach ($jetonlar as $i => $jeton) {
        if ($jeton === '{' || (is_array($jeton) && in_array($jeton[0], [T_CURLY_OPEN, T_DOLLAR_OPEN_CURLY_BRACES], true))) {
            $derinlik++;
        } elseif ($jeton === '}') {
            $derinlik--;
        }
        if (!is_array($jeton) || !in_array($jeton[0], [T_CLASS, T_INTERFACE, T_TRAIT, T_ENUM, T_FUNCTION], true)) {
            continue;
        }
        if ($jeton[0] === T_FUNCTION && $derinlik > 0) {
            continue; // methods and closures stay out of the map
        }
        $j = $i + 1;
        while (isset($jetonlar[$j]) && is_array($jetonlar[$j]) && $jetonlar[$j][0] === T_WHITESPACE) {
            $j++;
        }
        if (isset($jetonlar[$j]) && is_array($jetonlar[$j]) && $jetonlar[$j][0] === T_STRING) {
            $klasorler[dirname($yol)][] = $jetonlar[$j][1] . ($jeton[0] === T_FUNCTION ? '()' : '');
        }
    }
}
​
ksort($klasorler);
$kullanilan = 0;
echo "Code map (reuse these first; open a file only when you need its details):\n";
foreach ($klasorler as $klasor => $adlar) {
    $satir = $klasor . '/: ' . implode(', ', array_slice(array_unique($adlar), 0, 30));
    if ($kullanilan + strlen($satir) > $butce) {
        continue;
    }
    echo $satir, "\n";
    $kullanilan += strlen($satir) + 1;
}

Its output on the same project:

Metin
Code map (reuse these first; open a file only when you need its details):
src/Domain/: StokDeposu, Musteri, Durum
src/Service/: SiparisService, OdemeService
src/Support/: Zamanlayici, para_bicimle(), slug_uret()

The script passes php -l and ran on two projects under PHP 8.3.6. It's a static list, so regenerate it when the code changes; a git hook is enough.

When does it help, and when doesn't it?#

It helps in projects where the agent meets every task with a new class, a new wrapper or a new dependency. /ponytail-review also reads the files a change touches, not just the diff, and is designed to catch things like a renamed field breaking an untouched file elsewhere.

It doesn't help as a guarantee. The rule is a prompt: if the model ignores it, it's ignored, and the hook only loads text without checking the result. The benchmark used one agent and one model. Shorter code is not safer code, and the measurement doesn't claim it is. Off-the-rack interface clichés are Impeccable's job, not Ponytail's.

Maintenance status#

  • Licence: MIT.
  • Release: v5.3.3 (29 October 2026); last commit 22 November 2026.
  • Age: first commit 12 June 2026.
  • Attention (repo page, 24 Nov 2026): about 197k stars, 11.1k forks, 146 open issues, 173 open PRs.
  • Security note: in Claude Code and Codex, Node.js hooks run on SessionStart, UserPromptSubmit and SubagentStart. The "band" dashboard reads your Claude Code session logs to build a cost table; per the project, everything stays on your machine under ~/.config/ponytail/band/. The author explicitly says to install only from the DietrichGebert/ponytail repo or the @dietrichgebert/ponytail npm package, and that any copy shipping .exe or .dll files is not his. With a project this popular, take impostor packages seriously.
  • Business model: the code is free. The project site has a "coming soon" waitlist that doesn't say what's coming, and GreenPT is listed as a sponsor.

Ponytail is built by Dietrich Gebert; about 150 of the 372 commits in its history are his, the rest come from more than a hundred contributors.

Alternatives at a glance#

Tool What it does Licence When
Ponytail A "smallest complete change" rule in every session, plus review/audit commands MIT Your agent writes too much code
Superpowers (Jesse Vincent) A full methodology with brainstorming, planning, red/green TDD and YAGNI (v7.0.2) MIT You're setting up the whole process
Your own AGENTS.md rule You write the same idea in three lines Yours Your team already has rules files
PHPStan Deterministic static analysis MIT You need a bug gate; alongside Ponytail, not instead of it

Where it fits on my desk#

On the native PHP and MariaDB side, the best fit is legacy projects. In a repo like Altınkaynak, which we've been renovating in the Urban Renewal series, asking the agent to "fetch rates from the new endpoint" and getting a second HTTP client next to the existing one is the textbook unauthorised extra floor. The second and third rungs ("already in the code? in the standard library?") are the brake right there. But I wouldn't trust Ponytail's PHP map until I feed it my own; in a service layer full of readonly classes, the agent sees an empty shelf. Marking shortcuts with shortcut: comments and keeping them next to the debt meter is a sensible pairing too.

The repairman never orders a part without checking the shelf. Keep the shelf list wrong, though, and he'll order the washer that's already sitting there.

Stay with the technology.

Comments

0 comments

Leave a comment

Replying to

Comments appear after approval. Your email address is never shared. How is your personal data processed?