duet-agent: Skill for Claude Code

.agents/skills/refactor-clean/SKILL.md

refactor-clean is a skill for Claude Code, Codex from dzhng/duet-agent. It costs 80 tokens per session (2,717 once invoked), scanned A, a copy of refactor-clean, Apache-2.0.

A code-refactoring workflow for giving each idea one clear home in a codebase. Refactoring means changing internal structure without changing the intended behavior.

In plain words
What is it for?
For consolidating duplicate owners, splitting overloaded modules, moving concepts to the right place, and removing stale compatibility paths.
Why use it?
It removes duplicated concepts, obsolete wrappers, parallel abstractions, and modules that have accumulated too many responsibilities.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: installed under .agents/ (shared by several agents).

This is dzhng/duet-agent's own configuration. It tells Claude Code and Codex how to work on duet-agent itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything duet-agent configures →

Reuse

Borrowing it

Nothing to install: this file belongs to dzhng/duet-agent. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/dzhng/duet-agent/main/.agents/skills/refactor-clean/SKILL.md
Clone the repo
git clone --depth 1 https://github.com/dzhng/duet-agent

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 refactor-clean

README.md
[![agentmods](https://agentmods.dev/badge/skills/dzhng/duet-agent/refactor-clean/github.svg)](https://agentmods.dev/skills/dzhng/duet-agent/refactor-clean)
Your own site
<a href="https://agentmods.dev/skills/dzhng/duet-agent/refactor-clean"><img src="https://agentmods.dev/badge/skills/dzhng/duet-agent/refactor-clean/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for refactor-clean

Your own site · 80×15
<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="Reviewed on agentmods" width="80" height="20"></a>
Per session 80 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,717 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin 88% copy Near-identical to another mod 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.00080 $0.02717
Opus 5.5 $0.00032 $0.01087
Sonnet 5.5 $0.00016 $0.00543
Haiku 4.5 $0.00008 $0.00272

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

Security

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 14d 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.

Origin

This is a copy

88% identical to refactor-clean — 0 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.

.agents/skills/refactor-clean/SKILL.md · 181 lines

How it starts

The opening of the file, as written. The whole thing — 181 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

  1. Sweep names in every touched path, even when no structural refactor is needed. Ask whether each name describes the concept's current scope. Rename misleading files, symbols, imported bindings and shared exports immediately; update every consumer, test, doc and agent instruction in the same pass. Keep scenario names only for scenario-specific code, then search again for stale references.
  2. 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.
  3. Find every current owner and consumer. Treat wrappers, aliases, pass-local constants, copied structs, migration comments and "temporary" branches as sediment until proven otherwise.
  4. Run a deletion pass before relaxing checks or making inputs optional. For each input, flag, guard, fallback, and adapter in the affected path, ask what required behavior breaks if it disappears. Trace its writers, transport, readers, validators, and consumers; compare them with the authoritative owner. Making a redundant input optional is not completion. If removing it preserves required behavior, delete the mechanism and its call-site, test, and documentation residue.
  5. Promote any remaining 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.
  6. Retain compatibility only for an identified consumer and a concrete behavior that removal would break. Old inputs that can safely be ignored need no parser, validator, or adapter just because they may still arrive. If a bridge is needed, keep it tiny and give it a removal condition; hypothetical callers do not count.
  7. Verify behavior through consumers, including affected failure and retry paths. Search again for the removed mechanism across code, tests, docs, and agent instructions. Finish only when each retained mechanism in the affected path has a named consumer and behavior it preserves; report retained bridges and their removal conditions.

Read the full file on GitHub · 181 lines

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. 14d ago Changed · +3 tokens per session fc7835430a08
  2. 26d ago Changed · +33 lines · +18 tokens per session ddc8c7955ada
  3. 1mo ago First seen · 148 lines · 59 tokens per session scan A ace3b796545e

Subscribe to this mod's changes

refactor-clean is a skill published in the GitHub repository dzhng/duet-agent (52 stars, last pushed 7d ago), licensed Apache-2.0. It adds 80 tokens to every session and 2,717 once invoked, about $0.0003 per session on Opus 5.5. A static security scan graded it A with 0 findings. It is 88% identical to refactor-clean, differing in 0 lines, and is treated as a copy.

Related

Other skills, from other repositories

evaluator-review-contract

Internal Auto-Harness evaluator skill for sprint contract review before implementation. Use only inside the Evaluator subagent during review mode.

redker56/auto-harness · 30 tokens

open-code-review

Performs AI-powered code review on Git changes using the ocr CLI from alibaba/open-code-review. Use when the user asks to review code, review a pull request, review staged/unstaged changes, review a commit, or compare branches for code quality issues. Produces line-level review comments and can automatically apply…

alibaba/open-code-review · 98 tokens

open-code-review-delegate

Delegation mode for open-code-review (OCR). Instead of OCR calling an LLM endpoint, this skill instructs the host agent to perform the code review itself, using OCR only for deterministic engineering: file selection and rule resolution. Use when the host agent should drive the review with its own LLM capabilities.

alibaba/open-code-review · 68 tokens

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…

walkinglabs/learn-harness-engineering · 142 tokens

md-audit

Read-only code quality audit — scan the current working directory for common issues (bugs, dead code, security hotspots, missing error handling) and return a prioritised findings report. No files are edited. Use when asked to "audit the code", "quick audit", "find issues", "code scan", or "what's wrong with this…

chaitanyagiri/munder-difflin · 85 tokens

review

Comprehensive security and correctness audit. Use for review, deep review, thermo nuclear, or thermonuclear requests and branch or PR diff audits.

vercel/eve · 31 tokens