
Razor
- 17 repo stars
- Updated February 21, 2026
- blader/razor
Razor is a Claude Code skill that minimizes an uncommitted branch's diff against its merge base using only behavior-preserving, scope-preserving reductions.
About
Razor reduces the size of an uncommitted branch diff measured against its merge base, using only behavior-preserving and scope-preserving changes. A developer uses it to shrink a large pull request by removing cross-file duplication and redundant abstractions before review. It reads every changed file each iteration, writes a ranked reduction plan to TRIM_CODEX.MD, applies the safe cuts, and re-measures insertions and churn.
- Minimizes local diff size against the merge base without changing behavior or scope
- Plans PR-wide architectural reductions in a TRIM_CODEX.MD file each iteration
- Behavior-preserving only; never removes comments and never uses destructive git commands
Razor by the numbers
- Data as of Jul 7, 2026 (Skillselion catalog sync)
razor capabilities & compatibility
- Capabilities
- code review · refactoring · diff reduction
- Works with
- github
- Use cases
- code review · refactoring
What razor says it does
Reduce local diff size with merge-base-anchored architectural planning and behavior-preserving execution only.
Always anchor to merge base: `MB=$(git merge-base <base-ref> HEAD)` (`origin/latest` by default).
Never use destructive git commands.
npx skills add https://github.com/blader/razor --skill razorAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| repo stars | ★ 17 |
|---|---|
| Last updated | February 21, 2026 |
| Repository | blader/razor ↗ |
What it does
Shrink a large PR's diff against its merge base with behavior-preserving architectural cuts, then report the reduction.
Who is it for?
Trimming oversized PRs by consolidating duplication across files while preserving behavior.
Skip if: Reducing scope, removing functionality, or trimming comments and doc-comments.
When should I use this skill?
You want to shrink a large uncommitted branch diff before opening or updating a pull request.
What you get
The PR's non-comment insertions and churn are measurably reduced without any change to behavior or scope.
- A smaller diff plus a TRIM_CODEX.MD plan with before/after metrics
By the numbers
- 11-step workflow
- 8-point output contract
- reads every line of every diff file each iteration
Files
Razor
Reduce local diff size with merge-base-anchored architectural planning and behavior-preserving execution only.
Core Iteration Directive
On every iteration, follow this exact directive:
"Deeply analyze this implementation across the entire PR (not file-by-file in isolation), and create a detailed plan called TRIM_CODEX.MD with the most impactful architectural ideas to dramatically reduce the total size of this PR, without reducing scope or behavior. Comments do not count."
Non-negotiables
- Always anchor to merge base:
MB=$(git merge-base <base-ref> HEAD)(origin/latestby default). - Use unified working-tree diff only:
git diff "$MB". - Include untracked code-file lines in insertion totals.
- Only propose/apply behavior-preserving, scope-preserving reductions.
- Never generate functionality-loss or scope-reduction options.
- Do not remove/trim comments or doc-comments. Comment lines do not count toward reduction targets.
- Keep optimization priority:
1. Primary: reduce non-comment insertions. 2. Secondary: reduce non-comment total churn.
- Optimize at PR architecture level first:
1. Identify duplication and redundant abstractions spanning multiple files/components. 2. Prefer ideas that remove whole cross-file patterns or flows, not local line edits. 3. Treat file-local cleanups as fallback only after high-impact PR-wide ideas are exhausted.
- Read every line of every file in the diff on every iteration.
- Update
TRIM_CODEX.MDevery iteration before execution, then refresh after re-measurement. - Run formatting on touched files and run targeted validation each pass.
- Never use destructive git commands.
Workflow
1. Establish base and merge base. 2. Measure unified diff (status, numstat, name-status, untracked files, untracked code lines). 3. Compute baseline metrics:
- insertions
- deletions
- total churn
- comment-line additions (reported separately, not targeted)
4. Full-diff read (mandatory):
- For each file in
git diff --name-status "$MB", read full current file contents. - For modified files, also review
git diff "$MB" -- <file>hunks.
5. Deep architectural analysis:
- Identify structural duplication and avoidable abstraction layers across the full PR surface.
- Map cross-file data/control flow to find consolidation cuts that remove entire repeated paths.
- Rank ideas by expected PR-wide churn reduction; prioritize multi-file high-leverage cuts.
6. Write/update TRIM_CODEX.MD with:
- Goal and invariants.
- Merge-base baseline and divergence.
- Runtime/test hotspot ranking.
- Architectural diagnosis of churn drivers.
- Ranked behavior-preserving architectural ideas with explicit PR-wide scope (estimated insertion/churn savings, risk, validation notes).
- Clear separation of
PR-wide architectural cutsvslocal cleanup(local cleanup only when no higher-impact architectural cuts remain). - Ordered execution sequence and validation gates.
- Iteration history.
7. Apply viable behavior-preserving ideas. 8. Format touched files. 9. Run targeted validation. 10. Re-measure and refresh TRIM_CODEX.MD with before/after metrics and applied/skipped status. 11. Rerun fresh planning on the updated tree.
Output contract
Always return: 1. Base ref and merge-base SHA. 2. Before stats and after stats (insertions, deletions, churn). 3. Primary and secondary percent reductions. 4. Comment-line additions count (reported separately). 5. Ranked behavior-preserving ideas and applied changes. 6. Confirmation TRIM_CODEX.MD was refreshed this iteration. 7. Confirmation every diff file was fully read this iteration. 8. Explicit statement whether any additional behavior-preserving, scope-preserving reductions remain after fresh rerun.
.DS_Store
interface:
display_name: "Cut Down Diff"
short_description: "Shrink merge-base diff with explicit tradeoffs"
default_prompt: "Use $cut-down-diff to minimize my local diff against merge base with behavior-preserving refactors first, then increasing-loss options."
MIT License
Copyright (c) 2025 blader
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Razor
Minimize your branch diff against merge base with structured, explicit tradeoffs.
Razor analyzes your working branch against its merge base and produces a ranked reduction plan: behavior-preserving refactors first, then a ladder of options with increasing functionality loss. You pick which cuts to make.
What it does
1. Anchors to your merge base (not just HEAD~1) 2. Measures insertions, deletions, netlines, and total churn 3. Ranks files by diff contribution 4. Proposes behavior-preserving refactors (section A) — no feature loss 5. Proposes a functionality-loss ladder (section B) — low/medium/higher impact options 6. Applies only what you select, re-measures, and loops
Install
Claude Code
# Clone into your Claude Code skills directory
git clone https://github.com/blader/razor.git ~/.claude/skills/razorThen restart Claude Code. The skill will be available as /razor.
Codex
# Clone into your Codex skills directory
git clone https://github.com/blader/razor.git ~/.codex/skills/razorThen restart Codex. The skill will be available as $razor.
One-liner (auto-detect)
SKILLS_DIR="${CLAUDE_SKILLS_DIR:-${CODEX_SKILLS_DIR:-$HOME/.claude/skills}}" && \
git clone https://github.com/blader/razor.git "$SKILLS_DIR/razor"Usage
Claude Code:
/razorCodex:
$razorOr just ask naturally:
Shrink my diff against latest
Tighten this branch's diff
Minimize my local changes
How it works
Razor optimizes in strict priority order:
| Priority | Metric | Formula |
|---|---|---|
| Primary | netlines | insertions - deletions |
| Secondary | total churn | insertions + deletions |
Guardrails
- Never recommends reducing tests, docs, or comments
- Never recommends splitting into multiple PRs
- Never uses destructive git commands
- Never cuts the core purpose of the branch
- Tracks declined options across iterations (won't re-suggest them)
License
MIT
Related skills
FAQ
Does razor change what the code does?
No, it applies only behavior-preserving and scope-preserving reductions and never removes functionality.
What does it anchor the diff to?
The merge base computed with git merge-base against the base ref (origin/latest by default), using the unified working-tree diff.