This guide is for repositories that already have backlog: unused code, duplicates, complexity hotspots, and existing exceptions.
By the end of this guide you will have:
fallow audit enforcing the same policy on changed filesThese are different goals. Both matter. Do them in order.
Full-repo analysis to understand and clean the whole codebase.
Use fallow, fallow dead-code, fallow dupes, and fallow health.
Changed-files gate that enforces the policy on every PR.
Use fallow audit after the repo is clean.
Start with repo clean. Then turn on PR clean.
Run fallow migrate first to port your knip config, then follow this guide.
Apply this flow per workspace package. Use fallow --workspace <name> and a shared root config.
From your project root:
npx fallow
The quick start covers the focused commands you will use during cleanup (dead-code, dupes, health) and fallow init for generating a starting config.
Do not start by suppressing findings one by one. That path turns into an ever-growing list of inline exceptions and no coherent policy.
Not the policy owner? Run section 3 first on a branch, then bring the findings into the policy discussion. Fallow output is a good forcing function for the "what do we actually care about" conversation.
First decide, as a team:
A reasonable starting point:
{
"$schema": "https://raw.githubusercontent.com/fallow-rs/fallow/main/schema.json",
"ignorePatterns": ["**/*.generated.ts", "**/*.d.ts"],
"rules": {
"unresolved-imports": "error",
"unlisted-dependencies": "error",
"unused-exports": "warn"
}
}
Rules you do not list inherit their defaults. Health thresholds default to maxCyclomatic: 20 and maxCognitive: 15; override in a health block only when your repo's realistic baseline differs.
Use warn during rollout when you need visibility without blocking CI. Promote rules to error as the backlog shrinks. See the rules reference for every issue type and severity.
Use this order for most existing repos. Each step removes noise that would otherwise distort the next step.
High confidence, low debate. These are real bugs waiting to happen and should be cleared first.
npx fallow dead-code --unresolved-imports
npx fallow dead-code --unlisted-depsUnreachable files are usually safe cleanup. Use fallow list --entry-points to sanity-check reachability before deleting anything you are unsure about.
npx fallow dead-code --unused-files
npx fallow list --entry-pointsRemove dead packages early. This reduces noise in later steps and speeds up installs.
npx fallow dead-code --unused-depsUsually the biggest category. Fix real dead code. Model intentional API surface with visibility tags or config instead of suppressing it. Hand this step to an agent using the prompt in section 8.
npx fallow dead-code --unused-exports --unused-typesAdd --unused-enum-members and --unused-class-members when you want to focus on those categories explicitly. In a TypeScript project, add --type-aware when aliases, re-exports, class contracts, packages, or exact consumers affect the decision. This starts an optional, slower semantic pass. See Type-aware TypeScript analysis and the fallow dead-code reference.
Merge repeated logic into shared helpers. Only ignore generated or template-heavy files when the duplication is genuinely intentional.
npx fallow dupes
npx fallow dupes --mode semantic # also catch renamed-variable clonesfallow health output includes Hotspots and Targets sections that rank the worst offenders. Use those to prioritize. Do not bike-shed every file above the mean.
npx fallow healthDo not default to inline suppression. Pick the mechanism that matches the reason.
Exports consumed outside the repo (published libraries, SDKs, public packages).
Prefer, in order:
@public, @internal, @beta, @alpha JSDoc visibility tags on the exportpublicPackages as the coarse switch for "this whole package is external API"ignoreExports only when file-level or export-level exceptions cannot be expressed any other waypublicPackages and visibility tags are complementary, not alternatives: publicPackages marks the package as externally consumed; @public/@internal tags distinguish public API from internal helpers that happen to be exported for cross-file use.
Files your framework or runtime invokes but no other module imports directly (workers, CLI scripts, route files, plugin modules).
Prefer, in order:
entry for project-specific entry globsdynamicallyLoaded for code pulled in through reflection, manifests, or dynamic importsfallow list --entry-points to inspect what Fallow already considers reachableFiles produced by a build step, code generator, or vendored third-party bundle.
Prefer:
ignorePatterns to exclude them from analysis entirelyhealth.ignore when the noise is health-only and dead-code analysis should still runPackages installed for runtime usage only (no static import), CLI tools, or peer dependencies.
Prefer:
ignoreDependencies with the exact package namesAn export you want to keep around deliberately (compatibility shims, future API).
Prefer:
/** @expected-unused */ on the export@expected-unused is self-cleaning. Unlike inline fallow-ignore comments, Fallow tracks the tag for staleness: the moment the export becomes imported, the tag is reported as a stale suppression so you can remove it. Use it liberally for shims and future API surface.
A specific site where Fallow is wrong and no config rule captures the reason cleanly.
Prefer:
// fallow-ignore-next-line <issue> on the line above// fallow-ignore-file <issue> only when the whole file is truly exceptionalThe project genuinely has a different standard for a whole category.
Prefer:
rules, health, duplication thresholds, or overrides blocksDo this only when it reflects a real team policy, not to hide a few ugly hotspots.
See suppression for the full decision tree and examples, and configuration overview for every key.
Narrow exceptions are an asset. Broad exceptions are a debt.
Good:
@public export on a library entry pointignoreDependencies entry for a runtime-provided packageentry pattern for worker scriptsBad:
ignorePatterns that silently exclude half the repohealth.maxCyclomatic to hide a handful of hotspots (acceptable only when the new threshold reflects a thought-through project standard with written justification)If you cannot explain an exception in one sentence, it is probably the wrong mechanism.
Work in two stages. Most teams ship fallow audit at the end of stage 1 and finish stage 2 over the following weeks.
fallow auditfallow audit is wired into CI and passes for new changes against the default branchOnce stage 1 is done, add the PR gate:
npx fallow audit
fallow audit runs dead code, duplication, and complexity analysis scoped to changed files, then returns a pass, warn, or fail verdict. See the fallow audit reference for flags and CI recipes.
Best for smaller teams. CI never blocks; fixes land under social pressure.
{
"rules": {
"unused-exports": "warn",
"unused-files": "warn",
"unused-dependencies": "warn"
}
}Risk: warn-only gates become warning-forever gates. Set a calendar reminder to promote rules to error after the first clean month.
You can also configure baselines in .fallowrc.json and run fallow audit with no flags:
{
"audit": {
"deadCodeBaseline": "fallow-baselines/dead-code.json",
"healthBaseline": "fallow-baselines/health.json",
"dupesBaseline": "fallow-baselines/dupes.json"
}
}
Baselines are a debt ledger, not a steady state. If the baseline file only grows, the policy is not being enforced.
Fallow finds the problems. An AI agent (Claude Code, Cursor, Codex, Windsurf, any shell-capable coding assistant) is the right tool to fix them: edits are mechanical but decisions ("delete this export" vs. "mark it @public" vs. "add it to entry") benefit from code-aware judgement.
Three levels of integration, pick whichever your agent supports:
Install fallow-skills for Claude Code, Cursor, Windsurf, or any Agent Skills compatible agent. Once installed, the skill works offline; the agent does not need to fetch docs URLs during use.
Structured tool calling with JSON output and _meta explanations. Works alongside skills.
Any agent that can run a shell command can drive Fallow. Use the copy-paste prompt below.
Paste this prompt into your agent. It is self-contained: the agent does not need to fetch this page to follow it.
Adopt Fallow in this repository.
Goal:
- use full-repo analysis first (`fallow`, `fallow dead-code`, `fallow dupes`, `fallow health`), not `fallow audit`
- fix real dead code, duplication, and complexity issues in code
- model intentional exceptions with the narrowest correct mechanism
- end with no functions above the repo's chosen health thresholds, or a consciously widened threshold with written justification
- then set up `fallow audit` as a PR gate
Process:
1. Run `npx fallow`, then `npx fallow dead-code`, `npx fallow dupes`, and `npx fallow health`. Use `--format json` if you want structured output.
2. If no config exists, run `fallow init` and create a minimal repo policy.
3. Fix high-confidence issues first:
- unresolved imports
- unlisted dependencies
- unused files (sanity-check with `fallow list --entry-points`)
- unused dependencies
4. For each remaining finding, choose one path:
- fix it in code (preferred)
- model it in config
- add a narrow inline exception only if it is truly one-off
5. Match reasons to mechanisms:
- external API: `@public` / `@internal` / `@beta` / `@alpha`, or `publicPackages`
- runtime or framework entry point: `entry`, `dynamicallyLoaded`, plugin-aware config
- generated code: `ignorePatterns`, `health.ignore`
- intentionally retained dependency: `ignoreDependencies`
- intentional unused export: `@expected-unused` (preferred over inline comments because it self-cleans)
- one-off false positive: `fallow-ignore-next-line`
- repo-wide policy: `rules`, `health`, duplication settings, `overrides`
6. Prefer config-level modeling over repeated suppression.
7. Keep every exception narrow and explain why it exists in a commit message.
8. Re-run Fallow after each batch until the repo is clean under the chosen policy.
9. Only after repo cleanup, run `npx fallow audit` and wire it into CI.
At the end, report:
- code changes
- config changes
- exceptions added and why
- anything left
- the final commands and outputs that show the repo is clean