Sponsor Suno AI Music arrow_forward
Slash Command

Refine Code

Analyze code quality across 6 dimensions (duplication, algorithms, clean code, architecture, errors, style) and apply fixes.

Type
Slash Command
GitHub stars
339
License
MIT
Repo last updated
Sep 24, 2026

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

  1. Download refine-code.md from the repository.
  2. 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.
  3. Run it by typing / followed by its name.

Claude Cowork

  1. Turn the command into a skill: create a folder with the file saved as SKILL.md and zip it.
  2. In Customize → Skills, click +, then upload the ZIP.
  3. 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 --apply

Options

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:

  1. Creates backup branch: backup/refine-YYYYMMDD-HHMMSS
  2. Shows each finding with proposed change
  3. Prompts: [y]es / [n]o / [d]iff / [s]kip rest / [q]uit
  4. Runs tests after each change
  5. Rolls back on test failure
  6. 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

Browse all skills, subagents, and plugins →

Listing data comes from the public GitHub repository and was last checked in September 2026. Excerpts are © their authors and shared under MIT. This directory is independent and not affiliated with Anthropic or the resource's authors.