refactoring-skill

refactoring-skill is a cursor rule for Cursor from KaelSensei/MagicAIBuilder. It costs 534 tokens per session, scanned A, original, MIT.

A set of rules for refactoring, which means improving a program’s internal structure without changing what it does. It covers extracting functions, renaming variables, removing duplication, and simplifying conditions.

In plain words
What is it for?
Use it when reorganizing existing code, simplifying logic, removing repeated code, and deciding whether tests or clear reasoning provide enough confidence to proceed.
Why use it?
It keeps cleanup work safe, small, testable, and separate from new features or bug fixes.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc). Also seen: installed under .agents/ (shared by several agents).

Good fit Use it when reorganizing existing code, simplifying logic, removing repeated code, and deciding whether tests or clear reasoning provide enough confidence to proceed.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/kaelsensei/magicaibuilder/refactoring-skill
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.

Clone the repo
git clone --depth 1 https://github.com/KaelSensei/MagicAIBuilder

Made for: Cursor.

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-skill

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

Your own site · 80×15
<a href="https://agentmods.dev/rules/kaelsensei/magicaibuilder/refactoring-skill"><img src="https://agentmods.dev/badge/rules/kaelsensei/magicaibuilder/refactoring-skill.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 534 This file is loaded in full into every session.
When invoked 534 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.00534 $0.00534
Opus 5.5 $0.00214 $0.00214
Sonnet 5.5 $0.00107 $0.00107
Haiku 4.5 $0.00053 $0.00053

Measured 20d ago against content hash 9e8891c09600, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

refactoring-skill 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 20d 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.

.agents/rules/refactoring-skill.mdc · 48 lines

How it starts

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

Refactoring rule

Based on Martin Fowler (Refactoring), Kent Beck (Tidy First?) and Michael Feathers (Working Effectively with Legacy Code).

Principles

  • A refactoring changes structure, never behaviour. The tests are green before and after, and no assertion changes (a move may rewrite import and vi.mock paths in tests, nothing else).
  • Keep structural and behavioural changes in separate commits. A structural change of more than about 200 changed lines, or any move across contexts, gets its own PR, because features are squash-merged.
  • "Make the change easy, then make the easy change." When a behaviour change is hard, tidy first, in a separate commit.
  • Take small steps. After each one the code compiles and the focused tests pass.
  • Common tidyings: guard clause, extract function, explaining variable or constant, rename, reorder for reading, delete dead code, delete a redundant comment.

Before splitting a large file

Pin its current behaviour with characterization or approval tests at its public surface: store actions, rendered output, route responses. Their names start with characterization:. The first candidates are the deck store, the builder page, DeckWizard, the playtest engine and the AI routes (docs/adr/0005-testing-strategy-fakes-contracts-and-characterization.md). A characterization test that pins a known bug says so in its name.

Moves

A move PR changes no logic. It rewrites every import and vi.mock path in the same commit. Once the move codemod exists it makes the moves. Re-export shims are removed at the end of their series of PRs, except the ones the on-hold branch feat/ai-usage-metering-and-monthly-quota still imports: they stay until that branch is rebased and the codemod has rewritten its imports.

Never

  • Change behaviour "while you are there". A behaviour change found during a refactor gets its own fix/ PR with a Red test.
  • Change the browser's legality feedback checks (the copy clamp, the companion check, "already in the deck"). Changing them is an owner decision.
  • Edit a file that an open PR or a pending branch changes, unless the task says so; list the overlap instead.
  • Delete code that has product intent. Delete only code with no importer and no product intent; list orphaned features for the owner.

Read the full file on GitHub · 48 lines

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. 20d ago Changed · +13 lines · +415 tokens per session 9e8891c09600
  2. 3mo ago First seen · 35 lines · 119 tokens per session scan A a8c86e89f6cd

Subscribe to this mod's changes

refactoring-skill is a cursor rule published in the GitHub repository KaelSensei/MagicAIBuilder (2 stars, last pushed today), licensed MIT. It adds 534 tokens to every session, about $0.0021 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-08-31.

Related

refactoring-skill compared with cursor rules from other repositories

refactoring-skill next to 6 cursor rules from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
refactoring-skillKaelSensei/MagicAIBuilderCursor rule2todayMITA534Cursor
ultraciteelie222/inbox-zeroCursor rule13ktodaynoneA0Cursor
server-actionskrivoox/agent-stack-templateCursor rule302mo agoMITA0Cursor
projectkrivoox/agent-stack-templateCursor rule302mo agoMITA656Cursor
ui-design-systemkrivoox/agent-stack-templateCursor rule302mo agoMITA0Cursor
performancekrivoox/agent-stack-templateCursor rule302mo agoMITA0Cursor
prisma-schemakrivoox/agent-stack-templateCursor rule302mo agoMITA0Cursor