AGENT SKILL
dry-refactoring
Guided workflow to eliminate copy-paste duplication detected by jscpd.
- License 许可
- MIT
- 最近更新
- 2026-07-20
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- dry-refactoring
- description
- Guided workflow to eliminate copy-paste duplication detected by jscpd.
03 SKILL.md 正文
dry-refactoring
Guided workflow to eliminate copy-paste duplication in source code. Use after running jscpd to detect clones.
Prerequisites
First, run jscpd to identify duplications:
npx jscpd@4.0.5 --reporters ai <path>
Workflow
- Run jscpd with
--reporters aion the target path - Parse each clone line to identify the two duplicated locations
- Read both code fragments from the source files
- Understand what the duplicated code does
- Design a refactoring: extract a shared function, class, module, or constant
- Apply the refactoring — update both locations and all other usages
- Re-run jscpd to confirm the clone is eliminated
- Repeat for remaining clones, highest-impact first
Refactoring Strategies
| Strategy | When |
|---|---|
| Extract function | Same logic repeated with different inputs |
| Extract constant | Same literal values repeated |
| Extract base class | Parallel class hierarchies with shared behaviour |
| Extract module | Shared utilities across multiple modules |
| Template method | Same algorithm structure, different steps |
04 同仓库更多 Skills
ui-ux-frontend
Frontend UX, accessibility, responsive layout, and Storybook interaction quality standards.
★ 0
testing-conventions
暂无简介
★ 0
tdd
暂无简介
★ 0
shadcn-ui
shadcn/ui component conventions and composition patterns
★ 0
sdd
暂无简介
★ 0
quality-gate
暂无简介
★ 0