check-similarity-rs

Identify duplicate Rust code using AST-based similarity analysis.

821|20|Updated Jun 16, 2025
One-click install
npx skills add https://github.com/mizchi/similarity --skill check-similarity-rs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: check-similarity-rs
Source: https://github.com/mizchi/similarity/tree/main/.claude/skills/check-similarity-rs
Command: npx skills add https://github.com/mizchi/similarity --skill check-similarity-rs

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Rust projects often accumulate duplicate logic across modules that hampers maintainability. This skill uses AST-based similarity analysis to identify and surface duplicate or highly similar code in Rust sources (.rs files), enabling targeted refactoring.

Core Features & Use Cases

  • Detect exact duplicates and near-duplicates in Rust code across modules.
  • Analyze struct/enum definitions and impl blocks for shared patterns.
  • Produce actionable refactoring recommendations to reduce duplication and improve maintainability.

Quick Start

Run similarity-rs on your Rust project to detect duplicates and receive refactoring guidance.

Frequently Asked Questions about check-similarity-rs

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I find duplicate Rust code across modules?

AST-based similarity analysis detects exact duplicates and near-duplicate patterns in .rs files by parsing functions, structs, and impl blocks. It surfaces shared logic across modules to guide targeted refactoring and improve maintainability.

What is AST-based code similarity analysis in Rust?

AST-based code similarity analysis parses Rust source files into abstract syntax trees to compare structural patterns. It identifies exact duplicates and similar logic across functions and impl blocks, enabling targeted refactoring to reduce redundancy.

Do I need the Rust toolchain to analyze code similarity in .rs files?

Yes, analyzing code similarity in .rs files requires the Rust toolchain and the similarity-rs binary installed. These prerequisites provide the necessary environment for AST parsing and duplicate detection across your Rust project.

Can I tune the similarity threshold for Rust duplicate detection?

Yes, Rust duplicate detection supports threshold tuning to control matching sensitivity. Adjusting the threshold allows you to surface exact duplicates or expand the analysis to include highly similar patterns across structs and impl blocks.

What's the best way to detect similar struct and enum definitions in Rust?

Using AST-based similarity analysis is the best way to detect similar struct and enum definitions in Rust. By comparing abstract syntax trees, this method identifies shared patterns across modules to guide refactoring.

When should I use AST analysis instead of text search for Rust refactoring?

Use AST analysis for Rust refactoring when text search fails to identify near-duplicate logic with minor variations. AST analysis compares structural patterns across impl blocks and functions, surfacing semantic similarities that text matching misses.