sailop refactor-llm
The Pro command that sends a slop file to Anthropic with this project's brand-aware rules pack and writes back the refactored version. When the regex auto-fix can't handle structural slop, this can.
sailop activate sl_pro_xxxxxxxxxxxxxxxxxxxx. Your Anthropic API key is yours — Sailop never proxies. Anthropic bills you directly.Quick start
# 1. activate Pro sailop activate sl_pro_xxxxxxxxxxxxxxxxxxxx # 2. set your Anthropic key (one of these — read in this order) export ANTHROPIC_API_KEY=sk-ant-... # or export SAILOP_ANTHROPIC_KEY=sk-ant-... # 3. refactor a file sailop refactor-llm src/app/page.tsx
The command reads .sailop/brand.json (created by sailop install) for your palette, fonts, sector, and voice. It builds a system prompt from generateRulesPack(brand): every banned hex / font / utility paired with this project's actual replacement value, plus brand-correct TSX exemplars so the model pattern-matches the right shapes.
What you see in the terminal
┌─ SAILOP ─────────────────────────────────────────────────────────┐
│ LLM refactor (Pro). BYO Anthropic key. │
└──────────────────────────────────────────────────────────────────┘
file: src/app/page.tsx
size: 6.1 KB
brand: #C24A36 · Fraunces · Cardo
model: claude-sonnet-4-6
est. tokens: 4220 in · 1740 out
est. cost: ~$0.0387 (billed by Anthropic, not Sailop)
[1/3] Calling Anthropic…
● 4180 in · 1822 out · $0.0398 · 4.7s
[2/3] Re-scanning…
score: 67/D → 18/A ▼ 49 pts
diff: +84 -71 lines
--- preview (first 40 changed lines) ---
- <button className="bg-blue-500 hover:bg-blue-600 text-white px-6 py-3 rounded-2xl shadow-xl">
+ <button className="px-5 py-2.5 rounded-md hover:opacity-90"
+ style={{ background: '#C24A36', color: '#f7f1e7', fontFamily: 'Fraunces, serif' }}>
...
[3/3] Apply changes
? write refactored output? [Y/n]: y
● backup: .sailop/backup/page.tsx.1714838291000.bak
● wrote: src/app/page.tsx
✓ done.Flags
| Flag | What it does |
|---|---|
--key <sk-ant-…> | Anthropic API key. Defaults to $ANTHROPIC_API_KEY or $SAILOP_ANTHROPIC_KEY. |
-m, --model <name> | opus | sonnet (default) | haiku. Or full IDs (claude-sonnet-4-6). |
--max-cost <usd> | Confirm before exceeding this estimate. Default 0.50. |
-y, --yes | Skip cost confirm + diff preview. For scripts. |
-o, --output <file> | Write to a different file. Default: in-place with backup at .sailop/backup/<name>.<ts>.bak. |
--dry-run | Show diff but don't write. |
Cost
Anthropic public list pricing (per million tokens, May 2026):
| Model | Input | Output | ~Per file |
|---|---|---|---|
| opus 4.7 | $15 | $75 | ~$0.20 |
| sonnet 4.6 · default | $3 | $15 | ~$0.04 |
| haiku 4.5 | $1 | $5 | ~$0.013 |
Per-file estimates assume a typical TSX (4-6 KB). The exact spend is always reported by the API and shown in the terminal after each call.
System prompt
The system prompt is the brand-aware CLAUDE.md from generateRulesPack(brand) — same content the AI agents read at every keystroke after sailop install. So whatever Claude Code refused to write because of the rules pack, the LLM refactor will rewrite using the same rules.
The prompt includes:
- Project identity (name, sector, voice, tagline)
- Page-object format catalog (essay-long-form, manifesto, dashboard-density, catalog-spread, …)
- Brand palette (8 roles) with actual hex values
- Brand fonts (display / body / mono) with actual family names
- Hard bans paired with this project's replacement values
- Brand-correct TSX exemplars (button / heading / body / link)
- Sector-specific copy bans (dev-tool, fintech, creative-agency, editorial-media, …)
- Required patterns (one CTA per section, vary container widths, etc.)
sailop install and there's no .sailop/brand.json, the command falls back to a generic anti-slop spec. The output will be less precise — run sailop install first for sharper refactors.What it preserves
- All imports + exports + prop types (unless they themselves are slop)
- Section structure and semantic HTML
- Component logic (event handlers, state, side effects)
- Any user content outside the rule of slop
What it changes
- Banned hex (Tailwind blue, indigo, slate dark/light) → this project's palette
- Banned fonts (Inter, Geist, Manrope, Cal Sans) → this project's display/body
- Banned utilities (
rounded-2xl,shadow-xl,backdrop-blur) → brand-appropriate - Banned copy ("Get Started", "Ship faster", "Powered by AI", eyebrow pills with emoji) → project-specific verbs
- SaaS-skeleton sections → page-object alternatives (essay paragraph, lab-notebook entry, manifesto thesis)
Privacy
Your file content is sent to Anthropic with your API key. Sailop never sees the file, the key, or the response. The CLI calls https://api.anthropic.com/v1/messages directly. The only thing Sailop validates is your Pro license (one POST to sailop.com/api/license/validate on sailop activate, never on refactor-llm itself).
Failure modes
- Empty output — the model occasionally returns nothing on tiny files. Try
--model opus. - Code-fence wrapping — Sailop strips
```tsx … ```automatically if the model wraps despite our instruction. - Score regression — rare, but possible. The terminal shows score before/after; if after > before, hit
nand try a different model. - Rate limits — handle Anthropic 429 by waiting, then re-run. Sailop doesn't auto-retry to keep cost predictable.
See also
- Getting Started — install ceremony walkthrough
- CLI Reference — every command + flag
- Scoring System — what the score means
- Pricing — Free / Pro €99 / Team €299