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.
npx agentmods add skills/dzhng/duet-agent/refactor-cleannpx skills add dzhng/duet-agent --skill refactor-cleangit clone --depth 1 https://github.com/dzhng/duet-agentWrote 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/dzhng/duet-agent/refactor-clean)<a href="https://agentmods.dev/skills/dzhng/duet-agent/refactor-clean"><img src="https://agentmods.dev/badge/skills/dzhng/duet-agent/refactor-clean.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 | $0.00059 | $0.02158 |
| Opus 5 | $0.00030 | $0.01079 |
| Sonnet 5 | $0.00012 | $0.00432 |
| Haiku 4.5 | $0.00006 | $0.00216 |
Grade A, and why
refactor-clean 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 5d 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.
This is a copy
88% identical to refactor-clean — 11 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.
How it starts
The opening of the file, as written. The whole thing — 148 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Clean Refactoring
Replace the old shape with the simpler shape the codebase would want if it were designed today. Refactoring is not adding a compatibility layer beside the problem; it is moving ownership until every concept has exactly one clear home. That cuts both ways: merging N duplicated owners into one, and splitting one over-loaded module into the several owners it was hiding.
Workflow
- Name the concept that lacks one clear owner — duplicated across several owners, or several concepts fused into one over-loaded module. Identify the thing(s) that should each have one owner: environment, pricing rule, geometry source, state machine, data contract, renderer phase, API shape, UI state, or test oracle.
- Find every current owner and consumer. Treat wrappers, aliases, pass-local constants, copied structs, and "temporary" branches as sediment until proven otherwise.
- Promote the concept to its natural home. Pick the module that would own it from scratch, then make old call sites consume that owner directly.
- Delete or collapse the stale path in the same pass when feasible. If a bridge must remain, make it tiny, named as compatibility, and give it a removal condition.
- Verify behavior through consumers, not just the new module. A clean refactor is only proven when the surfaces that used to diverge now report or exercise the same source of truth.
Rules
- Every line is debt — the best mechanism is the one you don't write.
Before building any guard, validator, convergence protocol, or cleanup
path, two checks gate it:
- Does the platform already do this? Read the component/framework you are working around before coding around it — its crons, retries, defaults, and lifecycles. A hand-built janitor beside a component that already vacuums itself is pure debt, and it will be debugged by someone who doesn't know the component made it unnecessary.
- Does the failure it guards change any real outcome? Trace the guarded condition to its consumer. If the consumer is indifferent — an ordering check feeding a consumer that doesn't care about order, a validation on data only our own code produces — the guard tests nothing and must not be written. A common shape: an invariant re-checked at read time that the single write path already establishes, so the branch can only fire on hand-corrupted rows. Ask which caller could produce the bad state; if the honest answer is "none, short of someone editing the database", delete the branch. "It could be inconsistent" is not a reason; "the consumer would then do the wrong thing" is. The bar is not "is this correct?" — defensive code is usually correct. The bar is "what breaks, for whom, if this line doesn't exist?" No concrete answer → no line.
- Measure the change, and treat a bad size-to-behaviour ratio as a shape defect. Before accepting a change, count what it actually cost — production code apart from tests and docs, and comments apart from logic, because a diff dominated by explanation is not the same as one dominated by machinery:
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.
- 5d ago First seen · 148 lines · 59 tokens per session scan A ace3b796545e
refactor-clean is a skill published in the GitHub repository dzhng/duet-agent (42 stars, last pushed 3d ago), licensed Apache-2.0. It adds 59 tokens to every session and 2,158 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. It is 88% identical to refactor-clean, differing in 11 lines, and is treated as a copy.
Other skills, from other repositories
harness-creator
Build, audit, and improve harnesses that make AI coding agents reliable: AGENTS.md/CLAUDE.md instruction files, feature/state tracking, verification gates, scope boundaries, session handoff, memory persistence, context budgets, tool-permission safety, and multi-agent coordination. Use this whenever a coding agent is…
evaluator-write-qa-parallel
Internal Auto-Harness evaluator skill for parallel sprint QA and QA report writing. Use only inside the Evaluator subagent during evaluatorqaparallel.
evaluator-write-qa
Internal Auto-Harness evaluator skill for sprint QA and QA report writing. Use only inside the Evaluator subagent during qa mode.
evaluator-write-retest-parallel
Internal Auto-Harness evaluator skill for parallel sprint retest and retest report writing. Use only inside the Evaluator subagent during evaluatorretestparallel.
evaluator-write-retest
Internal Auto-Harness evaluator skill for sprint retest and retest report writing. Use only inside the Evaluator subagent during retest mode.
generator-fix-integrator
Internal Auto-Harness generator skill for worktree-merge fix integration. Use only inside the parallel Generator integrator when it is addressing named defects from QA or retest.