DRY Refactoring With jscpd
kucherenko/jscpd
Removes copy-paste duplication found by jscpd, starting with exact clones and hotspots, then renamed and near-miss copies, using proven refactoring strategies.
Deep code simplification and refactoring preserving behavior across Python, Go, TypeScript, Rust.
$ npx skills add Mathews-Tom/armory --skill code-refiner -a claude-codeProject install by default; add -g for ~/.claude/skills/.
$ gh skill install Mathews-Tom/armory code-refiner --agent claude-codeProject scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).
$ git clone --depth 1 https://github.com/Mathews-Tom/armory.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/code-refiner .claude/skills/code-refiner && rm -rf skills-srcUse ~/.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/
Install the "code-refiner" agent skill from https://github.com/Mathews-Tom/armory/tree/main/skills/code-refiner into .claude/skills/code-refiner/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "code-refiner", then confirm the skill loads.Claude Code copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$skill-installer install https://github.com/Mathews-Tom/armory/tree/main/skills/code-refinerType this inside Codex. $skill-installer <name> installs a curated skill from openai/skills. The installer writes to $CODEX_HOME/skills (default ~/.codex/skills). Restart Codex if the skill does not show up.
$ npx skills add Mathews-Tom/armory --skill code-refiner -a codexProject install goes to .agents/skills/; add -g for ~/.codex/skills/.
$ gh skill install Mathews-Tom/armory code-refiner --agent codexProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/Mathews-Tom/armory.git skills-src && mkdir -p .agents/skills && cp -r skills-src/skills/code-refiner .agents/skills/code-refiner && rm -rf skills-srcUse ~/.agents/skills/ instead of .agents/skills for a personal install.
Codex skills documentation · loads skills from .agents/skills/
Install the "code-refiner" agent skill from https://github.com/Mathews-Tom/armory/tree/main/skills/code-refiner into .agents/skills/code-refiner/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "code-refiner", then confirm the skill loads.Codex copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add Mathews-Tom/armory --skill code-refiner -a cursorProject install goes to .agents/skills/; add -g for ~/.cursor/skills/.
$ gh skill install Mathews-Tom/armory code-refiner --agent cursorProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/Mathews-Tom/armory.git skills-src && mkdir -p .cursor/skills && cp -r skills-src/skills/code-refiner .cursor/skills/code-refiner && rm -rf skills-srcUse ~/.cursor/skills/ instead of .cursor/skills for a personal install.
Cursor skills documentation · loads skills from .cursor/skills/, .agents/skills/, .claude/skills/, .codex/skills/
Install the "code-refiner" agent skill from https://github.com/Mathews-Tom/armory/tree/main/skills/code-refiner into .cursor/skills/code-refiner/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "code-refiner", then confirm the skill loads.Cursor copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gemini skills install https://github.com/Mathews-Tom/armory.git --path skills/code-refiner--scope user (default) or --scope workspace; --path is the subfolder of the repo that holds the skill; --consent skips the security confirmation prompt.
$ npx skills add Mathews-Tom/armory --skill code-refiner -a gemini-cliProject install goes to .agents/skills/; add -g for ~/.gemini/skills/.
$ gh skill install Mathews-Tom/armory code-refiner --agent gemini-cliProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/Mathews-Tom/armory.git skills-src && mkdir -p .gemini/skills && cp -r skills-src/skills/code-refiner .gemini/skills/code-refiner && rm -rf skills-srcUse ~/.gemini/skills/ instead of .gemini/skills for a personal install, then run /skills reload.
Gemini CLI skills documentation · loads skills from .gemini/skills/, .agents/skills/
Install the "code-refiner" agent skill from https://github.com/Mathews-Tom/armory/tree/main/skills/code-refiner into .gemini/skills/code-refiner/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "code-refiner", then confirm the skill loads.Gemini CLI copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gh skill install Mathews-Tom/armory code-refinerInstalls for Copilot at project scope by default; add --scope user for a personal install. Preview a skill first with gh skill preview. Needs GitHub CLI 2.90.0 or later (public preview).
$ npx skills add Mathews-Tom/armory --skill code-refiner -a github-copilotProject install goes to .agents/skills/; add -g for ~/.copilot/skills/.
$ git clone --depth 1 https://github.com/Mathews-Tom/armory.git skills-src && mkdir -p .github/skills && cp -r skills-src/skills/code-refiner .github/skills/code-refiner && rm -rf skills-srcUse ~/.copilot/skills/ instead of .github/skills for a personal install. Commit .github/skills so cloud agent and code review can use it.
GitHub Copilot skills documentation · loads skills from .github/skills/, .claude/skills/, .agents/skills/
Install the "code-refiner" agent skill from https://github.com/Mathews-Tom/armory/tree/main/skills/code-refiner into .github/skills/code-refiner/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "code-refiner", then confirm the skill loads.GitHub Copilot copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add Mathews-Tom/armory --skill code-refiner -a opencodeOpenCode documents no install command of its own. Project install goes to .agents/skills/; add -g for ~/.config/opencode/skills/.
$ gh skill install Mathews-Tom/armory code-refiner --agent opencodeProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/Mathews-Tom/armory.git skills-src && mkdir -p .opencode/skills && cp -r skills-src/skills/code-refiner .opencode/skills/code-refiner && rm -rf skills-srcUse ~/.config/opencode/skills/ instead of .opencode/skills for a personal install.
OpenCode skills documentation · loads skills from .opencode/skills/, .claude/skills/, .agents/skills/
Install the "code-refiner" agent skill from https://github.com/Mathews-Tom/armory/tree/main/skills/code-refiner into .opencode/skills/code-refiner/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "code-refiner", then confirm the skill loads.OpenCode copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
code-refinerDeep code simplification and refactoring preserving behavior across Python, Go, TypeScript, Rust.
Code Refiner is an agent skill from Mathews-Tom/armory. Deep code simplification and refactoring preserving behavior across Python, Go, TypeScript, Rust. Targets complexity, anti-patterns, readability debt. Triggers on: "simplify this code", "refactor for clarity", "reduce complexity", "make this more readable", "tech debt cleanup", "too much nesting".
Its SKILL.md is about 3.1k tokens, which your agent loads only when the skill is triggered. The skill folder holds 9 other files, including scripts and reference files (for example `evals/cases.yaml`, `references/go.md` and `references/python.md`).
It sits in Development, covering Code simplification, Refactoring and Technical debt. It works with Python, Rust, TypeScript and Git. The repository describes itself as: Curated, production-grade skills for AI coding agents. Battle-tested workflows for developers who use AI seriously. The licence is MIT.
5 steps, taken from the step headings in SKILL.md.
Read from SKILL.md and the folder at commit 4594fb7. It shows what the files ask for, not the result of running them.
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.
Ships 1 file in scripts/ (Python), which the agent can run.
Shell commands in SKILL.md call:
gitruffmypytscFrom the folder's file list and the shell code blocks in SKILL.md.
No URLs in SKILL.md. Its commands use git, which can reach the network depending on how they are called.
From URLs in SKILL.md, links to its own repository left out.
Names no API keys, tokens, secrets or passwords.
From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.
Code Refiner loads about 3.1k tokens when it runs, and up to ~8.5k if it reads all its reference files. Until then it costs about 78 tokens; SKILL.md has 1,479 words of instructions outside code blocks.
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.
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); the scripts in this folder are not scanned.
The full file from Mathews-Tom/armory at commit 4594fb7, republished under its MIT licence (© Mathews-Tom). 1,479 words, ~3,115 tokens.
.claude/skills/code-refiner/SKILL.md (or your agent's skills folder). This skill also uses 6 other files; get the full folder from GitHub.A structured, multi-pass code refinement skill that transforms complex, verbose, or tangled code into clean, idiomatic, maintainable implementations — without changing what the code does.
The goal is not fewer lines. The goal is code that a tired engineer at 2am can read, understand, and safely modify. Every change must pass three tests:
When clarity and brevity conflict, clarity wins. When idiom and explicitness conflict, consider the team's experience level. When DRY and locality conflict, prefer locality for code read more than modified.
git diff) when the user doesn't specify target filesscripts/complexity_report.py for quantitative complexity metricsFollow this sequence. Each phase builds on the previous one. Do not skip phases, but adapt depth to the scope of the request (a single function gets a lighter pass than a full module).
Before touching anything, build a mental model:
git diff --name-only HEAD~5 or git diff --staged --name-onlyreferences/ if needed for idiom-specific guidanceIdentify what's actually wrong before reaching for solutions. Categorize issues by severity:
Critical (always fix):
High (fix unless there's a clear reason not to):
Medium (fix when it improves clarity without adding risk):
Low (fix only in a dedicated cleanup pass):
Apply changes using these tactics, ordered by impact-to-risk ratio:
Remove before restructuring. Less code = less to think about.
Reduce nesting and cognitive load:
if nesting to early returnsis_valid_order = ...)else branch is the "happy path", flip itMake the code's intent visible:
data → user_records, process → validate_and_enqueueApply language-specific patterns (consult references/<language>.md for details):
? operator, From/Into, newtype patternTypes are documentation that the compiler checks:
any/interface{} to specific types where possibleNever skip this phase. Simplification that breaks behavior is not simplification.
If tests fail or behavior diverges: revert the specific change, don't try to fix the test.
Present changes as a structured summary. This is important — the developer needs to understand and trust what changed before committing.
For each file modified, provide:
## <filename>
### Changes
- [Critical] Removed unreachable error branch in `parse_config` (dead code after L42 guard)
- [High] Extracted `validate_credentials()` from 60-line `handle_login()` (was 3 responsibilities)
- [Medium] Renamed `d` → `document`, `proc` → `process_batch`
### Complexity Delta
- `handle_login`: 4 levels nesting → 2, 8 branches → 5
- `parse_config`: removed 12 lines of dead code
### Risk Assessment
- Low risk: all changes are structural, no logic modifications
- Tests: 47/47 passingAdjust verbosity to scope. Single-function cleanup gets a one-liner. Multi-file refactor gets the full report.
These are hard rules. Do not violate them regardless of how much cleaner the code would look:
The user may specify different modes. If they don't, default to standard.
| Mode | Scope | Severity Threshold | Test Requirement |
|---|---|---|---|
quick | Single file or function | Critical + High only | Tests recommended |
standard | Recent git changes | Critical + High + Medium | Tests required if they exist |
deep | Entire module/package | All severities | Tests mandatory |
surgical | User-specified lines/functions | All severities | Manual trace sufficient |
The user can specify mode by saying things like "just do a quick pass" or "deep clean this module".
Push back (politely) if:
For language-specific idiom guidance, read the appropriate reference file:
references/python.md — Python-specific patterns, anti-patterns, and stdlib alternativesreferences/go.md — Go idioms, error handling patterns, and interface designreferences/typescript.md — TypeScript/JavaScript patterns, type narrowing, and module designreferences/rust.md — Rust idioms, ownership patterns, and iterator usageOnly load the reference file for the language(s) in the current scope. These provide detailed pattern catalogs that supplement the general methodology above.
| Rationalization | Reality |
|---|---|
| "It's readable enough" | "Enough" is not a standard — if the next developer needs to re-read a function 3 times, it's not readable |
| "Refactoring risks regressions" | Not refactoring risks accumulating debt — run the test suite before and after, that's what tests are for |
| "This is how the codebase has always done it" | Consistency with a bad pattern is still bad — improve incrementally, don't preserve anti-patterns |
| "The performance might get worse" | Benchmark before and after — most readability refactors have zero performance impact; premature optimization is the root of all evil |
| "It's not broken, don't fix it" | Refining isn't fixing — it's making working code maintainable, testable, and understandable for the next person |
| "I'll refactor the whole module later" | Incremental refinement works; big-bang rewrites fail — improve what you touch now |
ruff check + mypy --strict or tsc --noEmit + eslint© Mathews-Tom, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file
SKILL.md and 6 other files (scripts, references) in skills/code-refiner of Mathews-Tom/armory.
Open the folder on GitHubat commit 4594fb7
Code Refiner 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.
| Skill | Stars | Used in | Tokens | Auto-check | Licence | Repo updated |
|---|---|---|---|---|---|---|
| Code Refiner this skillMathews-Tom/armory | 327 | — | ~3.1k | Automated safety check: Pass | MIT | |
| DRY Refactoring With jscpdkucherenko/jscpd | 6.3k | — | ~2.1k | Automated safety check: Pass | MIT | |
| Coding Agentmastra-ai/mastra | 29k | — | ~2.3k | Automated safety check: Pass | Custom licence | |
| Dead Code Removal with Knipshift-editor/shift | 343 | — | ~1.8k | Automated safety check: Pass | Apache-2.0 | |
| Project Initathola/claude-night-market | 342 | — | ~1.2k | Automated safety check: Pass | MIT | |
| Worklog Designregisx001/Worklog | 258 | — | ~3.3k | Automated safety check: Pass | MIT |
kucherenko/jscpd
Removes copy-paste duplication found by jscpd, starting with exact clones and hotspots, then renamed and near-miss copies, using proven refactoring strategies.
mastra-ai/mastra
Authoring playbook for building agents that write, edit, review, or refactor code.
shift-editor/shift
Finds unused files, exports and class members with Knip, then verifies each candidate through reference tracing before removing anything, never using knip --fix.
athola/claude-night-market
Scaffolds new projects with git, CI/CD workflows, pre-commit hooks, and build config.
regisx001/Worklog
Design and UI skill for the Worklog desktop project manager.
shareAI-lab/learn-claude-code
Reviews code against a five-part checklist covering security, correctness, performance, maintainability and testing, and reports findings in a fixed format.
Mathews-Tom/armory
Architecture reviews across 7 dimensions (structural, scalability, enterprise readiness, performance, security, ops, data) with scored reports.
Mathews-Tom/armory
Turn concepts into static HTML visuals exported as PNG or SVG files via HTML/CSS/SVG.
Mathews-Tom/armory
A skill your agent uses when analyzing an existing video URL or local recording: "watch this video", "analyze youtube video", "summarize this video", "youtube transcript", "find this moment", "what…
Mathews-Tom/armory
Turn concepts into animated explainer videos using Manim (Python) with MP4/GIF output, audio overlay, multi-scene composition.
Mathews-Tom/armory
Maps the unresolved architecture, policy, and scope decisions that must be answered before planning can start: one durable decision ticket per question on the issue tracker, typed and blocker-linked…
Mathews-Tom/armory
Produces and refreshes .docs/handoff.md, a 200-line session-continuity runbook for coding agents.
Works with
Categories
Deep code simplification and refactoring preserving behavior across Python, Go, TypeScript, Rust. Code Refiner is an agent skill from Mathews-Tom/armory. Deep code simplification and refactoring preserving behavior across Python, Go, TypeScript, Rust.
Code Refiner fits situations like: : simplify this code; refactor for clarity; reduce complexity; make this more readable.
Run `npx skills add Mathews-Tom/armory --skill code-refiner -a claude-code`. Or copy the skill folder (skills/code-refiner in Mathews-Tom/armory) into .claude/skills/code-refiner in your project. Claude Code loads it when a task matches its description.
Run `npx skills add Mathews-Tom/armory --skill code-refiner -a codex`. Or copy the skill folder (skills/code-refiner in Mathews-Tom/armory) into .agents/skills/code-refiner in your project. Codex loads it when a task matches its description.
Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add Mathews-Tom/armory --skill code-refiner -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-refiner, .gemini/skills/code-refiner, .github/skills/code-refiner and .opencode/skills/code-refiner in your project.
Going by SKILL.md and its folder, Code Refiner needs Python for the scripts in its folder and the command-line tools its instructions call (git, ruff, mypy and tsc). Our summary lists: Python 3.
SKILL.md contains no URLs. Its commands use git, which can reach the network depending on how they are called. This is read from the text; nothing was executed.
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. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.
Code Refiner is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.
About 3.1k 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. Its references folder adds about 5.3k tokens, read only when the agent opens those files.
Skills that share tags, products or a category with Code Refiner: DRY Refactoring With jscpd (kucherenko/jscpd, 6.3k stars), Coding Agent (mastra-ai/mastra, 29k stars), Dead Code Removal with Knip (shift-editor/shift, 343 stars) and Project Init (athola/claude-night-market, 342 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.
Mathews-Tom (a GitHub user) maintains it in Mathews-Tom/armory, which has 327 GitHub stars. The repository holds 80 skills in this directory. The repository was last updated on October 6, 2026.
Source: Mathews-Tom/armory on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.