refactor

refactor is a skill for Claude Code from cniska/skills. It costs 61 tokens per session (1,458 once invoked), scanned A, original, MIT.

A method for changing or replacing a module's design while following the project's rules and keeping the new structure independent of the old one. It chooses a refactor when changes can stay working step by step, and a rewrite when the design is broadly wrong across connected modules.

In plain words
What is it for?
Use it to refactor a sound design, rewrite an interconnected and unsuitable design, or carry out a redesign after a design review has identified its causes.
Why use it?
It prevents a redesign from leaving behind the same patterns that caused the original problem. It also helps distinguish a safe incremental change from a rewrite that needs clear requirements first.

Skill for Claude Code

Written for Claude Code: argument-hint in frontmatter.

Good fit Use it to refactor a sound design, rewrite an interconnected and unsuitable design, or carry out a redesign after a design review has identified its causes.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/cniska/skills/refactor
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add cniska/skills --skill refactor
Clone the repo
git clone --depth 1 https://github.com/cniska/skills

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for refactor

README.md
[![agentmods](https://agentmods.dev/badge/skills/cniska/skills/refactor/github.svg)](https://agentmods.dev/skills/cniska/skills/refactor)
Your own site
<a href="https://agentmods.dev/skills/cniska/skills/refactor"><img src="https://agentmods.dev/badge/skills/cniska/skills/refactor/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for refactor

Your own site · 80×15
<a href="https://agentmods.dev/skills/cniska/skills/refactor"><img src="https://agentmods.dev/badge/skills/cniska/skills/refactor.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 61 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,458 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00061 $0.01458
Opus 5.5 $0.00024 $0.00583
Sonnet 5.5 $0.00012 $0.00292
Haiku 4.5 $0.00006 $0.00146

Measured 1mo ago against content hash d1f58da64124, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

refactor scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/refactor/SKILL.md · 58 lines

How it starts

The opening of the file, as written. The whole thing — 58 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Refactor

Change a design without letting the old one leak into the new. Agents write code that looks like the code around them, so the shape a refactor leaves behind is the one every later change copies. Design is more than half of this work.

Choose the mode

  • Refactor when the design is sound where it matters and the change can move in steps that each keep the tests green. If the code would be broken for longer than one step, it is not a refactor: stop and choose.
  • Rewrite when the design is wrong across modules whose patterns interlock, so fixing one module leaves the old shapes in its neighbors for the next agent to copy. A rewrite needs requirements that say what done is, a spec or its acceptance criteria. Without them, write them first with the owner, or refactor.

Decide from the fix history, the backlog and the requirements, never from reading the code a rewrite would replace. For a refactor, design-review's module review then finds the causes to remove; a concern that spans folders, such as navigation, is scoped by what it does, not by file prefix.

The repo's own rules hold throughout: its commit gate, its docs-with-behavior rule, its glossary. This skill never overrides them. Where docs contradict the code or each other, the owner decides which is right; list each contradiction for them rather than picking one.

Refactor

  1. Pin the behavior. Where no test pins what the code does now, write tests at the outermost surface the refactor keeps, such as the app, the CLI or the HTTP API, that assert what it does today, bugs included, before moving anything. These are the tests that stay untouched; a test of an internal the refactor removes goes with that internal, once the outer tests cover what it checked.
  2. Make the change easy, then make the easy change. Before a feature the structure fights, reshape the structure first in its own commits, then add the feature.
  3. Keep structure and behavior in separate commits. A commit either changes structure, with the pinning tests untouched and green, or changes behavior. Where splitting them would take a shim, the commit changes both and its subject says it changes behavior.
  4. Fix each pattern once, cleanly, in one place first. Pick the module agents will copy from, give it the right shape in full, and let the rest follow it. Take the shape from design-review's rules, never from the code beside it.
  5. Delete what the new design supersedes in the same change. Leftover behavior, a second path, a shim or a flag keeping the old way alive is not carried forward. A refactor that removes more than it adds is the good kind; one that adds more is questioned.
  6. Use a codemod for a rule-based change. A rename, a signature change or a moved import across many files goes through a deterministic tool (the language server, an AST transform), not a model editing file by file.
  7. Review when a part is done, not per slice. When a module or a pattern is complete, run design-review on it as a whole and fix every tier-1 finding before moving on.

Read the full file on GitHub · 58 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 58 lines · 61 tokens per session scan A d1f58da64124

Subscribe to this mod's changes

refactor is a skill published in the GitHub repository cniska/skills (6 stars, last pushed 1mo ago), licensed MIT. It adds 61 tokens to every session and 1,458 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-10-05.

Related

refactor compared with skills from other repositories

refactor next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
refactorcniska/skillsSkill61mo agoMITA61Claude Code
autoreviewopenclaw/clawhubSkill9.5ktodayMITA17Claude Code, Codex
agent-teams-simplify-and-hardenLeoYeAI/openclaw-master-skillsSkill2.2k6d agoMITA115Claude Code, Codex
omh-code-reviewrlaope/oh-my-hermesSkill5.2ktodayMITA48Claude Code, Codex
revdiff-planumputun/revdiffSkill9472d agoMITA84Claude Code
explore-unknownsdzhng/skillsSkill1.4ktodayMITA162Claude Code, Codex
re0-mergeLilMGenius/paperthinSkill1.4k4d agoMITA70Claude Code