Agent skill

Refactor

by poshan0126 in poshan0126/dotclaude

Safely refactor code with test coverage as a safety net. An agent skill from poshan0126/dotclaude.

MITAuto-check passedDevelopment

Install Refactor

skills CLI
$ npx skills add poshan0126/dotclaude --skill refactor -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install poshan0126/dotclaude refactor --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/poshan0126/dotclaude.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/refactor .claude/skills/refactor && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
refactor
GitHub stars
871
Token cost
~630 tokens
SKILL.md length
342 words
Files
1
Skills in repo
14
Repo updated
First seen
Licence
MIT

At a glance

Safely refactor code with test coverage as a safety net. An agent skill from poshan0126/dotclaude.

  • Works in 4 steps: Understand the current state → Plan the refactoring → Make changes in small, testable steps → …
  • Tasks that involve Refactoring
  • SKILL.md covers Process, Diff mode (--diff): simplify… and Rules
  • Calls git

What it does

Refactor is an agent skill from poshan0126/dotclaude. Safely refactor code with test coverage as a safety net. Use --diff to simplify just the current working diff before committing.

Its SKILL.md is about 630 tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Development, covering Refactoring and Test coverage. The repository describes itself as: The standard .claude/ folder structure for everyday development. The licence is MIT.

When your agent uses it

  • Tasks that involve Refactoring
  • Tasks that involve Test coverage

Example prompts

  • “/refactor”

Workflow steps

4 steps, taken from the step headings in SKILL.md.

  1. Understand the current state
  2. Plan the refactoring
  3. Make changes in small, testable steps
  4. Verify

What it can do on your machine

Read from SKILL.md and the folder at commit 94b84b9. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • git

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use git, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Refactor loads about 630 tokens when it runs. Until then it costs about 35 tokens; SKILL.md has 342 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~35
When it runs · the whole SKILL.md, loaded when a task matches
~630

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from poshan0126/dotclaude at commit 94b84b9, republished under its MIT licence (© poshan0126). 342 words, ~630 tokens.

