code-reuse-review
Skill345 starsChanged 36 days agoApache-2.0View on GitHub
Use during PR review when a diff adds new code that might duplicate something that already exists in the repo. Checks whether the author actually looked before writing, and whether the new code should instead extend, call, or replace an existing utility.
In this repository17 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- clickhouse-sink-reviewSkill
- code-quality-architectureSkill
- code-quality-bashSkill
- code-quality-goSkill
- code-quality-jvmSkill
- code-quality-pythonSkill
- code-quality-sqlSkill
- code-reuse-firstSkill
- design-note-debtSkill
- destructive-operation-safetySkill
- mandatory-code-change-validationSkill
- pr-self-reviewSkill
- repro-harness-negative-proofSkill
- sink-connector-mysql-source-of-truthSkill
The file
Files
Code Reuse Review
Overview
A diff that adds a new helper, parser, or utility is only a problem if the
repo already has one that does the same thing. This skill is the
reviewer's half of code-reuse-first — checking, from the outside, whether
an author's new code duplicates existing logic rather than reusing it.
Earlier guidance in this space mistakenly optimized for brevity (shortest possible diff) as the goal; that framing was dropped — the actual goal is not writing code that already exists, not minimizing line count.
When to Use
- Reviewing a PR that adds a new module, function, or script
- Any diff that "re-implements" parsing, retry, config-loading, or comparison logic that sounds like it should already exist somewhere
Review Questions
- Does something equivalent already exist in this repo? Grep for the
concept (not just the exact name) across
sink-connector,sink-connector-lightweight,sink-connector-client, andsink-connector/pythonbefore accepting that new code is necessary. - Did the author actually read the existing code, or just confirm a file with a similar name exists and move on? A new function with a suspiciously similar signature to an existing one, placed in a new file, is a signal reuse wasn't considered.
- Is the duplication justified? Sometimes a small, local copy is
correct — e.g., when sharing code across language boundaries
(
sink-connector-clientin Go genuinely can't call intosink-connector's Java code) or when coupling two call sites would be worse than a few duplicated lines. State the reason in the PR if so; silent duplication is the problem, not duplication itself. - Does the new code belong where it was added, or does it belong in an
existing shared location (e.g., a comparison helper added inside a CLI
script instead of in
sink-connector/python/db_compare, where other comparison logic already lives)? - If existing code was close-but-not-quite right, was it extended rather than copied-and-modified? A copy-paste-and-tweak is a maintenance liability: the next fix has to be applied twice, and usually isn't.
Example
# BAD: new file sink-connector/python/ch_sink_tools/compare_helpers.py
# re-implements row hashing that db_compare already does
def hash_row(row):
return hashlib.sha256(str(row).encode()).hexdigest()
# GOOD: import and reuse
from sink_connector.python.db_compare.hashing import hash_rowAnti-Patterns
A new utility with the same purpose as an existing one, placed in a new file "to keep things simple" · copy-pasted logic with small tweaks instead of a shared, parameterized function · duplication introduced silently, with no note in the PR explaining why reuse wasn't possible.
Cross-References
code-reuse-first, pr-self-review, code-quality-architecture.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

