Skip to content
Skill Authoring
Skill

/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

BOOST
From plugin
pi
12238 skills5 agents
Install
$ npx -y skills add espennilsen/pi --skill dry-code-review --agent claude-code

How it fires

How this skill gets triggered: by you, by Claude, or both.

  • Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
  • You can call itInvoke it directly when you want it.
  • Slash command/dry-code-review

Context preview

The summary Claude sees to decide when to auto-load this skill.

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

SKILL.md

dry-code-review.SKILL.md
name: dry-code-review
description: >
  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.

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-Imp
Read more
Ships withpi

This repository is my Pi coding agent home directory. I keep it under version control and symlink it to ~/.pi/agent so Pi loads configuration, extensions, skills, and runtime state from here.

Get the whole plugin

Other skills on pi.