code-refinement
FreeNo executable scriptsNot checkedImproves code quality across duplication, efficiency, and architectural fit
by athola1,912 installs in other catalogsAbout this skill
Night Market Skill: ported from claude-night-market/pensive. For the full experience with agents, hooks, and commands, install the Claude Code plugin.
Code Refinement Workflow
Analyze and improve living code quality across six dimensions.
Quick Start
/refine-code
/refine-code --level 2 --focus duplication
/refine-code --level 3 --report refinement-plan.md
When To Use
- After rapid AI-assisted development sprints
- Before major releases (quality gate)
- When code "works but smells"
- Refactoring existing modules for clarity
- Reducing technical debt in living code
When NOT To Use
- Removing dead/unused code (use conserve:bloat-detector)
Analysis Dimensions
| # | 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 |
| 7 | Additive Bias | imbue:justify |
Workarounds over root fixes, test tampering, unnecessary additions |
Plugin-Specific Patterns
Detection patterns for plugin and skill codebases where standard code quality heuristics miss structural issues.
Delegation Stub Bodies
A skill that declares "delegates to X" but still carries the full template body is doing double duty. The delegating skill should be a thin wrapper (under 30 lines) that routes to the target. Flag any delegating skill whose body exceeds 50 lines.
Module Explosion
Flag skills with 10+ module files where 40% or more of content overlaps. Signal: two modules covering the same API surface from different angles (e.g., both describing the same config options or the same CLI flags).
Oversized Single Modules
Flag individual module files exceeding 500 lines as candidates for splitting or trimming. Large modules defeat progressive loading by forcing full-file reads for partial information.
Dead Python References
Skills referencing Python commands (python -m module.name or
python -c "from module import ...") where the referenced
module does not exist in the plugin's src/ directory. These
are stale references to renamed or removed code.
Progressive Loading
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 coupling
Load all for thorough refinement. For focused work, load only relevant modules.
Required Progress Items
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 perimbue:proof-of-workrefine:findings-verified: Citations confirmed bycitation_verifier.pyrefine:execution-complete: All wave-listed candidates closed-or-rationale'd (only required when invocation includes "execute findings" or stronger; see Step 6)
Workflow
Step 1: Establish Context (refine: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
Step 2: Dimensional Scan (refine:scan-complete)
Load relevant modules and execute analysis per tier level.
For dimension 7 (Additive Bias), run Skill(imbue:justify)
to compute the bias score, check Iron Law compliance,
and flag unnecessary additions or workarounds.
Step 3: Prioritize (refine:prioritized)
Rank findings by:
- Impact: How much quality improves (HIGH/MEDIUM/LOW)
- Effort: Lines changed, files touched (SMALL/MEDIUM/LARGE)
- **
Install code-refinement in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
Allowed tools
Tools this skill is permitted to call.
No restriction — this skill can use any tool.
FAQ
What does the code-refinement skill do?
Improves code quality across duplication, efficiency, and architectural fit
How do I install the code-refinement skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the code-refinement skill run scripts?
No, this skill is instructions only (SKILL.md) with no executable scripts.
Related skills
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
by Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
by Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
by Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
by Anthropic