sloth CLI Getting Started
The sloth CLI manages component contract workflows.
Scope
The CLI is focused on component contracts only.
- in scope: list, inspect, add, verify, push component contracts
- out of scope: page content authoring and runtime page editing
Initialize Workspace
Run init from your project root:
sloth init
This creates a local workspace:
.sloth/
config.yaml
contracts/
sets/
manifests/
lock.json
Configure Host Profiles
The CLI resolves configuration with explicit precedence:
- YAML config from
.sloth/config.yaml(highest priority) - Environment variables (when YAML values missing)
- Built-in defaults (fallback)
- Runtime flags override all (explicit override only)
YAML Configuration
Set host URL and token in .sloth/config.yaml:
# yaml-language-server: $schema=https://phuhh98.github.io/sloth/schemas/cli-config/0.0.1/schema.json
currentProfile: default
profiles:
default:
host: http://localhost:1337
authorizationToken: ""
production:
host: https://api.production.example.com
authorizationToken: ""
Schema reference URL:
Use profile selection:
sloth contracts inspect --profile default
sloth contracts push --profile production
Environment Variable Fallback
If YAML config is missing or incomplete, the CLI checks these environment variables:
SLOTH_CONFIG: path to config file (default:.sloth/config.yaml)SLOTH_PROFILE: profile name (default:default)SLOTH_HOST: host URL (default:http://localhost:1337)SLOTH_AUTHORIZATION_TOKENorSLOTH_TOKEN: authorization token
Example in CI/CD:
export SLOTH_HOST=https://api.production.example.com
export SLOTH_AUTHORIZATION_TOKEN=secret-token-xyz
sloth contracts push --version 0.0.1
Runtime Flag Override
Use flags to override YAML and ENV values explicitly:
sloth contracts inspect --host https://custom-host:1337 --authorization-token custom-token
Supported flags:
--config: config file path--profile: profile name--host -H: host URL override--authorization-token -T: token override
Typical Workflow
- Inspect host status.
sloth contracts inspect --format table
- List available contracts for a plugin version.
sloth contracts ls --version 0.0.1 --format table
- Add contracts locally.
sloth contracts add --all --version 0.0.1
- Verify local contract files.
sloth contracts verify --file .sloth/contracts/hero-banner@0.0.1.json --version 0.0.1
- Push verified contracts.
sloth contracts push --version 0.0.1 --dry-run
sloth contracts push --version 0.0.1
Next
- See CLI Command Reference for all commands and flags.
- See CLI Validation and Testing for mock coverage and host verification strategy.
- See CLI Distribution and Release for cross-platform build and npm packaging.