Agent skill

Code Refinement

by athola in athola/claude-night-market

Improves code quality across duplication, efficiency, and architectural fit.

MITAuto-check passedDevelopment

Install Code Refinement

skills CLI
$ npx skills add athola/claude-night-market --skill code-refinement -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install athola/claude-night-market code-refinement --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/athola/claude-night-market.git skills-src && mkdir -p .claude/skills && cp -r skills-src/plugins/pensive/skills/code-refinement .claude/skills/code-refinement && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
code-refinement
GitHub stars
342
Token cost
~3k tokens
SKILL.md length
1,277 words
Files
7
Skills in repo
160
Repo updated
First seen
Licence
MIT

At a glance

Improves code quality across duplication, efficiency, and architectural fit.

  • Works in 6 steps: Establish Context… → Dimensional Scan (refine:scan-complete) → Prioritize (refine:prioritized) → …
  • Code passes tests but quality is poor
  • SKILL.md covers Quick Start, When To Use, When NOT To Use and Analysis Dimensions, plus 8 more sections
  • Calls python

What it does

Code Refinement is an agent skill from athola/claude-night-market. Improves code quality across duplication, efficiency, and architectural fit. Use when code passes tests but quality is poor or before a major release.

Its SKILL.md is about 3k tokens, which your agent loads only when the skill is triggered. The skill folder holds 7 other files (for example `modules/algorithm-efficiency.md`, `modules/architectural-fit.md` and `modules/clean-code-checks.md`).

It sits in Development, covering Code quality. It works with Python. 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… The licence is MIT.

When your agent uses it

  • Code passes tests but quality is poor
  • Before a major release

Example prompts

  • “Use the code-refinement skill to improve code quality across duplication, efficiency, and architectural fit”
  • “/code-refinement”

Requirements

  • Python 3

Workflow steps

6 steps, taken from the step headings in SKILL.md.

  1. Establish Context (refine:context-established)
  2. Dimensional Scan (refine:scan-complete)
  3. Prioritize (refine:prioritized)
  4. Generate Plan (refine:plan-generated)
  5. Evidence Capture (refine:evidence-captured)
  6. Execute Findings (refine:execution-complete)

What it can do on your machine

Read from SKILL.md and the folder at commit 9f3eb00. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • python

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Code Refinement loads about 3k tokens when it runs. Until then it costs about 42 tokens; SKILL.md has 1,277 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~42
When it runs · the whole SKILL.md, loaded when a task matches
~3k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from athola/claude-night-market at commit 9f3eb00, republished under its MIT licence (© athola). 1,277 words, ~2,978 tokens.

