rightsize
rightsize adalah skill Claude Code yang mengaudit konteks yang dimuat Claude, seperti CLAUDE.md, AGENTS.md, rules, skill, dan subagent, lalu mengusulkan diff yang hanya menyisakan baris yang mencegah kesalahan nyata.
Contoh, dari fixture tes
Fixture tes di repositorinya adalah CLAUDE.md 125 baris untuk API Laravel. Run rightsize 0.1.3 pada fixture itu, 17 November 2026, menyisakan CLAUDE.md 10 baris, dan konteks yang dimuat setiap sesi turun dari sekitar 1.366 ke sekitar 520 token, 62% lebih sedikit. Runbook deploy menjadi skill yang hanya dijalankan manual, migrate:fresh diblokir hook, dan .env oleh aturan deny.
Delete: persona, stack, pohon direktori, duplikat, saran umum, rujukan basi, dan catatan bertanggal
@@ 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 stackBaris 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 structureBaris 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 commandsBaris 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## ArchitectureBaris 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: aturan mentah, ditulis dengan bahasa biasa
@@ 39 @@ rules
- NEVER add comments to code.6- Match the comment density of the surrounding code; most files here have none.Satu tes untuk setiap baris
Setiap instruksi dikelompokkan sebagai keep, rewrite, move, enforce, atau delete, dengan satu tes: kesalahan nyata apa yang akan dibuat Claude di repo ini tanpa baris ini?
Perlu keputusanmu: CLAUDE.md:39 bertentangan dengan .claude/rules/testing.md:6. Keduanya kini punya cakupan: di sini, ikuti kepadatan komentar di sekitarnya; di sana, komentar satu baris untuk setup tes boleh. Apakah itu maksud timnya?
Laporannya mencatat 5 rewrite; 4 lainnya ada di file .claude/.
Enforce: keluar dari prosa, masuk ke hook, aturan deny, dan aturan ask
@@ 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.Aturan yang harus berlaku
Aturan yang harus selalu berlaku menjadi hook dan aturan izin, ditambah satu baris biasa yang menjelaskan alasannya.
Hook-nya menolak migrate:fresh, migrate:reset, dan db:wipe kecuali dengan --env=testing; hook ini sudah dicoba pada perintah yang harus diblokir dan yang harus dibiarkan lewat. .env tidak boleh dibaca, dan edit ke config/ harus minta izin dulu.
Keep: jebakan uang dalam sen, judul, dan ringkasan proyek
@@ 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 overviewBaris yang mencegah kesalahan nyata
Tanpa baris 43, Claude bisa menyimpan uang sebagai float di repo ini, dan baris itu menjelaskan kenapa total invoice jadi salah. Baris ini dipertahankan apa adanya.
Ringkasan proyek tetap, dan kini memuat dua fakta yang tidak ada di manifest mana pun: MySQL 8 (baris 17) dan queue Redis (baris 124).
Move: contoh controller, checklist review, dan runbook deploy
@@ 51–78 @@ example controller
## Example controller7- New controllers follow `app/Http/Controllers/ProductController.php`.app/Http/Controllers/ProductController.php (pointer at CLAUDE.md:7)Baris 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)Baris 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)Baris 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`Dimuat hanya saat dibutuhkan
Langkah deploy menjadi skill baru yang hanya dijalankan manual, jadi dimuat saat dibutuhkan, bukan setiap sesi. Checklist-nya bergabung ke skill review yang sudah ada. Controller yang ditempel, yang sudah tidak sama dengan aslinya, diganti rujukan ke file aslinya.
Setiap baris berisi teks dari 125 baris ada di salah satu hunk; hanya 13 baris kosong di antara bagian yang dilewati. Angka tokennya estimasi rightsize 0.1.3, jumlah karakter dibagi 2,7.
Apa itu rightsize
Jalankan /rightsize:rightsize, atau minta Claude merampingkan CLAUDE.md yang terlalu gemuk. rightsize lalu bekerja dalam lima langkah:
- Memindai
- setiap file konteks dengan scanner Python yang deterministik dan hanya memakai standard library: apa yang dimuat setiap sesi dan apa yang dimuat saat dibutuhkan, estimasi token, dan 24 pengecekan. Scanner hanya membaca file.
- Mengelompokkan
- setiap instruksi sebagai keep, rewrite, move, enforce, atau delete, dengan satu tes: kesalahan nyata apa yang akan dibuat Claude di repo ini tanpa baris ini?
- Mengusulkan
- diff yang dikelompokkan per verdict. Tidak ada yang berubah sampai kamu memilih kelompok mana yang diterapkan.
- Menegakkan
- aturan yang harus selalu berlaku lewat hook dan aturan izin, ditambah satu baris biasa yang menjelaskan alasannya.
- Mengukur
- sebelum dan sesudah, dari snapshot pemindaian pertama.
Yang saya kerjakan
Saya membangun rightsize sendiri. 0.1.0 keluar pada 5 November 2026, dan 0.1.1 di hari yang sama, disetel pada file CLAUDE.md sungguhan dari repositori publik untuk mengurangi alarm palsu. 0.1.2 (7 November) memperbaiki temuan uji lapangan pada plugin Claude Code, aplikasi desktop, proyek Vite baru, dan ~/.claude pribadi, dan 0.1.3 (8 November) menulis file baru sebelum memotong konten yang dipindahkannya.
Status
0.1.3 adalah rilis terbaru (8 November 2026). Butuh Claude Code dan Python 3.8 atau lebih baru, dan bisa dipasang sebagai plugin atau skill pribadi. Kodenya publik di github.com/mrramdn/rightsize.
Kenapa dibuat
Kebanyakan file instruksi proyek masih membawa kebiasaan dari model lama: ALWAYS dan NEVER dalam huruf kapital, contoh kode yang ditempel, runbook deploy, aturan yang sama di tiga tempat. Claude membaca semuanya di setiap giliran.
Claude membaca stack dari composer.json dan package.json, dan bisa melihat pohon direktorinya sendiri. Baris persona dan “be thorough” adalah penopang yang sudah tidak dibutuhkan model sekarang. Aturan tes kini cukup ada sekali, di
.claude/rules/testing.md, dan perintah, dokumen, serta service yang disebut di sini tidak ada.