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

# gandalf apply: sync the team manifest locally

> Apply gandalf.toml to local Codex and Claude Code setups with Smart Merge. A pre-apply safety snapshot is created automatically for easy rollback.

`gandalf apply` synchronizes the declarative team manifest to your local agent setup. It runs Smart Merge (non-destructive) and creates a pre-apply safety snapshot before writing so you can roll back with `gandalf restore`.

## Synopsis

```bash theme={null}
gandalf apply [flags]
```

## Flags

| Flag              | Description              | Default                          |
| ----------------- | ------------------------ | -------------------------------- |
| `--manifest`      | Path to `gandalf.toml`   | search project root              |
| `--dry-run`       | Preview without writing  | off                              |
| `-y`, `--yes`     | Skip confirmation prompt | off                              |
| `-p`, `--project` | Project directory        | `.`                              |
| `--home`          | Home directory           | `$HOME`                          |
| `--store`         | Gandalf store directory  | `~/.gandalf` or `$GANDALF_STORE` |
| `--json`          | Emit JSON output         | off                              |

## Examples

```bash theme={null}
gandalf apply --dry-run
gandalf apply --yes
gandalf apply --manifest ./config/gandalf.toml --yes
```

## Behavior

1. Loads and validates `gandalf.toml`. Missing required env vars are warned on stderr.
2. Scans local agent setup and generates a sync plan.
3. Prints "Review Changes before Apply" with numbered items per agent.
4. If `--dry-run`, stops here.
5. Otherwise, prompts for confirmation unless `--yes` is passed.
6. Creates a pre-apply safety snapshot.
7. Applies changes with Smart Merge: new MCP servers, skills, and hooks are added or updated; existing personal settings are preserved.

On success, Gandalf prints the safety snapshot name and the exact rollback command:

```bash theme={null}
gandalf restore --snapshot <backup> --apply --experimental
```

<Note>
  Smart Merge never deletes or modifies unrelated personal settings. Only entries declared in the manifest are added or updated.
</Note>

## Related

* [`gandalf check`](/cli/check)
* [`gandalf init`](/cli/init)
* [Team manifest guide](/guides/team-manifest)
* [Manifest reference](/reference/manifest)
