fallow README

项目的 README,来自 github.com/fallow-rs/fallow。合并为一个 markdown 文件:README.md。

fallow

Codebase intelligence for TypeScript and JavaScript.
Health, complexity, duplication, architecture, styling, and unused code, from one graph of your repository.
One Rust binary. It needs no TypeScript compiler and no configuration to start.

npm npm downloads CI Coverage CodSpeed Socket MIT License OpenSSF Baseline

Docs · Quickstart · Terminal · Pull requests · Editors · Agents


Run it in the root of any JS or TS project:

npx fallow

A pull request gate on a fictional storefront monorepo might look like this:

$ npx fallow audit --base HEAD~15
Audit scope: 73 changed files vs HEAD~15

● Circular dependencies (24)
  packages/storefront/src/orders/process.ts (6 cycles)
    → payment.ts → context.ts → process.ts

── Duplication ────────────────────────────────────
⚠ 185 lines (0.2%) duplicated across 6 files

● High complexity functions (28)
  packages/storefront/src/orders/payment.ts
    :566 processPayment CRITICAL
          32 ! cyclomatic   47 ! cognitive  203 lines

── Styling ────────────────────────────────────────
  font sizes mix 3 units (3 px, 2 rem, 1 em; candidate, standardize unless intentional)

✗ dead code: 68 issues · complexity: 28 findings · duplication: 7 clone groups · 73 changed files
  audit gate excluded 98 inherited findings (run with --gate all to enforce)

Illustrative output for a fictional project. The gate fails (exit code 1) on findings in changed files. Findings that existed before the change are excluded.

fallow builds a repository graph of modules, exports, dependencies, functions, and styling tokens. Its analyses use that graph to find complexity, architecture drift, duplication, unused code, and risks in a pull request.

fallow runs in four places. All four read the same config file and use the same analysis engine.

Where Start with
Your terminal npx fallow
Pull requests uses: fallow-rs/fallow@v3
Your editor The VS Code extension or fallow-lsp
Coding agents npx fallow agent install

What fallow finds

Question Analysis Command
Is this change safe to merge? Changed-file gate over complexity, duplication, unused code, and styling drift, with a pass, warn, or fail result fallow audit
Where is the code hard to change? Complexity hotspots, a 0 to 100 health score, and refactoring targets, with git churn and ownership fallow health
Does the architecture hold? Boundary violations with bulletproof, layered, hexagonal, feature-sliced, and deep-modules presets, and circular dependencies fallow architecture, fallow guard
What is copied? Code duplication in JS, TS, CSS, and Vue, Svelte, and Astro components fallow dupes
Does the UI follow the design system? Styling drift in CSS and CSS-in-JS fallow health --css
What does nothing use? Unused files, exports, types, class and enum members, and dependencies, with an auto-fix and a dry-run preview fallow dead-code, fallow fix
Do the tests detect a code change? Mutation testing: small changes in the source that no test detects (opt-in, runs the project tests) fallow mutation
Which code paths are risky? Security candidates, ranked by reachability from entry points (opt-in) fallow security
Which functions do the same job? Functions with the same intent and different syntax (opt-in, uses a local model that you download once) fallow similar-code
Where are the feature flags? Feature-flag patterns across the codebase fallow flags

npx fallow viz opens an interactive HTML map of the project with lenses for health, duplication, architecture, and unused code.

Add --type-aware for exact TypeScript symbol identity across aliases, re-exports, and packages. This optional pass removes false positives from interfaces and base classes (how type-aware analysis works). A Homebrew, cargo install or release-archive binary gets the type-aware companion with fallow type-aware setup. Runtime coverage from production is an optional add-on that fallow merges into health and audit reports.

The CLI reference lists every command. fallow schema prints all commands, flags, output formats, and exit codes as JSON.

Why teams can depend on fallow

fallow keeps these properties from release to release:

The analyzer is written in Rust and uses Oxc for syntactic analysis. Static analysis needs no TypeScript compiler and no Node.js runtime.

In your terminal

npx fallow                  # health, duplication, and unused code in one run
npx fallow audit            # only the findings that your change introduces
npx fallow fix --dry-run    # preview the auto-fixes, then run `npx fallow fix`
npx fallow health --score   # health score with the largest deductions
npx fallow dead-code --trace src/api.ts:client   # prove an export is unused before you delete it

