fallow architecture
Find the options, output fields and exit codes of fallow architecture, which finds import cycles, boundary violations and policy violations.
fallow architecture reports import cycles, boundary violations and rule-pack policy violations.
For the concepts and the workflow, read Architecture.
Synopsis
fallow architecture [OPTIONS] [PATH]
Options
| Argument | Description |
|---|---|
[PATH] | Scope reported findings to this file or directory (default: whole project). The full project graph is still built; only reported items are narrowed |
| Option | Description |
|---|---|
--shared-state | Inventory direct imported writes and custom global access sites |
--cycles | Only report import cycles: circular dependencies, re-export cycles and package cycles |
--boundaries | Only report boundary violations, boundary coverage and forbidden calls |
--policy | Only report rule-pack policy violations |
--file <PATH> | Only report issues in the specified file(s). Accepts multiple values. |
--finding-id <ID> | Only report the findings with these finding_id values. Repeat the flag or pass a comma-separated list |
The global options are in these groups: Project, Output, Scope, Baselines, Gates, Duplication, Type-aware, Performance.
- Without
--cycles,--boundariesor--policy, the command reports all three groups. You can give more than one. --cyclesreports circular dependencies, re-export cycles and package cycles.--boundariesreports boundary violations, boundary coverage and forbidden calls.--policyreports policy violations.fallow dead-codewith--circular-deps,--re-export-cycles,--package-cycles,--boundary-violationsor--policy-violationsreports the same findings, with the same finding ids.
Option details
Requested rules that are off
When a selection option asks for a rule that the config sets to off, fallow does not run that check. The findings and the exit code do not change. Fallow prints a note on stderr, and adds a requested-rule-off entry with the rule and the flag to workspace_diagnostics:
Note: circular-dependencies is off in config, so --cycles did not check it. Set the rule to "error" or "warn" to run this check.
A run without a selection option gives no note.
Shared-state inventory
--shared-state adds a list of the places where code writes to an imported value, and of the custom properties of window, globalThis, self or global that more than one file reads or writes. Alone, it selects only the inventory. With --cycles, --boundaries or --policy, the run also reports those findings.
- An imported write is an assignment, an update or a delete of a property of an imported value, with the declaration that the import resolves to.
- A global group lists the reads and the writes of one custom property in different non-test files. These sites do not prove that the files share one runtime or an order of execution.
- The inventory is not a finding. It does not change the totals, the health score, a baseline or the exit code.
- Only the
human,jsonandmarkdownformats show it. Another format,--sarif-file,--group-byor--finding-idtogether with--shared-stateexits with code 2, also for an empty inventory. - The inventory uses static property keys only. It leaves out aliases, dynamic keys, mutator calls,
Object.assign, destructuring targets and iteration targets. Check each site in the source before you change the code. - In JSON,
shared_state.completeisfalsewhen a parse error or a limit cut the inventory, andshared_state.truncatedistruewhen a limit cut it. A complete inventory covers the supported syntax only. - When one site of a global group matches a file, workspace or diff filter, the output keeps all reads and writes of that group.
- The
fallow-ignore-next-line shared-stateandfallow-ignore-file shared-statecomments and thesharedStateAllowlistconfig key remove a site from the inventory.
Relation to fallow dead-code
The fallow dead-code options above are deprecated aliases. fallow dead-code also reports the architecture findings by default. In human output, it then prints a tip on stderr that points to fallow architecture.
Bare fallow reports the architecture findings in an "Architecture" category of its dead-code section. The machine formats keep them in the dead-code part of the output. --only architecture runs only this part, and --skip architecture leaves it out. See global options.
Output
3 entry points detected (2 package.json, 1 plugin)
── Architecture ─────────────────────────────────────
● Circular dependencies (1)
src/services/catalog.ts
→ orders.ts → catalog.ts
Import cycles that can cause initialization failures and prevent tree-shaking
https://fallow.tools/docs/explanations/dead-code/#circular-dependencies
● Boundary violations (1)
src/lib/format.ts:1 → src/services/catalog.ts (lib → services)
Imports that cross defined architecture zone boundaries
https://fallow.tools/docs/explanations/dead-code/#boundary-violations
✗ 1 circular dependency · 1 boundary violation (0.16s)
- A cycle shows its first file, then the files of the loop.
- A boundary violation shows the importing file and line, the imported file, and the two zones.
- The last line counts the findings of each issue type.
With --format json, the output has the shape of the fallow dead-code output, with these differences:
| Field | Content |
|---|---|
kind | "architecture". A --group-by run gives "architecture-grouped". |
schema_version | The version of the architecture output format, separate from the version of dead-code. |
circular_dependencies, re_export_cycles, package_cycles | The cycle findings. Re-export cycles gives the kind values of a re-export cycle. |
boundary_violations, boundary_coverage_violations, boundary_call_violations | The boundary findings. |
policy_violations | The rule-pack findings. |
shared_state | The inventory: version, complete, truncated, imported_writes and globals. Present only with --shared-state. |
The other issue arrays of dead-code are present and empty. The JSON output reference has each field.
fallow report renders a saved architecture or architecture-grouped result in another format. A result with shared_state renders only as Markdown.
Package cycles
A package cycle shows the packages in cycle order, from the package with the lowest name, and one example import for each step:
● Package cycles (1)
@acme/core → @acme/utils → @acme/core
packages/core/src/format.ts:3 → packages/utils/src/index.ts
packages/utils/src/log.ts:1 → packages/core/src/index.ts (type-only)
Each entry of package_cycles has these fields:
| Field | Content |
|---|---|
packages | The package labels in cycle order. The last package imports the first. |
package_roots | The root directory of each package, in the same order. |
length | The number of packages in the cycle. |
edges | One example import for each step: from_package, to_package, path, target_path, line, col and type_only. type_only is true when each import of the step is type-only. |
group_truncated | true when the group of packages that holds this cycle has more cycles than fallow lists. |
- A label is the package name. When two workspace packages have the same name, the label adds the package root, for example
example (examples/basic). - Fallow lists at most 20 cycles for one group of packages, shortest first. Each output format then shows the note
this package group has more cycles than listed. Break a listed cycle and run fallow again. --changed-since, the diff scope offallow auditand--workspacekeep a cycle when the file of one example import (edges[].path) is in scope. A new cycle always shows, because it adds a step whose imports are all new.--group-byputs a cycle in the group of its first example import file. Per-file severity inoverridesuses the highest severity of the example import files.- A regression baseline and
fallow auditidentify a cycle by its package labels, so a cycle that exists already does not fail a gate again.
Baselines
A fallow architecture baseline has the dead-code format and "kind": "dead-code". fallow architecture --baseline also reads a baseline of fallow dead-code --save-baseline. Because the run reports only some issue types, --fail-on-stale-baseline does not gate this command: the stale-baseline gate has the status skipped.
A baseline that fallow architecture --save-baseline writes lists only the architecture findings. When fallow dead-code reads it, fallow prints a warning that the baseline lists only part of the findings.
Exit codes
| Code | Meaning |
|---|---|
0 | No finding at error severity, and no other gate failed. |
1 | A finding has a rule at error. By default, circular dependencies, boundary violations, boundary coverage and forbidden calls are at error. Re-export cycles, package cycles and policy violations are at warn. A rule in a rule pack can set its own severity. |
2 | Invalid input, for example --shared-state with --format sarif. |
Exit codes has the codes that all commands share.
Examples
# Before an edit, show the rules of a file; after the edit, find the violations
fallow guard src/ui/App.ts --format json --quiet
fallow architecture --format json --quiet
# Report cycles, boundaries and policy rules
fallow architecture
# Report only the import cycles in files that changed since main
fallow architecture --cycles --changed-since main --format json --quiet
# Report only the boundary findings of one workspace
fallow architecture --boundaries --workspace web
# List the writes to imported values and to shared globals
fallow architecture --shared-state --format json
# Render a saved result as a GitHub job summary
fallow architecture --format json -o results.json
fallow report --from results.json --format github-summary
Related
- Architecture: zones, boundaries and cycles.
fallow guard: the rules that apply to a file before you edit it.- Boundaries config: define zones and rules.