From pensive
Refines code quality by analyzing duplication, algorithmic efficiency, clean code violations, architectural fit, anti-slop patterns, and error handling. Use after AI sprints, before releases, or for refactoring existing code.
How this skill is triggered — by the user, by Claude, or both
Slash command
/pensive:code-refinementThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
- [Quick Start](#quick-start)
Analyze and improve living code quality across six dimensions.
/refine-code
/refine-code --level 2 --focus duplication
/refine-code --level 3 --report refinement-plan.md
| # | Dimension | Module | What It Catches |
|---|---|---|---|
| 1 | Duplication & Redundancy | duplication-analysis | Near-identical blocks, similar functions, copy-paste |
| 2 | Algorithmic Efficiency | algorithm-efficiency | O(n^2) where O(n) works, unnecessary iterations |
| 3 | Clean Code Violations | clean-code-checks | Long methods, deep nesting, poor naming, magic values |
| 4 | Architectural Fit | architectural-fit | Paradigm mismatches, coupling violations, leaky abstractions |
| 5 | Anti-Slop Patterns | clean-code-checks | Premature abstraction, enterprise cosplay, hollow patterns |
| 6 | Error Handling | clean-code-checks | Bare excepts, swallowed errors, happy-path-only |
Load modules based on refinement focus:
modules/duplication-analysis.md (~400 tokens): Duplication detection and consolidationmodules/algorithm-efficiency.md (~400 tokens): Complexity analysis and optimizationmodules/clean-code-checks.md (~450 tokens): Clean code, anti-slop, error handlingmodules/architectural-fit.md (~400 tokens): Paradigm alignment and couplingLoad all for comprehensive refinement. For focused work, load only relevant modules.
refine:context-established — Scope, language, framework detectionrefine:scan-complete — Findings across all dimensionsrefine:prioritized — Findings ranked by impact and effortrefine:plan-generated — Concrete refactoring plan with before/afterrefine:evidence-captured — Evidence appendix per imbue:proof-of-workrefine:context-established)Detect project characteristics:
# Language detection
find . -not -path "*/.venv/*" -not -path "*/__pycache__/*" \
-not -path "*/node_modules/*" -not -path "*/.git/*" \
\( -name "*.py" -o -name "*.ts" -o -name "*.rs" -o -name "*.go" \) \
| head -20
# Framework detection
ls package.json pyproject.toml Cargo.toml go.mod 2>/dev/null
# Size assessment
find . -not -path "*/.venv/*" -not -path "*/__pycache__/*" \
-not -path "*/node_modules/*" -not -path "*/.git/*" \
\( -name "*.py" -o -name "*.ts" -o -name "*.rs" \) \
| xargs wc -l 2>/dev/null | tail -1
refine:scan-complete)Load relevant modules and execute analysis per tier level.
refine:prioritized)Rank findings by:
Priority = HIGH impact + SMALL effort + LOW risk first.
refine:plan-generated)For each finding, produce:
refine:evidence-captured)Document with imbue:proof-of-work (if available):
[E1], [E2] references for each findingFallback: If imbue is not installed, capture evidence inline in the report using the same [E1] reference format without TodoWrite integration.
| Tier | Time | Scope |
|---|---|---|
| 1: Quick (default) | 2-5 min | Complexity hotspots, obvious duplication, naming, magic values |
| 2: Targeted | 10-20 min | Algorithm analysis, full duplication scan, architectural alignment |
| 3: Deep | 30-60 min | All above + cross-module coupling, paradigm fitness, comprehensive plan |
| Dependency | Required? | Fallback |
|---|---|---|
pensive:shared | Yes | Core review patterns |
imbue:proof-of-work | Optional | Inline evidence in report |
conserve:code-quality-principles | Optional | Built-in KISS/YAGNI/SOLID checks |
archetypes:architecture-paradigms | Optional | Principle-based checks only (no paradigm detection) |
When optional plugins are not installed, the skill degrades gracefully:
imbue: Evidence captured inline, no TodoWrite proof-of-workconserve: Uses built-in clean code checks (subset)archetypes: Skips paradigm-specific alignment, uses coupling/cohesion principles onlynpx claudepluginhub athola/claude-night-market --plugin pensiveProvides a structured approach to refining and improving code quality, architecture, and implementation patterns across projects.
Reviews recently implemented code for reuse opportunities, quality issues, and efficiency problems. Dispatches parallel reviewers, applies user-approved fixes with test verification, and generates a structured simplification report.
Applies clean code principles (single responsibility, small functions, clear naming, complexity limits) to generated or refactored code. Triggered by 'clean code', 'refactor this', etc.