turborazor
Autonomous local diff reducer that repeatedly performs behavior-preserving, scope-preserving architectural reductions until no further viable cuts remain.
TurboRazor
Run $razor locally in a tight loop until no additional behavior-preserving, scope-preserving reductions remain.
Purpose
Use this skill when the user wants full autonomous cut-down-diff execution with no functionality-loss options.
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
- Run
$razordirectly in the current workspace; do not delegate. - At the start of every iteration, commit current behavior-preserving edits.
- Re-anchor each iteration to fresh merge base (
origin/latestby default). - Use unified diff only and include untracked code-file lines in insertion totals.
- Read every line of every file in the diff on every iteration.
- Only apply behavior-preserving, scope-preserving reductions.
- Never produce or apply functionality-loss/scope-reduction options.
- Prioritize PR-wide architectural reductions over file-level cleanups on every pass.
- Require cross-file consolidation analysis each iteration; local refactors are fallback only.
- Comments/doc-comments are never removable churn and do not count toward reduction targets.
- Update
TRIM_CODEX.MDbefore edits and after re-measurement on every iteration. - Run formatter(s) on touched files and targeted validation each pass.
- Keep looping until a fresh rerun finds zero viable behavior-preserving reductions OR a user-specified churn reduction target is met.
- When user specifies a reduction target (e.g., "cut churn by 50%"), keep iterating until that target is achieved. Do not stop early just because one pass found fewer cuts — there are always more savings to find through deeper cross-file analysis, consolidation, and dead-path elimination.
- Never use destructive git commands.
- If the user provides a standing instruction to auto-handle unexpected local changes, do not pause to ask again: inspect the unexpected diff, include behavior-preserving changes, and continue.
Startup
On first invocation, delete TRIM_CODEX.MD if it exists (without reading it). Each run starts fresh.
Iteration loop
- Commit current pass edits.
- Compute fresh anchor and baseline metrics vs merge base.
- Full-diff read of every changed file (and modified-file hunks).
- Perform deep PR-wide architectural analysis of churn drivers, emphasizing cross-file duplication and redundant abstraction layers.
- Write/update
TRIM_CODEX.MDwith ranked highest-impact behavior-preserving ideas, listing PR-wide architectural cuts before any local cleanup options. - Apply all currently viable behavior-preserving ideas.
- Run formatting.
- Run targeted validation.
- Re-measure vs the same merge base.
- Refresh
TRIM_CODEX.MDwith results. - Check if user-specified reduction target is met. If yes, stop. If no, continue.
- Rerun from fresh diff state; stop only when target is met or no viable reductions remain.
Cross-file rearchitecturing (mandatory every pass)
Every iteration MUST include a dedicated cross-file rearchitecturing analysis phase:
- Map data flow and call chains across ALL changed files to find where the branch introduced unnecessary indirection, wrapper types, adapter layers, or intermediate representations.
- Identify cases where the branch added parallel implementations in separate files that could be unified into a single site with parameterization.
- Look for "bridge" patterns: where file A calls file B which calls file C, and the branch's changes to B are purely pass-through — collapse B's changes out.
- Detect shared helper functions/types that were added in one file but could replace duplicated logic in other changed files (or vice versa: helpers that exist only to serve one call site and should be inlined).
- Check whether branch-added interfaces, structs, or type aliases are used in enough places to justify their existence, or if they can be eliminated by using the concrete type directly.
- When multiple files each add similar error handling, logging, or validation patterns, consolidate into a single shared implementation.
- Question every new file added by the branch: can its contents be absorbed into an existing file without loss of clarity?
- This phase produces the highest-impact cuts and MUST be completed before any local per-file cleanup.
Target-driven persistence
When a user specifies a churn reduction target (e.g., "cut by 50%"):
- If a pass yields diminishing returns, dig deeper: re-examine files previously considered "done", look for multi-file consolidation opportunities missed earlier, question whether helper functions/types added by the branch could be inlined, and check if any branch-added abstractions can be collapsed.
- When still above target, escalate to aggressive cross-file rearchitecturing: trace every branch-added function/method through all its callers and determine if the abstraction boundary is earning its churn cost. If a function is called from only 1-2 sites, inline it. If a type is instantiated in only one place, collapse it.
- Do NOT declare "no more reductions possible" while still above target unless you have exhaustively attempted every category: dead code removal, abstraction collapse, duplication elimination, unnecessary type/struct additions, over-logging, redundant error wrapping, cross-file consolidation, interface elimination, and test-only infrastructure bloat.
Commit discipline
- Use normal descriptive commit messages.
- Do not mention razor/turborazor automation details in commit messages.
- Commit only files that are part of the pass.
- Do not amend/squash unless explicitly requested.
- When unexpected local changes appear and the user pre-authorized handling, inspect and include them in the current pass if behavior-preserving; record what was included in
TRIM_CODEX.MD.
Cleanup
After the final iteration completes, delete TRIM_CODEX.MD from the working tree and ensure it is not tracked by git (remove from index if staged/committed during the run). The planning artifact is transient and must not persist after the skill finishes.
Reporting contract
After completion, report:
- Base ref and merge-base SHA.
- Before/after totals (insertions, deletions, total churn).
- Primary/secondary percent reductions.
- Comment-line additions count (separate from reduction target).
- Per-pass applied changes and validations.
- Confirmation every diff file was fully read every iteration.
- Explicit statement that a fresh rerun found no additional behavior-preserving, scope-preserving reductions.
이 스킬의 파일
이 스킬에는 보조 파일이 없습니다.