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

# lua pull

> Restore the project's source files from the latest backup or from the backup linked to an agent version

`lua pull` overwrites the files in your project with a source backup stored on the server, either the most recent one or the one linked to an agent version. Plain `lua pull` only reads from the server; `lua pull --version <n>` also records the restored state as a new source version. It changes nothing for end users.

*Verified against lua-cli 3.66.0.*

## Synopsis

```bash theme={null}
lua pull [--version <n>] [--force]
```

## Description

Every [`lua push`](https://docs.heylua.ai/reference/cli/push) records a backup of your project files as a numbered source version (see [`lua source`](https://docs.heylua.ai/reference/cli/source)), and every [agent version](https://docs.heylua.ai/reference/cli/version.md) links to the source version that was current when it was created. Without flags, `lua pull` restores the latest source version. It downloads the backed-up files, overwrites the working copy and records that version in `lua.skill.yaml` as the one your files match, so the next `lua push backup` sees no false changes. It makes no change on the server: no new source version, no `rollback to v<n>` entry in `lua source list`, and the active backup version stays as it was. That also means it works while a build session holds the agent; it reminds you that an open build session may have newer work that is not in the backup yet. Before lua-cli 3.66.0, a plain pull also pushed the restored files back as a new source version.

With `--version <n>`, it looks up agent version `n` and restores the source version linked to it; a version without a linked backup fails with `Version v<n> has no source backup linked. Cannot pull source for this version.` This form works like [`lua source rollback`](https://docs.heylua.ai/reference/cli/source): the files are prepared in a temporary folder and recorded as a new source version first, and your working copy changes only once the server has accepted it. If the server refuses, for example because a build session holds the agent, every local file stays as it was, the command prints `Rollback to v<m> stopped: your local files were not changed.` and exits non-zero with the server's message.

In both forms, files that exist locally but not in the backup are left in place.

Before writing, plain `lua pull` asks `Pulling backup v<n> will overwrite local files. Continue?` and `lua pull --version <n>` asks `Rolling back to v<m> will overwrite local files and create a new version. Continue?`, where `v<m>` is the backup linked to the agent version. Pass `--force` to skip the prompt. The global `--ci` flag does not suppress this prompt, so automation must pass `--force`. Unlike [`lua sync --pull`](https://docs.heylua.ai/reference/cli/sync), `lua pull` performs no local-changes check: edits in files the backup contains are lost. Commit them, or run `lua push backup` first so they become the latest backup.

With [`lua git connect`](https://docs.heylua.ai/reference/cli/git) enabled, the restored files are committed automatically. The command needs a project and a credential. Pulling never changes what is live; to change the live agent, promote a version with `lua version promote`.

## Arguments

None.

## Options

| Option | Description | Default |
| - | - | - |
| `--version <n>` | Agent version whose linked source backup to restore; `3` or `v3`. | latest source backup |
| `--force` | Skip the confirmation prompt. Required in automation. | off |

## Examples

Restore the most recent backup into an existing checkout, without changing anything on the server:

```bash theme={null}
lua pull
```

Check out the exact source behind agent version 3 before deciding whether to promote it:

```bash theme={null}
lua pull --version 3
lua version promote 3
```

Restore without a prompt, in a script:

```bash theme={null}
lua pull --version v3 --force --ci
```

The command prints which backup it restores, `Pulling latest source backup (v<n>)…` or `Pulling source for agent version v<n> (backup v<m>)…`. With `--version`, the backup push that records the new source version follows.

## Exit codes

| Code | Meaning |
| - | - |
| `0` | Files restored (with `--version`, also recorded as a new source version), or the prompt was declined. |
| `1` | `No backup versions available to pull.`, the agent version does not exist, it has no linked backup, or the download failed. |
| `2` | Not inside a project, or no agent configured in `lua.skill.yaml`. |
| `9` | No credential, or the server rejected it. |
| `11` | The server or network is unavailable. |

## See also

* [Back up and restore source](https://docs.heylua.ai/ship/backups-and-restore.md)
* [`lua source`](https://docs.heylua.ai/reference/cli/source) — list source versions and restore by source number
* [`lua version`](https://docs.heylua.ai/reference/cli/version) — agent versions and the promote path
* [`lua sync`](https://docs.heylua.ai/reference/cli/sync) — guarded pull of drifted primitives only


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.