code-refactor

code-refactor is a skill for Claude Code from bahayonghang/my-ai-cli-toolkit. It costs 110 tokens per session (1,959 once invoked), scanned A, original, MIT.

A guide for changing existing code while keeping its observable behavior the same. It covers tasks such as splitting files, extracting methods, renaming, removing unused code, and reducing duplication.

In plain words
What is it for?
Use it for safe refactoring of files, functions, duplicated code, names, comments, or unused symbols. It also helps verify that the changes preserve existing behavior.
Why use it?
It helps make code easier to read, change, and test without accidentally changing what the software does. Broad cleanup is broken into smaller proposed steps for approval.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: mentions AGENTS.md.

Good fit Use it for safe refactoring of files, functions, duplicated code, names, comments, or unused symbols. It also helps verify that the changes preserve existing behavior.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/bahayonghang/my-ai-cli-toolkit/code-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 bahayonghang/my-ai-cli-toolkit --skill code-refactor
Clone the repo
git clone --depth 1 https://github.com/bahayonghang/my-ai-cli-toolkit

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 code-refactor

README.md
[![agentmods](https://agentmods.dev/badge/skills/bahayonghang/my-ai-cli-toolkit/code-refactor/github.svg)](https://agentmods.dev/skills/bahayonghang/my-ai-cli-toolkit/code-refactor)
Your own site
<a href="https://agentmods.dev/skills/bahayonghang/my-ai-cli-toolkit/code-refactor"><img src="https://agentmods.dev/badge/skills/bahayonghang/my-ai-cli-toolkit/code-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 code-refactor

Your own site · 80×15
<a href="https://agentmods.dev/skills/bahayonghang/my-ai-cli-toolkit/code-refactor"><img src="https://agentmods.dev/badge/skills/bahayonghang/my-ai-cli-toolkit/code-refactor.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 110 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,959 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. Third-party audits
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 1 finding, up to medium

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • medium Excessive Agency · line 28
    Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.
    Fix: Add human-in-the-loop confirmation for destructive, irreversible, or high-impact operations. Never auto-execute commands that modify files, send data, or alter system state.
How audits are shown
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.00110 $0.01959
Opus 5.5 $0.00044 $0.00784
Sonnet 5.5 $0.00022 $0.00392
Haiku 4.5 $0.00011 $0.00196

Measured 12d ago against content hash 4286aeb39b3a, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

code-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 12d ago.

The scan reads SKILL.md. This mod also ships 1 executable file (tests/code-refactor.test.mjs), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

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/development-workflows/code-refactor/SKILL.md · 174 lines

How it starts

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

Code Refactor

Refactor existing code without changing behavior. The skill's job is to make code easier to understand, modify, and test while keeping the observable contract stable.

Refactoring is not a license for broad cleanup. Treat every edit as a behavior-preserving transformation with evidence, a bounded target, and verification.

Default Behavior

Choose the mode from the user's scope.

  • Broad request: If the user says things like "refactor this module", "clean up this project", or "optimize the code structure", inspect first, propose safe refactor slices, and wait for user approval before broad edits.
  • Narrow request: If the user names a file, function, duplicated block, dead symbol, or specific cleanup, directly implement the smallest safe slice and verify it.
  • Review-only request: If the user asks for an independent diff or PR review (functional regressions, concurrency, test gaps) without asking to edit, use code-auditor. If the user asks for code quality review or maintainability findings without asking to edit, use code-quality-review.
  • Architecture/RFC request: If the user wants deep-module design, module-boundary candidates, or an architecture RFC rather than a behavior-preserving refactor, treat that as a separate design effort and surface it instead of refactoring in place.

Refactor Types

Classify the requested work before editing. A task may include more than one type, but execute one coherent slice at a time.

Type Use when Good outcome
Module split A file or subsystem mixes unrelated responsibilities Files align with functional modules, ownership, and test boundaries
Function/method extraction One function has multiple small behaviors or hidden phases Public API stays small; private helpers name meaningful substeps
Duplicate consolidation Similar logic appears repeatedly and may drift A shared helper removes real duplication without adding thin indirection
Naming cleanup Names hide intent, encode stale details, or force readers to inspect implementation Names are concise, intention-revealing, and consistent with local style
Comment cleanup Comments repeat code, miss invariants, or hide key assumptions Comments explain why, contracts, edge cases, and non-obvious decisions
Dead-code removal Code appears uncalled, stale, or orphaned Removal is backed by call-site, export, framework, and verification checks

Read the full file on GitHub · 174 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 12d ago Changed · +13 tokens per session 4286aeb39b3a
  2. 1mo ago First seen · 174 lines · 97 tokens per session scan A ea94a9d34864

Subscribe to this mod's changes

code-refactor is a skill published in the GitHub repository bahayonghang/my-ai-cli-toolkit (17 stars, last pushed 5d ago), licensed MIT. It adds 110 tokens to every session and 1,959 once invoked, about $0.0004 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-08-30.

Related

Other skills, from other repositories

absolute-simplify

Use when the user wants to simplify, clean up, refactor, tidy, or refine code — their staged/unstaged git changes or a target file/path. Reduces complexity, flattens nesting, removes redundancy and dead code, scores each change by value (holding low-value churn), then runs tests to prove nothing broke. Invoke on…

maddhruv/absolute · 178 tokens

arch-optimize

A software architecture review workflow that scans a codebase for structural risks and measures code quality. It checks issues such as overly complex code, repeated knowledge, changes spreading across many files, circular dependencies, and distorted domain models.

bfxh/arch-optimize · 114 tokens

code-simplification

Simplifies code for clarity. Use when refactoring code for clarity without changing behavior. Use when code works but is harder to read, maintain, or extend than it should be. Use when reviewing code that has accumulated unnecessary complexity.

vanja-emichi/a0_agent_skills · 51 tokens

refactoring

Improve code structure without changing behavior using proven refactoring patterns. Use when cleaning up code, reducing duplication, improving readability, or restructuring modules.

asgarovf/locusai · 31 tokens

refactoring-patterns

Apply safe refactoring patterns to improve code structure without changing behavior. Use when cleaning up code, reducing technical debt, or improving maintainability.

summarybotng/summarybot-ng · 33 tokens

software-code-refactoring

Improve production code quality while preserving all existing test behavior. Commonly used for the Refactor phase of TDD red-green-refactor, but applicable to any codebase with tests. Use when production code works but needs cleanup — reducing duplication, improving naming, simplifying complexity, aligning with…

stencila/stencila · 102 tokens