Singularity
API Reference

CLI Reference

Complete command reference for the three Singularity CLI tools — services, tasks, and scripts — plus app.py startup arguments.

Singularity ships three CLI entry points defined in pyproject.toml under [project.scripts]:

[project.scripts]
services = "cli.services:main"
tasks = "cli.tasks:main"
scripts = "cli.scripts:main"

After installing with uv sync, these commands are available directly in your shell.


services CLI

Service Management Utility. Discover, create, delete, enable, inspect, validate, and visualize services.

services list

List all discovered services.

FlagShortTypeDefaultDescription
--detailed-dflagfalseShow detailed information (path, endpoint, type, RPC status, methods)
--json-jflagfalseOutput as JSON
--all-aflagfalseInclude disabled and core services
services list
services list --detailed --all
services list --json

services info

Show detailed information about a specific service.

ArgumentTypeRequiredDescription
SERVICE_NAMEstrYesService name or path (e.g. payments or v1/payments)
services info payments
services info v1/auth

Output includes: path, module, API endpoint, class name, status (Active/DISABLED), docstring, HTTP methods, exposed routes, RPC attributes, blacklist, webhook events.

services create

Create a new service with boilerplate code.

ArgumentTypeRequiredDescription
SERVICE_NAMEstrYesService name or nested path (e.g. users or v1/users)
FlagShortTypeDefaultDescription
--description-dstr""Description of the service (used in docstring)
--template-tchoicecrudBase template: crud, minimal, empty, or webhook
--methods-mstr(none)Comma-separated HTTP methods (overrides template default). Valid: get, post, put, delete, patch.
--rpcflagfalseEnable RPC exposure (rpc_exposed = True)
--websocket / --wsflagfalseAdd WebSocket support (ws=connect endpoint)
--authflagfalseAdd JWT authentication (replaces GET with authenticated version)
--dbflagfalseAdd database session dependency imports
--overwrite-iflagfalseOverwrite existing service if it exists
singularity generate service users
singularity generate service users -d "User management service"
singularity generate service v1/auth --template minimal --auth
singularity generate service billing --rpc --methods get,post
singularity generate service chat --websocket
singularity generate service stripe_hooks --template webhook
singularity generate service v1/github_hooks --template webhook --db

services delete

Delete or disable a service. Requires either --soft or --hard.

ArgumentTypeRequiredDescription
SERVICE_NAMEstrYesService name or path
FlagShortTypeDefaultDescription
--softflagfalseDisable service without deleting files (adds to .services_disabled)
--hardflagfalsePermanently delete the service directory
--force-fflagfalseSkip confirmation prompt (with --hard only)
services delete old_service --soft
services delete old_service --hard
services delete old_service --hard --force

--soft and --hard are mutually exclusive. You must specify exactly one.

services enable

Re-enable a previously soft-deleted (disabled) service.

ArgumentTypeRequiredDescription
SERVICE_NAMEstrYesService name or path
services enable old_service

After enabling, restart the server to load the service.

services validate

Validate a service name and preview what would be created.

ArgumentTypeRequiredDescription
SERVICE_NAMEstrYesService name or path to validate
FlagShortTypeDefaultDescription
--template-tchoicecrudBase template: crud, minimal, empty, or webhook
--rpcflagfalsePreview with RPC exposure
--websocket / --wsflagfalsePreview with WebSocket support
--authflagfalsePreview with JWT authentication
services validate my_new_service
services validate v1/auth --template minimal --auth
services validate stripe_hooks --template webhook

Output includes: name, class name, directory, service file path, API endpoint, template, methods, RPC, acquire, websocket, auth, and the exact command to run.

services graph

Show the service dependency graph. Detects RPC descriptors, remote Microservice descriptors, and blacklist declarations.

FlagShortTypeDefaultDescription
--json-jflagfalseOutput as JSON
--dotflagfalseOutput as DOT (Graphviz) format
--all-aflagfalseInclude disabled and core services
services graph
services graph --json
services graph --dot
services graph --dot | dot -Tpng -o deps.png

Default output (ASCII): Shows Local RPC edges, Remote (cross-deployment) edges, Blacklisted entries, and Isolated services.

tasks CLI

Task Management Utility. Manage, list, run, and serve background tasks.

tasks list

List all available background tasks.

(no flags)

tasks list

Output: Table with columns: Name, Description, Params (count).

tasks info

Show detailed info and parameters for a task.

ArgumentTypeRequiredDescription
TASK_NAMEstrYesThe unique task identifier
tasks info send_email

Output includes: task name, description, parameter table (name, type, required, default), and config (notifications, max retries, retry delay, time limit).

tasks create

Create a new task file with boilerplate.

