Index of every page on this site: llms.txt
All skills
Run it yourself

Use when the user invokes /budget-diff, states a line budget for a change ("keep it under 150 lines"), or asks for a minimal diff / smallest possible change — before writing any implementation code. Not for ordinary tasks where diff size was never raised.

Use this Skill: https://skilld.dev/gh/ferriskleier/skills/budget-diff

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SKILL.md

≈68 tokens for metadata: the name and description. ≈1.7k when used: this file.

Description uses 3.4% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈269 characters, or 3.4%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

budget-diff — Set a line budget before coding, then live inside it

Overview

The budget is set the way a manager sets one for a worker: before the work starts, and not by the person who will spend it. The executor never grants themself more room — every extra line is bought from the user, in advance.

Core principle: simplicity is the spec. The right solution is the one that fits the budget and reads plainly stupid at a whiteboard.

The budget bounds how the task is built, never what the task is. Every deliverable the user named gets priced into the budget as they meant it — a requested test file means test code, a requested flag means the flag. Shrinking or redefining a deliverable to shrink the number is cheating the metric. A scope cut is an option you present, priced in lines, for the user to choose — never a decision you make.

The two modes

  • No budget given → Propose mode: analyze, propose a budget, and stop until the user approves it. Not one line of code before approval.
  • Budget given (a number in the invocation like /budget-diff 200 <task>, or stated anywhere in the prompt) → Execute mode: the user already acted as manager; start working inside that number as soon as the scope below is settled.

Budget scope — commit or branch?

A budget bounds a diff, and there are two diffs it could bound. Establish which one before any code — ask the user unless they already said:

  • Commit scope — only this task's work. Base: the commit HEAD points at when work starts — record its SHA. Committing mid-task never resets the meter; the base stays pinned.
  • Branch scope — the whole branch/PR diff. Base: the merge-base with the default branch (git merge-base <default-branch> HEAD). Everything the branch already added is budget already spent — measure and report the starting spend before writing a line.

In propose mode, ask together with the proposal. In execute mode, it is the one question allowed before work starts.

What counts as a line

Change Counts against budget?
Added implementation line yes
Added test line yes — tracked as its own split
Deleted line free (deletion is encouraged)
Docs, lockfiles, generated files excluded

Added lines in the diff, nothing else. Deleting code elsewhere earns no credit — the metric is additions, not net.

The count is never a mental tally — it is read from the diff itself:

git diff --numstat "$BASE"   # BASE from the scope above: the pinned SHA or the merge-base

Sum the first column (added lines), skip excluded files, split impl vs test by path. Binary files show - and don't count. A tally kept in your head that disagrees with this command is simply wrong — the diff is the ledger.

Propose mode

  1. Explore first, thoroughly. Read the code the task touches. Hunt for existing helpers, patterns, and seams to reuse — every reused line is a line off the budget. The proposal must be the true minimum, not a guess.

  2. Sketch the minimal design — the plainly-stupid version. No error handling, config, or abstraction the task didn't ask for.

  3. Estimate per component, lean, no padding. Surprises are handled by the breach protocol later, never by a pre-baked margin.

  4. Present and stop:

    Proposed budget: 180 lines
      parser        ~60
      runner        ~70
      tests         ~50
    Scope: commit only, or the whole branch? (branch has 42 lines already added)

    Under branch scope, the lines the branch already added come off the top — measure them and show them in the proposal.

    Wait for explicit approval. The user may cut it — that's the point.

Execute mode

Work in logical steps. After each step, measure — run git diff --numstat "$BASE" and sum it — then report the measured count and one whiteboard sentence describing the whole system built so far (not the last step — this is the drift detector):

Budget: 84 impl + 31 test = 115/200 (measured, branch scope)
Whiteboard: parser reads the config, hands a flat dict to the runner.

Finish with the same report plus how to try the result.

Breach protocol

The moment projection shows the remaining work won't fit — before writing the overflowing code — stop and present exactly two options:

  1. Simplify the approach to fit the budget (show how).
  2. The user explicitly raises the budget.

Never overrun silently. Never write the code first and ask forgiveness — once it exists, sunk cost argues to keep it.

Rationalizations — all of them mean stop

Excuse Reality
"Error handling is basic hygiene" If the task didn't ask for it, it's budget. Put it in the proposal or leave it out.
"Tests need proper scaffolding" Subprocess e2e + setUp/tearDown for a 20-line tool triples the test bill. Call the function, assert the value.
"It's stdlib-only, so it's minimal" Minimal dependencies ≠ minimal diff. The budget counts lines.
"It's only a few lines over" A few lines over is the breach protocol's call, and the protocol belongs to the user.
"A rounder/higher budget gives room" Padding is the executor granting themself budget. Estimate lean; breaches go to the user.
"I'll delete elsewhere to make room" Deletions are free but earn no credit. Additions are the metric.
"A sample data file counts as the test file" Redefining a deliverable to dodge its lines is a scope cut. Price real test code; if it doesn't fit, that's the breach protocol.
"Running it by hand counts as testing" If the user asked for tests, manual verification doesn't discharge it. Assertions or a priced-out scope proposal.
"My running tally says it fits" The tally isn't the metric — the diff is. Run git diff --numstat; when they disagree, the diff wins.
"Earlier commits on the branch shouldn't count" Under branch scope they are the budget's first spend. The scope belongs to the user; report the starting count, don't renegotiate it.
"Scope is obvious, no need to ask" Commit vs branch changes the number by every line the branch already added. One question, asked once, before code.

Red flags — stop and re-read this skill

  • Code written before a budget exists or is approved
  • Code written before the scope (commit vs branch) is settled
  • A count reported without running git diff --numstat
  • A "while I'm here" addition
  • A step finished without its budget report
  • An estimate produced after the code
  • A budget raised by anyone but the user
  • A requested deliverable quietly redefined, downgraded, or dropped to fit the number

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts3mo3 checks · Risk SAFE
  • Gen Agent Trust Hub3mo

    This skill is a development tool designed to enforce line count budgets on code changes. It utilizes standard git commands to measure diff sizes and provides a structured protocol for proposing, executing, and monitoring code changes within specified limits. No malicious patterns or security vulnerabilities were identified.

  • Socket3mo

    No alerts

  • Snyk3mo

    Risk: LOW · No issues

Signed by skilld at 0fd50f1. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 weeks ago.

Activeupdated 4 months ago
optimized for
Claude Code, Codex, OpenCode

README badge

README badge for ferriskleier/skills/budget-diff