> ## 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 history

> List or restore infrastructure.ts snapshots from an application's .fjall history with the Fjall CLI.

<Accordion title="Prerequisites">
  * An application created with `fjall create app`, so it has a `fjall/<app>/infrastructure.ts` file.
  * At least one codemod (`fjall add`, `fjall modify`, or `fjall remove`) that wrote a snapshot to the application's `.fjall/history` directory. A brand-new application with no edits has no snapshots to list.
  * Node 22 or later.
</Accordion>

## List or restore snapshots

Every codemod that edits `infrastructure.ts` saves a timestamped snapshot in the application's `.fjall/history` directory. Run `fjall history` to list those snapshots, or pass `--restore` to roll the file back to one of them.

```bash theme={null}
fjall history --app <name> [--restore <timestamp>]
```

List the snapshots for an application:

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

Output shows one row per snapshot with its ISO 8601 timestamp, size, and file path:

```
History snapshots for api: 3
  2026-05-29T14:02:11.482Z      1842 bytes  /path/to/fjall/api/.fjall/history/2026-05-29T14-02-11.482Z.ts
  2026-05-29T11:47:03.119Z      1715 bytes  /path/to/fjall/api/.fjall/history/2026-05-29T11-47-03.119Z.ts
  2026-05-28T09:15:55.004Z      1490 bytes  /path/to/fjall/api/.fjall/history/2026-05-28T09-15-55.004Z.ts
```

Restore a specific snapshot by its timestamp:

```bash theme={null}
fjall history --app api --restore 2026-05-29T14:02:11.482Z
```

## What Happens

When you list snapshots, Fjall reads the application's `.fjall/history` directory and prints each recorded snapshot. No files change.

When you pass `--restore <timestamp>`, Fjall:

1. Looks up the matching snapshot for that timestamp.
2. Writes a `.bak` backup of the current `infrastructure.ts` so the in-place state is recoverable.
3. Overwrites `infrastructure.ts` with the snapshot contents.

If no snapshot matches the timestamp, the command prints the available-snapshots hint and exits without touching `infrastructure.ts`. Run `fjall history --app <name>` first to copy an exact timestamp from the list.

Restoring only rewrites the local `infrastructure.ts` file. Run `fjall deploy` afterwards to apply the restored infrastructure to AWS. To undo the most recent codemod instead of restoring a named snapshot, use `fjall undo`.

In agent mode (`--agent`), the listing returns structured tabular output and the restore returns the snapshot path plus the `.bak` backup path, both suited to scripted callers.

## Options

| Option                  | Description                                                | Default       |
| ----------------------- | ---------------------------------------------------------- | ------------- |
| `-a, --app <name>`      | Application whose history to inspect. Required.            | None          |
| `--restore <timestamp>` | Restore the snapshot identified by its ISO 8601 timestamp. | List only     |
| `-v, --verbose`         | Enable verbose logging.                                    | Off           |
| `--non-interactive`     | Force plain CLI output (no interactive UI).                | Auto-detected |

### 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, which records a new snapshot.
  </Card>

  <Card title="fjall modify" icon="pen" href="/cli/modify">
    Change a resource's properties, recording a snapshot before the edit.
  </Card>

  <Card title="fjall remove" icon="trash" href="/cli/remove">
    Remove a resource from infrastructure, recording a snapshot before the edit.
  </Card>

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