refactoring-workflow

refactoring-workflow is a skill for Claude Code from personamanagmentlayer/pcl. It costs 83 tokens per session (2,066 once invoked), scanned A, original, Apache-2.0.

A guided method for restructuring existing code without changing what it does. It uses small steps and a passing test suite to check that behaviour stays the same.

In plain words
What is it for?
Use it to clean up, simplify, or reorganise code; make a feature easier to add; or make a component easier to test in isolation.
Why use it?
It reduces duplication, tangled dependencies, and overly large modules while keeping changes easier to review. It also separates cleanup from new behaviour or bug fixes.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Good fit Use it to clean up, simplify, or reorganise code; make a feature easier to add; or make a component easier to test in isolation.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/personamanagmentlayer/pcl/refactoring-workflow
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 personamanagmentlayer/pcl --skill refactoring-workflow
Clone the repo
git clone --depth 1 https://github.com/personamanagmentlayer/pcl

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 refactoring-workflow

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

Your own site · 80×15
<a href="https://agentmods.dev/skills/personamanagmentlayer/pcl/refactoring-workflow"><img src="https://agentmods.dev/badge/skills/personamanagmentlayer/pcl/refactoring-workflow.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 83 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,066 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. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
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.00083 $0.02066
Opus 5.5 $0.00033 $0.00826
Sonnet 5.5 $0.00017 $0.00413
Haiku 4.5 $0.00008 $0.00207

Measured 1mo ago against content hash fcf31a69f549, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

refactoring-workflow 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.

stdlib/workflows/refactoring-workflow/SKILL.md · 240 lines

How it starts

The opening of the file, as written. The whole thing — 240 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Refactoring Workflow

Refactoring is changing the structure of code without changing its behaviour. If behaviour changes, it is not a refactor — it is a rewrite, and it needs a different plan and a different review.

When to Use This Skill

  • The user asks to refactor, clean up, restructure or simplify
  • A feature is hard to add because the current structure resists it
  • Duplication has reached the point where a change must be made in several places
  • A module has grown beyond what one reader can hold in mind
  • Coupling makes a unit impossible to test in isolation

Do not refactor when the tests are red, when you do not understand the current behaviour, or as a side quest inside a feature branch. Refactoring merged together with behaviour change is unreviewable.

Core Concepts

The Two Hats

You are either adding behaviour or restructuring — never both in the same edit. Kent Beck's metaphor: swap hats deliberately, and know which one you are wearing. When a refactor reveals a bug, note it and finish the refactor; fix the bug in a separate change with its own test.

The Precondition

A refactor is safe only to the extent that behaviour is observable. That means a green test suite covering the paths you will touch. Without it you are not refactoring, you are editing and hoping.

If coverage is missing, stop and add characterisation tests first — see the tdd-workflow skill, which covers seams and characterisation in depth.

Small Steps

Each step should be small enough that you can name what it did and revert it alone. Run the suite after every step. Two hours of unverified restructuring followed by a red suite gives you no information about which edit broke it.

Make the Change Easy, Then Make the Easy Change

When a feature is hard to add, do not force it into the existing shape. First refactor until the feature becomes a small addition, then add it. These are two commits, in that order.

The Workflow

1. Confirm green and clean

Read the full file on GitHub · 240 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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 · 240 lines · 83 tokens per session scan A fcf31a69f549

Subscribe to this mod's changes

refactoring-workflow is a skill published in the GitHub repository personamanagmentlayer/pcl (44 stars, last pushed 7d ago), licensed Apache-2.0. It adds 83 tokens to every session and 2,066 once invoked, about $0.0003 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-09-05.

Related

Other skills, from other repositories

software-code-refactoring

Improve production code quality while preserving all existing test behavior. Commonly used for the Refactor phase of TDD red-green-refactor, but applicable to any codebase with tests. Use when production code works but needs cleanup — reducing duplication, improving naming, simplifying complexity, aligning with…

stencila/stencila · 102 tokens

code-quality-review

A code-review guide for judging whether software stays easy to understand, change, test, and extend.

bahayonghang/my-ai-cli-toolkit · 149 tokens

absolute-simplify

Use when the user wants to simplify, clean up, refactor, tidy, or refine code — their staged/unstaged git changes or a target file/path. Reduces complexity, flattens nesting, removes redundancy and dead code, scores each change by value (holding low-value churn), then runs tests to prove nothing broke. Invoke on…

maddhruv/absolute · 178 tokens

arch-optimize

A software architecture review workflow that scans a codebase for structural risks and measures code quality. It checks issues such as overly complex code, repeated knowledge, changes spreading across many files, circular dependencies, and distorted domain models.

bfxh/arch-optimize · 114 tokens

refactor-engineer

Enforces characterize-before-change discipline with continuous green tests, separating structural changes from behavioral ones. Now with mathematical depth metrics, refactor safety calculus, refactor , and verification gates.

Kshitijpalsinghtomar/depth-skills · 41 tokens

unbiased-review

Use when reviewing a spec, plan, or implementation produced by another session - verifies its claims against the actual repo, grades TDD and hexagonal discipline, and reports severity-ranked findings without writing the fix. Triggers on "review this spec/plan/implementation", "second opinion on", "check this design"…

karsten-s-nielsen/mad-scientist-skills · 84 tokens