AgentSkillsCN

enonic-cli

Enonic CLI(enonic命令)的参考手册。涵盖所有命令,包括项目创建、沙盒管理、数据导出/导入、快照、转储、应用生命周期、云端部署以及服务器管理。当用户需要运行Enonic命令、管理Enonic XP实例、部署应用,或使用Enonic CLI工具执行数据操作时,可使用此功能。

SKILL.md
--- frontmatter
name: enonic-cli
description: >
  Reference for the Enonic CLI (enonic command). Covers all commands including
  project creation, sandbox management, data export/import, snapshots, dumps,
  application lifecycle, cloud deployment, and server administration. Use when
  the user needs to run enonic commands, manage Enonic XP instances, deploy
  applications, or perform data operations with the Enonic CLI tool.
license: MIT
compatibility: Claude Code, Codex
allowed-tools: Bash(enonic:*) Read
metadata:
  author: enonic
  cli-version: "3.4.0"

Critical Rules

  1. Always use -f (force) flag. Every enonic command that accepts -f must include it. This prevents interactive prompts that block automation. The only exception is enonic cloud login (browser-based OAuth).

  2. Local vs remote commands:

    • Local commands run against files on disk — no auth needed: project *, sandbox *, create, dev, latest, upgrade, uninstall.
    • Remote commands talk to a running XP instance via management API — auth required: snapshot *, dump *, export, import, app *, repo *, cms *, auditlog *, vacuum.
    • system info uses the info port (2609) — no auth.
    • project install is a local build + remote install hybrid — auth required.
  3. Management port is 4848, not 8080. The CLI talks to the management API on port 4848. Port 8080 is the web/content API. Never use 8080 for CLI remote operations.

  4. .enonic fileproject create writes a .enonic file in the project root linking it to a sandbox. Commands like project deploy and dev use this automatically.

  5. Command aliases:

    • enonic create = simplified enonic project create
    • enonic dev = enonic project dev
    • sandbox ls = sandbox list
    • dump ls = dump list
    • snapshot ls = snapshot list
    • repo ls = repo list

Command Syntax

code
enonic <group> <action> [positional-args] [flags]

Groups: project, sandbox, snapshot, dump, app, repo, cms, system, auditlog, cloud. Standalone: create, dev, export, import, vacuum, latest, upgrade, uninstall.

Auth Flags (Remote Commands)

MethodFlagsWhen to use
Basic auth-a user:passwordXP < 7.15 or quick local testing
Service account key--cred-file path/to/key.jsonXP 7.15+ / CI/CD (preferred)
Mutual TLS--client-cert cert.pem --client-key key.pemZero-trust environments

Priority: flags → environment variables → no auth. See references/auth-and-env.md for details.

Environment Variables

VariableDefaultPurpose
ENONIC_CLI_REMOTE_URLlocalhost:4848Management API endpoint
ENONIC_CLI_REMOTE_USERBasic auth user
ENONIC_CLI_REMOTE_PASSBasic auth password
ENONIC_CLI_CRED_FILEService account key file path
ENONIC_CLI_CLIENT_KEYmTLS private key path
ENONIC_CLI_CLIENT_CERTmTLS client cert path
ENONIC_CLI_HTTP_PROXYHTTP proxy URL
ENONIC_CLI_HOME_PATH~/.enonicCLI home directory

Project Commands

All run from the project root directory.

CommandDescriptionKey flags
project create [name]Create project from starter-r <repo>, -s <sandbox>, -v <version>, --prod, --skip-start
project sandbox [name]Set project's default sandbox
project buildBuild via Gradle
project cleanClean build artifacts
project testRun tests via Gradle
project deploy [sandbox]Build + deploy to sandbox--prod, --debug, -c (continuous), --skip-start
project installBuild + install to running XPAuth flags required
project shellOpen shell with XP env vars setNo -f needed
project gradle [args]Run arbitrary Gradle tasksForwards all args to gradlew
project envExport JAVA_HOME + XP_HOMEUse with eval $(...)

enonic create [name] is a shorthand for project create with sensible defaults. enonic dev starts hot-reload mode (sandbox detached, watches source files, exit with Ctrl-C).

Sandbox Commands

CommandDescriptionKey flags
sandbox create [name]Create new sandbox-v <version>, -t <template>, --skip-template, --prod, --skip-start
sandbox listList all sandboxes
sandbox start [name]Start sandbox--prod, --debug, -d (detach), --http.port <port>
sandbox stopStop running sandbox
sandbox upgrade [name]Upgrade XP version (no downgrade)-v <version>
sandbox delete [name]Delete sandbox and data
sandbox copy [src] [dst]Clone sandbox