Download SKILL.mdSave it as .claude/skills/refactor/SKILL.md (or your agent's skills folder).
name
refactor
description
Safely refactor code with test coverage as a safety net. Use `--diff` to simplify just the current working diff before committing.
argument-hint
[file, function, or pattern | --diff]
disable-model-invocation
true

Refactor $ARGUMENTS safely. If $ARGUMENTS contains --diff, use Diff mode below instead.

Process

1. Understand the current state
  • Read the code and its tests
  • Identify what the code does, its callers, and its dependencies
  • If there are no tests, WRITE TESTS FIRST. You need a safety net before changing anything
2. Plan the refactoring
  • State what you're changing and why (clearer naming, reduced duplication, better structure)
  • List the specific transformations (extract function, inline variable, move module, etc.)
  • Check: does this change any external behavior? If yes, this isn't a refactor. Reconsider.
3. Make changes in small, testable steps
  • One transformation at a time
  • Run tests after EACH step. Not at the end
  • If a test breaks, undo the last step and make a smaller change
4. Verify
  • All existing tests pass
  • Lint and typecheck pass
  • The public API hasn't changed (unless that was the explicit goal)
  • The code is objectively simpler. Fewer lines, fewer branches, clearer names

Diff mode (--diff): simplify what you just wrote

The pre-commit polish pass. Target = the current working diff (git diff + git diff --cached; if clean, the last commit). Goal: make the diff smaller and clearer with identical behavior.

  1. Read the diff. For each hunk ask: would a reviewer write this more simply?
    • Inline abstractions used once that the diff itself introduced
    • Remove dead parameters, unused returns, speculative generality ("might need it later")
    • Delete comments that restate the code, and defensive checks duplicating guarantees the codebase already makes
    • Align naming with the surrounding file's conventions
  2. Touch ONLY lines in the diff (plus mechanical consequences like an import). Never expand into surrounding code — that's regular refactor mode.
  3. Show the proposed simplifications, confirm, apply in small steps, run the tests for the touched files after each.
  4. Report: lines before → after. If nothing to simplify, say "diff is already minimal" and stop — don't invent work.

Rules

  • If you can't run the tests, don't refactor
  • Never mix refactoring with behavior changes in the same commit
  • If the refactoring is large (10+ files), break it into multiple commits

© poshan0126, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in skills/refactor of poshan0126/dotclaude.

Open the folder on GitHubat commit 94b84b9

Compare with similar skills

Refactor next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Refactor compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Refactor this skillposhan0126/dotclaude871—~630Automated safety check: PassMIT
Refactoringcitypaul/.dotfiles739—~2.9kAutomated safety check: PassCustom licence
Improvefossasia/eventyay-interpretation1.6k10 repos~3.7kAutomated safety check: WarnMIT
Refactor OpCVCUDA/CV-CUDA2.7k—~1.5kAutomated safety check: PassCustom licence
Test Guidelinesgetsentry/sentry-dart873—~3.1kAutomated safety check: PassMIT
Code ReviewerYikai-Liao/symusic1891 repos~1.3kAutomated safety check: PassMIT

Similar skills

  • Refactoring

    citypaul/.dotfiles

    Refactoring assessment and behavior-preserving patterns for code with a passing baseline and proportionate preservation evidence.

    739 GitHub stars~2.9k tokensUpdated 5 days ago
    DevelopmentAuto-check passed
  • Improve

    fossasia/eventyay-interpretation

    Survey any codebase as a senior advisor and produce prioritized, self-contained implementation plans for OTHER models/agents to execute.

    1.6k GitHub starsUsed in 10 repos~3.7k tokens
    Agent WorkflowsAuto-check: warnings
  • Refactor Op

    CVCUDA/CV-CUDA

    Find and safely apply per-operator refactoring / redundancy-reduction opportunities in a CV-CUDA operator (near-duplicate Tensor/VarShape kernels, reinvented shared utilities, dead code).

    2.7k GitHub stars~1.5k tokensUpdated 21 days ago
    DevelopmentAuto-check passed
  • Test Guidelines

    getsentry/sentry-dart

    Official

    Enforce Sentry Dart/Flutter SDK test conventions for naming, structure, and fixtures.

    873 GitHub stars~3.1k tokensUpdated today
    Testing & QAAuto-check passed
  • Code Reviewer

    Yikai-Liao/symusic

    Analyzes code diffs and files to identify bugs, security vulnerabilities (SQL injection, XSS, insecure deserialization), code smells, N+1 queries, naming issues, and architectural concerns, then…

    189 GitHub starsUsed in 1 repo~1.3k tokens
    DevelopmentAuto-check passed
  • Characterisation Tests

    citypaul/.dotfiles

    A skill your agent uses when modifying existing code that lacks tests and you need to document its actual current behavior before making changes -- the legacy code dilemma where you need tests to…

    739 GitHub stars~3.6k tokensUpdated 5 days ago
    Testing & QAAuto-check passed

More from poshan0126/dotclaude

All 14 skills in this repo
  • Session Catchup and Handoff

    poshan0126/dotclaude

    Rebuilds working context after /clear by reading a handoff note and the branch's git state, or writes that handoff note before a session ends.

    871 GitHub stars~811 tokensUpdated 1 mo ago
    Auto-check passed
  • Context Budget Check

    poshan0126/dotclaude

    Estimates the per-turn token cost of a project's .claude folder and CLAUDE.md, split into always-loaded, path-scoped and invoked-only files, and flags what runs over budget.

    871 GitHub stars~1.4k tokensUpdated 1 mo ago
    Auto-check passed
  • Codebase Onboarding Tour

    poshan0126/dotclaude

    Builds a quick mental model of an unfamiliar codebase by dispatching read-only Explore subagents and merging their findings into one brief.

    871 GitHub stars~858 tokensUpdated 1 mo ago
    Auto-check passed
  • Parallel Specialist PR Review

    poshan0126/dotclaude

    Reviews a pull request, staged changes or a file by sending the diff to specialist reviewer agents in parallel, then merges their findings into one compact report.

    871 GitHub stars~1.7k tokensUpdated 1 mo ago
    Auto-check passed
  • dotclaude Project Setup

    poshan0126/dotclaude

    Scans a codebase, interviews you, and installs only the justified Claude Code rules, hooks, agents and skills, tailored to the project's stack.

    871 GitHub stars~3.6k tokensUpdated 1 mo ago
    Auto-check passed
  • Ship Changes

    poshan0126/dotclaude

    Walks through commit, push and pull request creation for the current changes, asking you to confirm the files, message, push and PR text at each step.

    871 GitHub stars~953 tokensUpdated 1 mo ago
    Auto-check: notes

Questions about Refactor

What does Refactor do?

Safely refactor code with test coverage as a safety net. An agent skill from poshan0126/dotclaude. Refactor is an agent skill from poshan0126/dotclaude. Safely refactor code with test coverage as a safety net.

When should I use Refactor?

Refactor fits situations like: tasks that involve Refactoring; tasks that involve Test coverage.

How do I install Refactor in Claude Code?

Run `npx skills add poshan0126/dotclaude --skill refactor -a claude-code`. Or copy the skill folder (skills/refactor in poshan0126/dotclaude) into .claude/skills/refactor in your project. Claude Code loads it when a task matches its description.

How do I install Refactor in Codex?

Run `npx skills add poshan0126/dotclaude --skill refactor -a codex`. Or copy the skill folder (skills/refactor in poshan0126/dotclaude) into .agents/skills/refactor in your project. Codex loads it when a task matches its description.

Can I use Refactor in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add poshan0126/dotclaude --skill refactor -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/refactor, .gemini/skills/refactor, .github/skills/refactor and .opencode/skills/refactor in your project.

What does Refactor need to run?

Going by SKILL.md and its folder, Refactor needs the command-line tools its instructions call (git).

Does Refactor access the network?

SKILL.md contains no URLs. Its commands use git, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Refactor safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Refactor use?

Refactor is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Refactor use?

About 630 tokens (SKILL.md is roughly 2.5k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Refactor?

Skills that share tags, products or a category with Refactor: Refactoring (citypaul/.dotfiles, 739 stars), Improve (fossasia/eventyay-interpretation, 1.6k stars), Refactor Op (CVCUDA/CV-CUDA, 2.7k stars) and Test Guidelines (getsentry/sentry-dart, 873 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Refactor?

poshan0126 (a GitHub user) maintains it in poshan0126/dotclaude, which has 871 GitHub stars. The repository holds 14 skills in this directory. The repository was last updated on August 27, 2026.

Source: poshan0126/dotclaude on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.