> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fallow.tools/llms.txt
> Use this file to discover all available pages before exploring further.

# fallow fix

> CLI reference for fallow fix. Automatically remove unused exports and dependencies from source files with dry-run preview and JSON output.

Automatically remove unused exports and dependencies from your codebase. Fallow modifies your source files in place, so treat this like a refactoring tool.

<Warning>
  Always commit your changes before running `fallow fix`. This gives you a clean rollback point if anything unexpected happens.
</Warning>

<Tip>
  Use `--dry-run` first to preview exactly what will be removed before applying any changes.
</Tip>

```bash theme={null}
fallow fix
```

## Options

| Flag                    | Description                              |
| :---------------------- | :--------------------------------------- |
| `--dry-run`             | Preview changes without applying         |
| `--yes, --force`        | Skip confirmation (required in non-TTY)  |
| `-f, --format <FORMAT>` | Output format: `human` (default), `json` |

## What gets fixed

* **Unused exports**: the `export` keyword is removed, keeping the declaration. For exported enums where the enum itself is never referenced outside its body in the file, the entire `enum` block is deleted.
* **Unused dependencies**: removed from `package.json` when they are not imported by another workspace
* **Unused enum members**: removed from the enum declaration. When every member of an exported enum is unused, the whole declaration is deleted in one pass instead of leaving behind an empty `export enum X {}` shell. Importers in other files now reference a name that no longer exists, so run your TypeScript build to find and clean them up.
* **Unused pnpm catalog entries**: removed from `pnpm-workspace.yaml` by line-aware deletion (comments and stylistic choices in the file are preserved). Object-form entries such as `react:\n  specifier: ^18.2.0` are removed as one block. When the last entry of a catalog group is removed, the header is rewritten to `catalog: {}` (or `<name>: {}`) so the file stays installable; bare `catalog:` with no value parses as null and pnpm errors at install time. Entries whose `hardcoded_consumers` is non-empty (a workspace package still pins a hardcoded version of the same package) are skipped to avoid breaking the next `pnpm install`; the skip is surfaced in stderr and in the JSON output (`{"type": "remove_catalog_entry", "applied": false, "skipped": true, "skip_reason": "hardcoded_consumers", "consumers": [...]}`). After a successful catalog edit fallow reminds you to run `pnpm install` so `pnpm-lock.yaml` stays in sync. The JSON envelope grows a top-level `"skipped"` count alongside `"total_fixed"` for partial-fix gating in CI.

Unused files and class members are not auto-fixed. Use `fallow dead-code` to find those.

## Examples

<CodeGroup>
  ```bash Preview changes theme={null}
  # See what would be removed
  fallow fix --dry-run

  # JSON output for scripting
  fallow fix --dry-run --format json
  ```

  ```bash Apply fixes theme={null}
  # Interactive confirmation
  fallow fix

  # Skip confirmation (CI)
  fallow fix --yes
  ```
</CodeGroup>

## Example output

```bash title="$ fallow fix" theme={null}
Would remove export from src/components/Card/index.ts:1 `CardFooter`
Would remove export from src/providers/trpc-provider/index.tsx:12 `TRPCProvider`
Would remove export from src/server/jobs/queue.ts:61 `enqueueJobDelayed`
Would remove export from src/server/jobs/queue.ts:206 `sweepStuckProcessingJobs`
Would remove export from src/server/jobs/queue.ts:276 `getDeadLetterJobs`
Would remove `@trpc/react-query` from dependencies

6 changes to apply. Proceed? [y/N] y

✓ Applied 6 fixes (5 exports, 1 dependency)
```

## See also

<CardGroup cols={2}>
  <Card title="Auto-fix" icon="wand-magic-sparkles" href="/analysis/auto-fix">
    Details on what fallow can and cannot auto-fix.
  </Card>

  <Card title="Dead code analysis" icon="skull-crossbones" href="/analysis/dead-code">
    Understand the full range of dead code fallow detects.
  </Card>
</CardGroup>