ArgumentTypeRequiredDescription
TASK_NAMEstrYesTask name in snake_case (e.g. send_email)
FlagShortTypeDefaultDescription
--description-dstr""Description of the task
--overwrite-iflagfalseOverwrite existing task file
singularity generate task send_email
singularity generate task send_email -d "Send transactional emails"

tasks run

Trigger a task manually.

ArgumentTypeRequiredDescription
TASK_NAMEstrYesThe unique task identifier
ARGSstr...NoPositional arguments for the task
FlagShortTypeDefaultDescription
--kwargs-kstr(none)JSON dictionary of keyword arguments
--countdown-cint(none)Delay in seconds before the task starts
tasks run send_email --kwargs '{"to": "user@example.com", "subject": "Hello"}'
tasks run process_order -k '{"order_id": "123"}' --countdown 30

tasks result

Check the status and result of a task.

ArgumentTypeRequiredDescription
TASK_IDstrYesThe Celery task ID (returned by tasks run)
tasks result abc123-def456-789

Output: Task ID, State (PENDING, STARTED, SUCCESS, FAILURE, REVOKED), and Result/Error.

tasks worker

Start a Celery worker instance.

FlagShortTypeDefaultDescription
--concurrencyint2Number of concurrent worker processes
--loglevelchoiceinfoLogging level: debug, info, warning, error, critical
--queuesstr"celery"Comma-separated list of queues to consume from
--hostnamestr(auto)Set custom hostname for the worker
--max-tasks-per-childint1000Max tasks per child process before recycling
--prefetch-multiplierint1Prefetch multiplier
--poolchoicethreadsPool implementation: prefork, eventlet, gevent, threads, solo
--autoscalestr(none)Enable autoscaling (format: max,min)
--beatflagfalseEnable Celery Beat scheduler
tasks worker
tasks worker --concurrency 8 --pool gevent
tasks worker --queues celery,emails --loglevel debug
tasks worker --autoscale 10,3 --beat

When --pool gevent is used, gevent monkey patching is applied before any other imports. On Windows, --beat starts Celery Beat as a separate subprocess.

scripts CLI

Script Management Utility. Manages database migrations, data patches, and maintenance scripts.

scripts list

List all available executable scripts.

FlagTypeDefaultDescription
--detailed / --simpleflag--detailedShow detailed or simple information
scripts list
scripts list --simple

scripts create

Create a new script with boilerplate code.

ArgumentTypeRequiredDescription
SCRIPT_NAMEstrYesScript name in snake_case
FlagShortTypeDefaultDescription
--description-dstr""Description of what the script does
--overwrite-iflagfalseOverwrite existing script if it exists
singularity generate script seed_data -d "Seed initial data"
singularity generate script add_user_roles -d "Add default user roles"

scripts run

Run an existing script by name or ID.

ArgumentTypeRequiredDefaultDescription
IDENTIFIERstrNo(none)Script name (e.g. my_task) or numeric ID. If omitted, lists all scripts.
COMMANDchoiceNorunAction to perform: run, rollback, or status
scripts run seed_data
scripts run seed_data rollback
scripts run seed_data status
scripts run 1 status

scripts history

Show execution history of scripts from the database.

(no flags)

scripts history

scripts sync-hashes

Update script content hashes in the database. Used when script files have been edited and you want to mark them for re-execution.

(no flags)

scripts sync-hashes

scripts startup

Run all auto-run scripts (used during application startup).

(no flags)

scripts startup

app.py CLI Arguments

The application entry point app.py accepts the following command-line arguments via argparse:

uv run python app.py [OPTIONS]
ArgumentTypeDefaultDescription
--devflagfalseRun in development mode with Uvicorn (auto-reload enabled). Excludes scripts/*, servers/*, tests/*, *junk/* from reload watching.
--hoststr"0.0.0.0"Host to bind the server to
--portint8000Port to bind the server to
--workersint4Number of Gunicorn workers (production mode only)
--timeoutint600Worker timeout in seconds (production mode only)
--no-heartbeatflagfalseDisable the RPC heartbeat loop (sets SINGULARITY_NO_HEARTBEAT=1)

Development Mode

uv run python app.py --dev
uv run python app.py --dev --port 3000
uv run python app.py --dev --no-heartbeat

Uses Uvicorn with reload=True. Ideal for local development.

Production Mode

uv run python app.py --host 0.0.0.0 --port 8000 --workers 4
uv run python app.py --workers 8 --timeout 300

Uses Gunicorn with UvicornWorker, keep-alive=10, and graceful-timeout=60.

The --no-heartbeat flag is useful during development or testing when you do not have Redis running but still want the app to start without RPC heartbeat errors.