CLI Reference
Commands
Section titled “Commands”horsies worker
Section titled “horsies worker”Start a task worker.
horsies worker <module> [OPTIONS]Arguments:
| Argument | Description |
|---|---|
module | Python file or dotted module path containing Horsies instance |
Options:
| Option | Default | Description |
|---|---|---|
--processes N | 1 | Number of worker processes |
--loglevel LEVEL | INFO | DEBUG, INFO, WARNING, ERROR, CRITICAL |
--max-claim-batch N | 2 | Max claims per queue per pass |
--max-claim-per-worker N | 0 | Max total claimed tasks (0=auto) |
Examples:
# Basic worker (module:app format, recommended)horsies worker myapp.instance:app
# With 8 processeshorsies worker myapp.instance:app --processes=8
# Debug logginghorsies worker myapp.instance:app --loglevel=DEBUG
# Production settingshorsies worker myapp.instance:app --processes=8 --max-claim-batch=4 --loglevel=WARNING
# Using file path (also supported)horsies worker app/configs/instance.py:apphorsies scheduler
Section titled “horsies scheduler”Start the scheduler service.
horsies scheduler <module> [OPTIONS]Arguments:
| Argument | Description |
|---|---|
module | Python file or dotted module path containing Horsies instance |
Options:
| Option | Default | Description |
|---|---|---|
--loglevel LEVEL | INFO | DEBUG, INFO, WARNING, ERROR, CRITICAL |
Examples:
# Basic schedulerhorsies scheduler myapp.instance:app
# Debug logginghorsies scheduler myapp.instance:app --loglevel=DEBUGhorsies check
Section titled “horsies check”Validate configuration, task registration, workflow structure, and optionally broker connectivity without starting services. Runs the same validation that workers and schedulers perform at startup.
For details on validation phases, @app.workflow_builder, the guarantee model, and CI usage, see Startup Validation.
horsies check <module> [OPTIONS]Arguments:
| Argument | Description |
|---|---|
module | Dotted module path or file path containing Horsies instance |
Options:
| Option | Default | Description |
|---|---|---|
--loglevel LEVEL | WARNING | DEBUG, INFO, WARNING, ERROR, CRITICAL |
--live | false | Also test broker connectivity (SELECT 1) |
Examples:
# Validate tasks, config, and workflowshorsies check myapp.instance:app
# Include broker connectivity checkhorsies check myapp.instance:app --livehorsies get-docs
Section titled “horsies get-docs”Fetch the full documentation locally as markdown files. Useful for AI agents (Claude Code, Cursor, Copilot, etc.) that need to read docs without web requests.
horsies get-docs [OPTIONS]Options:
| Option | Default | Description |
|---|---|---|
--output DIR | .horsies-docs | Output directory |
Examples:
# Fetch docs to default locationhorsies get-docs
# Custom output directoryhorsies get-docs --output my-docs/
# Update existing docs (idempotent — overwrites cleanly)horsies get-docsUses git sparse checkout when git is available, falls back to tarball download otherwise. No app instance or database connection required.
Agent Skills (Repository)
Section titled “Agent Skills (Repository)”If you are using an AI coding agent from a source checkout, Horsies also ships guidance-oriented skill files in:
horsies/.agents/skills/
Available files:
SKILL.md— quick orientation and routingtasks.md— task authoring, send/retry, serialization, error handlingworkflows.md— DAG construction, handles, failure semantics, validationconfigs.md— configuration, scheduling, CLI checks, environment variables
These files are documentation-focused (no bundled scripts) and are intended for on-demand loading by agents that support markdown skill files.
Module Formats
Section titled “Module Formats”The recommended format is a dotted module path with an explicit variable name:
horsies worker myapp.instance:appWhere app is the variable name of your Horsies instance in the module.
File paths are also supported:
horsies worker app/configs/instance.py:appDo not mix dotted module notation with a .py extension (e.g., myapp.instance.py). The CLI will reject this with a helpful error.
If the module contains exactly one Horsies instance, the :name suffix can be omitted — the CLI will auto-discover it. If multiple instances exist, the suffix is required.
Module Discovery
Section titled “Module Discovery”from horsies import Horsies, AppConfig, PostgresConfig
app = Horsies(AppConfig(...)) # Auto-discovered
@app.task("my_task")def my_task(): ...
app.discover_tasks(["myapp.tasks"])Requirements:
- Module must have exactly one
Horsiesinstance (or use:namesuffix) - Instance can have any variable name
Process Signals
Section titled “Process Signals”Both commands handle graceful shutdown:
| Signal | Behavior |
|---|---|
SIGTERM | Graceful shutdown |
SIGINT (Ctrl+C) | Graceful shutdown |
Workers wait for running tasks to complete before exiting.
Exit Codes
Section titled “Exit Codes”| Code | Meaning |
|---|---|
| 0 | Clean shutdown |
| 1 | Error (check logs) |
Environment Variables
Section titled “Environment Variables”DATABASE_URL=postgresql+psycopg://... horsies worker myapp.instance:appUse in config:
import os
config = AppConfig( broker=PostgresConfig(database_url=os.environ["DATABASE_URL"]),)Deployment
Section titled “Deployment”Systemd
Section titled “Systemd”[Unit]Description=Horsies WorkerAfter=postgresql.service
[Service]Type=simpleUser=appWorkingDirectory=/appExecStart=/usr/bin/horsies worker myapp.instance:app --processes=8Restart=always
[Install]WantedBy=multi-user.targetDocker
Section titled “Docker”FROM python:3.13
WORKDIR /appCOPY . .RUN pip install horsies
CMD ["horsies", "worker", "myapp.instance:app", "--processes=8"]Procfile
Section titled “Procfile”worker: horsies worker myapp.instance:app --processes=8scheduler: horsies scheduler myapp.instance:app