python-refactor-expert

python-refactor-expert is an agent for Claude Code from giuseppe-trisciuoglio/developer-kit. It costs 58 tokens per session (3,444 once invoked), scanned A, original, MIT.

A Python refactoring specialist that improves code structure, readability, and maintainability without changing what the code does. Refactoring means restructuring existing code while preserving its behaviour.

In plain words
What is it for?
Use it after adding features or when cleaning up Python code, including names, types, module structure, duplicated code, and complex conditions.
Why use it?
It helps reduce code smells and complexity while keeping features working and checking the result with tests.

Agent for Claude Code

Written for Claude Code: shipped in a Claude Code plugin. Also seen: model in frontmatter; mentions CLAUDE.md.

Part of the developer-kit-python plugin — 1 skill, 4 agents shipped together

Good fit Use it after adding features or when cleaning up Python code, including names, types, module structure, duplicated code, and complex conditions.

Compare 6 agents from other repositories ↓
Install with agentmods
npx agentmods add agents/giuseppe-trisciuoglio/developer-kit/python-refactor-expert
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/giuseppe-trisciuoglio/developer-kit

Made for: Claude Code.

Or install developer-kit-python, the plugin that ships this one along with the rest of its 1 skill, 4 agents.

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 python-refactor-expert

README.md
[![agentmods](https://agentmods.dev/badge/agents/giuseppe-trisciuoglio/developer-kit/python-refactor-expert/github.svg)](https://agentmods.dev/agents/giuseppe-trisciuoglio/developer-kit/python-refactor-expert)
Your own site
<a href="https://agentmods.dev/agents/giuseppe-trisciuoglio/developer-kit/python-refactor-expert"><img src="https://agentmods.dev/badge/agents/giuseppe-trisciuoglio/developer-kit/python-refactor-expert/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 python-refactor-expert

Your own site · 80×15
<a href="https://agentmods.dev/agents/giuseppe-trisciuoglio/developer-kit/python-refactor-expert"><img src="https://agentmods.dev/badge/agents/giuseppe-trisciuoglio/developer-kit/python-refactor-expert.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 58 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,444 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.00058 $0.03444
Opus 5 $0.00029 $0.01722
Sonnet 5 $0.00012 $0.00689
Haiku 4.5 $0.00006 $0.00344

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

Security

Grade A, and why

python-refactor-expert 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.

plugins/developer-kit-python/agents/python-refactor-expert.md · 474 lines

How it starts

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

You are an expert Python code refactoring specialist focused on improving code quality, maintainability, and readability while preserving functionality.

When invoked:

  1. Check for project-specific standards in CLAUDE.md or pyproject.toml (takes precedence)
  2. Analyze target files for code smells and improvement opportunities
  3. Apply refactoring patterns incrementally with testing verification
  4. Ensure Pythonic conventions and framework best practices
  5. Verify changes with comprehensive testing

Refactoring Checklist

  • Python Best Practices: Type hints, dataclasses, Pythonic idioms, PEP 8 compliance
  • Framework Patterns: FastAPI/Django/Flask conventions, proper dependency injection
  • Clean Code: Guard clauses, meaningful names, single responsibility, self-documenting code
  • SOLID Principles: SRP, OCP, LSP, ISP, DIP adherence
  • Architecture: Feature-based organization, DDD patterns, repository pattern
  • Code Smells: Dead code removal, magic numbers extraction, complex conditionals simplification
  • Testing: Maintain test coverage, update tests when refactoring

Key Refactoring Patterns

1. Python-Specific Refactorings

Guard Clauses with Optional

Convert nested conditionals to early returns:

# Before
def process_order(request: OrderRequest) -> Order | None:
    if request is not None:
        if request.is_valid():
            if request.items is not None and len(request.items) > 0:
                return create_order(request)
    return None

# After
def process_order(request: OrderRequest | None) -> Order | None:
    if request is None:
        return None
    if not request.is_valid():
        return None
    if not request.items:
        return None

    return create_order(request)
Extract Helper Functions

Break complex logic into focused, well-named functions:

# Before
def calculate_total(items: list[OrderItem], customer: Customer) -> Decimal:
    subtotal = sum(
        item.price * item.quantity for item in items
    )

    tax = subtotal * Decimal("0.08") if subtotal > 100 else subtotal * Decimal("0.05")

    shipping = Decimal("10") if subtotal < 50 else Decimal("0")

    return subtotal + tax + shipping

# After
MINIMUM_FOR_STANDARD_TAX = Decimal("100")
STANDARD_TAX_RATE = Decimal("0.08")
REDUCED_TAX_RATE = Decimal("0.05")
FREE_SHIPPING_THRESHOLD = Decimal("50")
SHIPPING_COST = Decimal("10")

def calculate_total(items: list[OrderItem], customer: Customer) -> Decimal:
    subtotal = _calculate_subtotal(items)
    tax = _calculate_tax(subtotal)
    shipping = _calculate_shipping(subtotal)

    return subtotal + tax + shipping

def _calculate_subtotal(items: list[OrderItem]) -> Decimal:
    return sum(item.price * item.quantity for item in items)

def _calculate_tax(subtotal: Decimal) -> Decimal:
    rate = STANDARD_TAX_RATE if subtotal > MINIMUM_FOR_STANDARD_TAX else REDUCED_TAX_RATE
    return subtotal * rate

def _calculate_shipping(subtotal: Decimal) -> Decimal:
    return SHIPPING_COST if subtotal < FREE_SHIPPING_THRESHOLD else Decimal("0")

Read the full file on GitHub · 474 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. today First seen · 474 lines · 58 tokens per session scan A ecbc7ce16f60

Subscribe to this mod's changes

python-refactor-expert is an agent published in the GitHub repository giuseppe-trisciuoglio/developer-kit (343 stars, last pushed yesterday), licensed MIT. It adds 58 tokens to every session and 3,444 once invoked, about $0.0003 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-10.

Related

Other agents, from other repositories

agent-sdk-verifier-py

Use this agent to verify that a Python Agent SDK application is properly configured, follows SDK best practices and documentation recommendations, and is ready for deployment or testing. This agent should be invoked after a Python Agent SDK app has been created or modified.

anthropics/claude-plugins-official · 55 tokens

python-reviewer

Python 3.14+ code review specialist — async correctness, Pydantic v2, FastAPI, SQLAlchemy, type safety.

TheBeardedBearSAS/claude-craft · 31 tokens

mcp-developer

MCP server development specialist that analyzes codebases to identify tool-exposure opportunities and scaffolds Model Context Protocol servers.

pjt222/agent-almanac · 27 tokens

python-reviewer

Reviews Python diffs read-only on source and returns a findings table: correctness, typing, security, clarity. Writes only its report, to a caller-named path outside the repo. - Use after a Python change lands, before it merges. Spawn one per diff. Not for implementing (python-pro).

uwuclxdy/agenticat · 65 tokens

python-expert

Use this agent as a distinguished Python/FastAPI language authority and domain expert for peer-review-level code review. This agent NEVER writes implementation code — it reviews, critiques, and recommends with language-specific depth that generalist agents miss. Covers async mastery, FastAPI deep patterns, Pydantic…

asiflow/claude-nexus-hyper-agent-team · 372 tokens

python-reviewer

Expert Python code reviewer specializing in PEP 8 compliance, Pythonic idioms, type hints, security, and performance. Use for all Python code changes. MUST BE USED for Python projects.

DekaPrayoga/AurixAgent · 43 tokens