fallow similar-code finds functions that may do the same kind of work even
when they are written differently.
Use it after fallow dupes when copied structure is not the whole story. The
normal duplication detector finds exact, normalized, and near-miss copies.
Similar-code discovery compares the meaning represented by complete functions.
Set up the local model
The matching native companion installs with the mainfallow npm package.
Check whether its pinned model is ready:
--yes
only when you already approved the download and need a non-interactive command.
Project config and agents cannot approve setup for you.
After setup, analysis is offline. Function source stays on your machine. The
companion receives bounded source over local process input and does not save it.
Fallow persists derived vectors in the project cache so later runs are faster.
Find candidates
- the exact companion, model revision, artifact digest, and parameters
- whether every analysis phase completed
- limits and skipped work
- vector-cache hits and misses
- non-severity diagnostics
completion.status is
"complete". A "partial" run tells you which limit or provider problem made
the result incomplete.
Focus the search
--file keeps pairs that touch the selected file. --changed-since and
workspace options use the same project scoping as other fallow analyses.
Inspect before judging
Copycandidate_id from the discovery output:
generation.threshold and generation.min_lines values. Human
output includes the calibrated part of the inspect command. MCP callers pass
the same discovery options to inspect_similar_code.
Inspect first reproduces the candidate against your current source. This
prevents a stale result from being reviewed after either function changed. It
then adds bounded evidence where available:
- source windows for both functions
- import-graph relationship and entry-point reachability
- callers and callees
- CODEOWNERS ownership and recent churn
- related tests
- overlap with deterministic duplication results
- syntax clues such as async behavior, throws, awaits, and possible side effects
Record a separate verdict
The raw candidate document never changes. A person or agent writes a separate verdict after inspecting the code:
Use
null when you cannot answer. refactor_safe: true requires
behaviorally_equivalent: true, which requires candidate_worthy: true.
Available outcomes are same-responsibility, related-but-distinct,
intentional-duplication, unrelated, and needs-human-review.
Use it with an agent
The MCP server exposes two read-only tools:find_similar_codereturns unverified candidates with provenance and completion accounting.inspect_similar_codereproduces one candidate and returns its evidence packet.
fallow similar-code setup --local.
An agent should return needs-human-review when tests, callers, behavior, or
side effects are unclear.
Configure project defaults
Where it does not run
Similar-code discovery is separate from barefallow, audit, dupes, CI
gates, SARIF, LSP, VS Code diagnostics, and auto-fix. It is a review aid, not a
new finding category. It accepts only the official pinned local model and does
not send source to a remote provider.
See also
Code duplication
Find deterministic and near-miss copied structure.
Agent integration
Connect the read-only discovery and inspect tools.
Configuration
Set project-owned thresholds, size floors, and ignore globs.