rightsize
rightsize is a Claude Code skill that audits the context Claude loads, such as CLAUDE.md, AGENTS.md, rules, skills and subagents, and proposes a diff that keeps only the lines that prevent real mistakes.
An example, from the test fixture
The repository's test fixture is a 125-line CLAUDE.md for a Laravel API. A run of rightsize 0.1.3 on it, on 17 November 2026, left CLAUDE.md at 10 lines, and the context loaded every session went from about 1,366 to about 520 tokens, 62% less. The deploy runbook became a manual-only skill, migrate:fresh is blocked by a hook and .env by a deny rule.
Delete: the persona, the stack, the tree, duplicates, generic advice, stale pointers and the dated notes
@@ 3 @@ persona
You are an expert senior Laravel developer with 15 years of experience. Think step by step before answering.@@ 5 @@ section heading (its text is kept)
## Project overview@@ 9–16 @@ tech stack
## Tech stackLines 10–16 · tech stack, 6 items
- Laravel 11- PHP 8.3- laravel/sanctum for API authentication- spatie/laravel-permission for roles- Pest for tests- Vite for frontend assets@@ 19–34 @@ directory tree
## Directory structureLines 20–34 · directory tree, 16 lines
```app/├── Http/│ ├── Controllers/│ └── Requests/├── Models/├── Services/routes/├── api.php└── web.phptests/├── Feature/└── Unit/```@@ 36–41 @@ rules
## Rules- IMPORTANT: ALWAYS write tests for every change..claude/rules/testing.md:3 (rewritten there)- Use camelCase for variables and PascalCase for classes.- ALWAYS use Form Requests for validation.@@ 46–49 @@ rules
- Double-check your work before saying you are done.- Be thorough and careful.- Follow PSR-12.- IMPORTANT: ALWAYS write tests for every change..claude/rules/testing.md:3 (rewritten there)@@ 110–125 @@ commands, architecture, notes
## Useful commandsLines 111–115 · useful commands
- `composer test` runs the test suite- `composer run analyse` runs PHPStan- `npm run lint` lints the frontend- `npm run dev` starts Vite## ArchitectureLines 118–119 · architecture pointer to missing files
See `docs/architecture.md` for the full architecture and `app/Services/PaymentService.php` for the payment flow.## Notes- 2026-03-02: fixed the cart total bug, check cart totals after changes- 2026-04-11: added the refunds endpointRewrite: a bare rule, said plainly
@@ 39 @@ rules
- NEVER add comments to code.6- Match the comment density of the surrounding code; most files here have none.One test per line
Every instruction is classified as keep, rewrite, move, enforce or delete, with one test: what concrete mistake would Claude make in this repo without this line?
Needs your call: CLAUDE.md:39 conflicted with .claude/rules/testing.md:6. Both are scoped now: match the surrounding density here; a one-line comment on test setup is welcome there. Is that what the team means?
The report counts 5 rewrites; the other 4 are in .claude/ files.
Enforce: out of the prose, into a hook, a deny rule and an ask rule
@@ 42–45 @@ rules
- DO NOT modify files in config/ without asking.10- Edits to `config/` ask for the user's OK first (an ask rule).- NEVER run `php artisan migrate:fresh` against production. It drops every table.8- `php artisan migrate:fresh`, `migrate:reset` and `db:wipe` are blocked by a hook, because they drop every table; reset the test database with `--env=testing`.- The .env file contains secrets. DO NOT read it or print it.9- `.env` holds secrets and Claude can't read it (a deny rule); ask the user for any value you need from it.Rules that must hold
Rules that must always hold become hooks and permission rules, plus one plain line saying why.
The hook refuses migrate:fresh, migrate:reset and db:wipe unless --env=testing; it was run on commands it must block and ones it must let through. .env is denied to Read, and edits to config/ ask first.
Keep: the money-in-cents gotcha, the title and the overview
@@ 1 @@ title
# Acme Shop API1# Acme Shop API@@ 7 @@ overview
Acme Shop is the backend for our online store. It serves a JSON API to the Flutter app and the admin panel.3Acme Shop is the backend for our online store. It serves a JSON API to the Flutter app and the admin panel. It runs on MySQL 8, and the queue driver is Redis.- MySQL 8CLAUDE.md:3 (after), in the overview@@ 43 @@ rules
- Prices are stored as integers in cents in the `amount` column; never use floats for money, because rounding errors break invoice totals.5- Prices are stored as integers in cents in the `amount` column; never use floats for money, because rounding errors break invoice totals.- 2026-03-09: switched the queue driver to redisCLAUDE.md:3 (after), in the overviewLines that prevent a real mistake
Without line 43, Claude could store money as floats in this repo, and the line says why that breaks invoice totals. It stays word for word.
The overview stays and takes the two facts no manifest shows: MySQL 8 (line 17) and the Redis queue (line 124).
Move: the example controller, the review checklist and the deploy runbook
@@ 51–78 @@ example controller
## Example controller7- New controllers follow `app/Http/Controllers/ProductController.php`.app/Http/Controllers/ProductController.php (pointer at CLAUDE.md:7)Lines 53–78 · pasted PHP example, 27 lines
Use this as the template for every new controller:```php<?phpnamespace App\Http\Controllers;use App\Http\Requests\StoreProductRequest;use App\Models\Product;use Illuminate\Http\JsonResponse;class ProductController extends Controller{ public function index(): JsonResponse { return response()->json(Product::query()->paginate(20)); } public function store(StoreProductRequest $request): JsonResponse { $product = Product::create($request->validated()); return response()->json($product, 201); }}```@@ 80–95 @@ code review checklist
## Code review checklist.claude/skills/code-review/SKILL.md (merged)Lines 81–95 · checklist, 12 items
When reviewing code, check:1. Naming is clear2. Validation uses Form Requests3. No N+1 queries (use eager loading)4. Authorization is handled by policies5. Money is stored in cents6. Tests cover the happy path7. Tests cover failure cases8. No secrets in code9. API resources are used for responses10. Migrations are reversible11. Jobs are idempotent12. Logs don't contain personal data@@ 97–108 @@ deploy runbook
## Deploying to the VPS.claude/skills/deploy/SKILL.md (new, manual-only)Lines 98–108 · deploy steps, 10 items
1. SSH into the server: `ssh deploy@203.0.113.10`2. Go to the app directory: `cd /var/www/acme-shop`3. Put the app in maintenance mode: `php artisan down`4. Pull the latest code: `git pull origin main`5. Install dependencies: `composer install --no-dev --optimize-autoloader`6. Run migrations: `php artisan migrate --force`7. Build assets: `npm ci && npm run build`8. Clear and rebuild caches: `php artisan optimize`9. Restart the queue workers: `php artisan queue:restart`10. Bring the app back up: `php artisan up`Loaded only when needed
The deploy steps became a new manual-only skill, so they load on demand instead of every session. The checklist joined the review skill that already existed. The pasted controller, which had drifted from the real one, became a pointer to it.
Every line of the 125 with words on it is in a hunk; only the 13 blank lines between sections are left out. The token figures are rightsize 0.1.3's estimates, characters divided by 2.7.
What it is
You run /rightsize:rightsize, or ask Claude to trim a bloated CLAUDE.md. rightsize then works in five steps:
- Scans
- every context file with a deterministic, standard-library Python scanner: what loads every session and what loads on demand, estimated tokens, and 24 checks. It only reads files.
- Classifies
- every instruction as keep, rewrite, move, enforce or delete, with one test: what concrete mistake would Claude make in this repo without this line?
- Proposes
- a diff grouped by verdict. Nothing changes until you say which groups to apply.
- Enforces
- rules that must always hold with hooks and permission rules, plus one plain line saying why.
- Measures
- before and after, from a snapshot of the first scan.
What I did
I built rightsize alone. 0.1.0 came out on 5 November 2026, and 0.1.1 the same day, tuned against real CLAUDE.md files from public repositories to cut false alarms. 0.1.2 (7 November) fixed what a field test on a Claude Code plugin, a desktop app, a new Vite project and a personal ~/.claude turned up, and 0.1.3 (8 November) writes new files before cutting the content it moves.
Status
0.1.3 is the latest release (8 November 2026). It needs Claude Code and Python 3.8 or newer, and installs as a plugin or as a personal skill. The code is public at github.com/mrramdn/rightsize.
Why it exists
Most project instruction files still carry habits from older models: ALWAYS and NEVER in capitals, pasted code examples, deploy runbooks, the same rule in three places. Claude reads all of it on every turn.
Claude reads the stack from composer.json and package.json and lists the tree itself. The persona and the “be thorough” lines are scaffolding current models don't need. The tests rule now lives once, in
.claude/rules/testing.md, and the commands, docs and services named here don't exist.