Only one sandbox can run at a time. Default start mode is development.

Data Commands

Export / Import

code
enonic export -t <name> --path <repo:branch:path> -f
enonic import -t <name> --path <repo:branch:path> -f

Path format: repo:branch:path — e.g. cms-repo:draft:/content/my-site

CommandKey flagsNotes
export-t <name>, --path, --skip-ids, --skip-versions, --dryAuth required. Output in $XP_HOME/data/export/
import-t <name>, --path, --xsl-source, --xsl-param key=val, --skip-ids, --skip-permissions, --dryAuth required

Snapshots

CommandKey flagsNotes
snapshot create-r <repo> (omit for all)Online operation, no downtime
snapshot lsShows all snapshots with status
snapshot restore--snap <name>, --repo <name>, --clean--clean deletes indices first
snapshot delete--snap <name>, -b <date>Date format: 2 Jan 06

All snapshot commands require auth.

Dumps

CommandKey flagsNotes
dump create-d <name>, --skip-versions, --max-version-age <days>, --max-versions <n>, --archiveFull system export
dump upgrade-d <name>Output: <name>_upgraded_<version>
dump lsList all dumps
dump load-d <name>, --upgrade, --archiveDeletes existing repos before loading

All dump commands require auth. Dumps are stored in $XP_HOME/data/dump/.

Warning: dump load replaces all existing repositories. Always create a backup first.

Server Commands

App

CommandDescriptionKey flags
app installInstall app on all nodes--url <address> or --file <path> (--file takes precedence)
app start <key>Start installed appApp key, e.g. com.enonic.myapp
app stop <key>Stop running appApp key

Repository

CommandDescriptionKey flags
repo reindexRebuild search indices-r <repo>, -b <branches> (comma-separated), -i (recreate indices)
repo readonly <bool>Toggle write protection-r <repo> (omit for all)
repo replicas <1-99>Set cluster replica count
repo listList repositories

CMS

CommandDescriptionKey flags
cms reprocessReprocess content metadata--path <branch:path>, --skip-children

Typically used after content migration. Path format is branch:path (no repo prefix).

System

CommandDescriptionNotes
system infoShow XP instance infoUses info port 2609, no auth needed

Audit Log

CommandDescriptionKey flags
auditlog cleanupRemove old audit records--age <ISO-8601> (e.g. P30D, P1DT12H)

Vacuum

code
enonic vacuum [-b] [-t <ISO-8601-duration>] -f

Purges node versions older than threshold (default P21D = 21 days). -b also removes unused binary blobs. Incompatible with snapshots older than the threshold.

Cloud Commands

CommandDescriptionNotes
cloud loginLogin via browser OAuthInteractive — no -f flag. Supports -qr for mobile.
cloud logoutLog out
cloud app installInstall JAR to cloud-j <jar-path> (default: ./build/libs/*.jar), -t <timeout>, -y (skip confirm)

Cloud login is the only interactive command. It opens a browser for OAuth. Cannot be automated.

CLI Maintenance

CommandDescription
enonic latestShow latest available CLI version
enonic upgradeUpgrade CLI to latest version
enonic uninstallRemove CLI from system

File Locations

ItemPath
CLI home~/.enonic/
Sandboxes~/.enonic/sandboxes/<name>/
Cloud auth~/.enonic/cloud/
Dumps$XP_HOME/data/dump/
Exports$XP_HOME/data/export/
Snapshots$XP_HOME/snapshots/
Project config<project-root>/.enonic

Common Patterns

bash
# Create project with specific starter and sandbox
enonic project create my-app -r starter-vanilla -s my-sandbox -f

# Build and install to remote server
ENONIC_CLI_REMOTE_URL="server:4848" enonic project install -a su:password -f

# Export content tree
enonic export -t site-backup --path cms-repo:draft:/content/my-site -a su:password -f

# Full backup with dump
enonic dump create -d nightly --skip-versions -a su:password -f

# Reindex repository after schema changes
enonic repo reindex -r cms-repo -b draft,master -i -a su:password -f

# Vacuum + audit log cleanup (maintenance)
enonic vacuum -b -t P30D -a su:password -f
enonic auditlog cleanup --age P90D -a su:password -f

Reference Files

FileContent
references/commands.mdFull flag tables for every command
references/auth-and-env.mdAuth methods, env vars, ports, CI/CD patterns
references/workflows.mdMulti-step recipes for common operations