Download SKILL.mdSave it as .claude/skills/code-refinement/SKILL.md (or your agent's skills folder). This skill also uses 6 other files; get the full folder from GitHub.
name
code-refinement
description
Improves code quality across duplication, efficiency, and architectural fit. Use when code passes tests but quality is poor or before a major release.
alwaysApply
false
category
code-quality
tags
refactoring, clean-code, algorithms, duplication, anti-slop, craft
usage_patterns
code-quality-improvement, duplication-reduction, algorithm-optimization, clean-code-enforcement
complexity
advanced
model_hint
deep
estimated_tokens
350
progressive_loading
true
dependencies
pensive:safety-critical-patterns, imbue:proof-of-work, imbue:justify, imbue:review-core, imbue:structured-output
modules
modules/duplication-analysis.md, modules/algorithm-efficiency.md, modules/clean-code-checks.md, modules/architectural-fit.md, modules/insight-generation.md

Code Refinement Workflow

Analyze and improve living code quality across six dimensions.

Quick Start

bash
/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

#DimensionModuleWhat It Catches
1Duplication & Redundancyduplication-analysisNear-identical blocks, similar functions, copy-paste
2Algorithmic Efficiencyalgorithm-efficiencyO(n^2) where O(n) works, unnecessary iterations
3Clean Code Violationsclean-code-checksLong methods, deep nesting, poor naming, magic values
4Architectural Fitarchitectural-fitParadigm mismatches, coupling violations, leaky abstractions
5Anti-Slop Patternsclean-code-checksPremature abstraction, enterprise cosplay, hollow patterns
6Error Handlingclean-code-checksBare excepts, swallowed errors, happy-path-only
7Additive Biasimbue:justifyWorkarounds 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 consolidation
  • modules/algorithm-efficiency.md (~400 tokens): Complexity analysis and optimization
  • modules/clean-code-checks.md (~450 tokens): Clean code, anti-slop, error handling
  • modules/architectural-fit.md (~400 tokens): Paradigm alignment and coupling

Load all for thorough refinement. For focused work, load only relevant modules.

Required TodoWrite Items

  1. refine:context-established: Scope, language, framework detection
  2. refine:scan-complete: Findings across all dimensions
  3. refine:prioritized: Findings ranked by impact and effort
  4. refine:plan-generated: Concrete refactoring plan with before/after
  5. refine:evidence-captured: Evidence appendix per imbue:proof-of-work
  6. refine:findings-verified: Citations confirmed by citation_verifier.py
  7. refine: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:

bash
# 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)
  • Risk: Likelihood of introducing bugs (LOW/MEDIUM/HIGH)

Priority = HIGH impact + SMALL effort + LOW risk first.

Step 4: Generate Plan (refine:plan-generated)

For each finding, produce:

  • File path and line range
  • Anchor: verbatim source text at the cited line
  • Current code snippet
  • Proposed improvement
  • Rationale (which principle/dimension)
  • Estimated effort
Step 5: Evidence Capture (refine:evidence-captured)

Document with imbue:proof-of-work (if available):

  • [E1], [E2] references for each finding
  • Metrics before/after where measurable
  • Principle violations cited

Fallback: If imbue is not installed, capture evidence inline in the report using the same [E1] reference format without TodoWrite integration.

Step 6: Execute Findings (refine:execution-complete)

Steps 1-5 produce a plan. Steps 6 produces closures. Both are part of the skill. Execution does not stop at planning unless the user explicitly says "plan only".

Execution mode detection

Match the user's invocation phrasing against this table to determine execution scope:

User saidModeStop when
/code-refinement (no qualifier)Plan onlyAfter Step 5
--dry-run or "just plan"Plan onlyAfter Step 5
"execute findings" / "apply fixes"Plan, execute Wave 1After all SMALL-effort, and LOW-risk findings closed
"execute all findings" / "all phases" / "all waves"Plan and execute every waveAfter every finding (or every wave-listed candidate) is either closed by commit or has explicit per-item rationale in the synthesis
"ignore scope guard"Override branch-size limitsBranch metrics do not gate execution. Continue past RED zone.
"do not stop until complete" / "until ALL ... complete"No mid-task summariesOnly declare done when synthesis has every wave-listed candidate closed-or-rationale'd

The triggers compose: --tier 3 --execute all findings --ignore-scope-guard means run every Wave 2 and Wave 3 candidate to closure regardless of branch size.

Show full SKILL.md (538 more words)Show less
Completion gate (when execution mode is active)

The task is not complete until ALL of the following hold:

  1. Wave 2 candidates (medium-effort, listed in synthesis "Wave 2 Candidates" section): every entry has either a closure commit or an explicit per-item line in the synthesis stating why it is not viable.
  2. Wave 3 candidates (large-effort, listed in synthesis "Wave 3 Candidates" section): same gate. Do not pre-emptively defer LARGE-effort items with generic "needs dedicated PR" rationale when the user said "execute all". Execute the mechanical ones (split-by-class, mixin-package, module-merge) and reserve "deferred" only for items requiring architecture-level decisions (schema changes, new dependency declarations, new venv layouts).
  3. Synthesis updated: docs/refinement/<date>/00-synthesis.md records every closure with its commit SHA and every deferral with one-sentence rationale.
Anti-pattern detector for the agent itself

If the model finds itself doing any of the following during execution, this is a stop-hook leak. Go back to executing findings:

Anti-patternRecognise as
"Wave 2 closed. Moving to Wave 3." (mid-run summary)Premature turn-completion signal: keep working
"Documenting deferred items with rationale" before all mechanical items are doneSkipping execution under a paper trail
Writing a completion summary while >0 listed candidates lack closure-or-rationaleViolation of completion gate
Re-asking user "should I continue?" when invocation included "do not stop"Ignoring the explicit no-mid-task-summary contract
What decides the gate

The gate reads records, not the agent's account of its own work: .review/findings.json and the citation verifier's exit code (see the next section) say which candidates are closed, and the synthesis lists the rest. Execution is bounded by max_waves (default 3, one wave per pass over the open candidates). When the budget runs out, or when the harness fires a stop signal, the run stops: record every remaining candidate in the synthesis as a gap with what would close it, and end the turn. Do not resume past a stop signal. A harness stop is a signal from outside the run, and a run that overrides it has made itself the judge of its own completeness, which is the arrangement measured to drift (arXiv 2607.17641).

Verify Findings Are Grounded (refine:findings-verified)

Write findings to .review/findings.json, run the citation verifier (Skill(imbue:review-core) Step 5), and drop or label UNVERIFIED any the verifier rejects.

Exit Criteria

  • All six analysis dimensions have a verdict (finding or "no issue detected") for the target scope.
  • Each finding includes a file path, line range, and verbatim Anchor (the exact source text at that line).
  • Every reported finding carries a Location + verbatim Anchor confirmed by citation_verifier.py (exit 0), or unverified findings were dropped or labeled UNVERIFIED.

Tiered Analysis

TierTimeScope
1: Quick (default)2-5 minComplexity hotspots, obvious duplication, naming, magic values
2: Targeted10-20 minAlgorithm analysis, full duplication scan, architectural alignment
3: Deep30-60 minAll above and cross-module coupling, paradigm fitness, thorough plan

Cross-Plugin Dependencies

DependencyRequired?Fallback
imbue:proof-of-workOptionalInline evidence in report
conserve:code-quality-principlesOptionalBuilt-in KISS/YAGNI/SOLID checks
archetypes:architecture-paradigmsOptionalPrinciple-based checks only (no paradigm detection)

Supporting Modules

When optional plugins are not installed, the skill degrades gracefully:

  • Without imbue: Evidence captured inline, no TodoWrite proof-of-work
  • Without conserve: Uses built-in clean code checks (subset)
  • Without archetypes: Skips paradigm-specific alignment, uses coupling/cohesion principles only

© athola, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 6 other files in plugins/pensive/skills/code-refinement of athola/claude-night-market.

  • SKILL.md
  • modules/algorithm-efficiency.md
  • modules/architectural-fit.md
  • modules/clean-code-checks.md
  • modules/code-quality-analysis.md
  • modules/duplication-analysis.md
  • modules/insight-generation.md

Open the folder on GitHubat commit 9f3eb00

Compare with similar skills

Code Refinement next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Code Refinement compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Code Refinement this skillathola/claude-night-market342—~3kAutomated safety check: PassMIT
Dignified Python Standardsdocling-project/docling68k—~1.5kAutomated safety check: PassApache-2.0
Code Review Skillawesome-skills/code-review-skill2.1k—~2.8kAutomated safety check: NotesMIT
Code Reviewerjewbetcha/opentrace1162 repos~1.1kAutomated safety check: NotesMIT
Code Review Specialistluongnv89/claude-howto42k—~764Automated safety check: PassMIT
Cross-Language Coding Standardszereight/gitlab-mcp2k1 repos~1.4kAutomated safety check: PassMIT

Similar skills

  • Dignified Python Standards

    docling-project/docling

    Applies opinionated production Python conventions chosen by the project's Python version: modern type syntax, pathlib, explicit checks and interface guidance.

    68k GitHub stars~1.5k tokensUpdated yesterday
    DevelopmentAuto-check passed
  • Code Review Skill

    awesome-skills/code-review-skill

    Provides comprehensive code review guidance for React 19, Vue 3, Angular 17+, Svelte 5, Rust, TypeScript, Java, Java 8, PHP, Ruby, Rails, Python, Django, FastAPI, Go, C/.NET, Kotlin, Swift, Dart…

    2.1k GitHub stars~2.8k tokensUpdated 29 days ago
    DevelopmentAuto-check: notes
  • Code Reviewer

    jewbetcha/opentrace

    Comprehensive code review skill for TypeScript, JavaScript, Python, Swift, Kotlin, Go.

    116 GitHub starsUsed in 2 repos~1.1k tokens
    DevelopmentAuto-check: notes
  • Code Review Specialist

    luongnv89/claude-howto

    Reviews code for security, performance, quality and maintainability, using a checklist, a finding template and two metrics scripts.

    42k GitHub stars~764 tokensUpdated 7 days ago
    DevelopmentAuto-check passed
  • Shared reference for naming, function size, complexity and error handling rules that reviewer agents apply across TypeScript, Python, Go, Rust, Java, C# and Swift.

    2k GitHub starsUsed in 1 repo~1.4k tokens
    DevelopmentAuto-check passed
  • Audit Repo

    1838904818/audit-repo

    Audit a software repository and turn reproducible signals into a prioritized, evidence-backed health report or compare audit snapshots over time.

    157 GitHub stars~2.8k tokensUpdated 1 mo ago
    DevelopmentAuto-check passed

More from athola/claude-night-market

All 160 skills in this repo
  • Night Market Diagnostics Toolkit

    athola/claude-night-market

    Run and interpret repo diagnostic scripts (ratchets, validators, token stats).

    342 GitHub stars~3.4k tokensUpdated yesterday
    Auto-check passed
  • Skills Eval

    athola/claude-night-market

    Evaluate Claude skill quality through auditing. An agent skill from athola/claude-night-market.

    342 GitHub stars~1.6k tokensUpdated yesterday
    Auto-check passed
  • Agent Teams

    athola/claude-night-market

    Coordinates Claude agent teams via filesystem protocol. An agent skill from athola/claude-night-market.

    342 GitHub stars~2.5k tokensUpdated yesterday
    Auto-check passed
  • Delegation Core

    athola/claude-night-market

    Delegates execution to eight CLIs (Gemini, Qwen, MiniMax, GLM, Muse, Codex, OpenCode, Glimmer).

    342 GitHub stars~2.5k tokensUpdated yesterday
    Auto-check passed
  • Elegant Code

    athola/claude-night-market

    Guide minimal code via a decision ladder with full safety, edge, and negative-case coverage.

    342 GitHub stars~2.1k tokensUpdated yesterday
    Auto-check passed
  • Skill Library Mission

    athola/claude-night-market

    Build a project skill library in .claude/skills/ via discovery, parallel authoring, and review.

    342 GitHub stars~1.6k tokensUpdated yesterday
    Auto-check passed

Works with

Categories

Questions about Code Refinement

What does Code Refinement do?

Improves code quality across duplication, efficiency, and architectural fit. Code Refinement is an agent skill from athola/claude-night-market. Improves code quality across duplication, efficiency, and architectural fit.

When should I use Code Refinement?

Code Refinement fits situations like: code passes tests but quality is poor; before a major release.

How do I install Code Refinement in Claude Code?

Run `npx skills add athola/claude-night-market --skill code-refinement -a claude-code`. Or copy the skill folder (plugins/pensive/skills/code-refinement in athola/claude-night-market) into .claude/skills/code-refinement in your project. Claude Code loads it when a task matches its description.

How do I install Code Refinement in Codex?

Run `npx skills add athola/claude-night-market --skill code-refinement -a codex`. Or copy the skill folder (plugins/pensive/skills/code-refinement in athola/claude-night-market) into .agents/skills/code-refinement in your project. Codex loads it when a task matches its description.

Can I use Code Refinement in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add athola/claude-night-market --skill code-refinement -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/code-refinement, .gemini/skills/code-refinement, .github/skills/code-refinement and .opencode/skills/code-refinement in your project.

What does Code Refinement need to run?

Going by SKILL.md and its folder, Code Refinement needs the command-line tools its instructions call (python). Our summary lists: Python 3.

Does Code Refinement access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Code Refinement safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Code Refinement use?

Code Refinement is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Code Refinement use?

About 3k tokens (SKILL.md is roughly 12k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Code Refinement?

Skills that share tags, products or a category with Code Refinement: Dignified Python Standards (docling-project/docling, 68k stars), Code Review Skill (awesome-skills/code-review-skill, 2.1k stars), Code Reviewer (jewbetcha/opentrace, 116 stars) and Code Review Specialist (luongnv89/claude-howto, 42k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Code Refinement?

athola (a GitHub user) maintains it in athola/claude-night-market, which has 342 GitHub stars. The repository holds 160 skills in this directory. The repository was last updated on October 6, 2026.

Source: athola/claude-night-market on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.