Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

similar

Find semantically similar code chunks or scan for near-duplicate clusters.

Synopsis

bobbin similar [OPTIONS] [TARGET]
bobbin similar --scan [OPTIONS]

Description

The similar command uses vector similarity to find code that is semantically close to a target, or to scan the entire codebase for duplicate/near-duplicate clusters.

Single-target mode: Provide a chunk reference (file.rs:function_name) or free text to find similar code.

Scan mode: Set --scan to detect duplicate/near-duplicate code clusters across the codebase.

Options

OptionShortDefaultDescription
--scanScan entire codebase for near-duplicate clusters
--threshold <SCORE>-t0.85Minimum cosine similarity threshold
--limit <N>-n10Maximum number of results or clusters
--repo <NAME>-rFilter to a specific repository
--cross-repoIn scan mode, compare chunks across different repos

Examples

Find code similar to a specific function:

bobbin similar "src/search/hybrid.rs:search"

Find code similar to a free-text description:

bobbin similar "error handling with retries"

Scan the codebase for near-duplicates:

bobbin similar --scan

Lower the threshold for broader matches:

bobbin similar --scan --threshold 0.7

JSON output:

bobbin similar --scan --json

Prerequisites

Requires a bobbin index. Run bobbin init and bobbin index first.

See Also

  • search — semantic and hybrid search
  • grep — keyword/regex search