python-refactor-agent

python-refactor-agent is an agent for Claude Code from acaprino/daodan. It costs 74 tokens per session (415 once invoked), scanned A, original, MIT.

An agent for refactoring existing Python code, meaning changing its structure without changing its intended behavior. It focuses on clearer code, lower complexity, dead-code removal, imports, comments, and docstrings.

In plain words
What is it for?
Use it to remove unused code, simplify nested logic, improve documentation, and apply tools such as Ruff, Vulture, and mypy.
Why use it?
It helps make older or difficult Python code easier to maintain while preserving external behavior.

Agent for Claude Code

Written for Claude Code: shipped in a Claude Code plugin. Also seen: model in frontmatter.

Part of the python-development plugin — 9 skills, 3 commands, 3 agents shipped together

Good fit Use it to remove unused code, simplify nested logic, improve documentation, and…

Compare 6 agents from other repositories ↓
Install with agentmods
npx agentmods add agents/acaprino/daodan/python-refactor-agent
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/acaprino/daodan

Made for: Claude Code.

Or install python-development, the plugin that ships this one along with the rest of its 9 skills, 3 commands, 3 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-agent

README.md
[![agentmods](https://agentmods.dev/badge/agents/acaprino/daodan/python-refactor-agent.svg)](https://agentmods.dev/agents/acaprino/daodan/python-refactor-agent)
Your own site
<a href="https://agentmods.dev/agents/acaprino/daodan/python-refactor-agent"><img src="https://agentmods.dev/badge/agents/acaprino/daodan/python-refactor-agent.svg" alt="Measured on agentmods" height="20"></a>
Per session 74 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 415 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.00074 $0.00415
Opus 5 $0.00037 $0.00208
Sonnet 5 $0.00015 $0.00083
Haiku 4.5 $0.00007 $0.00042

Measured yesterday against content hash 360de6157345, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

python-refactor-agent 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 yesterday.

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.

exports/claude/plugins/python-development/agents/python-refactor-agent.md · 38 lines

What it actually says

ROLE

Expert Python Refactoring Agent. You transform complex, hard-to-understand code into clear, well-documented, maintainable Python 3.12+ code while preserving correctness.

CAPABILITIES

  • Code Quality Tools: ruff, vulture, mypy.
  • Refactoring Patterns: Extract Method, Replace Conditional with Polymorphism, introducing Dataclasses/Protocols.
  • Complexity Reduction: Reducing cognitive complexity, flattening nested loops/conditionals.
  • Dead Code Removal: Finding and eliminating unused imports, variables, functions, and classes.
  • Documentation: Applying antirez's 9-type comment taxonomy, auditing docstrings (Google style).
  • Companion Skills: You leverage python-refactor, python-dead-code, python-comments, and python-performance-optimization.

APPROACH

  1. Analyze the code targeted for refactoring.
  2. If requested, run vulture or ruff to identify dead code or linting errors.
  3. Formulate a refactoring plan (e.g., splitting a monolithic function into smaller, testable units).
  4. Apply changes incrementally, ensuring you do not break existing behavior.
  5. Improve docstrings and inline comments.

CONSTRAINTS

  • NEVER change the external behavior or public API of the functions you refactor unless explicitly instructed.
  • Ensure strict type hints (typing) are added or maintained.
  • Follow modern Python 3.12+ idioms.
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. yesterday First seen · 38 lines · 74 tokens per session scan A 360de6157345

Subscribe to this mod's changes

python-refactor-agent is an agent published in the GitHub repository acaprino/daodan (8 stars, last pushed yesterday), licensed MIT. It adds 74 tokens to every session and 415 once invoked, about $0.0004 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-05.

Related

Other agents, from other repositories

Geoprocessing Specialist

ArcPy and Python toolbox expert who automates spatial workflows — builds .pyt toolboxes, Model Builder processes, batch geoprocessing automation, and custom analysis scripts for ArcGIS Pro.

SHAdd0WTAka/Zen-Ai-Pentest · 45 tokens

python-pro

Write idiomatic Python code with advanced features like decorators, generators, and async/await. Optimizes performance, implements design patterns, and ensures comprehensive testing. Use PROACTIVELY for Python refactoring, optimization, or complex Python features.

echoVic/blade-code · 51 tokens

python-spec

A reference guide for modern Python 3.12 and later development, including asynchronous code, uv, ruff, and pydantic.

Dannykkh/skill-olympus · 51 tokens

python-worker-reviewer

Reviews standalone Python background worker services (Pub/Sub, Cloud Scheduler, GCS-triggered). Checks error surfacing, external client injection, DB access patterns, structlog usage, and test coverage. Use after any changes to worker services that are not FastAPI REST APIs or ADK agents.

kumaran-is/claude-code-onboarding · 63 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

script-operator

Specialized in bash and Python. Can inspect/modify the environment and create/edit/execute scripts.

MadGraphTeam/MadAgents · 24 tokens