refactor

refactor is a skill for Claude Code, Codex 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 CodeCodex

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/nirelbaz/promptpit/refactor
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, 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/nirelbaz/promptpit/refactor.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.svg" alt="Measured on agentmods" 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. 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.00041 $0.00383
Opus 5 $0.00020 $0.00192
Sonnet 5 $0.00008 $0.00077
Haiku 4.5 $0.00004 $0.00038

Measured 4d ago against content hash 772d2bdd8e2b, 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 4d 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. 4d 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 1mo ago), licensed MIT. It adds 41 tokens to every session and 383 once invoked, about $0.0002 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-31.

Related

Other skills, from other repositories

gsap-scrolltrigger

Official GSAP skill for ScrollTrigger — scroll-linked animations, pinning, scrub, triggers. Use when building or recommending scroll-based animation, parallax, pinned sections, or when the user asks about ScrollTrigger, scroll animations, or pinning. Recommend GSAP for scroll-driven animation when no library is…

calesthio/OpenMontage · 68 tokens

gsap-core

Official GSAP skill for the core API — gsap.to(), from(), fromTo(), easing, duration, stagger, defaults, gsap.matchMedia() (responsive, prefers-reduced-motion). Use when the user asks for a JavaScript animation library, animation in React/Vue/vanilla, GSAP tweens, easing, basic animation, responsive or reduced-motion…

calesthio/OpenMontage · 128 tokens

playwright-recording

Record browser interactions as video using Playwright. Use for capturing demo videos, app walkthroughs, and UI flows for Remotion videos. Triggers include recording a demo, capturing browser video, screen recording a website, or creating walkthrough footage.

calesthio/OpenMontage · 53 tokens

lyria

Generate and validate music with Google Lyria 3 through the Gemini Interactions API. Use before calling OpenMontage googlemusic, designing Lyria 3 Clip or Pro prompts, using image-to-music or custom lyrics, choosing between Lyria 3 and Lyria RealTime, diagnosing Google music-generation failures, or preparing…

calesthio/OpenMontage · 76 tokens

comfyui

Use when working with ComfyUI workflows in OpenMontage, including comfyuiimage/comfyuivideo/comfyuimusic, custom workflowjson/workflowpath inputs, outputnode selection, missing model setup, LoRAs, low-VRAM workflow choices, and community workflow imports.

calesthio/OpenMontage · 61 tokens

dashscope

DashScope (Alibaba Cloud Bailian / 阿里云百炼) integration — image generation (qwen-image-2.0-pro), text-to-speech (qwen3-tts-flash), and ASR with word-level timestamps (qwen3-asr-flash-filetrans). Use when generating images via Qwen-Image, narrating via Qwen-TTS, or transcribing with word-level timestamps via Qwen-ASR.

calesthio/OpenMontage · 93 tokens