Skip to content
Fallow home
All docs pages

fallow similar-code: find semantically similar functions

Reference for fallow similar-code: flags, subcommands, and exit codes. Find functions that may do the same job with a pinned local model, then inspect and review them.

fallow similar-code finds pairs of functions that may do the same kind of work, also when their code looks different. A pinned local model compares complete functions. Every result is an unverified candidate. A person or an agent inspects it and decides.

The command is opt-in. It does not run in bare fallow, audit, dupes, CI gates, SARIF, LSP, or auto-fix. For the full workflow, see Semantic similar code.

fallow similar-code status
fallow similar-code setup --local
fallow similar-code --format json --quiet > similar-code.json
fallow similar-code inspect <CANDIDATE_ID> --candidates similar-code.json
fallow similar-code review --candidates similar-code.json --verdicts verdicts.json

Discovery options

Without a subcommand, fallow similar-code runs discovery and prints the candidates.

FlagDescription
-r, --root <ROOT>Project root directory.
-c, --config <CONFIG>Path to the config file.
--allow-remote-extendsAllow trusted config files to extend HTTPS URLs.
-f, --format <FORMAT>human (default) or json.
--prettyIndent the JSON output.
-q, --quietSuppress progress output and the guidance for a cold run.
--no-cacheDo not use the incremental vector cache.
--threads <THREADS>Number of parser threads.
--changed-since <REF>Report only pairs that touch files changed since this git ref.
--diff-file <PATH>Unified diff for line-level scoping.
--diff-stdinRead the unified diff from stdin.
-w, --workspace <WORKSPACE>Scope the output to the selected workspaces.
--changed-workspaces <REF>Scope the output to the workspaces that changed since this git ref.
--max-file-size <MB>Skip source files that are larger than this number of megabytes.
--explainAdd metadata that explains the metrics and the model.
--threshold <0..1>The minimum cosine similarity of a candidate. Default: similarCode.threshold in the config, else 0.8.
--min-lines <N>The minimum number of source lines of a function. Default: similarCode.minLines in the config, else 3.
--top <N>Show at most this number of candidates. The limit applies after the comparison.
--file <PATH>Report only pairs that touch these project-relative files.
-o, --output-file <PATH>Write the report to a file, not to stdout.

The scope flags select which functions fallow compares first. Fallow compares only pairs where at least one function is fully in scope.

Subcommands

SubcommandWhat it doesFlags
statusShows if the companion and the pinned model are ready. It does not read project source.--format, --pretty, --quiet
setup --localDownloads and verifies the pinned local model. It asks for confirmation first.--local (required), --yes to confirm without a prompt, --format, --pretty, --quiet
inspect <CANDIDATE_ID>Reproduces one candidate against the current source and adds size-limited evidence.--candidates <PATH> (the saved discovery JSON), --root, --config, --allow-remote-extends, --format, --pretty, --quiet, --output-file
reviewJoins the candidate JSON with a separate verdict document.--candidates <PATH>, --verdicts <PATH>, --require-verdict-for-each-candidate, --format, --pretty, --quiet, --output-file
cache clearRemoves the derived vectors of the project. The downloaded model stays.--yes (required), --root, --config, --allow-remote-extends, --format, --pretty, --quiet

Use --yes on setup only when a person already approved the download. Project config and agents cannot approve the download.

Exit codes

CodeMeaning
0The command ran. Candidates do not change the exit code.
2Invalid input, for example a missing --yes on cache clear, an invalid verdict document, or a candidate without a verdict under --require-verdict-for-each-candidate. Also a failure of the local provider.
3The local model is not ready. Run fallow similar-code setup --local.

status exits 0 also when the model is not ready. Read model_ready in its JSON output to decide.

See also