refactor

A step-by-step protocol for restructuring code without changing its behavior. Refactoring means improving code structure while keeping what the program does the same.

In plain words
What is it for?
Use it to plan and perform safe refactors, run the test suite and linter when available, and keep the change focused without deleting tests.
Why use it?
It catches regressions by requiring a passing baseline, small changes, tests after each change, and final verification.

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/supersynergy/awesome-agentic-coding/refactor
Any agent
npx skills add Supersynergy/awesome-agentic-coding --skill refactor
Clone the repo
git clone --depth 1 https://github.com/Supersynergy/awesome-agentic-coding

Made for: Claude Code, Codex.

Per session 13 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 279 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.00013 $0.00279
Opus 5 $0.00006 $0.00139
Sonnet 5 $0.00003 $0.00056
Haiku 4.5 $0.00001 $0.00028

Measured 2d ago against content hash 37f85e59d156, 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 2d 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.

skills/refactor/SKILL.md · 39 lines

What it actually says

Safe Refactoring Protocol

Target: $ARGUMENTS

Step 1: Baseline

  • Run tests first. If they fail, stop — fix tests before refactoring.
  • Note current test count and pass rate.

Step 2: Plan

List every change you will make. Group into atomic steps where:

  • Each step leaves the code in a working state
  • Each step can be verified independently
  • Steps are ordered by dependency

Step 3: Execute (one step at a time)

For each step:

  1. Make the change
  2. Run tests
  3. If tests pass: continue to next step
  4. If tests fail: undo this step and investigate

Step 4: Final Verification

  • Run full test suite
  • Compare test count (should be same or higher, never lower)
  • Run linter if available

Rules

  • Never change behavior. Only structure.
  • Never delete tests. Never skip tests.
  • If a refactoring step breaks tests, it means the refactoring is wrong, not the test.
  • Keep the diff minimal. Don't rename things "while you're at it."
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. 2d ago First seen · 39 lines · 13 tokens per session scan A 37f85e59d156

Subscribe to this mod's changes

refactor is a skill published in the GitHub repository Supersynergy/awesome-agentic-coding (1 stars, last pushed 1mo ago), licensed MIT. It adds 13 tokens to every session and 279 once invoked, about $0.0001 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

aiwiki-research-refresh-privacy

定期为 AiWiki「LLM 隐私保护」主题做一次「高质量一手来源研究 → 去重 → 三道硬闸门把关 → 走隐私条目流水线 → 过闸门」的扩充。当需要发现并新增 LLM 隐私攻防新选题(尤其由月度定时触发器拉起的无人值守会话),且要保证一手出处、不与现有条目重复、不制造假安全时使用。.

XuebinMa/AIWiki · 116 tokens

aiwiki-privacy-entry-author

为 AiWiki「LLM 隐私保护」主题撰写或修订一条攻防条目(privacy/ 下的 .mdx)。当需要新增/改写隐私条目、并保证第一人称红线、九节结构、三道硬闸门、隐私 frontmatter 与一手出处时使用。.

XuebinMa/AIWiki · 81 tokens

aiwiki-research-refresh

定期为 AiWiki 做一次「高质量来源研究 → 去重 → 质量把关 → 走条目流水线 → 过闸门」的扩充。当需要发现并新增「AI 使用误区」新选题(尤其由月度定时触发器拉起的无人值守会话),且要保证来源质量、不与现有条目重复时使用。.

XuebinMa/AIWiki · 91 tokens

aiwiki-entry-author

为 AiWiki 撰写或修订一条「误区」条目(docs/ 下的 .mdx)。当需要新增/改写误区条目、并保证第一人称 AI 声音、七段结构、frontmatter 规范与可核查出处时使用。.

XuebinMa/AIWiki · 68 tokens

aiwiki-translator

把一条 AiWiki 中文误区条目(docs/ 下的 .mdx)翻译成英文镜像,输出到 i18n/en/ 对应路径。当需要为新增或修订的中文条目生成/更新英文版时使用。.

XuebinMa/AIWiki · 60 tokens

issue-triage

Issue triage: audit open issues, categorize, detect duplicates, cross-ref PRs, risk assessment, post comments. Args: "all" for deep analysis of all, issue numbers to focus (e.g. "42 57"), "en"/"fr" for language, no arg = audit only in French.

rtk-ai/rtk · 70 tokens