# Command Reference

> **Status:** Draft 0.2, 2026-11-23. What a person types: starting a session, the two modes, moving around the tree, every command in each mode, pipes, completion and help, and how commands map to the API that pipelines use. Companion to [Tree Model](tree-model.md) and [Commit Model](commit-model.md).

The command structure is deliberately close to Junos. Someone who has configured an SRX or an MX should recognize almost everything: the two modes, `edit` and `set`, `show | compare`, `commit check`, `commit confirmed`, `rollback`, and `display set`. Where Gravity Keep differs, it is because AWS differs: convergence takes time, resources hold data, and the console exists.

# 1. Starting a session

The client is `gkeep`. It signs in through the company's SSO (passkeys at minimum, as the Standard requires) and opens a WebSocket session to the control plane.

```
$ gkeep tidewater
Signing in to keep.tidewater.com ... approved on passkey
Gravity Keep 0.2  control plane tidewater  active COMMIT-41 (2026-11-20 16:12 CST, alee)
1 candidate from a previous session (edited 2026-11-21 19:58). Resume with: configure resume

eric@tidewater>
```

The same session is available in a browser terminal at the control plane's address. Both are clients of the same API ([CTL-042](rules.md#sessions-and-interfaces)).

One-shot use, for scripts and pipelines:

```
$ gkeep tidewater -c "show drift /tidewater/lending"
$ gkeep tidewater load source /tidewater/lending/prod at 9f3c2e1
$ gkeep tidewater commit comment "lending 2.4.1 infrastructure" acknowledge destructive 0
```

# 2. Modes and prompts

