refactor

refactor is a skill for Claude Code from nirelbaz/promptpit. It costs 41 tokens per session (383 once invoked), scanned A, original, MIT.

A code-cleanup method that makes existing programs easier to read and maintain while keeping their behavior unchanged. Refactoring can include splitting large functions, removing repeated logic, or improving names.

In plain words
What is it for?
Use it before adding features to difficult code, when logic is repeated, or when functions and files have become too complex.
Why use it?
It reduces the difficulty of understanding and changing code, while tests help check that the cleanup did not alter what the program does.

Skill for Claude Code

Written for Claude Code: user-invocable in frontmatter.

Good fit Use it before adding features to difficult code, when logic is repeated, or when functions and files have become too complex.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/nirelbaz/promptpit/refactor
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.

Any agent
npx skills add nirelbaz/promptpit --skill refactor
Clone the repo
git clone --depth 1 https://github.com/nirelbaz/promptpit

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 refactor

README.md
[![agentmods](https://agentmods.dev/badge/skills/nirelbaz/promptpit/refactor/github.svg)](https://agentmods.dev/skills/nirelbaz/promptpit/refactor)
Your own site
<a href="https://agentmods.dev/skills/nirelbaz/promptpit/refactor"><img src="https://agentmods.dev/badge/skills/nirelbaz/promptpit/refactor/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 refactor

Your own site · 80×15
<a href="https://agentmods.dev/skills/nirelbaz/promptpit/refactor"><img src="https://agentmods.dev/badge/skills/nirelbaz/promptpit/refactor.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 41 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 383 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.00041 $0.00383
Opus 5.5 $0.00016 $0.00153
Sonnet 5.5 $0.00008 $0.00077
Haiku 4.5 $0.00004 $0.00038

Measured 1mo ago against content hash 772d2bdd8e2b, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, 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 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.

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.

.promptpit/skills/refactor/SKILL.md · 46 lines

What it actually says

Refactor

Clean up code. Make it simpler, clearer, or more maintainable without changing what it does.

When to refactor

  • You're about to add a feature and the existing code makes it hard
  • You see the same logic in three or more places
  • A function is longer than 40 lines
  • You need to read a function twice to understand it
  • Nesting is deeper than 3 levels

When NOT to refactor

  • Code you're not otherwise touching. Stay focused on the task at hand.
  • Code that works and nobody needs to change. Leave it alone.
  • Right before a deadline. Refactoring is for when you have room to verify.

Techniques

  • Extract function: repeated code becomes a named function
  • Early return: replace nested if/else with guard clauses
  • Rename: if the name doesn't explain the purpose, change it
  • Inline: if a function is called once and adds no clarity, inline it
  • Split file: if a file has two unrelated responsibilities, split it

Process

  1. Make sure tests pass before you start
  2. Make one small change at a time
  3. Run tests after each change
  4. Commit when tests pass
  5. Repeat

Rules

  • Never refactor and change behavior in the same commit. Refactoring means the tests still pass with no changes to the tests.
  • Don't abstract prematurely. Three concrete examples before you extract a pattern.
  • Simpler is better. If your refactor adds more code than it removes, reconsider.
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 First seen · 46 lines · 41 tokens per session scan A 772d2bdd8e2b

Subscribe to this mod's changes

refactor is a skill published in the GitHub repository nirelbaz/promptpit (6 stars, last pushed 2mo ago), licensed MIT. It adds 41 tokens to every session and 383 once invoked, about $0.0002 per session on Opus 5.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-31.

Related

Other skills, from other repositories

cn-check

Install and run the Continue CLI (cn) to execute AI agent checks on local code changes. Use when asked to "run checks", "lint with AI", "review my changes with cn", or set up Continue CI locally.

continuedev/continue · 49 tokens

yfm

YAML front matter (YFM) for any markdown article. x-cmd's default is three top-level fields: tags, description, memo. Default borrows the Agent Skills frontmatter shape — see . The yfm module is a helper: x yfm ls / init / lint.

x-cmd/x-cmd · 74 tokens

pr-writing-review

Extract and analyze writing improvements from GitHub PR review comments. Use when asked to show review feedback, style changes, or editorial improvements from a GitHub pull request URL. Handles both explicit suggestions and plain text feedback. Produces structured output comparing original phrasing with reviewer…

evalstate/fast-agent · 64 tokens

hypotheses

Turns a research direction into testable hypotheses with predictions, competing explanations and the experiments that discriminate between them, including the design (controls, randomization, blocking), sample size or seed count, the pre-specified analysis, and the result that would falsify each hypothesis. Use when a…

synthetic-sciences/openscience · 99 tokens

check

Comprehensive rule-based check. Triggered by "/check [target]" to evaluate all source files against project rules and report every violation.

x-cmd/x-cmd · 29 tokens

review

Review pull requests or code changes. Triggered by "/review [prlink]" or when user asks to review pending changes.

x-cmd/x-cmd · 27 tokens