Refactor Planner — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited Refactor Planner (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
This skill directs the agent to analyze a block of code (or an entire module) and produce an ordered, safe refactoring plan. Rather than rewriting everything at once, it breaks the work into small, reversible steps — each one leaving the tests green and the behavior unchanged. It identifies code smells, maps dependencies, flags high-risk areas, and sequences the changes so you can ship incrementally without introducing regressions.
Use this when you have messy, hard-to-understand code that works but needs cleaning up before you can safely add features.
Copy this file to .agents/skills/refactor-planner/SKILL.md in your project root.
Then ask the agent:
Paste in the code you want refactored, or point to a file path.
Add the "Prompt / Instructions" section below to your .cursorrules file, or paste it directly into the Cursor AI pane before sharing the code you want refactored.
Paste the target code into the chat along with the instructions from the section below. For large files, include the full file plus any files that import from it so Codex can map dependencies.
When asked to plan a refactor, follow these steps precisely:
## Code Smells Found
- [Smell type]: [Description] — [Location]
...
## Dependency Map
- `functionName` is called by: X, Y, Z
- `functionName` depends on: A, B
...
## Refactoring Plan
### Step 1 — [Title] [Risk: Low/Medium/High]
**What:** [What to change]
**Why:** [Which smell this addresses]
**How:** [Concrete action, e.g., "Extract lines 45–67 into a new function called `validateInput`"]
**Verify:** [How to confirm nothing broke, e.g., "Run `npm test` — all existing tests should pass"]
### Step 2 — ...
...
## High-Risk Flags
[List any steps that need special attention, tests to write first, or API surface changes that require coordination]Input to Agent:
"Use the Refactor Planner skill on this function:
>
``ts function process(data: any) { let result = []; for (let i = 0; i < data.length; i++) { if (data[i].type === 'A') { if (data[i].value > 100) { if (data[i].active) { result.push({ id: data[i].id, score: data[i].value * 1.5 }); } } } else if (data[i].type === 'B') { if (data[i].value > 50) { result.push({ id: data[i].id, score: data[i].value * 1.2 }); } } } return result; } ``"Output from Agent:
## Code Smells Found - Deep nesting: Triple-nested conditionals make the logic hard to follow — lines 3–13 - Magic numbers:100,1.5,50,1.2have no named meaning — lines 5, 8, 12, 13 - Loose typing:data: anyloses all type safety — line 1
>
## Refactoring Plan
>
### Step 1 — Name the magic numbers [Risk: Low] What: Extract100,1.5,50,1.2into named constants at the top of the file. Why: Eliminates magic numbers, makes thresholds searchable. How: Addconst TYPE_A_THRESHOLD = 100,const TYPE_A_MULTIPLIER = 1.5, etc. Verify: Run existing tests — output should be identical.
>
### Step 2 — Add types [Risk: Low] What: Define anIteminterface and replaceany. Why: Prevents silent bugs from misshapen input. How:interface Item { id: string; type: 'A' | 'B'; value: number; active?: boolean }Verify: TypeScript should compile with no new errors.
>
### Step 3 — Extract per-type handlers [Risk: Medium] What: Move the type A and type B branches intoprocessTypeA(item)andprocessTypeB(item). Why: Eliminates deep nesting, makes each branch independently testable. How: Extract the innerifblocks into separate functions that return{ id, score } | null. Verify: Run tests; add a unit test for each new function before extracting.
~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.