similarity-rs

similarity-rs is a skill for Claude Code from chrisgliddon/bevy-skills. It costs 93 tokens per session (1,232 once invoked), scanned A, original, MIT.

A guide to finding repeated or nearly repeated Rust code with similarity-rs, a tool that compares code and reports possible duplication.

In plain words
What is it for?
Use it before adding utilities or similar structs, enums, Bevy systems, or plugin setup, and before commits or automated checks that look for duplication across files.
Why use it?
It helps prevent copy-paste code and reveals existing functions, data types, or shared patterns that could be reused or combined. Findings should be checked by a developer because the tool is still beta.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin. Also seen: mentions CLAUDE.md; mentions OpenCode.

Part of the bevy-skills plugin — 31 skills shipped together

Good fit Use it before adding utilities or similar structs, enums, Bevy systems, or plugin setup, and before commits or automated checks that look for duplication across files.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/chrisgliddon/bevy-skills/similarity-rs
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add chrisgliddon/bevy-skills --skill similarity-rs
Clone the repo
git clone --depth 1 https://github.com/chrisgliddon/bevy-skills

Made for: Claude Code.

Or install bevy-skills, the plugin that ships this one along with the rest of its 31 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for similarity-rs

README.md
[![agentmods](https://agentmods.dev/badge/skills/chrisgliddon/bevy-skills/similarity-rs/github.svg)](https://agentmods.dev/skills/chrisgliddon/bevy-skills/similarity-rs)
Your own site
<a href="https://agentmods.dev/skills/chrisgliddon/bevy-skills/similarity-rs"><img src="https://agentmods.dev/badge/skills/chrisgliddon/bevy-skills/similarity-rs/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for similarity-rs

Your own site · 80×15
<a href="https://agentmods.dev/skills/chrisgliddon/bevy-skills/similarity-rs"><img src="https://agentmods.dev/badge/skills/chrisgliddon/bevy-skills/similarity-rs.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 93 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,232 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 2 findings, up to high

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • high Tool Misuse · line 52
    Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).
    Fix: Validate all tool parameters against an allowlist. Reject dangerous parameter values (shell=True, --force, -rf /) and use safe defaults.
  • high Tool Misuse · line 74
    Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).
    Fix: Validate all tool parameters against an allowlist. Reject dangerous parameter values (shell=True, --force, -rf /) and use safe defaults.
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00093 $0.01232
Opus 5 $0.00046 $0.00616
Sonnet 5 $0.00019 $0.00246
Haiku 4.5 $0.00009 $0.00123

Measured 12d ago against content hash 19bb3405f00e, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

similarity-rs scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 12d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/similarity-rs/SKILL.md · 85 lines

How it starts

The opening of the file, as written. The whole thing — 85 lines — stays where its author put it; the contents beside it link to each section on GitHub.

similarity-rs 0.5 — Rust duplication detection

Tool status: Beta — not production-tested per the upstream README. Evaluate findings manually before acting.

When to use this skill

Antipattern triggers (act before writing code):

  • About to write a utility function — grep the codebase first; it may already exist.
  • Caught yourself thinking "I'll just inline this here."
  • Planning to copy-paste-modify an existing function with small changes.
  • Adding a new enum or struct that may overlap with an existing one.
  • Two Plugin setups that share large blocks of boilerplate.
  • Similar Bevy systems that differ only in their Query filter component.
  • Repeated commands.spawn((Mesh3d(...), MeshMaterial3d(...), ...)) patterns that belong in a Bundle.

Tool-integration triggers (run the check):

  • Before committing: verify you haven't introduced cross-file duplication.
  • During a cleanup sprint: identify consolidation candidates.
  • Setting up a pre-commit hook or GitHub Actions gate.
  • Adjusting -t/--threshold or --min-lines for a noisy or too-quiet run.

Canonical workflow

The pattern is: search first → write minimally → run the check.

# 1. Search before writing — check whether the helper already exists
rg "fn <verb>"               # e.g., rg "fn normalize" to find existing helpers
cargo doc --open --package <dep>  # inventory what your deps already provide

# 2. Write only what's missing.

# 3. Before committing, check for accidental duplication
cargo install similarity-rs   # one-time install
similarity-rs ./src            # scan the src tree

# 4. If --cross-file output is needed (catches LLM's most common antipattern)
similarity-rs --cross-file ./src

# 5. Tighten or loosen if needed (see references/tuning.md)
similarity-rs -t 0.85 -m 5 --cross-file --skip-test ./src

Consult cargo doc --open for every dependency before reaching for a one-off helper. LLMs reproduce functions from stdlib, itertools, or an already-declared crate dep more often than from thin air.

Read the full file on GitHub · 85 lines

Files

What ships with it

6 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 12d ago First seen · 85 lines · 93 tokens per session scan A 19bb3405f00e

Subscribe to this mod's changes

similarity-rs is a skill published in the GitHub repository chrisgliddon/bevy-skills (12 stars, last pushed 17d ago), licensed MIT. It adds 93 tokens to every session and 1,232 once invoked, about $0.0005 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.