Skip to content
CVContact

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.

0.1.3, released 8 Nov 2026. Public on GitHub since 19 Nov 2026.Built it alonePython, Claude Code skill, Claude Code plugin, GitHub Actions

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.

CLAUDE.md Made-up example

125 to 10 lines

Every session ~1,366 to ~520 tokens −62%

Delete: the persona, the stack, the tree, duplicates, generic advice, stale pointers and the dated notes

@@ 3 @@ persona

3You are an expert senior Laravel developer with 15 years of experience. Think step by step before answering.

@@ 5 @@ section heading (its text is kept)

5## Project overview

@@ 9–16 @@ tech stack

9## Tech stack
Lines 10–16 · tech stack, 6 items
10
11- Laravel 11
12- PHP 8.3
13- laravel/sanctum for API authentication
14- spatie/laravel-permission for roles
15- Pest for tests
16- Vite for frontend assets

@@ 19–34 @@ directory tree

19## Directory structure
Lines 20–34 · directory tree, 16 lines
20
21```
22app/
23├── Http/
24│ ├── Controllers/
25│ └── Requests/
26├── Models/
27├── Services/
28routes/
29├── api.php
30└── web.php
31tests/
32├── Feature/
33└── Unit/
34```

@@ 36–41 @@ rules

36## Rules
38- IMPORTANT: ALWAYS write tests for every change..claude/rules/testing.md:3 (rewritten there)
40- Use camelCase for variables and PascalCase for classes.
41- ALWAYS use Form Requests for validation.

@@ 46–49 @@ rules

46- Double-check your work before saying you are done.
47- Be thorough and careful.
48- Follow PSR-12.
49- IMPORTANT: ALWAYS write tests for every change..claude/rules/testing.md:3 (rewritten there)

@@ 110–125 @@ commands, architecture, notes

110## Useful commands
Lines 111–115 · useful commands
111
112- `composer test` runs the test suite
113- `composer run analyse` runs PHPStan
114- `npm run lint` lints the frontend
115- `npm run dev` starts Vite
117## Architecture
Lines 118–119 · architecture pointer to missing files
118
119See `docs/architecture.md` for the full architecture and `app/Services/PaymentService.php` for the payment flow.
121## Notes
122
123- 2026-03-02: fixed the cart total bug, check cart totals after changes
125- 2026-04-11: added the refunds endpoint

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.

Rewrite: a bare rule, said plainly

@@ 39 @@ rules

39- 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

42- DO NOT modify files in config/ without asking.10- Edits to `config/` ask for the user's OK first (an ask rule).
.claude/settings.json ask: Edit(./config/**), Write(./config/**)
44- 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`.
.claude/hooks/block-destructive.py (PreToolUse hook in .claude/settings.json)
45- 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.
.claude/settings.json deny: Read(./.env), Read(./.env.*)

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

1# Acme Shop API1# Acme Shop API

@@ 7 @@ overview

7Acme 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.
17- MySQL 8CLAUDE.md:3 (after), in the overview

@@ 43 @@ rules

43- 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.
124- 2026-03-09: switched the queue driver to redisCLAUDE.md:3 (after), in the overview

Lines 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

51## Example controller7- New controllers follow `app/Http/Controllers/ProductController.php`.
52app/Http/Controllers/ProductController.php (pointer at CLAUDE.md:7)
Lines 53–78 · pasted PHP example, 27 lines
53Use this as the template for every new controller:
54
55```php
56<?php
57
58namespace App\Http\Controllers;
59
60use App\Http\Requests\StoreProductRequest;
61use App\Models\Product;
62use Illuminate\Http\JsonResponse;
63
64class ProductController extends Controller
65{
66 public function index(): JsonResponse
67 {
68 return response()->json(Product::query()->paginate(20));
69 }
70
71 public function store(StoreProductRequest $request): JsonResponse
72 {
73 $product = Product::create($request->validated());
74
75 return response()->json($product, 201);
76 }
77}
78```

@@ 80–95 @@ code review checklist

80## Code review checklist.claude/skills/code-review/SKILL.md (merged)
Lines 81–95 · checklist, 12 items
81
82When reviewing code, check:
83
841. Naming is clear
852. Validation uses Form Requests
863. No N+1 queries (use eager loading)
874. Authorization is handled by policies
885. Money is stored in cents
896. Tests cover the happy path
907. Tests cover failure cases
918. No secrets in code
929. API resources are used for responses
9310. Migrations are reversible
9411. Jobs are idempotent
9512. Logs don't contain personal data

@@ 97–108 @@ deploy runbook

97## Deploying to the VPS.claude/skills/deploy/SKILL.md (new, manual-only)
Lines 98–108 · deploy steps, 10 items
98
991. SSH into the server: `ssh deploy@203.0.113.10`
1002. Go to the app directory: `cd /var/www/acme-shop`
1013. Put the app in maintenance mode: `php artisan down`
1024. Pull the latest code: `git pull origin main`
1035. Install dependencies: `composer install --no-dev --optimize-autoloader`
1046. Run migrations: `php artisan migrate --force`
1057. Build assets: `npm ci && npm run build`
1068. Clear and rebuild caches: `php artisan optimize`
1079. Restart the queue workers: `php artisan queue:restart`
10810. 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.