Skip to content

Creating Commands

Commands are defined as YAML or JSON files validated against a JSON Schema. This guide covers all the fields available in a command spec.

Terminal window
my cli init deploy

This creates deploy/command.yaml with a starter template. Use --force to overwrite an existing file.

Every command spec has these top-level fields:

command.yaml
schemaVersion: 1
kind: command
metadata:
name: deploy
slug: deploy
description: Deploy application to an environment
tags: [ops, deploy]
args:
positional:
- name: environment
description: Target environment
required: true
flags:
- name: dry-run
short: n
type: bool
description: Preview without applying
defaults:
shell: /bin/bash
timeout: 5m
env:
APP_NAME: myapp
steps:
- name: validate
run:
- echo "Deploying to {{.args.environment}}..."
- name: deploy
run:
- ./deploy.sh {{.args.environment}}
policy:
requireConfirmation: true
allowedExecutables: [/bin/bash, /bin/echo]
FieldRequiredDescription
nameYesHuman-readable name
slugYesURL-safe identifier. Must match ^[a-z][a-z0-9-]*$
descriptionNoShort description of what the command does
tagsNoArray of tags for organization
aliasesNoAlternative slugs for the command

Specify required binaries that are checked before execution:

dependencies:
- curl
- jq

If any dependency is missing, the command will fail with a helpful error message before running any steps.

Positional args are parsed in order from the command line:

args:
positional:
- name: environment
description: Target environment
required: true
- name: version
description: Version to deploy
required: false

Named flags with optional short aliases:

args:
flags:
- name: verbose
short: v
type: bool
description: Enable verbose output
- name: replicas
type: int
default: "3"
description: Number of replicas
- name: region
type: string
default: us-east-1
description: AWS region

Supported flag types: string (default), bool, int.

Set defaults that apply to all steps:

defaults:
shell: /bin/bash # Default shell for all steps
timeout: 30s # Default timeout for all steps
env: # Default env vars for all steps
APP_NAME: myapp

Each step runs one or more shell commands:

steps:
- name: build
run:
- npm ci
- npm run build
timeout: 2m
env:
NODE_ENV: production
- name: deploy
run:
- ./deploy.sh
shell: /bin/bash
continueOnError: false
FieldRequiredDescription
nameYesStep identifier
runYesArray of shell commands to execute
envNoStep-specific environment variables
timeoutNoOverride the default timeout
shellNoOverride the default shell
continueOnErrorNoIf true, continue to next step on failure

Control execution behavior:

policy:
requireConfirmation: true
allowedExecutables: [/bin/bash, /usr/bin/curl]
  • requireConfirmation — prompts the user for confirmation before running
  • allowedExecutables — restricts which binaries can be invoked by steps

You can run a spec file directly without pushing:

Terminal window
my cli run -f command.yaml -- production