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

# fjall undo

> Undo the last Fjall codemod by restoring an application's infrastructure.ts from its .bak backup.

`fjall undo` restores the most recent backup of an application's `infrastructure.ts`. Each `fjall add`, `fjall remove`, and `fjall modify` writes a sibling `.bak` file before changing the source. `undo` rolls the file back to that backup in one step.

<Accordion title="Prerequisites">
  * An application with an `infrastructure.ts` file (created with `fjall create app`).
  * A prior codemod (`fjall add`, `fjall remove`, or `fjall modify`) on that application. The `.bak` file is written by the most recent codemod, so there must be one to restore.
</Accordion>

## Restore the last change

```bash theme={null}
fjall undo --app <name>
```

Undo the last change to the `api` application:

```bash theme={null}
fjall undo --app api
```

Skip the confirmation prompt (useful in scripts):

```bash theme={null}
fjall undo --app web --yes
```

## What Happens

`undo` reads the `.bak` sidecar next to the application's `infrastructure.ts` and writes its contents back over the source file.

| Step | Action                                                           |
| ---- | ---------------------------------------------------------------- |
| 1    | Resolve the application's `infrastructure.ts` path from `--app`. |
| 2    | Read the sibling `infrastructure.ts.bak` backup.                 |
| 3    | Restore the backup over `infrastructure.ts`.                     |
| 4    | Print the path it restored from.                                 |

The `.bak` file holds a single prior version. `undo` reverts the most recent codemod only. To step back through older states, use the timestamped snapshots in the application's `.fjall/history` directory.

If no `.bak` file exists, `undo` exits with an error and leaves `infrastructure.ts` untouched.

**Agent mode.** Pass `--agent` to emit a structured result for AI-agent and scripted callers. The output reports the restored path and a follow-up suggestion instead of human-readable text.

## Options

| Option              | Description                                         | Default |
| ------------------- | --------------------------------------------------- | ------- |
| `-a, --app <name>`  | Application whose infrastructure to undo. Required. | None    |
| `-y, --yes`         | Skip confirmation prompts.                          | `false` |
| `-v, --verbose`     | Enable verbose logging.                             | `false` |
| `--non-interactive` | Force plain CLI output (no interactive UI).         | `false` |

### Agent flags

These flags shape output for AI-agent and scripted callers.

| Flag                | Description                                            |
| ------------------- | ------------------------------------------------------ |
| `--agent`           | Enable agent output mode.                              |
| `--budget <level>`  | Output budget: `minimal`, `compact`, or a token count. |
| `--fields <fields>` | Request additional fields in output.                   |
| `--full`            | Disable content truncation.                            |

## Next Steps

<CardGroup cols={2}>
  <Card title="fjall add" icon="plus" href="/cli/add">
    Add a resource to an application's infrastructure.
  </Card>

  <Card title="fjall list" icon="list" href="/cli/list">
    List the resources defined in an application's infrastructure.
  </Card>

  <Card title="fjall deploy" icon="rocket" href="/cli/deploy">
    Deploy infrastructure changes to AWS.
  </Card>

  <Card title="Add resources" icon="layer-group" href="/deployment/add-resources">
    Walk through adding and changing resources end to end.
  </Card>
</CardGroup>
