Getting it into your agent
It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.
git clone --depth 1 https://github.com/humanerd-drew/opencode-drewgentnpx agentmods add skills/humanerd-drew/opencode-drewgent/incremental-refactoringWrote 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.
[](https://agentmods.dev/skills/humanerd-drew/opencode-drewgent/incremental-refactoring)<a href="https://agentmods.dev/skills/humanerd-drew/opencode-drewgent/incremental-refactoring"><img src="https://agentmods.dev/badge/skills/humanerd-drew/opencode-drewgent/incremental-refactoring.svg" alt="Measured on agentmods" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00022 | $0.06641 |
| Opus 5 | $0.00011 | $0.03320 |
| Sonnet 5 | $0.00004 | $0.01328 |
| Haiku 4.5 | $0.00002 | $0.00664 |
Grade A, and why
incremental-refactoring scanned grade A with 0 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.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 704 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Incremental Refactoring — Safe Codebase Surgery
Refactor a codebase without breaking it. Map the dependency graph first, then make one change at a time with live server verification between each step.
Core principle: The safest refactoring is one you can revert at any step. If you'd be afraid to deploy after refactoring, you're doing it wrong.
Second principle: Question every optimization assumption. A claimed waste ("this adds N KB of unnecessary download") is not a valid concern until proven — check browser caching, real user flow patterns, and actual render performance. When the user pushes back on a cost assumption, they are correct: test impact before asserting waste. Before calling something unnecessary, verify: is the resource cached? Is this page the user's first hit? Does the browser actually download it, or was it preloaded?
Third principle: Systematic understanding before action. The user wants to see the full picture first — present evidence, let them decide, then execute. Never skip to a conclusion without showing the data: reference counts, HTTP response codes, actual file sizes, import chains. If you are proposing a change, the user should see why you think it is safe.
Fourth principle: Investigate before proposing. If you think there is a problem (dead code, duplication, config waste), trace EVERY reference before declaring. A config key that looks unused might still be read at runtime. An unused constant.js ENDPOINT might seem dead until you check all files that import it. Show your work — the grep commands, the zero hits, the curl 404s — so the user can independently verify your conclusion.
When to Use
- User asks to "clean up" / "리팩토링" / "정리" a codebase
- Code review revealed structural issues (monoliths, dead code, duplication)
- You need to remove code but aren't sure what depends on it
- Before splitting a large file into modules
Skip when: The user only wants a code review (use requesting-code-review)
or cleanup of recent git changes (use simplify-code).
What ships with it
1 file 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.
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.
- 3d ago First seen · 704 lines · 22 tokens per session scan E 518831a9db79
incremental-refactoring is a skill published in the GitHub repository humanerd-drew/opencode-drewgent (2 stars, last pushed 1mo ago), licensed MIT. It adds 22 tokens to every session and 6,641 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.
Other skills, from other repositories
absolute-prune
Dead code and dependency cleanup, repo-wide: unused deps, unreferenced exports, unreachable code, orphaned files — removed only with tool evidence, in reversible waves. Runs on green main. For diff-scoped cleanup use absolute-simplify. Triggers on "absolute prune", "remove dead code", "find unused deps/exports", "what…
dead-code
Find unused functions and dead code in the codebase.
dead-code-eliminator
A scanner for finding code that is no longer used, including exports, variables, and files, with suggestions for removing it safely.
misakanet-failure-memory
Search and record failure-recovery lessons from real engineering sessions; submit and verify debugging lessons across the MisakaNet network.
bloat-detector
Detects codebase bloat via dead code, duplication, complexity, and doc bloat scans. Use when codebase feels large or before a release.
code-agent
General-purpose coding agent that reads, writes, and edits code, and searches codebases.