Skip to content
Back to skills

Simple Refactor

ASecurity

Refactor code with minimal changes to remove redundancy (DRY) and improve readability, without changing behavior. Covers the files just changed by default, or the whole repo with leftover and unused file cleanup when the user asks. Use after finishing a series of modules or a phase, or when the user asks to refactor, clean up, or reduce duplication.

  • 2 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added October 15, 2026
ai-agentsgonodetestinggitapi

Works with

  • api

Security analysis

A100/100

Scanned December 2, 2026

npx -y skills add denniemok/simple-skills --skill simple-refactor --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Simple Refactor?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Simple Refactor
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/denniemok-simple-refactor/badge)](https://www.skillsdirectory.com/skills/denniemok-simple-refactor)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: simple-refactor
description: Refactor code with minimal changes to remove redundancy (DRY) and improve readability, without changing behavior. Covers the files just changed by default, or the whole repo with leftover and unused file cleanup when the user asks. Use after finishing a series of modules or a phase, or when the user asks to refactor, clean up, or reduce duplication.
metadata:
  author: denniemok
  version: "2.1.0"
license: MIT
---

# Simple Refactor

Clean up code without breaking it. Make it easier to read and maintain, so other collaborators can follow it. The golden rule is to change only what is necessary. If the code is good enough, leave it.

## Scope

- Default: what the user points at, or the files changed in the current work. Do not roam the whole codebase.
- Whole repo: only when the user asks for a full, whole-repo, or deep refactor or cleanup. Skip third-party, generated, and build output folders (`node_modules`, `dist`, lock files, and similar). Work module by module, and also look for leftovers and unused files (see "Whole repo only").

## Workflow

1. Find in scope:
   - Repeated logic, data, or patterns
   - Near-copies: two components or helpers that do the same job in slightly different ways
   - Dead code, unused imports, and unreachable branches
   - Wrappers, adapters, or pass-through functions with one caller that only forward
   - State kept wider than it needs to be, or a copy kept in sync that could be derived
   - Long functions or files doing more than one job
   - Deep nesting that early returns would flatten
   - Magic numbers and strings that need a named constant
   - Unclear names
2. Read nearby usage and existing tests to confirm current behavior.
3. Pick the safest fix:
   - Same file: extract a helper or constant.
   - Across files: extract to the most natural shared location, reusing an existing helper if one fits.
4. Update call sites. Add or adjust tests only when needed to guard against regressions.
5. Run the checks. If you cannot, say what should be run.

## Rules

- Keep behavior and public APIs unchanged unless the user asks otherwise.
- Prefer small edits over sweeping changes.
- Extract only when the duplication is meaningful. Two similar lines are not a reason to add an abstraction.
- Do not add layers that bring indirection without clear benefit.
- When you merge copies into one, give it only the options the real uses need, and delete the old forms. No re-export aliases or compatibility shims unless code outside the repo still uses them.
- Split a file because it does more than one job, never to meet a line count. A long file that hangs together stays as it is.
- Keep comments and move them with the code they describe.
- Follow the repo's existing naming, style, and file layout.

## Whole repo only

1. Read the tree first and detect the repo's conventions, entry points, and tooling.
2. Also find leftovers (debug logs, commented-out code, temp or backup files) and files or dependencies that nothing references.
3. Before changing anything, propose a plan: the code changes in short, plus every file and dependency to delete with the reason. Wait for approval before deleting.

Deleting files:

- Before deleting a file, confirm nothing references it. Search imports, dynamic imports, configs, scripts, HTML, and docs.
- Never delete entry points, config files, or files the tooling or framework loads by path or convention (routes, migrations, public assets, workflows).
- Keep files that may be valuable later, even if unused now: docs, notes, examples, templates, fixtures, seed data, migrations, scripts, design assets, and drafts of planned features. When unsure, keep it and list it as "unused, kept".
- Delete with `git rm` when in a git repo, so it can be restored.

## Output

A short summary of what changed, plus any risks or areas that need testing. For a whole-repo run, also list the deleted files and dependencies, and the unused files kept and why.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.