codebase-refactoring

codebase-refactoring is a skill for Claude Code, Codex from humanerd-drew/opencode-drewgent. It costs 44 tokens per session (5,538 once invoked), scanned C, original, MIT.

A cautious method for refactoring a codebase by removing unused code, consolidating duplicate data, and simplifying CSS one change at a time.

In plain words
What is it for?
Use it to map files and imports, find dead code, combine duplicated resources, protect personal data, and confirm that the app still responds correctly.
Why use it?
It reduces the risk of breaking a working application during cleanup. Each change is traced through its references and checked with a running development server.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to map files and imports, find dead code, combine duplicated resources, protect personal data, and confirm that the app still responds correctly.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/humanerd-drew/opencode-drewgent/codebase-refactoring
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.

Any agent
npx skills add humanerd-drew/opencode-drewgent --skill codebase-refactoring
Clone the repo
git clone --depth 1 https://github.com/humanerd-drew/opencode-drewgent

Made for: Claude Code, Codex.

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 codebase-refactoring

README.md
[![agentmods](https://agentmods.dev/badge/skills/humanerd-drew/opencode-drewgent/codebase-refactoring.svg)](https://agentmods.dev/skills/humanerd-drew/opencode-drewgent/codebase-refactoring)
Your own site
<a href="https://agentmods.dev/skills/humanerd-drew/opencode-drewgent/codebase-refactoring"><img src="https://agentmods.dev/badge/skills/humanerd-drew/opencode-drewgent/codebase-refactoring.svg" alt="Measured on agentmods" height="20"></a>
Per session 44 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 5,538 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 2 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.00044 $0.05538
Opus 5 $0.00022 $0.02769
Sonnet 5 $0.00009 $0.01108
Haiku 4.5 $0.00004 $0.00554

Measured 3d ago against content hash d7fd46376d21, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade C, and why

codebase-refactoring scanned grade C with 2 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 3d 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.

Recursive force deletehighDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

| Dedicated directory | `rm -rf` entire dir | `terminal` |

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

curl -s -o /dev/null -w "%{http_code}" "http://localhost:PORT/path/to/deleted/file"
skills/software-development/codebase-refactoring/SKILL.md · 320 lines

How it starts

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

코드베이스 안전 리팩토링

Systematic, safe refactoring — not big-bang rewrites. One change at a time, verified between each step.

Core Principles

  1. Map before you cut. Never delete or move code without tracing its import/reference graph first.
  2. Smallest safe step first. Dead config removal → orphan file deletion → data consolidation → structural change. Each step must be independently reversible.
  3. Verify between each change. With a running dev server, confirm HTTP 200 before the next edit.
  4. Master data pattern. When the same data exists in 2+ places (frontend constants, backend arrays, separate workers), extract to a JSON file and have every consumer import it. JSON is universally readable by JS and TS.
  5. No "while I'm here" expansions. One class of change per session.

Step-by-step Workflow

Phase 1 — Discovery

# 1. Map all files under the project root (exclude node_modules, build artifacts)
find . -type f -name '*.ts' -o -name '*.js' -o -name '*.html' -o -name '*.css' -o -name '*.sql' | grep -v node_modules | sort

# 2. Map all import/reference edges
grep -rn "^import\|from.*['\"]" --include='*.ts' --include='*.js' . | grep -v node_modules | sort

# 3. Identify dead code by reference counting
# If a file/export has zero import references, it's a candidate for deletion
grep -rn "export const\|export function\|export class" --include='*.ts' . | grep -v node_modules
# Cross-reference each export against import statements in other files

Phase 2 — Dead Code Removal (Risk: 🟢 Zero)

Safe to delete when:

  • No import or require references from any other file
  • No <script src="..."> or <link href="..."> from any HTML
  • Config keys that are defined but never read (grep for the read-side)

Verification command:

# After deletion, confirm 404 on deleted paths and 200 on everything else
curl -s -o /dev/null -w "%{http_code}" "http://localhost:PORT/path/to/deleted/file"

Phase 2.5 — Complete Feature Removal (Risk: 🟢 Low–🟡 Medium)

Read the full file on GitHub · 320 lines

Files

What ships with it

6 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 3d ago First seen · 320 lines · 44 tokens per session scan C d7fd46376d21

Subscribe to this mod's changes

codebase-refactoring is a skill published in the GitHub repository humanerd-drew/opencode-drewgent (2 stars, last pushed 1mo ago), licensed MIT. It adds 44 tokens to every session and 5,538 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it C with 2 findings (recursive force delete, makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

Other skills, from other repositories

health-check

Get an overall Python code quality health score using pyscn. Use when user asks how healthy or good the code is, wants a quality overview, a grade, a summary of technical debt, or a before/after quality comparison.

ludo-technologies/pyscn · 49 tokens

code-agent

General-purpose coding agent that reads, writes, and edits code, and searches codebases.

initializ/forge · 21 tokens

dead-code-cleanup

Use when the user asks about cleanup, removing unused code, refactoring, reducing bundle size, or identifying dead code in a Repowise-indexed codebase (.repowise/ directory exists). Also activates when discussing technical debt, code hygiene, or repository maintenance.

repowise-dev/repowise · 59 tokens

guardrails-developer-guide

Routes NVIDIA NeMo Guardrails library product-usage questions to the canonical documentation. Use when users ask how to install, configure, integrate, evaluate, observe, deploy, troubleshoot, or use the NVIDIA NeMo Guardrails library. Trigger keywords - install guardrails, configure rails, guardrail catalog, Colang…

NVIDIA-NeMo/Guardrails · 92 tokens

ast-grep

Write, debug, and validate ast-grep structural code search rules. Use for syntax-aware code search, AST pattern matching, structural refactor discovery, or searches plain text tools like rg can miss — functions with particular descendants, calls inside specific contexts, decorators, or other Tree-sitter-backed…

bahayonghang/my-ai-cli-toolkit · 64 tokens

tldr-code

Token-efficient code analysis via 5-layer stack (AST, Call Graph, CFG, DFG, PDG). 95% token savings.

parcadei/Continuous-Claude-v3 · 33 tokens