| Mode | Prompt | Purpose |
|---|---|---|
| Operational | `eric@tidewater>` | Look at the active configuration, observed state, drift, and history. Make `request`s. Never changes AWS or configuration except through a `request` ([CTL-043](rules.md#sessions-and-interfaces)). |
| Configuration | `eric@tidewater#` | Edit the session's candidate, check it, and commit it. |

Configuration mode always shows the current level above the prompt, as Junos does:

```
eric@tidewater> configure
Entering configuration mode (private candidate, base COMMIT-41)

[edit]
eric@tidewater# edit /tidewater/lending/prod

[edit /tidewater/lending/prod]
eric@tidewater#
```

`run <command>` runs an operational command from configuration mode: `run show drift`.

# 3. Moving around the tree

| Command | Effect |
|---|---|
| `edit <path>` | Go to a namespace, creating it in the candidate if it doesn't exist. An absolute path starts with `/`. A relative one is from the current level. |
| `edit resource <type> <name>` | Go into a resource. |
| `edit <statement>` | Go into a block: `edit defaults s3.bucket`, `edit policy`. |
| `up [n]` | Up one level, or `n`. |
| `top` | To `[edit]`, the root. |
| `exit` | Up one level. At the root, leaves configuration mode (and warns if the candidate has uncommitted changes). |
| `exit configuration-mode` | Leaves configuration mode from anywhere. The candidate is kept. |

# 4. Configuration mode

## 4.1 Changing the candidate

| Command | Effect |
|---|---|
| `set <statement>` | Set a value at the current level. `set /path <statement>` sets at an absolute path. |
| `delete <statement>` | Remove a statement, block, resource, or namespace from the candidate. |
| `deactivate <statement>` / `activate <statement>` | Keep a statement in the candidate but leave it out of the resolved configuration. A deactivated resource is treated as removed, with the same deletion rules. Shown with `inactive:` as in Junos. |
| `rename <name> to <new-name>` | Rename a namespace or resource. Never replaces a resource ([CTL-006](rules.md#tree)), unless the name is also a create-only property, which commit check reports. |
| `move <path> under <path>` | Move a namespace to a new parent. Placement may change by inheritance, which commit check reports. |
| `copy <path> to <path>` | Copy a namespace or resource. Globally unique values (bucket names) will conflict, and commit check says where. |
| `promote <statement> to <path>` | Set a statement at a higher namespace and delete the identical copies beneath it, in one commit ([tree-model 5](tree-model.md#5-defaults-and-guardrails)). |
| `annotate <statement> "<text>"` | Attach a comment, shown as `/* text */` in hierarchical form and kept in history. |
| `protect <path>` / `unprotect <path>` | Set or remove protection ([CTL-048](rules.md#ownership-and-deletion)). |
| `apply <template> { ... }` | Apply a template at the current namespace ([tree-model 6](tree-model.md#6-templates)). |
| `explore [types [ ... ]] [regions [ ... ]] [tags { ... }] [all]` | Search the inventory for unmanaged resources in the current namespace's area, narrowed by the filters, and add them to the candidate with `adopt-from` ([commit-model 8.2](commit-model.md#82-adopt-and-explore)). Beneath a Git source, print them for a pull request. |
| `evict <path> [types [ ... ]] [tags { ... }]` | Remove resources or a branch from the candidate, to be left in AWS untagged when committed ([commit-model 8.4](commit-model.md#84-evict)). |
| `adopt <arn> at <path> name <name>` | Read an existing resource and add it to the candidate ([commit-model 8](commit-model.md#82-adopt-and-explore)). Beneath a Git source, print it with `adopt-from` for a pull request instead. |
| `set source <child> git <repo> branch <branch> file <file>` / `delete source <child>` | At a parent: hand a child namespace to a Git source, or take it back ([tree-model 11.3](tree-model.md#113-handing-a-namespace-to-git-and-back)). |

## 4.2 Loading

| Command | Effect |
|---|---|
| `load merge <source>` | Merge the source into the candidate. |
| `load replace <source> [path <path>]` | Replace the subtree at `path` (or the whole tree) with the source. |
| `load set <source>` | Apply a list of `set` and `delete` lines. |
| `load source <path> [at <commit>]` | Load a Git-sourced namespace from its declared file, at a commit on its declared branch (the head if none is named) ([commit-model 12](commit-model.md#12-git-sourced-namespaces)). The only load allowed beneath a Git source. Add `acknowledge out-of-step` when the namespace is out of step. |
| `load candidate <session>` | Restore an expired candidate. |

For `load merge`, `load replace`, and `load set`, the source is `terminal` (paste, end with Ctrl-D), a file uploaded to the session, or `git+https://<repo>@<commit> [file <file>]`, and the Git commit is recorded. None of them works beneath a Git-sourced namespace, and a file marked as an export is refused everywhere ([CTL-056](rules.md#sources)).

Beneath a Git-sourced namespace, every command that edits the candidate is refused as it is typed:

```
[edit /tidewater/lending/prod/east]
jordan@tidewater# set resource s3.bucket documents lifecycle-configuration rules { ... }
error: /tidewater/lending/prod is sourced from Git (CTL-052)
       https://github.com/tidewater/infrastructure  branch main  file lending/prod.conf
       change it by pull request
```

## 4.3 Checking and committing

| Command | Effect |
|---|---|
| `show \| compare` | The candidate's difference from its base, in hierarchical form with `+` and `-`. |
| `update` | Bring the latest active configuration into the candidate, keeping non-conflicting changes ([commit-model 2](commit-model.md#2-the-candidate)). |
| `update templates [<path>]` | Re-resolve every template version constraint beneath the path (or the current level) to the newest matching version, in the candidate. Commit check then shows each version it moves ([tree-model 6.1](tree-model.md#61-version-constraints)). |
| `commit check` | Verify and plan, without committing ([commit-model 3](commit-model.md#3-commit-check)). |
| `commit [comment "<text>"]` | Commit. A comment is required beneath a reviewed namespace. Also confirms a pending `commit confirmed`. |
| `commit confirmed <minutes>` | Commit, and revert unless confirmed within the time after convergence ([commit-model 5](commit-model.md#5-commit-confirmed)). A plain `commit` becomes one automatically when policy requires it for a type in the plan; commit check says so. Never used for loads from a Git source. |
| `commit acknowledge destructive <count>` | Commit a plan with `<count>` deletions or replacements of stateful or identity-bearing resources ([CTL-028](rules.md#candidate-and-commit)). |
| `commit request [comment "<text>"]` | Freeze the difference as a request for a second person to approve. |
| `commit request confirmed <minutes>` | A request that, once approved, commits as `commit confirmed`. The author confirms; confirming needs no second approval because it changes nothing. |
| `commit and-quit` | Commit and leave configuration mode. |
| `commit and-wait` | Commit, then wait for convergence to finish before returning the prompt ([commit-model 4.5](commit-model.md#45-waiting)). Combines with `confirmed`, `acknowledge`, and `comment`. |
| `rollback <n>` / `rollback commit <number>` | Replace the candidate with the configuration of an earlier commit. `rollback 0` discards the session's changes. |
| `status` | Who else is in configuration mode, at which levels, and which subtrees are locked. |

Options combine: `commit confirmed 10 comment "open 443 from the new office range"`.

# 5. Operational mode

## 5.1 Looking

| Command | Shows |
|---|---|
| `show configuration [<path>]` | The active configuration. |
| `show commits [<path>] [count <n>]` | Commit history, newest first, with state and author. |
| `show commit <number>` | One commit: its difference, check result, and each resource's convergence outcome. |
| `show status [<path>]` | The state of each resource (`stable`, `converging`, `drifted`, `failed`, `unknown`) with its reason, and each namespace's rolled-up state and counts ([commit-model 4.2](commit-model.md#42-resource-state)). |
| `show resource <path>` | One resource: its state, configured, resolved, and observed values, and any drift, side by side. `create` and `destroy` values are marked with their phase, write-only properties `write-only`, and secrets show only their reference and version. |
| `show observed <path>` | Observed state only, with the time it was read. |
| `show drift [<path>]` | Every drifted property beneath the path, who changed it (from CloudTrail), when, and what the policy did. |
| `show unmanaged [<path>]` | Resources in the path's area that aren't in the tree, which other tool manages them if known, the age of the inventory's index, and the types the inventory doesn't cover there. |
| `show retained [<path>]` | Stateful resources retained after leaving the tree. |
| `show findings [<path>]` | Violations of audit guardrails, and of guardrails by resources in `observed` namespaces ([tree-model 5](tree-model.md#5-defaults-and-guardrails)). |
| `show sources [<path>]` | Each Git-sourced namespace: repository, branch, file, the last Git commit loaded or written, and whether it is in step. |
| `show holds` / `show requests` / `show sessions` | Active holds with their time left, extensions, and held changes; pending commit requests; open sessions. |
| `show events <path> [since <time>]` | The CloudTrail changes that touched a resource. |
| `show templates [<name>]` / `show types [<filter>]` / `show type <type>` | Templates and versions; resource types; one type's properties, scope, and statefulness. |

## 5.2 Watching and waiting

| Command | Streams |
|---|---|
| `monitor commit <number>` | A commit's convergence, resource by resource, until it finishes. |
| `monitor drift [<path>]` | Drift as it is observed. |
| `wait commit <number> [timeout <d>]` | Blocks until every resource the commit affected is stable, or the commit fails or is superseded. Exit code 0 stable, 1 failed, 2 timed out, 3 superseded ([commit-model 4.5](commit-model.md#45-waiting)). |
| `wait <path> [timeout <d>]` | Blocks until everything beneath the path is stable. `drifted` and `unknown` never count as stable ([CTL-062](rules.md#convergence)). Default timeout one hour. |

Streams arrive over the session's WebSocket. Ctrl-C stops watching; it does not stop the work.

## 5.3 Requesting

| Command | Effect |
|---|---|
| `request reconcile <path> [create]` | Read everything beneath the path now and converge it, without waiting for an event or the sweep. With `create`, also apply the current `create` values to existing resources ([tree-model 4.1](tree-model.md#41-lifecycle-phases)). |
| `request hold <path> duration <d> reason "<text>"` | Suspend remediation beneath the path ([commit-model 6.1](commit-model.md#61-holds)). `request hold release <path>` ends it early. |
| `request hold extend <id> duration <d> reason "<text>"` | Give a hold more time, within the policy's maximum and total. Anyone granted `hold`. |
| `request hold capture <id> [resource <path>]` | Write the held changes' observed values as desired state: a candidate, a commit request, or a Git fragment, by the namespace's route ([CTL-075](rules.md#drift)). |
| `request remediation resume <path>` | Resume remediating a resource that was stopped for fighting ([CTL-032](rules.md#drift)), after the cause is found. |
| `request revert commit <number> [acknowledge destructive <count>]` | Commit, at once, the configuration from before that commit beneath the paths it changed, and write the revert to Git if the namespace is Git-sourced ([commit-model 7](commit-model.md#7-rollback), [CTL-058](rules.md#candidate-and-commit)). Needs `revert`. |
| `request commit approve <id>` / `request commit reject <id> reason "<text>"` | Decide a commit request ([commit-model 10](commit-model.md#10-reviewed-commits)). |

# 6. Pipes

Output can be passed through one or more pipes, as in Junos:

| Pipe | Effect |
|---|---|
| `\| compare [rollback <n> \| commit <number>]` | Difference from the base, an earlier rollback, or a named commit. |
| `\| display set` | Set form. |
| `\| display status` | Hierarchical form with each resource's state and reason as a `##` note. |
| `\| display inheritance` | Hierarchical form with a `##` note on every inherited or imposed value ([tree-model 9](tree-model.md#9-how-a-value-is-resolved)). |
| `\| display templates` | Marks which template and version supplied each resource. |
| `\| display json` | Canonical JSON. |
| `\| display cloudformation` | The resolved subtree as a CloudFormation template, for rescue and for export ([architecture 7](architecture.md#7-managing-itself)). |
| `\| match <pattern>` / `\| except <pattern>` | Keep or drop matching lines. |
| `\| count` / `\| last <n>` / `\| no-more` | Count lines; keep the last lines; don't page. |
| `\| save <name>` | Save output as a file in the session, for `load` or download. |

# 7. Completion and help

- `?` lists what can come next at the cursor: commands, namespaces, resource types, property names, enumeration values, and resources a reference can point to. Everything comes from the tree and the type schemas.
- Tab completes a unique prefix.
- `help <command>` explains a command. `help type s3.bucket property versioning-configuration` shows the schema's description, type, allowed values, whether it is create-only, and whether any guardrail affects it at the current level.

```
[edit /tidewater/lending/prod resource s3.bucket documents]
eric@tidewater# set versioning-configuration status ?
Possible completions:
  Enabled              Versioning is on for every object
  Suspended            New objects are not versioned; existing versions are kept
```

# 8. Commands and the API

Every command is a call to the control plane's API ([CTL-042](rules.md#sessions-and-interfaces)). Configuration commands act on a candidate resource, and operational commands read or create records.

| Command | API |
|---|---|
| `configure` | `POST /sessions/{id}/candidates` |
| `set`, `delete`, `rename`, `move`, `apply`, `adopt` | `PATCH /candidates/{id}` with a list of operations |
| `load` | `PUT /candidates/{id}` or `PATCH` with a source |
| `commit check` | `POST /candidates/{id}/check` |
| `commit` | `POST /candidates/{id}/commit` |
| `commit request` | `POST /candidates/{id}/requests` |
| `show configuration` | `GET /configuration?path=` |
| `show commit` | `GET /commits/{number}` |
| `show drift` | `GET /drift?path=` |
| `request hold` | `POST /holds` |
| `monitor` | A subscription message on the session WebSocket |
| `wait` | `GET /commits/{number}/wait` or `GET /status/wait?path=`, a long poll that returns within 30 seconds and is repeated by the client until the wait ends |
| `show status` | `GET /status?path=` |

A pipeline uses the same calls with its execution role, and needs no interactive session.

# 9. Questions

| # | Question | Leaning |
|---|---|---|
| CTLQ-012 | **Browser terminal.** A good terminal in the browser usually means a library such as xterm.js, and the Standard avoids heavy front-end dependencies. Is one terminal library acceptable for this one screen? | Accept one, recorded as a `DESIGN-nnn`, since the CLI is the product's main interface. |
| CTLQ-013 | **`copy` across accounts.** Should `copy` be allowed to produce a namespace in another account, which is how a person would clone an environment? | Allow it; commit check already catches name conflicts and placement problems. |
