fallow
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseFallow: codebase intelligence for JavaScript and TypeScript
Fallow:面向JavaScript和TypeScript的代码库智能分析工具
Codebase intelligence for JavaScript and TypeScript. The free static layer finds unused code, circular dependencies, code duplication, complexity hotspots, architecture boundary violations, and feature flag patterns. The optional paid runtime layer (Fallow Runtime) merges production execution data into the same report for hot-path review, cold-path deletion confidence, and stale-flag evidence. 90 framework plugins, zero configuration, sub-second static analysis.
fallow health面向JavaScript和TypeScript的代码库智能分析工具。免费静态分析层可检测未使用代码、循环依赖、代码重复、复杂度热点、架构边界违规以及特性标记模式。可选付费运行时层(Fallow Runtime)可将生产环境执行数据整合到同一份报告中,用于热路径审查、冷路径删除确认以及过期标记验证。支持90种框架插件,零配置,静态分析耗时不到一秒。
fallow healthWhen to Use
使用场景
- Finding dead code (unused files, exports, types, enum/class members)
- Finding unused or unlisted dependencies
- Detecting code duplication and clones
- Checking code health and complexity hotspots
- Cleaning up a codebase before a release or refactor
- Auditing a project for structural issues
- Setting up CI checks for dead code or duplication thresholds
- Auto-fixing unused exports and dependencies
- Detecting feature flag patterns (environment gates, SDK calls, config objects)
- Investigating why a specific export or file appears unused
- 查找死代码(未使用的文件、导出项、类型、枚举/类成员)
- 查找未使用或未声明的依赖
- 检测代码重复与克隆
- 检查代码健康度与复杂度热点
- 发布或重构前清理代码库
- 审计项目的结构性问题
- 为死代码或重复代码阈值设置CI检查
- 自动修复未使用的导出项与依赖
- 检测特性标记模式(环境网关、SDK调用、配置对象)
- 排查特定导出项或文件显示未使用的原因
When NOT to Use
非适用场景
- Runtime error analysis or debugging
- Type checking (use for that)
tsc - Linting style or formatting issues (use ESLint, Biome, Prettier)
- Security vulnerability scanning
- Bundle size analysis
- Projects that are not JavaScript or TypeScript
- 运行时错误分析或调试
- 类型检查(请使用)
tsc - 代码风格或格式检查(请使用ESLint、Biome、Prettier)
- 安全漏洞扫描
- 包体积分析
- 非JavaScript/TypeScript项目
Prerequisites
前置条件
Fallow must be installed. If not available, install it:
bash
npm install -g fallow # prebuilt binaries (fastest)必须安装Fallow。若未安装,可执行以下命令:
bash
npm install -g fallow # 预构建二进制包(速度最快)or
或
npx fallow dead-code # run without installing
npx fallow dead-code # 无需安装直接运行
or
或
cargo install fallow-cli # build from source
undefinedcargo install fallow-cli # 从源码构建
undefinedAgent Rules
Agent规则
- Always use for machine-readable output. The
--format json --quiet 2>/dev/nulldiscards stderr so progress messages and threshold warnings don't corrupt the JSON on stdout. Never use2>/dev/null2>&1 - Always append to every fallow command. Exit code 1 means "issues found" (normal), not a runtime error. Without
|| true, the Bash tool treats exit 1 as failure and cancels parallel commands. Only exit code 2 is a real error (invalid config, parse failure)|| true - Use to include a
--explainobject in JSON output with metric definitions, ranges, and interpretation hints_meta - Use issue type filters (,
--unused-exports, etc.) to limit output scope--unused-files - Always before
--dry-run, thenfixto applyfix --yes - All output paths are relative to the project root
- Never run . It is interactive and never exits
fallow watch
- **始终使用**以获取机器可读的输出。
--format json --quiet 2>/dev/null用于丢弃stderr输出,避免进度消息和阈值警告破坏stdout中的JSON格式。请勿使用2>/dev/null2>&1 - 始终在每个fallow命令后追加。退出码1表示“发现问题”(正常情况),而非运行时错误。如果不添加
|| true,Bash工具会将退出码1视为失败,并取消并行命令。只有退出码2才代表真正的错误(无效配置、解析失败)|| true - **使用**以在JSON输出中包含带有指标定义、范围和解释提示的
--explain对象_meta - 使用问题类型过滤器(、
--unused-exports等)限制输出范围--unused-files - **执行前务必先
fix**确认,然后使用--dry-run应用修复fix --yes - 所有输出路径均相对于项目根目录
- 切勿运行。该命令为交互式,不会自动退出
fallow watch
Commands
命令列表
| Command | Purpose | Key Flags |
|---|---|---|
| Run all analyses: dead code + duplication + complexity (default) | |
| Dead code analysis ( | |
| Code duplication detection | |
| Auto-remove unused exports/deps | |
| Generate config file or pre-commit hook | |
| Convert knip/jscpd config | |
| Inspect project structure | |
| Function complexity analysis | |
| Combined dead-code + complexity + duplication for changed files | |
| Detect feature flag patterns (env vars, SDK calls, config objects) | |
| Manage the local license JWT for paid features (activate, status, refresh, deactivate) | |
| Production-coverage workflow helper (paid) | |
| Dump CLI definition as JSON | |
| Show the loaded config path and resolved config (verifies which | |
| 命令 | 用途 | 关键参数 |
|---|---|---|
| 运行所有分析:死代码+重复代码+复杂度(默认) | |
| 死代码分析( | |
| 代码重复检测 | |
| 自动移除未使用的导出项/依赖 | |
| 生成配置文件或预提交钩子 | |
| 转换knip/jscpd配置 | |
| 查看项目结构 | |
| 函数复杂度分析 | |
| 针对变更文件的死代码+复杂度+重复代码综合分析 | |
| 检测特性标记模式(环境变量、SDK调用、配置对象) | |
| 管理付费功能的本地许可证JWT(激活、状态查询、刷新、停用) | |
| 生产环境覆盖率工作流辅助工具(付费) | |
| 将CLI定义导出为JSON格式 | |
| 显示加载的配置文件路径和解析后的配置(验证当前生效的 | |
Issue Types
问题类型
| Type | Filter Flag | Description |
|---|---|---|
| Unused files | | Files unreachable from entry points |
| Unused exports | | Symbols never imported elsewhere |
| Unused types | | Type aliases and interfaces |
| Unused dependencies | | Packages in |
| Unused enum members | | Enum values never referenced |
| Unused class members | | Methods and properties |
| Unresolved imports | | Imports that can't be resolved |
| Unlisted dependencies | | Used packages missing from package.json |
| Duplicate exports | | Same symbol exported from multiple modules |
| Circular dependencies | | Import cycles in the module graph |
| Boundary violations | | Imports crossing architecture zone boundaries. Presets: |
| Stale suppressions | | |
| Test-only dependencies | n/a | Production deps only imported from test files (should be devDependencies) |
| 类型 | 过滤参数 | 描述 |
|---|---|---|
| 未使用文件 | | 无法从入口点访问的文件 |
| 未使用导出项 | | 从未被其他地方导入的符号 |
| 未使用类型 | | 类型别名和接口 |
| 未使用依赖 | | |
| 未使用枚举成员 | | 从未被引用的枚举值 |
| 未使用类成员 | | 方法和属性 |
| 未解析导入 | | 无法解析的导入项 |
| 未声明依赖 | | 已使用但未在package.json中声明的包 |
| 重复导出项 | | 从多个模块导出的相同符号 |
| 循环依赖 | | 模块图中的导入循环 |
| 边界违规 | | 跨越架构区域边界的导入。预设规则: |
| 过期抑制规则 | | |
| 仅测试依赖 | n/a | 仅从测试文件导入的生产依赖(应移至devDependencies) |
MCP Tools
MCP工具
When using fallow via MCP (), the following tools are available:
fallow-mcp| Tool | Description |
|---|---|
| Full dead code analysis. Set |
| Incremental analysis of files changed since a git ref |
| Code duplication detection. Set |
| Dry-run auto-fix preview |
| Apply auto-fixes (destructive) |
| Complexity metrics, health scores, hotspots, and refactoring targets |
| Merge V8 or Istanbul production-coverage data into the health report (paid). Required |
| Combined dead-code + complexity + duplication for changed files, returns verdict |
| Project metadata. Set |
| Architecture boundary zones and access rules. Returns |
| Detect feature flag patterns (env vars, SDK calls, config objects). Set |
| Trace why an export is used or unused ( |
| Trace all graph edges for a file ( |
| Trace where a dependency is imported ( |
| Trace duplicate-code groups at a location ( |
All tools accept , , , and params. The MCP server subprocess timeout defaults to 120s, configurable via .
rootconfigno_cachethreadsFALLOW_TIMEOUT_SECSAll JSON responses include structured arrays on every finding (dead code, health, duplication), enabling programmatic fix application or suppression.
actions通过MCP()使用fallow时,可使用以下工具:
fallow-mcp| 工具 | 描述 |
|---|---|
| 完整的死代码分析。设置 |
| 针对Git基准版本以来变更文件的增量分析 |
| 代码重复检测。设置 |
| 自动修复的预演(干运行) |
| 应用自动修复(破坏性操作) |
| 复杂度指标、健康评分、热点区域和重构目标分析 |
| 将V8或Istanbul生产环境覆盖率数据整合到健康报告中(付费)。必填 |
| 针对变更文件的死代码+复杂度+重复代码综合分析,返回结论 |
| 项目元数据。设置 |
| 架构边界区域和访问规则。若未配置边界,则返回 |
| 检测特性标记模式(环境变量、SDK调用、配置对象)。设置 |
| 追踪导出项被使用或未被使用的原因( |
| 追踪文件的所有图边( |
| 追踪依赖的导入位置( |
| 追踪指定位置的重复代码组( |
所有工具均接受、、和参数。MCP服务器子进程的默认超时时间为120秒,可通过配置。
rootconfigno_cachethreadsFALLOW_TIMEOUT_SECS所有JSON响应的每个检测结果(死代码、健康度、重复代码)均包含结构化的数组,支持程序化应用修复或抑制规则。
actionsNode.js Bindings
Node.js绑定
When embedding fallow inside a Node.js process (editor extensions, long-running servers, custom tooling), prefer the NAPI bindings over spawning the CLI. Same analysis engine, same JSON envelopes, no subprocess or JSON parsing overhead.
bash
npm install @fallow-cli/fallow-nodets
import { detectDeadCode, detectDuplication, computeHealth } from '@fallow-cli/fallow-node';
const deadCode = await detectDeadCode({ root: process.cwd(), explain: true });
const dupes = await detectDuplication({ root: process.cwd(), mode: 'mild', minTokens: 30 });
const health = await computeHealth({ root: process.cwd(), score: true, ownershipEmails: 'handle' });Six async functions: , , , , , . Each returns the same JSON envelope the CLI emits for . Rejected promises throw a with , , and optional , , fields that mirror the CLI's structured error surface.
detectDeadCodedetectCircularDependenciesdetectBoundaryViolationsdetectDuplicationcomputeComplexitycomputeHealth--format jsonFallowNodeErrormessageexitCodecodehelpcontextEnum-like fields take lowercase CLI-style literals (, , , ). Write-path commands (, , , , ) are not exposed; use the CLI for those.
"mild""cyclomatic""handle""low"fixinitsetup-hookslicense activatecoverage setupSee https://docs.fallow.tools/integrations/node-bindings for the full field reference.
将fallow嵌入Node.js进程(编辑器扩展、长期运行的服务器、自定义工具)时,优先使用NAPI绑定而非调用CLI。使用相同的分析引擎和JSON格式,无进程开销或JSON解析开销。
bash
npm install @fallow-cli/fallow-nodets
import { detectDeadCode, detectDuplication, computeHealth } from '@fallow-cli/fallow-node';
const deadCode = await detectDeadCode({ root: process.cwd(), explain: true });
const dupes = await detectDuplication({ root: process.cwd(), mode: 'mild', minTokens: 30 });
const health = await computeHealth({ root: process.cwd(), score: true, ownershipEmails: 'handle' });提供六个异步函数:、、、、、。每个函数返回与CLI输出相同的JSON格式。 Promise拒绝时会抛出,包含、以及可选的、、字段,与CLI的结构化错误输出一致。
detectDeadCodedetectCircularDependenciesdetectBoundaryViolationsdetectDuplicationcomputeComplexitycomputeHealth--format jsonFallowNodeErrormessageexitCodecodehelpcontext枚举类字段接受小写的CLI风格字面量(、、、)。写入类命令(、、、、)未对外暴露;请使用CLI执行这些操作。
"mild""cyclomatic""handle""low"fixinitsetup-hookslicense activatecoverage setupReferences
参考文档
- CLI Reference: complete command and flag specifications
- Gotchas: common pitfalls, edge cases, and correct usage patterns
- Patterns: workflow recipes for CI, monorepos, migration, and incremental adoption
- CLI参考文档:完整的命令和参数说明
- 常见陷阱:常见误区、边缘情况和正确使用模式
- 工作流模式:CI、单体仓库、迁移和增量采用的工作流方案
Common Workflows
常见工作流
Audit a project for all dead code
审计项目中的所有死代码
bash
fallow dead-code --format json --quietParse the JSON output. It contains arrays for each issue type (, , , , etc.) plus and metadata. Each issue object includes an array with structured fix suggestions (action type, flag, description, and optional suppression comment).
unused_filesunused_exportsunused_typesunused_dependenciestotal_issueselapsed_msactionsauto_fixablebash
fallow dead-code --format json --quiet解析JSON输出。输出包含每种问题类型的数组(、、、等),以及和元数据。每个问题对象包含数组,其中包含结构化的修复建议(操作类型、标记、描述以及可选的抑制注释)。
unused_filesunused_exportsunused_typesunused_dependenciestotal_issueselapsed_msactionsauto_fixableFind only unused exports (smaller output)
仅查找未使用的导出项(输出更简洁)
bash
fallow dead-code --format json --quiet --unused-exportsbash
fallow dead-code --format json --quiet --unused-exportsCheck if a PR introduces dead code
检查PR是否引入死代码
bash
fallow dead-code --format json --quiet --changed-since main --fail-on-issuesExit code 1 if new dead code is introduced. Only analyzes files changed since the branch.
mainbash
fallow dead-code --format json --quiet --changed-since main --fail-on-issues如果引入新的死代码,退出码为1。仅分析分支以来变更的文件。
mainFind code duplication
查找代码重复
bash
fallow dupes --format json --quiet
fallow dupes --format json --quiet --mode semanticThe mode detects renamed variables. Other modes: (exact), (default, syntax normalized), (different literals).
semanticstrictmildweakbash
fallow dupes --format json --quiet
fallow dupes --format json --quiet --mode semanticsemanticstrictmildweakSafe auto-fix cycle
安全的自动修复流程
bash
undefinedbash
undefined1. Preview what will be removed
1. 预览将被移除的内容
fallow fix --dry-run --format json --quiet
fallow fix --dry-run --format json --quiet
2. Review the output, then apply
2. 查看输出后,应用修复
fallow fix --yes --format json --quiet
fallow fix --yes --format json --quiet
3. Verify the fix worked
3. 验证修复效果
fallow dead-code --format json --quiet
The `--yes` flag is required in non-TTY environments (agent subprocesses). Without it, `fix` exits with code 2.fallow dead-code --format json --quiet
非TTY环境(Agent子进程)中必须使用`--yes`参数。否则`fix`命令会以退出码2终止。Discover project structure
查看项目结构
bash
fallow list --entry-points --format json --quiet
fallow list --plugins --format json --quietShows detected entry points and active framework plugins (91 built-in: Next.js, Vite, Jest, Storybook, Tailwind, PandaCSS, etc.).
bash
fallow list --entry-points --format json --quiet
fallow list --plugins --format json --quiet显示检测到的入口点和激活的框架插件(内置91种:Next.js、Vite、Jest、Storybook、Tailwind、PandaCSS等)。
Production-only analysis
仅生产环境分析
bash
fallow dead-code --format json --quiet --productionExcludes test/dev files (, , ) and only analyzes production scripts.
*.test.**.spec.**.stories.*bash
fallow dead-code --format json --quiet --production排除测试/开发文件(、、),仅分析生产脚本。
*.test.**.spec.**.stories.*Analyze specific workspaces
分析特定工作区
bash
undefinedbash
undefinedSingle package
单个包
fallow dead-code --format json --quiet --workspace my-package
fallow dead-code --format json --quiet --workspace my-package
Multiple packages
多个包
fallow dead-code --format json --quiet --workspace web,admin
fallow dead-code --format json --quiet --workspace web,admin
Glob (matched against package name AND workspace path)
通配符(匹配包名称和工作区路径)
fallow dead-code --format json --quiet --workspace 'apps/*'
fallow dead-code --format json --quiet --workspace 'apps/*'
Exclude one workspace from a set
从集合中排除一个工作区
fallow dead-code --format json --quiet --workspace 'apps/*,!apps/legacy'
fallow dead-code --format json --quiet --workspace 'apps/*,!apps/legacy'
Monorepo CI: auto-scope to workspaces containing any file changed since origin/main
单体仓库CI:自动限定为origin/main以来有文件变更的工作区
(replaces hand-written --workspace lists that drift as the repo evolves)
(替代手写的--workspace列表,避免仓库演进时列表失效)
fallow dead-code --format json --quiet --changed-workspaces origin/main
Scopes output while keeping the full cross-workspace graph. Patterns are tested against BOTH the package name (from `package.json`) AND the workspace path relative to the repo root; either match counts. Use `!`-prefixed patterns to exclude.
`--changed-workspaces <REF>` auto-derives the set from `git diff`. It's the CI primitive: point it at the PR base branch (e.g. `origin/main`) and fallow reports only on workspaces touched by the change. Mutually exclusive with `--workspace`. A missing ref or non-git directory is a hard error (exit 2) rather than a silent full-scope fallback, so CI never quietly widens back to the whole monorepo.fallow dead-code --format json --quiet --changed-workspaces origin/main
在保持完整跨工作区图的同时限定输出范围。模式会同时匹配包名称(来自`package.json`)和相对于仓库根目录的工作区路径;任一匹配即可。使用`!`前缀的模式进行排除。
`--changed-workspaces <REF>`通过`git diff`自动推导工作区集合。这是CI的核心功能:将其指向PR的基准分支(如`origin/main`),fallow仅报告变更涉及的工作区。该参数与`--workspace`互斥。如果基准分支不存在或目录不是Git仓库,会触发严重错误(退出码2),而非静默回退到全范围分析,确保CI不会意外扩大分析范围到整个单体仓库。Scope to specific files (lint-staged)
限定为特定文件(lint-staged)
bash
fallow dead-code --format json --quiet --file src/utils.ts --file src/helpers.tsOnly reports issues in the specified files. Project-wide dependency issues are suppressed. Warns on non-existent paths.
bash
fallow dead-code --format json --quiet --file src/utils.ts --file src/helpers.ts仅报告指定文件中的问题。项目级依赖问题会被抑制。路径不存在时会发出警告。
Catch typos in entry file exports
捕获入口文件导出项中的拼写错误
bash
fallow dead-code --format json --quiet --include-entry-exportsReports unused exports in entry files (package.json /, framework pages). By default, exports in entry files are assumed externally consumed. This flag catches typos like instead of .
mainexportsmeatdatametadatabash
fallow dead-code --format json --quiet --include-entry-exports报告入口文件(package.json的/、框架页面)中的未使用导出项。默认情况下,入口文件中的导出项被视为外部使用。此参数可捕获类似而非的拼写错误。
mainexportsmeatdatametadataDebug why something is flagged
调试标记问题的原因
bash
undefinedbash
undefinedTrace an export's usage chain
追踪导出项的使用链
fallow dead-code --format json --quiet --trace src/utils.ts:myFunction
fallow dead-code --format json --quiet --trace src/utils.ts:myFunction
Trace all edges for a file
追踪文件的所有关联
fallow dead-code --format json --quiet --trace-file src/utils.ts
fallow dead-code --format json --quiet --trace-file src/utils.ts
Trace where a dependency is used
追踪依赖的使用位置
fallow dead-code --format json --quiet --trace-dependency lodash
undefinedfallow dead-code --format json --quiet --trace-dependency lodash
undefinedMigrate from knip or jscpd
从knip或jscpd迁移
bash
undefinedbash
undefinedPreview migration
预览迁移
fallow migrate --dry-run
fallow migrate --dry-run
Apply migration (creates .fallowrc.json)
应用迁移(创建.fallowrc.json)
fallow migrate
fallow migrate
Migrate to TOML (creates fallow.toml)
迁移到TOML格式(创建fallow.toml)
fallow migrate --toml
Auto-detects `knip.json`, `.knip.json`, `.jscpd.json`, and package.json embedded configs.fallow migrate --toml
自动检测`knip.json`、`.knip.json`、`.jscpd.json`以及package.json中的嵌入式配置。Initialize a new config
初始化新配置
bash
fallow init # creates .fallowrc.json, adds .fallow/ to .gitignore
fallow init --toml # creates fallow.toml, adds .fallow/ to .gitignore
fallow init --hooks # scaffold a pre-commit git hook
fallow init --hooks --branch develop # hook using custom base branchbash
fallow init # 创建.fallowrc.json,将.fallow/添加到.gitignore
fallow init --toml # 创建fallow.toml,将.fallow/添加到.gitignore
fallow init --hooks # 生成预提交Git钩子
fallow init --hooks --branch develop # 使用自定义基准分支的钩子Exit Codes
退出码
| Code | Meaning |
|---|---|
| 0 | Success, no error-severity issues |
| 1 | Error-severity issues found |
| 2 | Runtime error (invalid config, parse failure, or |
When is active and exit code is 2, errors are emitted as JSON on stdout:
--format jsonjson
{"error": true, "message": "invalid config: ...", "exit_code": 2}| 代码 | 含义 |
|---|---|
| 0 | 成功,未发现错误级问题 |
| 1 | 发现错误级问题 |
| 2 | 运行时错误(无效配置、解析失败,或非TTY环境中执行 |
当启用且退出码为2时,错误信息会以JSON格式输出到stdout:
--format jsonjson
{"error": true, "message": "invalid config: ...", "exit_code": 2}Configuration
配置
Fallow reads config from project root: > > . Most projects work with zero configuration thanks to 90 auto-detecting framework plugins.
.fallowrc.jsonfallow.toml.fallow.tomljsonc
{
"$schema": "https://raw.githubusercontent.com/fallow-rs/fallow/main/schema.json",
"entry": ["src/index.ts"],
"ignorePatterns": ["**/*.generated.ts"],
"ignoreDependencies": ["autoprefixer"],
"publicPackages": ["@myorg/shared-lib"],
"dynamicallyLoaded": ["plugins/**/*.ts"],
"rules": {
"unused-files": "error",
"unused-exports": "warn",
"unused-types": "off"
}
}Rules: (fail CI), (report only), (skip detection).
"error""warn""off"Config fields:
- : workspace packages that are public libraries; exports from these packages are not flagged as unused
publicPackages - : glob patterns for files loaded at runtime (plugin dirs, locale files); treated as always-used
dynamicallyLoaded - : class method/property names that extend the built-in Angular/React lifecycle allowlist with framework-invoked names. Each entry is a plain string (global suppression) or a scoped object
usedClassMembersmatching only classes with the given heritage. Use scoped rules for common names like{ extends?, implements?, members }orrefreshto avoid false negatives on unrelated classes; global strings for unique names likeexecute. Example:agInit. An unconstrained scoped rule (no["agInit", { "implements": "ICellRendererAngularComp", "members": ["refresh"] }, { "extends": "BaseCommand", "members": ["execute"] }]orextends) is rejected at load time. Use plugin-levelimplementsin ausedClassMembersfile for library-specific allowlists.fallow/plugins/*.jsonc - : additional package.json
resolve.conditions/exportscondition names to honor during module resolution. Baseline conditions (imports,development,import,require,default,types, plusnode/react-nativeunder RN/Expo) are always included; user entries prepend ahead of them. Use for community conditions likebrowser,worker,edge-light, or custom bundler conditions. Example:deno{ "resolve": { "conditions": ["worker", "edge-light"] } }
Fallow从项目根目录读取配置,优先级为: > > 。借助90种自动检测的框架插件,大多数项目无需配置即可运行。
.fallowrc.jsonfallow.toml.fallow.tomljsonc
{
"$schema": "https://raw.githubusercontent.com/fallow-rs/fallow/main/schema.json",
"entry": ["src/index.ts"],
"ignorePatterns": ["**/*.generated.ts"],
"ignoreDependencies": ["autoprefixer"],
"publicPackages": ["@myorg/shared-lib"],
"dynamicallyLoaded": ["plugins/**/*.ts"],
"rules": {
"unused-files": "error",
"unused-exports": "warn",
"unused-types": "off"
}
}规则取值:(CI失败)、(仅报告)、(跳过检测)。
"error""warn""off"配置字段说明:
- : 作为公共库的工作区包;这些包的导出项不会被标记为未使用
publicPackages - : 运行时加载的文件的通配符模式(插件目录、本地化文件);这些文件被视为始终在使用
dynamicallyLoaded - : 类方法/属性名称,用于扩展Angular/React内置生命周期允许列表,添加框架调用的名称。每个条目可以是普通字符串(全局抑制)或作用域对象
usedClassMembers,仅匹配具有指定继承关系的类。对于{ extends?, implements?, members }或refresh等通用名称,使用作用域规则避免无关类的误报;对于execute等唯一名称,使用全局字符串。示例:agInit。未加约束的作用域规则(无["agInit", { "implements": "ICellRendererAngularComp", "members": ["refresh"] }, { "extends": "BaseCommand", "members": ["execute"] }]或extends)会在加载时被拒绝。对于库特定的允许列表,可在implements文件中使用插件级的.fallow/plugins/*.jsoncusedClassMembers - : 模块解析时需要额外支持的package.json
resolve.conditions/exports条件名称。基线条件(imports、development、import、require、default、types,以及RN/Expo环境下的node/react-native)始终会被包含;用户添加的条件会前置到基线条件之前。用于支持社区条件如browser、worker、edge-light或自定义打包器条件。示例:deno{ "resolve": { "conditions": ["worker", "edge-light"] } }
Inline suppression
内联抑制
typescript
// fallow-ignore-next-line
export const keepThis = 1;
// fallow-ignore-next-line unused-export
export const keepThisToo = 2;
// fallow-ignore-file
// fallow-ignore-file unused-export
// Mark as intentionally unused (tracked for staleness)
/** @expected-unused */
export const deprecatedHelper = () => {};typescript
// fallow-ignore-next-line
export const keepThis = 1;
// fallow-ignore-next-line unused-export
export const keepThisToo = 2;
// fallow-ignore-file
// fallow-ignore-file unused-export
// 标记为有意未使用(会追踪是否过期)
/** @expected-unused */
export const deprecatedHelper = () => {};Key Gotchas
关键陷阱
- is required in non-TTY (agent) environments. Without it,
fix --yesexits with code 2fix - Zero config by default. 90 framework plugins auto-detect. Don't create config unless customization is needed
- Syntactic analysis only. No TypeScript compiler, so fully dynamic is not resolved
import(variable) - Function overloads are deduplicated. TypeScript function overload signatures are merged into a single export (not reported as separate unused exports)
- Re-export chains are resolved. Exports through barrel files are tracked, not falsely flagged
- is additive. Only new issues in changed files, not all issues in the project
--changed-since
For the full list with examples, see references/gotchas.md.
- 非TTY(Agent)环境必须使用。否则
fix --yes命令会以退出码2终止fix - 默认零配置。90种框架插件自动检测。除非需要自定义,否则无需创建配置文件
- 仅语法分析。不使用TypeScript编译器,因此无法解析完全动态的
import(variable) - 函数重载会被去重。TypeScript函数重载签名会合并为单个导出项(不会被报告为单独的未使用导出项)
- 重导出链会被解析。桶文件的导出会被追踪,不会被误标记
- 是增量式的。仅报告变更文件中的新问题,而非项目中的所有问题
--changed-since
完整示例请查看references/gotchas.md。
Instructions
操作指南
- Identify the task from the user's request (audit, fix, find dupes, set up CI, migrate, debug)
- Run the appropriate command with
--format json --quiet - Use filter flags to limit output when the user asks about specific issue types
- Always dry-run before fix. Show the user what will change, then apply
- Report results clearly. Summarize issue counts, list specific findings, suggest next steps
- For false positives, suggest inline suppression comments or config rule adjustments
If is provided, use it as the path or pass it as the target for the appropriate fallow command.
$ARGUMENTS--root- 从用户请求中识别任务(审计、修复、查找重复代码、设置CI、迁移、调试)
- 运行相应的命令并添加参数
--format json --quiet - 使用过滤参数在用户询问特定问题类型时限制输出范围
- 执行修复前务必先干运行。向用户展示将变更的内容,然后再应用修复
- 清晰报告结果。总结问题数量,列出具体检测结果,建议下一步操作
- 对于误报,建议使用内联抑制注释或调整配置规则
如果提供了,将其作为路径或传递给相应fallow命令的目标路径。",
$ARGUMENTS--root