From rpi-kit
Razor analyzes the implementation for reuse, quality, and efficiency improvements.
How this command is triggered — by the user, by Claude, or both
Slash command
/rpi-kit:simplify <feature-name>rpi/This command is limited to the following tools:
The summary Claude sees in its command listing — used to decide when to auto-load this command
# /rpi:simplify — Simplify Phase
Razor analyzes the full implementation diff across 3 dimensions — reuse, quality, and efficiency — and applies improvements directly. Tests must pass before and after.
---
## Step 1: Load config and validate
1. Read `.rpi.yaml` for config. Apply defaults if missing:
- `folder`: `rpi/features`
- `context_file`: `rpi/context.md`
- `commit_style`: `conventional`
2. Parse `$ARGUMENTS` to extract `{slug}`.
3. Validate `rpi/features/{slug}/implement/IMPLEMENT.md` exists. If not:
Stop.
4. Read `rpi/features/{slug}/implement/IMPLEMENT.md`. Verify...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}
npx claudepluginhub dmend3z/rpi-kit --plugin rpi-kit/code-simplifySimplifies recently changed code by reducing complexity without altering behavior — applies guard clauses, splits long functions, renames for clarity, deduplicates logic, and removes dead code with incremental test verification.
/simplifyAnalyzes specified code scope (default: uncommitted changes) for duplication, dead code, unnecessary complexity, and AI bloat, producing a simplification report with follow-up options.
/code-simplifierAnalyzes recent git changes for simplification opportunities and applies them one by one after user approval.
/self-reviewRuns a two-phase self-review on changed files: Simplifier refines code clarity, then Scrutinizer applies a 9-pillar quality gate with architectural decision and feature knowledge context.
/simplifySimplifies and refactors target code files or modules, reducing complexity and duplication while preserving behavior with included tests.
/candid-improve-implementationReviews code implementation for approach, clarity, quality improvements; suggests next-version enhancements, supports selection/application with tone, focus, exclude flags, and optional auto-commit.