> ## 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 export: write gandalf.toml from local agent setup

> Export existing Cursor, Claude Code, and Codex configs into a team gandalf.toml. gandalf import is a backward-compatible alias for the same command.

`gandalf export` scans local AI agent configurations and writes a canonical `gandalf.toml`. It is the local-environment → manifest direction. Applying that manifest back onto local agent configs is [`gandalf apply`](/cli/apply).

`gandalf import` is a backward-compatible alias for `gandalf export`. Prefer `export` in new scripts and docs.

## Synopsis

```bash theme={null}
gandalf export [flags]
gandalf import [flags]
```

## Flags

| Flag                  | Description                                                     | Default                          |
| --------------------- | --------------------------------------------------------------- | -------------------------------- |
| `--project-only`      | Scan repository files only (ignore user home)                   | off                              |
| `--from`              | Export strictly from a specific configuration file or directory | (discovered paths)               |
| `--dry-run`           | Preview generated `gandalf.toml` without writing                | off                              |
| `-f`, `--force`       | Overwrite an existing `gandalf.toml`                            | off                              |
| `-o`, `--output`      | Output manifest path                                            | `gandalf.toml`                   |
| `-i`, `--interactive` | Launch the interactive TUI wizard                               | off (TTY default)                |
| `-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 export --dry-run
gandalf export --project-only
gandalf export --force
gandalf import --dry-run
```

`--json`, `--dry-run`, and piped I/O stay headless. On a TTY, export opens a wizard to toggle servers/skills, preview a masked manifest, and confirm overwrite.

## Behavior

1. Discovers project and (unless `--project-only`) user-home agent configs for Cursor, Claude Code, and Codex.
2. Reconciles sources with project-over-global precedence.
3. Redacts secrets into `[env_template]`.
4. Mirrors team skills into `.gandalf/skills/` with symlink-safe path confinement and atomic rollback.
5. Writes `gandalf.toml` unless `--dry-run` is set. Existing manifests require `--force`.

<Note>
  Export is manifest only (local agent config → `gandalf.toml`). Secrets, logins, and agent installs are out of scope. Other machines need [`gandalf apply`](/cli/apply) (agents already installed; `${ENV}` filled there). Use [`gandalf check`](/cli/check) to detect drift.
</Note>

## Related

* [`gandalf apply`](/cli/apply)
* [`gandalf check`](/cli/check)
* [`gandalf init`](/cli/init)
* [Team manifest guide](/guides/team-manifest)
* [Support matrix](/reference/support-matrix)
