Razor analyzes the implementation for reuse, quality, and efficiency improvements.
From rpi-kitnpx claudepluginhub dmend3z/rpi-kit --plugin rpi-kit<feature-name>rpi//simplifyRefactors code to boost readability and maintainability: reduces nesting, extracts functions, improves naming, removes duplication, simplifies conditionals. Runs tests to verify behavior preservation.
/simplifySimplifies complex code by reducing nesting, eliminating duplication, and improving clarity. Produces a report with before/after metrics, code changes, explanations, and test results.
/simplifySimplifies specified system or approach to essentials by applying constraints: no unproven abstractions, no hypothetical solutions, prefer simple over complex, remove valueless elements.
/simplifyPerforms on-demand simplification review on code scope (uncommitted changes default), detecting duplication, dead code, unnecessary complexity, and AI bloat. Produces findings report.
/simplifyPlans incremental simplification of Rails codebase toward Vanilla Rails philosophy. Analyzes architecture, identifies over-engineering, and outputs phased step-by-step plan with code examples, effort, and risk estimates. Supports specific goals like service reduction.
/simplifyEvaluates proposed solutions for unnecessary complexity, suggests simpler alternatives, and iterates via skeptic agent with user feedback.
Razor analyzes the full implementation diff across 3 dimensions — reuse, quality, and efficiency — and applies improvements directly. Tests must pass before and after.
.rpi.yaml for config. Apply defaults if missing:
folder: rpi/featurescontext_file: rpi/context.mdcommit_style: conventional$ARGUMENTS to extract {slug}.rpi/features/{slug}/implement/IMPLEMENT.md exists. If not:
IMPLEMENT.md not found for '{slug}'. Run /rpi:implement {slug} first.
Stop.rpi/features/{slug}/implement/IMPLEMENT.md. Verify all tasks are marked [x] (done). If any task is [ ] (pending) or BLOCKED:
Implementation is not complete for '{slug}'. {N} tasks remaining.
Complete all tasks before simplifying: /rpi:implement {slug}
Stop.rpi/features/{slug}/implement/IMPLEMENT.md — extract all commit hashes from the Execution Log.git diff {first_commit}^..{last_commit}
$IMPL_DIFF.$CHANGED_FILES.rpi/features/{slug}/plan/eng.md if it exists — store as $ENG.rpi/context.md (project context) if it exists — store as $CONTEXT.npm test # or whatever the project uses
Tests are already failing before simplification. Fix failing tests first.
Stop.$BASELINE_TESTS.Launch Razor agent with this prompt:
You are Razor. Simplify the implementation for feature: {slug}
## Implementation Diff
{$IMPL_DIFF}
## Changed Files
{$CHANGED_FILES}
## Engineering Spec
{$ENG}
## Project Context
{$CONTEXT}
Your task — analyze the implementation across 3 dimensions IN PARALLEL:
### 1. Reuse
- Scan for duplicated code within the changed files
- Scan for duplication against existing codebase utilities
- Identify extraction opportunities (shared functions, constants, types)
- Check for reimplemented functionality that already exists in the project
### 2. Quality
- Naming: unclear variable/function names, inconsistent conventions
- Complexity: functions doing too much, deep nesting, long parameter lists
- Code smells: magic numbers, dead code, commented-out code, unnecessary abstractions
- Consistency: does the new code match the patterns in context.md?
### 3. Efficiency
- Algorithm choices: O(n^2) where O(n) is possible, unnecessary iterations
- Database/API queries: N+1 problems, missing batching, redundant calls
- Imports: unused imports, heavy imports where lighter alternatives exist
- Memory: unnecessary copies, large objects held in scope too long
RULES:
1. Read ALL changed files before making any modifications
2. Apply fixes directly to the code — do not just list suggestions
3. Each fix must preserve existing behavior (no functional changes)
4. Match the project's existing style and patterns
5. Do NOT over-abstract — only extract if there are 3+ duplications
6. After all fixes, list what you changed and why
Output format:
## Changes Applied
- {file}: {what changed} — {why}
## Metrics
- Reuse: {N} fixes
- Quality: {N} fixes
- Efficiency: {N} fixes
- Lines removed: {N}
- Lines added: {N}
After simplification, append your activity to rpi/features/{slug}/ACTIVITY.md:
### {current_date} — Razor (Simplify)
- **Action:** Simplified implementation for {slug}
- **Key decisions:** {for each <decision> tag you emitted: "summary (rationale)", separated by semicolons. If none: "No decisions in this phase."}
- **Reuse fixes:** {count}
- **Quality fixes:** {count}
- **Efficiency fixes:** {count}
- **Lines removed:** {count}
- **Quality:** {your quality gate result}
Store Razor's output as $RAZOR_OUTPUT.
npm test
git checkout -- .Razor's changes broke {N} tests. Changes have been reverted.
Review the failures and re-run: /rpi:simplify {slug}
git add {list of files Razor modified}
commit_style from config:
git commit -m "refactor({slug}): simplify implementation — Razor"
$SIMPLIFY_COMMIT.Append a simplification results section to rpi/features/{slug}/implement/IMPLEMENT.md:
## Simplify
Agent: Razor
Date: {YYYY-MM-DD}
Commit: {$SIMPLIFY_COMMIT}
### Changes
{list of changes from $RAZOR_OUTPUT}
### Metrics
- Reuse fixes: {N}
- Quality fixes: {N}
- Efficiency fixes: {N}
- Net lines: {+/-N}
rpi/features/{slug}/ACTIVITY.md.<decision> tags from entries belonging to the Simplify phase (Razor entries from this run).rpi/features/{slug}/DECISIONS.md if it exists (to get the last decision number for sequential numbering).rpi/features/{slug}/DECISIONS.md:## Simplify Phase
_Generated: {current_date}_
| # | Type | Decision | Alternatives | Rationale | Impact |
|---|------|----------|-------------|-----------|--------|
| {N} | {type} | {summary} | {alternatives} | {rationale} | {impact} |
Simplify complete: {slug}
Razor applied {total} fixes:
- Reuse: {N}
- Quality: {N}
- Efficiency: {N}
Tests: all passing
Commit: {$SIMPLIFY_COMMIT}
Next: /rpi {slug}
Or explicitly: /rpi:review {slug}