refactor

refactor is a skill for Claude Code, Codex from vstorm-co/pydantic-deepagents. It costs 12 tokens per session (251 once invoked), scanned A, original, MIT.

A code-cleanup workflow for improving a program’s internal structure while keeping its external behavior unchanged.

In plain words
What is it for?
Use it to split large functions, remove repeated code, improve names, simplify conditionals, group related code, and reduce circular dependencies.
Why use it?
It reduces tangled, duplicated, or hard-to-follow code without mixing cleanup with new features. Tests help confirm that the program still works the same way.

Skill for Claude CodeCodex

About the project

Pydantic Deep Agents is a self-hosted terminal AI assistant and Python framework for building coding, research, and other AI agents. It gives agents tools such as file access, shell commands, planning, memory, sub-agents, sandboxed execution, and MCP connections, and supports different models.

vstorm-co/pydantic-deepagents · 1,058 stars · on GitHub

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 skills/vstorm-co/pydantic-deepagents/refactor
Any agent
npx skills add vstorm-co/pydantic-deepagents --skill refactor
Clone the repo
git clone --depth 1 https://github.com/vstorm-co/pydantic-deepagents

Made for: Claude Code, Codex.

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

README.md
[![agentmods](https://agentmods.dev/badge/skills/vstorm-co/pydantic-deepagents/refactor.svg)](https://agentmods.dev/skills/vstorm-co/pydantic-deepagents/refactor)
Your own site
<a href="https://agentmods.dev/skills/vstorm-co/pydantic-deepagents/refactor"><img src="https://agentmods.dev/badge/skills/vstorm-co/pydantic-deepagents/refactor.svg" alt="Measured on agentmods" height="20"></a>
Per session 12 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 251 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 $0.00012 $0.00251
Opus 5 $0.00006 $0.00125
Sonnet 5 $0.00002 $0.00050
Haiku 4.5 $0.00001 $0.00025

Measured 5d ago against content hash 6838d73006df, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

refactor 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 5d 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.

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.

apps/cli/skills/refactor/SKILL.md · 45 lines

What it actually says

Refactor

Improve code structure without changing external behavior.

Process

  1. Understand — Read all related code, run existing tests
  2. Plan — Identify what to change and why
  3. Execute — Make changes incrementally
  4. Verify — Run tests after each change

Common Refactoring Patterns

Extract

  • Long function → smaller focused functions
  • Repeated code → shared helper
  • Magic numbers → named constants

Simplify

  • Deep nesting → early returns / guard clauses
  • Complex conditionals → descriptive functions
  • Large classes → smaller focused classes

Rename

  • Unclear names → descriptive names
  • Inconsistent naming → consistent conventions

Reorganize

  • Related functions scattered → grouped in modules
  • Circular dependencies → dependency inversion

Rules

  • Never change behavior — tests must pass before and after
  • One refactoring type per commit
  • If tests don't exist, write them first
  • Don't refactor and add features in the same change
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. 5d ago First seen · 45 lines · 12 tokens per session scan A 6838d73006df

Subscribe to this mod's changes

refactor is a skill published in the GitHub repository vstorm-co/pydantic-deepagents (1,058 stars, last pushed 13d ago), licensed MIT. It adds 12 tokens to every session and 251 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-08-30.

Related

Other skills, from other repositories

add-new-model

Add support for a newly-released LLM model in pydantic-ai (e.g. openai:gpt-5.6, anthropic:claude-sonnet-5). Use when a provider ships a new model id and you need to wire literals, profile flags, and tests to recognize it. Handles SDK-lag, gateway list conventions, and capability probing.

pydantic/pydantic-ai · 80 tokens

building-pydantic-ai-agents

Build AI agents with Pydantic AI — tools, capabilities (including on-demand loading), structured output, streaming, testing, and multi-agent patterns. Use when the user mentions Pydantic AI, imports pydanticai, or asks to build an AI agent, add tools/capabilities, defer capability loading, stream output, define agents…

pydantic/pydantic-ai · 85 tokens

complete-partial-pr

Evaluate and complete an issue or PR where the submitted patch fixes only a narrow symptom of the reported pain point. Use when a contribution may miss adjacent integration surfaces, provider/spec semantics, roundtrip behavior, tests, docs, or historical maintainer decisions.

pydantic/pydantic-ai · 55 tokens

testing-skill

Record, rewrite, and debug VCR cassettes for HTTP recordings. Use when running tests with --record-mode, verifying cassette playback, or inspecting request/response bodies in YAML cassettes.

pydantic/pydantic-ai · 44 tokens

pre-push-review

Run a high-judgment local review of the current branch before pushing, both before a PR exists and between PR iterations.

pydantic/pydantic-ai · 24 tokens

adding-a-provider-api-feature

Add a new provider API capability (prompt caching, strict/structured tool calling, thinking/reasoning effort, service tier, safety settings, logprobs, etc.) to Pydantic AI. Use when wiring a provider feature through the library — it enforces reasoning from the existing cross-provider abstraction before designing…

pydantic/pydantic-ai · 97 tokens