跳到正文
cccskills
免费在 GitHub 公开

dry-code-review

Perform a comprehensive DRY (Don't Repeat Yourself) code review on a codebase. Identifies duplicated code, repeated logic, redundant patterns, and opportunities for abstraction. Use this skill whenever the user asks to review code for duplication, reduce repetition, apply DRY principles, refactor for reusability, find copy-pasted code, deduplicate logic, or audit code quality with a focus on redundancy. Also trigger when users say things like "clean up my code", "find repeated patterns", "too much boilerplate", "reduce code duplication", or "refactor for maintainability". Works on any language or framework.

中文简介正在准备中。当前显示原文说明。

查看安装方法

包含的文件(2)

  • SKILL.md6.8 KB
  • scripts/find_duplicates.sh7.3 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

DRY Code Review Skill

Perform a structured, thorough code review focused on the DRY (Don't Repeat Yourself) principle. The review is planned and tracked via a markdown file in plans/.

Overview

The DRY principle states: "Every piece of knowledge must have a single, unambiguous, authoritative representation within a system." This skill systematically finds violations and recommends fixes.

Workflow

Phase 1: Setup & Discovery

  1. Create the tracking plan in plans/dry-review-<project-name>.md using the template below
  2. Inventory the codebase: List all source files, their languages, sizes, and roles
  3. Identify scope: Confirm with the user which directories/files to include or exclude (e.g., skip node_modules, vendor, generated files, test fixtures)

Phase 2: Automated Scanning

Run the scanning script to find likely duplication:

bash /path/to/dry-code-review/scripts/find_duplicates.sh <target_directory> [extensions]

The script detects:

  • Identical or near-identical code blocks (3+ lines repeated)
  • Repeated string literals and magic numbers
  • Similar function signatures across files
  • Repeated boilerplate and configuration patterns

Import/dependency lines are intentionally excluded from the duplicate-lines scan so they don't dominate the output.

Phase 3: Manual Analysis

After automated scanning, perform deeper analysis by reading the codebase. Look for these DRY violation categories:

Category 1: Literal Duplication

  • Copy-pasted code blocks (exact or near-exact)
  • Repeated string literals / magic numbers
  • Duplicate configuration values

Category 2: Structural Duplication

  • Functions/methods that do the same thing with minor variations
  • Repeated conditional logic (same if/else chains)
  • Similar class structures that could share a base class or mixin
  • Repeated error handling patterns

Category 3: Logical Duplication

  • Same business logic expressed differently in multiple places
  • Repeated validation rules
  • Duplicate data transformation pipelines
  • Same algorithm implemented in multiple places

Category 4: Cross-Cutting Duplication

  • Repeated boilerplate across files (logging, auth checks, error wrappers)
  • Similar API endpoint handlers
  • Repeated test setup/teardown code
  • Duplicate build/deploy configuration

Phase 4: Findings & Recommendations

For each finding, document:

  1. ID: Sequential identifier (DRY-001, DRY-002, ...)
  2. Category: Which of the 4 categories above
  3. Severity: 🔴 High (5+ repetitions or core logic) / 🟡 Medium (2-4 repetitions) / 🟢 Low (minor or cosmetic)
  4. Locations: File paths and line numbers of all occurrences
  5. Description: What is duplicated and why it matters
  6. Recommendation: Specific refactoring approach
  7. Effort: S / M / L estimate

Common Refactoring Recommendations

  • Extract Function/Method: Pull repeated logic into a shared function
  • Extract Constant/Config: Replace magic numbers and repeated literals
  • Create Base Class/Mixin: Share behavior across similar classes
  • Use Higher-Order Functions: Wrap repeated patterns (decorators, middleware)
  • Create Shared Utility Module: Centralize cross-cutting concerns
  • Use Templates/Generics: Parameterize structural duplication
  • Apply Strategy Pattern: Replace repeated conditional branches
  • Consolidate Configuration: Single source of truth for settings

Phase 5: Summary & Prioritization

Update the plan file with:

  • Total findings count by category and severity
  • A prioritized action list (quick wins first, then high-impact refactors)
  • Estimated effort for full remediation
  • Risk notes (what could break if refactored carelessly)

Plan File Template

The plan file MUST be created at plans/dry-review-<project-name>.md using this structure:

# DRY Code Review: <Project Name>

## Review Metadata
- **Date**: YYYY-MM-DD
- **Reviewer**: Claude (AI-assisted)
- **Scope**: <directories/files reviewed>
- **Languages**: <languages found>
- **Total Files Scanned**: <count>
- **Total Lines of Code**: <count>

## Status
- [ ] Phase 1: Setup & Discovery
- [ ] Phase 2: Automated Scanning
- [ ] Phase 3: Manual Analysis
- [ ] Phase 4: Findings & Recommendations
- [ ] Phase 5: Summary & Prioritization

## Scope Definition
### Included
- <list of included paths>

### Excluded
- <list of excluded paths and reasons>

## Findings

### Summary
| Category               | 🔴 High | 🟡 Medium | 🟢 Low | Total |
|------------------------|---------|----------|--------|-------|
| Literal Duplication    |         |          |        |       |
| Structural Duplication |         |          |        |       |
| Logical Duplication    |         |          |        |       |
| Cross-Cutting          |         |          |        |       |
| **Total**              |         |          |        |       |

### Detailed Findings

#### DRY-001: <Title>
- **Category**: <category>
- **Severity**: 🔴/🟡/🟢
- **Locations**:
  - `path/to/file1.ts:L10-L25`
  - `path/to/file2.ts:L30-L45`
- **Description**: <what is duplicated>
- **Recommendation**: <how to fix>
- **Effort**: S/M/L

<!-- Repeat for each finding -->

## Prioritized Action Plan

### Quick Wins (Small effort, immediate value)
1. <action item>

### High-Impact Refactors (Medium/Large effort)
1. <action item>

### Nice-to-Have (Low priority)
1. <action item>

## Risk Notes
- <things to watch out for when refactoring>

## Review Log
- YYYY-MM-DD: Review initiated
- YYYY-MM-DD: <phase completed>

Important Guidelines

  • Don't over-DRY: Not all repetition is bad. Flag but note when duplication is acceptable (e.g., test readability, intentional denormalization, simple 2-line patterns)
  • Respect boundaries: Code that looks similar but serves different domains may rightfully be separate (bounded contexts)
  • Consider churn: Frequently modified code benefits more from DRY than stable code
  • Preserve clarity: A refactoring that makes code harder to read is not an improvement
  • Track progress: Update the plan file checkboxes as each phase completes
  • Be specific: Always include file paths and line numbers, never vague references

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Audit, generate, update, and lint AGENTS.md files across all projects. Use when asked to check project context files, scaffold AGENTS.md for new projects, update stale ones, or run a cross-project audit.

中文简介正在准备中。当前显示原文说明。

espennilsen/pi1222026年10月12日 更新

blog-post

免费

Draft, edit, and publish blog posts for e9n.dev. Use when creating new posts, editing drafts, or refining existing content. Handles Eleventy frontmatter, Tailwind formatting, and Espen's authentic voice.

中文简介正在准备中。当前显示原文说明。

espennilsen/pi1222026年10月12日 更新

Generate a full operational status report for the Aivena bot. Checks all subsystems: extensions, webserver, Telegram, chat bridge, heartbeat, cron, database, memory, CRM, calendar, task management, jobs/telemetry, and storage. **Triggers — use this skill when:** - User asks for "status", "bot status", "system status", "operational status" - User asks "is everything running?", "how's Aivena doing?" - User says "health check", "diagnostics", "systems check" - User asks "what's the state of the bot?"

中文简介正在准备中。当前显示原文说明。

espennilsen/pi1222026年10月12日 更新

Parse git history and produce or update a CHANGELOG.md following the Keep a Changelog convention. Supports Conventional Commits, basic prefix conventions, and unstructured commit messages. Intelligently categorizes changes, detects breaking changes, links to PRs/issues, and handles both initial generation and incremental updates. **Triggers — use this skill when:** - User asks to "generate", "create", "update", or "write" a changelog - User mentions "CHANGELOG", "changelog", "release notes" - User says "document changes", "what changed since last release" - User wants to "prepare a release" and needs a changelog entry - User asks to "clean up" or "reformat" an existing changelog **Covers:** Any git-based project. Handles Conventional Commits (feat/fix/chore), Angular convention, basic prefixes (Add/Fix/Remove), and freeform commit messages. Outputs Keep a Changelog format with optional Common Changelog enhancements.

中文简介正在准备中。当前显示原文说明。

espennilsen/pi1222026年10月12日 更新

cmux

免费

Orchestrate cmux terminal panes — split terminals, run parallel processes, read output from other panes, and use the built-in browser. Use when working inside cmux and you need to run a dev server, watch tests, spawn sub-agents, or preview web pages.

中文简介正在准备中。当前显示原文说明。

espennilsen/pi1222026年10月12日 更新

Review code for quality, security, performance, and maintainability. Use when reviewing PRs, auditing a codebase, or refactoring. Covers TypeScript, Node.js, infrastructure-as-code, and full-stack web apps.

中文简介正在准备中。当前显示原文说明。

espennilsen/pi1222026年10月12日 更新

查看 espennilsen 的全部技能

报告此技能的问题