refactor

refactor is a command for Claude Code from hamr0/liteagents. It costs 7 tokens per session (3,120 once invoked), scanned A, original, Apache-2.0.

A command for simplifying code without changing what it does. It focuses on reducing complexity, improving names and readability, removing repetition, and making functions smaller.

In plain words
What is it for?
Use it for safe refactoring of an existing project. It detects the project’s test command, runs the relevant tests, and stops for a decision if the refactor causes failures.
Why use it?
It helps make code easier to understand and maintain while preserving the public interface. It requires existing tests to pass so accidental behavior changes are detected.

Command for Claude Code

Written for Claude Code: argument-hint in frontmatter. Also seen: mentions subagents; names the AskUserQuestion tool.

Good fit Use it for safe refactoring of an existing project. It detects the project’s test command, runs the relevant tests, and stops for a decision if the refactor causes failures.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/hamr0/liteagents/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.

Clone the repo
git clone --depth 1 https://github.com/hamr0/liteagents

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/commands/hamr0/liteagents/refactor/github.svg)](https://agentmods.dev/commands/hamr0/liteagents/refactor)
Your own site
<a href="https://agentmods.dev/commands/hamr0/liteagents/refactor"><img src="https://agentmods.dev/badge/commands/hamr0/liteagents/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/commands/hamr0/liteagents/refactor"><img src="https://agentmods.dev/badge/commands/hamr0/liteagents/refactor.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 7 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 3,120 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.00007 $0.03120
Opus 5.5 $0.00003 $0.01248
Sonnet 5.5 $0.00001 $0.00624
Haiku 4.5 $0.00001 $0.00312

Measured 6d ago against content hash 633daaacce03, 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 6d 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.

packages/droid/commands/refactor.md · 226 lines

How it starts

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

Refactor $ARGUMENTS. A targeted refactor includes the performance pass below — it is on by default, not a separate command.

Guardrails

  • Spawn a worker, mid tier stated explicitly (an omitted tier inherits the parent's; never a vendor model name). Run inline if your tool has no subagent mechanism.
  • Escalate, never assume. Anything you cannot decide, cannot verify, or that this spec does not cover → stop and report it to the orchestrator. Never improvise, never widen scope, never fix a side issue you noticed (for workers this overrides the Surgical dev rule).
  • The worker does the work itself — no sub-spawning. Every edit it reports and every test run it cites is one it made or ran with its own tool calls.
  • The HITL gates below belong to the orchestrator, not the worker. When one trips — a failing test, a crossed public API boundary, a change bigger than the bullet asked for — the worker stops there and hands the situation back, with the options and its reasoning but no choice made. The orchestrator asks.
  • Edit only the picked item (a surviving ledger bullet or a picked duplicate group). Ledger mode's scope is the bullets that survive revalidation, one change per bullet — not the neighbouring code, not the formatting, not a second finding noticed on the way past. Anything else goes back to the orchestrator to become a new bullet.
  • Prove the blast radius with two checks, because neither sees what the other does. git status --porcelain at exit must list only files the picked item named — that is this command's scope guarantee, and unlike /branch-review it is not expected to be empty. .factory/ is gitignored, so also hash the files there before you start and again before you report:
    find .factory/remember -maxdepth 1 -type f -exec md5sum {} + | sort -k2
    
    and show the comparison: in ledger mode only fix-ledger.md may differ; in duplicates mode nothing may differ. last-review.md is /branch-review's to write.

Read the full file on GitHub · 226 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. 6d ago Changed 633daaacce03
  2. 2mo ago Changed · +12 lines 0caa2311c2e5
  3. 2mo ago Changed · +7 lines 312aac25f0da
  4. 2mo ago Changed · +9 lines 38a573606529
  5. 2mo ago Changed · +31 lines f30e3a408bb3
  6. 2mo ago Changed · +45 lines · -1 tokens per session b3a912fa5e05
  7. 2mo ago Changed · +68 lines 800984bb498b
  8. 3mo ago First seen · 54 lines · 8 tokens per session scan A 554ad426b20f

Subscribe to this mod's changes

refactor is a command published in the GitHub repository hamr0/liteagents (28 stars, last pushed 4d ago), licensed Apache-2.0. It adds 7 tokens to every session and 3,120 once invoked, about $0.0000 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

refactor compared with commands from other repositories

refactor next to 6 commands from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
refactorhamr0/liteagentsCommand284d agoApache-2.0A7Claude Code
mainframe-tickets-findCATWILLgh/MAINFRAMECommand213d agoMITA0Claude Code
triageJewgah/claude-code-skillsCommand26d agoMITA27Claude Code
fixJewgah/claude-code-skillsCommand26d agoMITA19Claude Code
dbgartttj/rapid-stackCommand24mo agoMITA12Claude Code, OpenCode
cc-flowyeisonrestrepo/code-conductorCommand22todayMITA13Claude Code
debug-podrohitg00/awesome-claude-code-toolkitCommand2.9k6mo agoApache-2.0A0Claude Code