Skip to content
Agentmart
Submit a tool

refactor-codebase

Remove engineering debt, untangle large modules, collapse duplicated logic, and modernize legacy patterns without changing behavior.

Skill by MAHDTech

IndexedMIT
Write a review

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/mahdtech-refactor-codebase

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Remove engineering debt, untangle large modules, collapse duplicated logic, and modernize legacy patterns without changing behavior. Use when refactoring a codebase, removing dead code, or cleaning up stale abstractions.

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/refactor-codebase

What's inside

Skill name
refactor-codebase
Description
Remove engineering debt, untangle large modules, collapse duplicated logic, and modernize legacy patterns without changing behavior. Use when refactoring a codebase, removing dead code, or cleaning up stale abstractions.
License
MIT
Metadata
archived: 2026-09-04 · replaced-by: sculpt-code
Instructions
75 lines in SKILL.md · view on GitHub

Files (1)

  • SKILL.md

SKILL.md (first lines)

> **Deprecated - use `/sculpt-code` instead.** Its "Larger refactors" section now covers staged, behaviour-preserving debt reduction without the tool-specific framing. Kept here for reference only.

# Refactor your codebase

Remove dead code and modernize legacy patterns without changing behavior.

Use Codex to remove dead code, untangle large files, collapse duplicated logic, and modernize stale patterns in small reviewable passes.

## Best For

- Codebases with dead code, oversized modules, duplicated logic, or stale abstractions that make routine edits expensive.
- Teams that need to modernize code in place without turning the work into a framework or stack migration.

## Related Skills

- **[security-best-practices](https://github.com/openai/skills/tree/main/skills/.curated/security-best-practices)**: Review security-sensitive cleanup, dependency changes, auth flows, and exposed surfaces before merging a modernization pass.
- **[skill-creator](https://github.com/openai/skills/tree/main/skills/.system/skill-creator)**: Turn a proven modernization pattern, review checklist, or parity workflow into a reusable repo or team skill.

## Starter Prompt

### Modernize in Small Passes

> Modernize and refactor this codebase.
>
> Requirements:
>
> - Preserve behavior unless I explicitly ask for a functional change.
> - Start by identifying dead code, duplicated paths, oversized modules, stale abstractions, and legacy patterns that are slowing changes down.
> - For each proposed pass, name the current behavior, the structural improvement, and the validation check that should prove behavior stayed stable.
> - Break the work into small reviewable refactor passes such as deleting dead code, simplifying control flow, extracting helpers, or replacing outdated patterns with the repo's current conventions.
> - Keep public APIs stable unless a change is required by the refactor.
> - Call out any framework migration, dependency upgrade, API change, or architecture move that should be split into a separate migration task.
> - If the work is broad, propose the docs, specs, and parity checks we should create before implementation.
>
> Propose a plan to do this.

## Related Links

- [Modernizing your Codebase with Codex](https://cookbook.openai.com/examples/codex/code_modernization)

## Introduction

When your codebase has accumulated unused code, duplicated logic, stale abstractions, large files, or legacy patterns that make every change more expensive than it should be, you should consider reducing the engineering debt with a refactor. Refactoring is about improving the shape of the existing system without turning it into a stack migration.

Codex is useful here because it can first map the messy area, then land the cleanup in small reviewable passes: deleting unused paths, untangling large modules, collapsing duplicate paths, modernizing old framework patterns, and tightening validation around each pass.

The goal is to improve the current codebase in place:

1. Remove unused code, stale helpers, old flags, and compatibility shims that are no longer needed.
2. Shrink noisy modules by extracting helpers, splitting components, or moving side effects to clearer boundaries.
3. Replace legacy patterns with the repo's current conventions: newer framework primitives, clearer types, simpler state flow, or standard library utilities.
4. Keep public behavior stable while making the next change cheaper.

## How to use

1. Ask Codex to map the area before editing: noisy modules, duplicated logic, unused code, tests, public contracts, and any old patterns that the repo has outgrown.
2. Pick one cleanup theme at a time: remove unused code, simplify control flow, modernize an outdated pattern, or split a large file into smaller owned pieces.
3. Before Codex patches files, have it state the current behavior, the structural improvement it wants to make, and the smallest check that should prove behavior stayed stable.
4. Review and run the smallest useful check after each pass instead of batching the whole cleanup into one diff.
5. Keep stack changes, dependency migrations, and architecture moves as separate tasks unless they're required to finish the cleanup.

You can use Plan mode to create a plan for the refactor before starting the
work.

## Leverage ExecPlans

The [code modernization cookbook](https://developers.openai.com/cookbook/examples/codex/code_modernization) introduces ExecPlans: documents that let Codex keep an overview of the cleanup, spell out the intended end state, and log validation after each pass.
They're useful when the refactor spans more than one module or takes more than one session. Use them to record deletions, pattern updates, contracts that had to stay stable, and what's still deferred.

## Use skills for repeatable patterns

[Skills](https://developers.openai.com/codex/skills) are useful when the same cleanup rules repeat across repos, services, or teams. Use framework-specific skills when available, add security and CI skills around risky cleanups, and create a team skill when you have a proven checklist for unused-code removal, module extraction, or legacy-pattern modernization.
If you end up doing the same modernization pass across more than one codebase, Codex can help turn the first successful pass into a reusable skill.

From MAHDTech/agent-skills, MIT.

More from MAHDTech/agent-skills

Signals

Stars
0
Forks
0
Open issues
30
Last commit (this folder)
Sep 4, 2026 (1 month ago)
Last release
Oct 23, 2026 (5 days ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from MAHDTech

Cite this page

refactor-codebase skill. Agent Mart. https://agentmart.dev/skills/mahdtech-refactor-codebase (last updated 2026-10-24)