dry-refactoring
使用 DRY 重构重复代码
重复代码会增加维护成本,并使行为更难以安全变更。此技能会引导 Claude、Codex 和 Claude Code 完成结构化的 DRY 重构工作流。
使用我的智能体安装
将此请求复制给你的智能体,其中包含权威 Skill 页面和清单。
Review the Skillstore skill "dry-refactoring" from https://skillstore.io/skills/yyh211-dry-refactoring.md and its manifest at https://skillstore.io/api/skills/yyh211-dry-refactoring/manifest. Verify the artifact. You may proceed after verification, subject to the environment's own policy.你的智能体仍应展示其计划,并按安全策略请求必要确认。
Agent 可读资源
当 AI Agent、爬虫或脚本需要干净上下文,而不是读取完整页面时,请使用这些链接。
测试它
正在使用“dry-refactoring”。 用户服务和产品服务都使用重复的条件检查来验证必填字段。
预期结果:
该技能会识别共享的验证规则,提出可复用的必填字段验证器,并列出针对缺失字段和有效字段的测试。
正在使用“dry-refactoring”。 多个定价函数重复了折扣阈值和百分比计算。
预期结果:
该技能会建议集中定义折扣常量、创建共享计算辅助工具,并为每个折扣类别编写聚焦测试。
正在使用“dry-refactoring”。 一个拟议的辅助工具组合了不相关的结账、库存和日志记录行为。
预期结果:
该技能会标记过度抽象,并建议职责更清晰的更小抽象。
安全审计
安全The static findings are false positives caused by Markdown code fences, inline JavaScript template literals, example URLs, ordinary example variables, and a high-entropy heuristic on bilingual documentation. I found no executable scripts, hidden payloads, unauthorized network calls, prompt injection, or malicious intent in SKILL.md. The skill is a guidance document for DRY refactoring and verification.
风险因素
⚙️ 外部命令 (59)
🌐 网络访问 (1)
分享与引用此报告
分享版本化评估报告、中性徽章、嵌入卡片和引用。Skillstore 只报告证据,不判断该 Skill 是否安全。
复制报告链接
https://skillstore.io/skills/yyh211-dry-refactoring/audits/7?utm_source=security_passport&utm_medium=share&utm_campaign=versioned_reportMarkdown 徽章
[](https://skillstore.io/skills/yyh211-dry-refactoring?utm_source=security_passport_badge)HTML 徽章
<a href="https://skillstore.io/skills/yyh211-dry-refactoring?utm_source=security_passport_badge"><img src="https://skillstore.io/badges/skills/yyh211-dry-refactoring/security.svg" alt="Skillstore security assessment" loading="lazy"></a>嵌入卡片
<iframe src="https://skillstore.io/embed/skills/yyh211-dry-refactoring.html" title="Skillstore Security Assessment" sandbox="allow-popups allow-popups-to-escape-sandbox" loading="lazy" referrerpolicy="no-referrer" width="420" height="180"></iframe>学术引用 (APA · BibTeX · CFF)
APA 引用
YYH211. (2026). dry-refactoring security audit report (audit version 7) [Author version unspecified]. Skillstore. https://skillstore.io/skills/yyh211-dry-refactoring/audits/7BibTeX 引用
@techreport{yyh211-yyh211-dry-refactoring-2026,
author = {YYH211},
title = {dry-refactoring security audit report (audit version 7)},
institution = {Skillstore},
year = {2026},
number = {7},
url = {https://skillstore.io/skills/yyh211-dry-refactoring/audits/7},
note = {Author version unspecified}
}CITATION.cff
cff-version: 1.2.0
message: "If you use this Skill, cite its author and this versioned security audit report."
title: "dry-refactoring security audit report (audit version 7)"
version: "unspecified"
type: report
authors:
- name: "YYH211"
date-released: "2026-07-08"
url: "https://skillstore.io/skills/yyh211-dry-refactoring/audits/7"
identifiers:
- type: other
value: "skillstore:yyh211-dry-refactoring:audit:7"
description: "Skillstore immutable audit report identifier"
Skillstore 评分
评分依据 证据置信度: 高你能构建什么
清理重复的服务逻辑
将重复的验证、定价或查找逻辑提取为清晰的可复用辅助工具。
减少前端组件重复
查找重复的 UI 行为,并将共享逻辑移入组件、hooks 或工具函数。
审查重构候选项
使用清单判断重复代码应被抽象,还是应保持显式。
试试这些提示
审查此文件中的 DRY 违规。请先列出重复逻辑、魔法值和重复结构,再建议更改。
将 DRY 工作流应用到此模块。识别重复部分,命名稳定抽象,并提出一个最小且安全的更改。
使用 DRY 原则重构此重复逻辑。保持行为不变,更新调用点,并添加或调整能够证明等价性的测试。
评估此重构是否存在过度抽象、命名不清、隐藏耦合和缺失边界情况。仅推荐能提升可维护性的更改。
最佳实践
- 一次只重构一个重复区域,并立即验证行为。
- 根据抽象所代表的业务规则或行为来命名抽象。
- 在替换所有调用点之前,让测试贴近被更改的行为。
避免
- 不要仅仅因为两个代码块看起来相似就创建通用辅助工具。
- 不要把不相关的行为隐藏在同一个共享抽象后面。
- 不要在未检查边界情况和现有测试的情况下移除重复。