To keep fallow in the project, install it as a dev dependency:

npm install --save-dev fallow

The npm package includes the fallow, fallow-lsp, and fallow-mcp launchers. For pnpm, yarn, cargo install fallow-cli, and Docker, see the installation guide.

To check each commit before it leaves your machine, install the managed pre-commit hook:

npx fallow hooks install --target git

Adopt fallow on an existing codebase

You do not have to fix every finding before you add fallow to CI.

  1. Run npx fallow recommend. It detects the stack and proposes a config. It changes no files.
  2. Use fallow audit in pull requests. It compares each pull request with its base branch and blocks only the findings that the pull request adds. It needs no baseline file.
  3. For full runs of fallow, dead-code, dupes, or health, save a baseline once with npx fallow --save-baseline fallow-baseline.json. Pass --baseline fallow-baseline.json on each later run, so that only new findings fail.
  4. Reduce the backlog when your team has time. fallow fix --dry-run shows the fixes and changes no files. fallow fix applies them.

If findings are caused by missing entry points or generated files, add the missing entry points and exclude the generated files in the config:

{
  "$schema": "./node_modules/fallow/schema.json",
  "entry": ["src/cli.ts"],
  "ignorePatterns": ["**/*.generated.ts"]
}

To keep an intentional export, add a suppression comment:

// fallow-ignore-next-line unused-export -- kept for plugin consumers
export const keepThis = 1;

// fallow-ignore-file <issue-type> suppresses a whole file. JSDoc tags (@public, @internal) keep intentional library API quiet; keepExportTags selects which tags do. npx fallow suppressions lists every suppression in the project.

The adoption guide shows the staged path. Configuration has the full reference.

In pull requests

GitHub Actions:

- uses: actions/checkout@v4
  with:
    fetch-depth: 0
- uses: fallow-rs/fallow@v3
  with:
    command: audit

GitLab CI:

include:
  - remote: 'https://raw.githubusercontent.com/fallow-rs/fallow/v3.50.0/ci/gitlab-ci.yml'

fallow:
  extends: .fallow

fetch-depth: 0 is the recommended setup. A default shallow checkout also works for command: audit: the Action fetches the commits that it needs to find the merge base.

To start in report-only mode, add fail-on-issues: false. Remove it when the team is ready for a gate. With command: audit, a pull request fails only on findings that it introduces. Without command: audit, the Action runs the full pipeline, and any finding fails the job (fail-on-issues defaults to true). In a pull request, the Action scopes the analysis to the changed files, so its output can differ from a full local run.

The Action installs the fallow version that the project's package.json names. Pin an exact version there to use the same version in CI and on your machine. It can post a PR comment and inline review comments, and it can upload SARIF to GitHub Code Scanning. Other output formats are CodeClimate, GitHub annotations, and Markdown. The GitLab template URL names a release tag, because GitLab includes a file from a fixed ref. The CI guide covers inputs, permissions, and a staged rollout.

For a PR comment or review comments, give the job these permissions. id-token: write is optional: it lets the Action post as the fallow bot. Without it, the comments come from github-actions[bot].

permissions:
  contents: read
  id-token: write
  pull-requests: write
  checks: write

Exit code 0 means no error-severity findings, or an audit result of pass or warn. Exit code 1 means error-severity findings, or an audit result of fail. In CI, exit code 1 fails the job, and that is the gate. The rule severity in the config (error, warn, off) sets which findings count. Exit code 2 means invalid input or an execution error. A script that reads the JSON output can treat 0 and 1 as a completed run, but must not hide exit code 2 with || true.

All exit codes and the JSON error format
Exit code Meaning
0 Clean, or audit result pass or warn
1 Findings, or audit result fail (a normal outcome)
2 Validation or runtime error (JSON error on stdout with --format json)
3 A requested resource is unavailable, for example when config --path finds no config
8 Security gate hit (fallow security --gate)
4 to 7, 10 to 13 Runtime coverage, license, network, and upload errors

With --format json, an error arrives on stdout as {"error": true, "message": "...", "exit_code": 2}, not as a stack trace.

Editors and integrations

With coding agents

