refactoring-workflow

refactoring-workflow is a skill for Claude Code, Codex 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 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/personamanagmentlayer/pcl/refactoring-workflow
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, 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 refactoring-workflow

README.md
[![agentmods](https://agentmods.dev/badge/skills/personamanagmentlayer/pcl/refactoring-workflow.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.svg" alt="Measured on agentmods" 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. 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.1 $0.00083 $0.02066
Opus 5 $0.00042 $0.01033
Sonnet 5 $0.00017 $0.00413
Haiku 4.5 $0.00008 $0.00207

Measured today against content hash fcf31a69f549, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, 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 today.

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. today 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 (41 stars, last pushed today), licensed Apache-2.0. It adds 83 tokens to every session and 2,066 once invoked, about $0.0004 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-09-05.

Related

Other skills, from other repositories

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

code-quality-review

Run a maintainability and structure review focused on abstraction quality, branching complexity, file growth, canonical ownership, duplication, and refactoring opportunities. Use when the user asks for code quality review, maintainability review, 代码质量审查, 可维护性审查, or comments about whether the change stays easy to…

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

arch-optimize

架构优化技能 v3.2:六大衰退风险扫描(R1-R6)、质量度量(MI/CC/健康分)、回归防护。五阶段工作流配 4 个零依赖本地脚本(archscan/depgraph/riskdiagnose/qualitymetrics/regressionguard),全部输出 JSON。在架构审查、技术债评估、代码重构、质量提升、工程结构评审时调用。.

bfxh/arch-optimize · 103 tokens

devsecops-complete-audit

Audit professionnel complet d'un projet logiciel couvrant architecture, code mort, dette technique, dépendances, API, authentification, autorisation, sécurité applicative, CI/CD, performance, production et validation finale.

KxlSys/OpenSkill · 50 tokens

finding-duplicate-functions

Use when auditing a codebase for semantic duplication — functions that do the same thing but have different names or implementations, especially common in LLM-generated codebases.

bobmatnyc/claude-mpm · 36 tokens

refactoring-patterns

Apply safe refactoring patterns to improve code structure without changing behavior. Use when cleaning up code, reducing technical debt, or improving maintainability.

summarybotng/summarybot-ng · 33 tokens