/armory:code-refinerfrom armory
Multi-pass code refactoring skill that simplifies complex, verbose, or tangled code across Python, Go, TypeScript, and Rust while preserving behavior. Targets anti-patterns, readability debt, and excessive nesting.
Ships in armory. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
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 passing
Adjust 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 + eslintWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Python, Go, TypeScript, Rust
npx claudepluginhub mathews-tom/armory --plugin armory94 skills in this plugin
/adr-writerGenerates Architecture Decision Records capturing context, rationale, alternatives, and consequences in numbered status-tracked format. Triggers on: "write an ADR", "document this decision", "architecture decision record", "decision record", "design decision", "ADR for"./agent-builderBuild AI agents and automate Claude Code programmatically via the Claude Agent SDK and headless CLI mode. Covers Python SDK, claude -p, SDK MCP servers, hooks, sessions. Triggers on: "build an agent", "agent SDK", "headless mode", "automate Claude", "programmatic agent"./animateCreate Manim (Python) animated explainers: algorithm step-throughs, math and equation walkthroughs, pipeline and data-flow diagrams, comparisons and timelines, rendered to MP4, WebM or GIF with optional audio overlay. Includes a template path that renders validated config data with no model call, plus output checks (ffprobe duration, fps, dimensions, full decode, sampled-frame review receipt). Use when asked to "create a video", "animate this", "make an explainer", "manim animation", "animate this algorithm", or "motion graphic". NOT for HTML/CSS/GSAP or Hyperframes video, NOT for React or Remotion video, and NOT for a launch or promo video of the user's own project, use launch-video.Other plugins' skills for the same job