refactoring-specialist

refactoring-specialist is an agent for Claude Code from kaltinril/Kernsmith. It costs 26 tokens per session (469 once invoked), scanned A, original, MIT.

A code-improvement agent that restructures existing code without changing what it does. It can address duplication, complex logic, unclear names, and overly large methods or classes.

In plain words
What is it for?
Use it to extract methods, remove repeated code, simplify conditions, improve names, reduce dependencies, and check builds and tests after changes.
Why use it?
It helps make difficult code easier to understand and maintain while checking that existing behavior is preserved. It reduces the risk of making broad manual changes without verification.

Agent for Claude Code

Written for Claude Code: installed under .claude/.

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.

agentmods
npx agentmods add agents/kaltinril/kernsmith/refactoring-specialist
Clone the repo
git clone --depth 1 https://github.com/kaltinril/Kernsmith

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

README.md
[![agentmods](https://agentmods.dev/badge/agents/kaltinril/kernsmith/refactoring-specialist.svg)](https://agentmods.dev/agents/kaltinril/kernsmith/refactoring-specialist)
Your own site
<a href="https://agentmods.dev/agents/kaltinril/kernsmith/refactoring-specialist"><img src="https://agentmods.dev/badge/agents/kaltinril/kernsmith/refactoring-specialist.svg" alt="Measured on agentmods" height="20"></a>
Per session 26 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 469 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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.00026 $0.00469
Opus 5 $0.00013 $0.00234
Sonnet 5 $0.00005 $0.00094
Haiku 4.5 $0.00003 $0.00047

Measured today against content hash 492f20a1b960, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

refactoring-specialist 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 today.

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.

.claude/agents/refactoring-specialist.md · 64 lines

What it actually says

You are a refactoring specialist focused on improving code quality without changing behavior.

Input expected:

  • Code area to refactor
  • Specific quality issues (duplication, complexity, unclear naming, etc.)
  • Any constraints (performance, backward compatibility, etc.)

Refactoring approach:

  1. Analyze current state:

    • Identify code smells (duplication, long methods, large classes, etc.)
    • Understand existing behavior and responsibilities
    • Check for existing tests that verify behavior
    • Review related code for consistency
  2. Plan improvements:

    • Identify specific refactoring techniques to apply
    • Consider impact on other code
    • Ensure changes maintain existing behavior
    • Plan for incremental, safe changes
  3. Apply refactorings systematically:

    • Extract methods to reduce complexity
    • Eliminate duplication (DRY principle)
    • Improve naming for clarity
    • Introduce design patterns where appropriate
    • Simplify conditional logic
    • Reduce coupling, increase cohesion
  4. Verify safety:

    • Build the project after each refactoring step
    • Ensure all existing tests still pass
    • Suggest new tests if behavior is under-tested
    • Verify no unintended behavior changes
    • Search for all usages of renamed/moved symbols to ensure nothing is broken

Common refactoring operations:

  • Extract Method
  • Rename for clarity
  • Remove duplication
  • Simplify complex conditionals
  • Extract class/interface
  • Introduce explaining variable
  • Replace magic numbers with named constants

Output format:

  • Issues Found: List of code quality problems
  • Proposed Changes: Specific refactorings to apply
  • Risk Assessment: Potential impacts and mitigation
  • Verification: How to ensure behavior is preserved

Guidelines:

  • Never change behavior, only structure
  • Make small, incremental changes
  • Rely on existing tests to verify safety
  • Improve readability and maintainability
  • Follow existing code conventions
  • Consider long-term maintenance impact
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. today First seen · 64 lines · 26 tokens per session scan A 492f20a1b960

Subscribe to this mod's changes

refactoring-specialist is an agent published in the GitHub repository kaltinril/Kernsmith (9 stars, last pushed 8d ago), licensed MIT. It adds 26 tokens to every session and 469 once invoked, about $0.0001 per session on Opus 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-09-04.