CLI Basics

The leadcms command‑line interface provides a set of tools to initialise your project, synchronise content, generate deployment templates and more. All commands can be run through your package manager if the SDK is installed locally or globally. Use --help on any command to see its options.

Core commands

  • init – Interactive setup wizard. Connects to your LeadCMS instance, detects languages, configures directories and creates a .env file. See SDK Setup for details.
  • login – Authenticates the CLI for write access. Opens a browser for device authentication (v1.2.88+) or guides you through manual token extraction on older versions. In multi‑remote setups use -r / --remote to authenticate a specific CMS instance.
  • pull – Runs a full pull for all supported entities (settings, content, media, comments, email templates). Uses incremental sync for fast updates on subsequent runs.
  • pull-content – Downloads content files (MDX/JSON).
  • pull-media – Downloads only media files into your configured media directory. Run this after updating images in the CMS.
  • pull-comments – Downloads only comments. Use when you have user feedback but no content changes.
  • pull-email-templates / pull-settings – Pull email templates or tracked settings only (requires API key).
  • status – Unified status for content, media, email templates and settings.
  • status-content, status-media, status-email-templates, status-settings – Scoped status commands for one entity type.
  • push – Runs a full push flow (settings, content, email templates, media).
  • push-content, push-media, push-email-templates, push-settings – Push only one entity type.
  • watch – Watches your local files and pulls remote updates on the fly. Use this to develop a live preview server that reflects changes in both directions. See the Preview Setup and Deploy guides for configuration.
  • remote – Manage named remotes (CMS instances). Subcommands: list, add, remove, show, set-default, reset. See Multi‑Remote Environments for details.
  • docker – Generates Docker files and templates for deploying your static site and preview environment. Produces production and preview Dockerfiles, nginx configuration and helper scripts.
  • generate-env – Generates public/__env.js from NEXT_PUBLIC_* variables.
  • version/-v/--version – Displays the installed SDK version.
  • help – Shows general help or command‑specific usage information.

Run any command with --help to see its options. For example:

pnpm exec leadcms push --help

Outputs detailed descriptions of parameters such as --dry-run, --force, --reset, --delete, --slug, and --id.

Working with remotes

In multi‑remote setups, most auth and sync commands accept --remote / -r:

# Authenticate against a specific remote
npx leadcms login -r dev

# Pull from a non-default remote
npx leadcms pull -r prod

# Compare local files against one remote
npx leadcms status -r dev

# Push to a chosen remote
npx leadcms push -r prod

When you omit -r, the SDK uses the configured defaultRemote.

Workflow overview

In most projects your CLI workflow follows this pattern:

  1. Initialise – Run leadcms init once per project to create a .env file and optional config file.
  2. Authenticate – Run leadcms login if you need to push changes back to the CMS.
  3. Pull – Use leadcms pull for a full sync, or scoped pull commands (pull-content, pull-media, pull-comments, pull-email-templates, pull-settings) when needed.
  4. Work offline – Edit MDX/JSON files, add new content, update slugs and structure using your editor.
  5. Check status – Run leadcms status for a unified view, or leadcms status-content --preview for a detailed content diff.
  6. Push – Run leadcms push to apply all local updates, or a scoped push command for a single entity type. Use --dry-run, --delete, --force, and -r as needed.

Common CLI Commands:

# Initialize project
pnpm exec leadcms init

# Authenticate for write access
pnpm exec leadcms login

# Pull all supported entities
pnpm exec leadcms pull

# Check status before pushing
pnpm exec leadcms status

# Push local changes to CMS
pnpm exec leadcms push

Additional commands like watch and docker support previewing changes in real time and creating deployment artefacts. See the Preview Setup and deployment guides for more details.

Next steps

Now that you understand the CLI basics, dive deeper into specific operations: