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

Chalk Labs

Need help deploying refactor-codebase?

Chalk Labs sets up agents like this inside real teams: connected to your tools, tested on your data, with a human in the loop where it matters.

Book a call

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 and code. Checked Nov 1, 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 (10 days ago)

From GitHub (fetched Oct 24, 2026).

Details

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

More from MAHDTech

Done for you

Rather not set it up yourself?

Chalk Labs scopes, builds and runs agents for your team: the task audit, the eval harness, the integrations and the weekly ops report. Fixed scope, priced before we start.

See how we build AI agents →Read the case studies

Chalk Labs is a two-founder AI and growth studio. We build AI agents, CRMs and MVPs for Web3 and AI companies, and have shipped 50+ product and token launches.

launches shipped
50+
launches shipped
media placements
500+
media placements
founders on every account
2
founders on every account

Press we've placed: Forbes · CoinDesk · Decrypt · Cointelegraph · The Block

Rahil Jain, Co-founder, Chalk Labs. Ex-Goldman Sachs engineer. You talk to the person who builds it.

Get refactor-codebase running in your business

Tell us what you want to automate. A founder replies within one working day with a plan, not a pitch deck.

Goes to the Chalk Labs founders, not the newsletter. Privacy

Need help deploying refactor-codebase?

CallGet help
Cite this page

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