npx fallow agent install --dry-run   # show the plan
npx fallow agent install             # apply it

fallow agent install sets up the agents that it detects (Claude Code, Codex, and Cursor) in one pass. It writes an AGENTS.md task map, installs the fallow and fallow-setup skills, registers the MCP server, and adds a gate on git commit and git push. Run npx fallow agent status to see these changes. Run npx fallow agent uninstall to remove them.

To register only the MCP server:

{ "mcpServers": { "fallow": { "command": "npx", "args": ["--yes", "--package", "fallow", "fallow-mcp"] } } }

--package fallow selects the npm package that provides the fallow-mcp launcher.

Scripts and agents that call the CLI directly add --format json --quiet. Each command then writes one typed JSON document to stdout:

Do not run fallow watch in an agent loop, because it does not exit.

Exit codes and the JSON error format are in In pull requests. The agent skills guide has the details.

Migrate existing config

npx fallow migrate converts knip, jscpd, and stylelint config into fallow config. The migration guides for knip and jscpd show each step.

Contributing

To report a missing framework plugin or a false positive, open an issue. CONTRIBUTING.md covers the development setup. docs/README.md is the entry point for maintainer documentation.

Thank you to everyone who contributes code, bug reports and ideas.

Contributors, including people who open issues. Follow the link for their names.

License

MIT. See LICENSE.

If fallow helps you or your team, you can support its development through GitHub Sponsors.

fallow (fallow-rs/fallow)

正在搜索数据库…

这是什么?Fallow 是一款基于 Rust 的 TypeScript/JavaScript 代码库智能分析工具。它会为代码仓库构建一张统一的依赖关系图,并报告未使用的代码、循环依赖、代码重复、复杂度热点、架构边界违规,以及设计系统样式偏离问题。
它只是命令行工具,还是也能接入我的编辑器和 CI?它是一个由 Rust 编写的单一二进制程序,通过多种接口提供服务:命令行(CLI)、GitHub Action、LSP 服务器、供 AI 智能体使用的 MCP 服务器,以及 VS Code 扩展。所有接口都基于同一套共享的分析图运行。
我该如何安装和运行?npm 包内附带 fallow、fallow-lsp 和 fallow-mcp 启动器,因此首次运行时执行 `npx fallow` 即可零配置运行完整流程。安装指南中还介绍了其他方式:pnpm、yarn、`cargo install fallow-cli`,以及本地构建 Docker 镜像。
我需要安装 Node.js 或 TypeScript 编译器吗?不需要。默认的静态分析基于 Rust 原生实现,不依赖 Node.js 或 TypeScript 编译器。只有在启用较慢的 --type-aware 模式、以获取精确到符号级别的证据时,才需要可选的、版本匹配的 TypeScript 配套组件。
这些功能都是免费的,还是有些需要付费?核心分析器(CLI、LSP、MCP、VS Code、GitHub Action)采用 MIT 许可证,免费使用。Fallow Runtime 是一个独立的可选付费层,它会将生产环境的执行证据合并到同一份报告中,需要单独激活许可证。
什么是 Fallow Runtime?Fallow Runtime 是本产品的可选付费层。它会把生产环境的执行证据合并到同一份静态报告中,帮助确认哪些问题在运行时真正有影响。
Claude Code 或 Cursor 能直接使用 Fallow 吗?可以。运行 'fallow agent install' 即可一步完成 Claude Code、Codex 和 Cursor 的初始化配置。npm 包还附带了与版本匹配的智能体技能,以及 MCP 启动器(fallow-mcp),使智能体能够直接查询分析结果。
交互式 viz 命令会展示什么?'fallow viz' 会打开一个交互式 HTML 地图,提供未使用、重复、架构、健康度以及静态安全五种视角,并包含依赖、框架、样式和功能开关等视图。
能否迁移其他死代码或代码重复检测工具的现有配置?可以。运行 'fallow migrate' 即可将 knip、jscpd 或 stylelint 的配置转换为 Fallow 自身的配置格式。
有哪些类似的项目?repowise, knip, ruff, semgrep, desloppify, super-linter, rector, Aletheore
作者
fallow-rs
大小
140.1 MB
星标
5.4K
时长
8个月
提交 · 90 天