refactor-code

refactor-code is a command for Claude Code from centminmod/my-claude-code-setup. It costs 0 tokens per session (7,105 once invoked), scanned C, original, MIT.

An analysis-only command that finds refactoring opportunities and writes a detailed plan to a report file. Refactoring means reorganising code without changing what it does.

In plain words
What is it for?
Use it to examine target files, assess their safety for later refactoring, prioritise problem areas, and save the findings under the reports directory.
Why use it?
It helps identify complexity, missing test coverage, and technical debt before code is changed. It explicitly does not modify code or create tests.

Command for Claude Code

Written for Claude Code: installed under .claude/. Also seen: mentions CLAUDE.md; names the TodoWrite tool; mentions Claude Code.

Good fit Use it to examine target files, assess their safety for later refactoring, prioritise problem areas, and save the findings under the reports directory.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/centminmod/my-claude-code-setup/refactor-code
About the project

my-claude-code-setup is a starter configuration and memory-bank template for Claude Code, providing project guidance and reusable setup for Claude Code sessions. Developers use it to organize Claude Code behavior, memory, commands, skills, subagents, hooks, and settings. The catalogue entries are components of this Claude Code workflow.

centminmod/my-claude-code-setup · 2,667 stars · on GitHub · threads.com

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/centminmod/my-claude-code-setup

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

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

Your own site · 80×15
<a href="https://agentmods.dev/commands/centminmod/my-claude-code-setup/refactor-code"><img src="https://agentmods.dev/badge/commands/centminmod/my-claude-code-setup/refactor-code.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 7,105 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 2 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.00000 $0.07105
Opus 5.5 $0.00000 $0.02842
Sonnet 5.5 $0.00000 $0.01421
Haiku 4.5 $0.00000 $0.00711

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

Security

Grade C, and why

refactor-code scanned grade C with 2 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.

Asks the agent to reveal its instructionsmediumSystem prompt leakage

Directions to print, repeat or translate the system prompt extract configuration the operator did not intend to expose.

## FINAL OUTPUT INSTRUCTIONS

Unrestricted tool accessmediumExcessive agency

A wildcard tool grant or "run any command" leaves no least-privilege boundary at all.

- Execute any code changes
.claude/commands/refactor/refactor-code.md · 877 lines

How it starts

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

Refactoring Analysis Command

⚠️ CRITICAL: THIS IS AN ANALYSIS-ONLY TASK ⚠️

DO NOT MODIFY ANY CODE FILES
DO NOT CREATE ANY TEST FILES  
DO NOT EXECUTE ANY REFACTORING
ONLY ANALYZE AND GENERATE A REPORT

You are a senior software architect with 20+ years of experience in large-scale refactoring, technical debt reduction, and code modernization. You excel at safely transforming complex, monolithic code into maintainable, modular architectures while maintaining functionality and test coverage. You treat refactoring large files like "surgery on a live patient" - methodical, safe, and thoroughly tested at each step.

YOUR TASK

  1. ANALYZE the target file(s) for refactoring opportunities
  2. CREATE a detailed refactoring plan (analysis only)
  3. WRITE the plan to a report file: reports/refactor/refactor_[target]_DD-MM-YYYY_HHMMSS.md
  4. DO NOT execute any refactoring or modify any code

OUTPUT: A comprehensive markdown report file saved to the reports directory

REFACTORING ANALYSIS FRAMEWORK

Core Principles (For Analysis)

  1. Safety Net Assessment: Analyze current test coverage and identify gaps
  2. Surgical Planning: Identify complexity hotspots and prioritize by lowest risk
  3. Incremental Strategy: Plan extractions of 40-60 line blocks
  4. Verification Planning: Design test strategy for continuous verification

Multi-Agent Analysis Workflow

Break this analysis into specialized agent tasks:

  1. Codebase Discovery Agent: (Phase 0) Analyze broader codebase context and identify related modules
  2. Project Discovery Agent: (Phase 1) Analyze codebase structure, tech stack, and conventions
  3. Test Coverage Agent: (Phase 2) Evaluate existing tests and identify coverage gaps
  4. Complexity Analysis Agent: (Phase 3) Measure complexity and identify hotspots
  5. Architecture Agent: (Phase 4) Assess current design and propose target architecture
  6. Risk Assessment Agent: (Phase 5) Evaluate risks and create mitigation strategies
  7. Planning Agent: (Phase 6) Create detailed, step-by-step refactoring plan
  8. Documentation Agent: (Report) Synthesize findings into comprehensive report

Read the full file on GitHub · 877 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 · 877 lines · 0 tokens per session scan C d6163921ab22

Subscribe to this mod's changes

refactor-code is a command published in the GitHub repository centminmod/my-claude-code-setup (2,667 stars, last pushed 8d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 7,105 tokens. A static security scan graded it C with 2 findings (asks the agent to reveal its instructions, unrestricted tool access). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.