---
title: "CLI"
description: "Shelve CLI is a command-line interface designed for the Shelve app."
canonical_url: "https://shelve.cloud/docs/cli"
---
# CLI

> Shelve CLI is a command-line interface designed for the Shelve app.

The CLI is the primary way to sync secrets between your terminal and [Shelve](https://shelve.cloud). Use it to **inject** variables at runtime (`shelve run`), **push** local changes upstream, or **pull** secrets to disk when you really need a `.env` file.

<callout type="tip">

New to AI agents or CI? Start with [Agents & automation](https://shelve.cloud/docs/cli/agents-automation) and install the published skill: `npx skills add https://shelve.cloud`

</callout>

## Installation

Install `@shelve/cli` in your project or globally. See the [Quickstart](https://shelve.cloud/docs/getting-started/quickstart) guide.

```bash [terminal]
pnpm add -D @shelve/cli
```

## Command overview

| Command | Description |
| --- | --- |
| [`run`](https://shelve.cloud/docs/cli/run) | Inject secrets into a child process (preferred) |
| [`init`](https://shelve.cloud/docs/cli/init) | Agent-safe ignore files + `.gitignore` block |
| [`login`](https://shelve.cloud/docs/cli/login-logout) / [`logout`](https://shelve.cloud/docs/cli/login-logout) | Manage stored credentials |
| [`me`](https://shelve.cloud/docs/cli/login-logout) | Show the logged-in user |
| [`push`](https://shelve.cloud/docs/cli/push-pull) / [`pull`](https://shelve.cloud/docs/cli/push-pull) | Sync secrets with Shelve |
| [`diff`](https://shelve.cloud/docs/cli/sync-policies) / [`sync`](https://shelve.cloud/docs/cli/sync-policies) | Compare or apply sync policy |
| [`create`](https://shelve.cloud/docs/cli/create) | Create a project + `shelve.json` |
| [`config`](https://shelve.cloud/docs/cli/config) | Show merged configuration |
| [`generate`](https://shelve.cloud/docs/cli/generate) | Generate `.env.example` or ESLint config |
| [`upgrade`](https://shelve.cloud/docs/cli/upgrade) | Update the CLI package |
| [`doctor`](https://shelve.cloud/docs/cli/troubleshooting) | Validate config, auth, API, and cache |
| [`agents-automation`](https://shelve.cloud/docs/cli/agents-automation) | Global flags, JSON output, CI & agents |
| [`troubleshooting`](https://shelve.cloud/docs/cli/troubleshooting) | Error codes and common fixes |

## Global flags

Available on **every** command (before or after the subcommand):

| Flag | Alias | Description |
| --- | --- | --- |
| `--json` |  | Machine-readable stdout; structured errors on stderr |
| `--quiet` | `-q` | No spinners or clack UI |
| `--yes` | `-y` | Skip confirmation prompts |
| `--non-interactive` |  | Fail instead of prompting |
| `--debug` |  | Verbose logs (`SHELVE_DEBUG=1`) |

## Configuration

Configuration is loaded from the current working directory. Supported filenames: `shelve.json`, `shelve.config.json`, `.shelverc.json`. If none exists and a command requires config, the CLI can create `shelve.json` interactively (or fail in non-interactive mode).

JSON Schema: [shelve.cloud/schema.json](https://shelve.cloud/schema.json)

```json [shelve.json]
{
  "$schema": "https://shelve.cloud/schema.json",
  "slug": "nuxtlabs",
  "project": "@nuxt/ui",
  "defaultEnv": "development",
  "confirmChanges": false,
  "autoCreateProject": true
}
```

### Monorepo support

Shelve detects monorepo roots and **merges** the root `shelve.json` with the local one. Put the settings every package shares in the root file and the `project` in each package:

<code-tree default-value="shelve.json">

```json [apps/app/shelve.json]
{
  "project": "@nuxt/app"
}
```

```json [apps/api/shelve.json]
{
  "project": "@nuxt/api"
}
```

```json [shelve.json]
{
  "slug": "nuxtlabs",
  "defaultEnv": "development"
}
```

</code-tree>

The package config wins wherever the two disagree.

#### Running from the root

`push`, `pull`, `diff` and `sync` run once per package that has its own config file:

```bash [terminal]
shelve pull
```

That writes `apps/app/.env` and `apps/api/.env`. Packages without a config file are skipped, as is the root itself.

Target a single package with `--path`:

```bash [terminal]
shelve pull --path apps/app
```

To treat the root as a project of its own instead, give it a `project` in the root `shelve.json`. A bare command then runs in the root instead of fanning out. `--path` still targets a single package.

Inside a package, commands behave as they always have and only touch that package:

```bash [apps/app/terminal]
shelve pull
```

`run` is the exception: it executes your command in the current directory and never fans out.

## Configuration options

| Option | Type | Default | Description |
| --- | --- | --- | --- |
| `project` | `string` | `SHELVE_PROJECT` or nearest `package.json` name | Project name |
| `slug` | `string` | `SHELVE_TEAM_SLUG` | Team slug |
| `url` | `string` | `https://app.shelve.cloud` | Shelve instance URL (`https://`, or `http://` for localhost only) |
| `defaultEnv` | `string` | — | Default environment for `run`, `push`, `pull`, `diff`, `sync` |
| `confirmChanges` | `boolean` | `false` | Confirm before push/pull writes |
| `envFileName` | `string` | `.env` | Local env file name |
| `autoUppercase` | `boolean` | `true` | Uppercase keys on push |
| `autoCreateProject` | `boolean` | `true` | Create project if missing |
| `sync` | `object` | — | [Sync policies](https://shelve.cloud/docs/cli/sync-policies) (per-env push/pull rules) |

## Environment variables

| Variable | Description |
| --- | --- |
| `SHELVE_PROJECT` | Project name |
| `SHELVE_TEAM_SLUG` | Team slug |
| `SHELVE_TOKEN` | API key |
| `SHELVE_URL` | Shelve instance URL |
| `SHELVE_DEFAULT_ENV` | Default environment |
| `SHELVE_DEBUG=1` | Enable debug logging |
| `AI_AGENT` | Force AI-agent shell detection |

These are read from your shell environment only: the CLI does not load the project's `.env` file.

Credentials are stored in the **OS keychain** when available, with an XDG file fallback (`~/.config/.shelve`, mode `0600`). A stored API key is only sent to the Shelve URL it was issued for, so a `url` in a repository's `shelve.json` never receives your stored key for another server. `SHELVE_TOKEN` is different: it is sent to whichever `url` the configuration resolves, including one from a repository's `shelve.json`, so only set it for repositories you trust. A `token` key in `shelve.json` is ignored.


## Sitemap

See the full [sitemap](https://shelve.cloud/sitemap.md) for all pages.
