CommandMate: Agent for Claude Code

.claude/agents/refactoring-agent.md

refactoring-agent is an agent for Claude Code from Kewton/CommandMate. It costs 49 tokens per session (435 once invoked), scanned B, original, MIT.

A code-cleanup helper that reorganizes existing code to improve its structure and maintainability.

In plain words
What is it for?
Refactoring TypeScript code using common design principles, then checking that tests, linting, and type checking still pass.
Why use it?
It helps reduce duplication, tangled responsibilities, unnecessary complexity, and other quality problems while keeping the existing behavior working.

Agent for Claude Code

Written for Claude Code: installed under .claude/. Also seen: model in frontmatter; mentions subagents.

This is Kewton/CommandMate's own configuration. It tells Claude Code how to work on CommandMate itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything CommandMate configures →

Reuse

Borrowing it

Nothing to install: this file belongs to Kewton/CommandMate. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/Kewton/CommandMate/main/.claude/agents/refactoring-agent.md
Clone the repo
git clone --depth 1 https://github.com/Kewton/CommandMate

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 refactoring-agent

README.md
[![agentmods](https://agentmods.dev/badge/agents/kewton/commandmate/refactoring-agent/github.svg)](https://agentmods.dev/agents/kewton/commandmate/refactoring-agent)
Your own site
<a href="https://agentmods.dev/agents/kewton/commandmate/refactoring-agent"><img src="https://agentmods.dev/badge/agents/kewton/commandmate/refactoring-agent/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 refactoring-agent

Your own site · 80×15
<a href="https://agentmods.dev/agents/kewton/commandmate/refactoring-agent"><img src="https://agentmods.dev/badge/agents/kewton/commandmate/refactoring-agent.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 49 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 435 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 1 finding. 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.00049 $0.00435
Opus 5.5 $0.00020 $0.00174
Sonnet 5.5 $0.00010 $0.00087
Haiku 4.5 $0.00005 $0.00044

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

Security

Grade B, and why

refactoring-agent scanned grade B with 1 finding 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.

Reads agent configuration directoriesmediumAgent snooping

.claude/, .codex/, .gemini/ hold keys, settings and other credentials a mod has no legitimate need for.

cat .claude/prompts/refactoring-core.md
.claude/agents/refactoring-agent.md · 68 lines

What it actually says

Refactoring Agent

You are a code refactoring specialist working under PM Auto-Dev orchestration.

Operation Mode

Subagent Mode: You are being called by PM Auto-Dev with a context file.


Execution

Read and execute the core prompt:

cat .claude/prompts/refactoring-core.md

Follow the instructions in the core prompt exactly.

Important:

  • You are in Subagent Mode
  • Context file path: dev-reports/issue/{issue_number}/pm-auto-dev/iteration-{N}/refactor-context.json
  • Output file path: dev-reports/issue/{issue_number}/pm-auto-dev/iteration-{N}/refactor-result.json
  • Use Write tool to create the result JSON file
  • Report completion to PM Auto-Dev when done

Technology Stack

This project uses:

  • Language: TypeScript
  • Framework: Next.js 14
  • Test Framework: Vitest
  • Linter: ESLint
  • Type Checker: TypeScript (tsc --noEmit)

Refactoring Principles

  • SOLID: Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, Dependency Inversion
  • KISS: Keep It Simple, Stupid
  • DRY: Don't Repeat Yourself
  • YAGNI: You Aren't Gonna Need It

Success Criteria

  • All tests still pass after refactoring
  • Quality metrics improved (coverage, complexity)
  • Static analysis errors: 0 (ESLint, TypeScript)
  • Code committed
  • Result file created: refactor-result.json
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 Changed 5afe3e423f02
  2. 1mo ago First seen · 68 lines · 49 tokens per session scan B b26df84b284d

Subscribe to this mod's changes

refactoring-agent is an agent published in the GitHub repository Kewton/CommandMate (44 stars, last pushed today), licensed MIT. It adds 49 tokens to every session and 435 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it B with 1 finding (reads agent configuration directories). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.