Refine Code
Analyze code quality across 6 dimensions (duplication, algorithms, clean code, architecture, errors, style) and apply fixes.
- Type
- Slash Command
- Repository
- athola/claude-night-market
- GitHub stars
- 339
- License
- MIT
- Repo last updated
- Sep 24, 2026
- Source file
- plugins/pensive/commands/refine-code.md
What Refine Code is
Refine Code is a slash command published in the athola/claude-night-market repository on GitHub, which has about 339 stars. The repository describes itself as: “23 Claude Code plugins: TDD enforcement hooks, git/PR workflows, spec-driven development, code review, project lifecycle, fix-from-error, maintenance automation, context optimization, research, and multi-LLM delegation. 186 skills, 128 commands, 54 agents.”
A slash command is a reusable prompt saved as a markdown file and run by typing its name after a slash. In Claude Code, custom commands have been merged into skills: a file in .claude/commands/ and a skill folder in .claude/skills/ both create the same kind of command, and existing command files keep working.
Refine Code gives you a repeatable way to run the same instructions without retyping them, optionally with arguments.
How to install Refine Code
Claude Code
- Download refine-code.md from the repository.
- Save it to ~/.claude/commands/ (all projects) or .claude/commands/ (one project). As a skill, you can instead save it as ~/.claude/skills/<name>/SKILL.md.
- Run it by typing / followed by its name.
Claude Cowork
- Turn the command into a skill: create a folder with the file saved as SKILL.md and zip it.
- In Customize → Skills, click +, then upload the ZIP.
- Run it from any task with / and the skill name.
New to extending Cowork? Our plugins guide and Customize guide explain how skills, plugins, and connectors fit together.
Inside the source file
An excerpt from plugins/pensive/commands/refine-code.md, shared under the repository's MIT license. Read the full file on GitHub.
Analyze living code for quality issues and generate a prioritized refactoring plan.
When To Use
Use this command when you need to:
- After AI-assisted development to check for slop
- Before releases as a quality gate
- When code works but needs improvement
- Systematic refactoring of living code
- Reducing duplication and algorithmic inefficiency
When NOT To Use
Avoid this command if:
- Removing dead/unused code (use /unbloat)
- Bug hunting (use /bug-review)
- Selecting architecture paradigm (use archetypes)
Philosophy
- Craft over speed: Counter AI velocity with intentional quality
- Living code focus: Improve code that stays, not remove code that's dead
- Evidence-based: Every finding has file:line references and principle citations
- Actionable: Concrete before/after proposals, not vague suggestions
Usage
# Quick quality scan (Tier 1, default)
/refine-code
# Scan specific path
/refine-code src/
# Targeted analysis (Tier 2)
/refine-code --level 2
/refine-code --level 2 --focus duplication
/refine-code --level 2 --focus algorithms
# Deep analysis (Tier 3)
/refine-code --level 3 --report quality-report.md
# Apply refinements interactively
/refine-code --applyOptions
Analysis Dimensions
Scan Tiers
Tier 1: Quick (2-5 min)
- Complexity hotspots (long methods, god classes)
- Obvious duplication (exact blocks)
- Naming issues (generic names)
- Magic numbers
- Bare excepts
Tier 2: Targeted (10-20 min)
- Full duplication scan with structural similarity
- Algorithm inefficiency patterns
- Architectural coupling checks
- Anti-slop pattern detection
- Error handling completeness
Tier 3: Deep (30-60 min)
- All Tier 1 and Tier 2
- Cross-module dependency analysis
- Paradigm fitness evaluation (if archetypes available)
- Thorough refactoring plan with before/after code
- Quality score with benchmarks
Example Session
$ /refine-code src/ --level 2
Phase 1: Context
Language: Python | Framework: FastAPI | Size: 2,847 lines (34 files)
Phase 2: Scanning (6 dimensions)
[################] 34 files analyzed (8.3s)
Phase 3: Findings
[1/14] DUPLICATION | HIGH | SMALL effort
src/handlers/user.py:45-62 <-> src/handlers/order.py:23-40
18 duplicate lines (entity permission validation)
Strategy: Extract to shared validate_permissions()
[2/14] ALGORITHM | HIGH | SMALL effort
src/matching.py:45-58
Nested loop on same collection: O(n^2)
…Interactive Apply Mode
When --apply is used:
- Creates backup branch: backup/refine-YYYYMMDD-HHMMSS
- Shows each finding with proposed change
- Prompts: [y]es / [n]o / [d]iff / [s]kip rest / [q]uit
- Runs tests after each change
- Rolls back on test failure
- Reports summary with rollback instructions
Plugin Dependencies
Relationship to Other Commands
See Also
- code-refinement skill: Analysis dimensions and detection patterns
- code-refiner agent: Orchestration implementation
- /cleanup command: Unified cleanup orchestrator (conserve, if available)
- conserve:code-quality-principles: KISS/YAGNI/SOLID reference (if available)
- archetypes:architecture-paradigms: Paradigm detection (if available)
Before you install
- Read the whole file first. Skills, commands, and subagents are instructions Claude will follow, so make sure they match what you want.
- Check which tools, scripts, or MCP servers it uses. Local servers and scripts run with your permissions.
- Try it in a test project or a copy of your files before pointing it at real work.
- Pin the version you tested, and review changes before updating.
- Watch for instructions that fetch web content or run shell commands; those are where prompt injection risks start. See our prompt injection guide.
FAQ
What is Refine Code?
Refine Code is a slash command for Claude Code and Claude Cowork from the athola/claude-night-market repository on GitHub. Analyze code quality across 6 dimensions (duplication, algorithms, clean code, architecture, errors, style) and apply fixes.
How do I install Refine Code in Claude Code?
Download refine-code.md from the repository. Save it to ~/.claude/commands/ (all projects) or .claude/commands/ (one project). As a skill, you can instead save it as ~/.claude/skills/<name>/SKILL.md. Run it by typing / followed by its name.
Can I use Refine Code in Claude Cowork?
Turn the command into a skill: create a folder with the file saved as SKILL.md and zip it. In Customize → Skills, click +, then upload the ZIP. Run it from any task with / and the skill name.
Is Refine Code safe to install?
It is a third-party community resource, not reviewed by Anthropic or this site. Read the source file first, check which tools and connectors it uses, and install only from sources you trust.
Similar resources
- Garden Curator Manage digital garden health, metrics, notes, and curation. Use for knowledge base maintenance and garden tending tasks. Subagent · athola/claude-night-market
- Fix Pr Address PR/MR review feedback by reading comments, implementing fixes, and resolving threads. GitHub and GitLab support. Slash Command · athola/claude-night-market
- From Hook Convert Python SDK hooks to declarative rules Slash Command · athola/claude-night-market
- Filter Log Suggest tier-1 filter commands for a log file before any compression or paste. Anchors on the log-debugging-hygiene module. Slash Command · athola/claude-night-market
- Reinstall All Plugins Uninstall and reinstall all Claude Code plugins to refresh cache and resolve version mismatches. Slash Command · athola/claude-night-market
- Record Terminal Create terminal recordings with VHS tape scripts Slash Command · athola/claude-night-market
- Research Run a multi-source research session searching GitHub, HN, Lobsters, Reddit, arXiv, and Semantic Scholar. Use for multi-channel topic surveys. Slash Command · athola/claude-night-market
- Record Browser Record browser sessions using Playwright Slash Command · athola/claude-night-market