# rootform init

Prepare an existing project selection locally.

`init` prepares the exact external Dialects and Policy Pack sources selected
by `rootform.lock`. The optional path defaults to `.` and identifies the
Rootform project to prepare; it need not be a Terraform/OpenTofu root. `init`
does not detect providers, pick versions, or modify the lock.

<!-- BEGIN GENERATED CLI: rootform init -->

## Usage

```text
rootform init [path] [options]
```

## Options

### Preparation

| Flag | Type | Default | Description |
| --- | --- | --- | --- |
| ` --locked ` | ` bool ` | ` false ` | require and preserve the existing rootform.lock |
| ` --no-input ` | ` bool ` | ` false ` | never prompt; require deterministic action |
| ` --offline ` | ` bool ` | ` false ` | use no network; accept local and installed sources |

### Output

| Flag | Type | Default | Description |
| --- | --- | --- | --- |
| ` --details ` | ` bool ` | ` false ` | list every prepared unit's status and source on standard error |
| ` --format ` | ` string ` | ` "" ` | output format: `text\|json`; default: text |

### Global options

| Flag | Type | Default | Description |
| --- | --- | --- | --- |
| ` -h, --help ` | ` bool ` | ` false ` | show how to use rootform init |
| ` --color ` | ` mode ` | ` auto ` | color human output: `auto\|always\|never`; default: auto |
| ` --no-pager ` | ` bool ` | ` false ` | print a long report in full instead of opening it in less |

<!-- END GENERATED CLI -->

## Lock and acquisition

An existing lock is preserved. Without a lock, ordinary `init` has an empty
selection; `--locked` instead requires an existing valid lock. Embedded
Dialects need no acquisition. For selected OCI content, `init` may fetch
only exact selected digests when network use is allowed. If a vendor family
exists, `init` verifies its exact tree, including missing, extra, or changed
content; a valid tree needs no installed copy or registry access. `--offline`
restricts preparation to verified local content. `--no-input` disallows
prompts and requires deterministic action.

Replace `./infra` with an existing project directory. The `--locked` example
requires that project to contain a valid `rootform.lock` beforehand.
Run the first command to prepare its selection, the second to prove it can be
prepared from local bytes alone, and the third when a machine-readable result
is needed.

<!-- docs-check:cli-init -->
```sh
rootform init ./infra --no-input
rootform init ./infra --locked --offline --no-input
rootform init ./infra --format json
```

With external content selected, text output starts with `Project prepared`,
then reports `External Dialects` and `External Policy Packs` counts. With no
external content selected, it starts with `Project ready`, then reports
`External content  none`. Machine JSON goes to standard output; diagnostics and
`--details` output go to standard error. Neither text nor JSON writes
`rootform.lock`. Status `0` means preparation completed; `1` means selected
content is invalid, missing, or differs from `rootform.lock`; `2` means the
command was used incorrectly; `3` means `rootform.lock` is required or invalid,
or `--offline` needs content that is not installed; and `4` means a file, the
Rootform home, or the registry could not be read or written. See
[Select Dialects and Policy Packs](https://docs.rootform.dev/cli/) and
[External content storage](https://docs.rootform.dev/reference/storage/).
