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.envfile. 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/--remoteto 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– Generatespublic/__env.jsfromNEXT_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:
- Initialise – Run
leadcms initonce per project to create a.envfile and optional config file. - Authenticate – Run
leadcms loginif you need to push changes back to the CMS. - Pull – Use
leadcms pullfor a full sync, or scoped pull commands (pull-content,pull-media,pull-comments,pull-email-templates,pull-settings) when needed. - Work offline – Edit MDX/JSON files, add new content, update slugs and structure using your editor.
- Check status – Run
leadcms statusfor a unified view, orleadcms status-content --previewfor a detailed content diff. - Push – Run
leadcms pushto apply all local updates, or a scoped push command for a single entity type. Use--dry-run,--delete,--force, and-ras 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:
Pull Content
Master content synchronization with incremental pulls
Push Content
Learn how to push local changes back to LeadCMS safely
Email Templates
Pull, inspect, and push email templates
Settings Sync
Manage tracked settings with scoped commands
Media Sync
Use scoped media pull, status, and push workflows
Reset & Merge
Understand scoped reset and three-way merge behavior
Generate Env
Create runtime __env.js from NEXT_PUBLIC_ variables
Multi‑Remote
Work with multiple CMS instances from a single workspace