Skip to main content
Glama

find_code_duplicity

Scans a repository for duplicate or copy-pasted code blocks across files, flagging refactoring opportunities to extract shared utility functions.

Instructions

Scans the repository to identify duplicate or copy-pasted blocks of code across multiple files to identify refactoring opportunities.

Behavior:

  • Read-only: Hashes and compares source lines; does not modify code.

  • Idempotent: Deterministic duplicate detection for any codebase state.

  • 100% Offline: Fully local execution without network calls.

Usage Guidelines:

  • When to use: Run during refactoring sprints to locate redundant copy-pasted code blocks suitable for extraction into shared utility functions.

  • Sibling Routing: For full codebase quality and complexity audits, use 'audit_codebase_quality'. For unused unreferenced code, use 'find_dead_code'.

Returns: Markdown report detailing duplicate code clusters with file paths, line ranges, and side-by-side code snippets.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
min_linesNoMinimum identical consecutive lines to classify as a duplicate block (default: 6).
project_rootNoRoot directory of the repository to scan (default: current directory)..

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv0.1.1
    • addedInput schema / properties / min_lines / description
      Added value: +"Minimum identical consecutive lines to classify as a duplicate block (default: 6)."
    • addedInput schema / properties / project_root / description
      Added value: +"Root directory of the repository to scan (default: current directory)."
  2. First observedv0.1.0

TDQS

A4.7/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden and does so: it discloses read-only behavior (hashes/compares, does not modify), idempotency (deterministic for any state), and 100% offline execution. These are precisely the safety/behavioral traits an agent needs.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Sectioned into Behavior, Usage Guidelines, and Returns with the core action stated first. Every line is informative rather than filler, and the structure makes it scannable.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a read-only static analysis tool, the description covers purpose, behavior, routing, and even the return format (markdown report with clusters, paths, line ranges, snippets). An output schema exists, so return detail is bonus rather than required.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both params (min_lines, project_root) with defaults. The description adds no further parameter meaning, so the baseline of 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb (scans/identifies) and resource (duplicate copy-pasted code blocks across files) with the goal (refactoring opportunities). It explicitly distinguishes itself from siblings 'audit_codebase_quality' and 'find_dead_code', so an agent can route correctly without opening schemas.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides an explicit 'When to use' condition (refactoring sprints to locate redundant blocks) and a 'Sibling Routing' section naming the exact alternatives for adjacent tasks (quality/complexity audits and dead code). Both when-to-use and when-to-use-alternatives are covered.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.