Skip to content

CLI

The tmts CLI provides a command-line interface for interacting with the API server. It is published as the @template-monorepo-ts/cli workspace package and produces two build artefacts:

  • Node module (dist/index.js) — usable as bun run dist/index.js
  • Self-contained binary (bin/tmts) — zero-dependency native executable built with bun build --compile

Installation

From source

sh
# Build the binary
cd packages/cli
bun run build

# Add to PATH (example)
cp bin/tmts ~/.local/bin/tmts
sh
bun link @template-monorepo-ts/cli

Configuration

tmts resolves its configuration from three sources, in priority order (highest wins):

  1. CLI flags--server, --token, --key, --output
  2. Environment variablesTMTS_SERVER_URL, TMTS_TOKEN, TMTS_API_KEY, TMTS_OUTPUT
  3. Config file~/.config/tmts/config.json

The server URL is required for every command. If it cannot be resolved from any source, the CLI exits with an error message.

Config file

The config file is stored at ~/.config/tmts/config.json and contains the following keys:

KeyTypeDescription
serverUrlstringAPI server base URL
tokenstringBearer token (from auth login)
apiKeystringAPI key alternative to token
output"table" | "json"Default output format

Quick setup

sh
# Point the CLI at your running API instance
tmts config set serverUrl http://localhost:3000

# Authenticate
tmts auth login --email admin@example.com --password secret

Global flags

These flags are accepted by every command and override environment variables and the config file.

FlagEnv varDescription
--serverTMTS_SERVER_URLAPI server URL
--tokenTMTS_TOKENBearer token for authentication
--keyTMTS_API_KEYAPI key for authentication
--outputTMTS_OUTPUTOutput format: table (default) or json

Output formats

All commands support two output formats controlled by --output:

  • table (default) — human-readable tabular output
  • json — machine-readable JSON, useful for piping into jq or scripts
sh
tmts projects list --output json | jq '.[].name'

Command reference

tmts system

Commands that query the API server's operational status.

sh
tmts system <subcommand> [flags]
SubcommandDescription
versionShow the API server version
healthCheck API server health
readyCheck API server readiness
liveCheck API server liveness

Examples

sh
tmts system version
tmts system health
tmts system ready --output json

tmts auth

Commands for authenticating with the API server.

sh
tmts auth <subcommand> [flags]
SubcommandDescription
loginLogin with email/password or store an API key
logoutClear stored credentials from config
whoamiShow the currently authenticated user

tmts auth login

sh
tmts auth login [--email <email>] [--password <password>] [--key <api-key>]

Two authentication modes are supported:

  • Email/password — exchanges credentials for a bearer token via BetterAuth, then saves the token to the config file.
  • API key (--key) — stores the provided API key in the config file directly (no network request needed).

Examples

sh
# Interactive login (saves bearer token)
tmts auth login --email admin@example.com --password secret

# Store an API key
tmts auth login --key sk_live_abc123

tmts auth logout

Removes token and apiKey from the config file.

sh
tmts auth logout

tmts auth whoami

Calls the API's GET /session endpoint and prints the current session.

sh
tmts auth whoami
tmts auth whoami --output json

tmts projects

CRUD commands for managing projects.

sh
tmts projects <subcommand> [flags]
SubcommandDescription
listList all projects
getGet a project by ID
createCreate a new project
updateUpdate an existing project
deleteDelete a project

tmts projects list

sh
tmts projects list [--output json]

tmts projects get <id>

sh
tmts projects get 01J9Z3H2X5K7M8N4P6Q0R1S2T3

tmts projects create

sh
tmts projects create --name <name> [--description <description>]
sh
tmts projects create --name "My Project" --description "A sample project"

tmts projects update <id>

sh
tmts projects update <id> [--name <name>] [--description <description>]
sh
tmts projects update 01J9Z3H2X5K7M8N4P6Q0R1S2T3 --name "Renamed"

tmts projects delete <id>

sh
tmts projects delete 01J9Z3H2X5K7M8N4P6Q0R1S2T3

tmts config

Commands for reading and writing the local CLI config file (~/.config/tmts/config.json).

sh
tmts config <subcommand>
SubcommandDescription
set <key> <value>Set a config key to a value
get <key>Print the value of a config key
listList all config keys and values
delete <key>Remove a config key

Valid keys: serverUrl, token, apiKey, output.

Token and API key values are truncated (first 8 characters + ...) when listed for security.

Examples

sh
# Initial setup
tmts config set serverUrl https://api.example.com
tmts config set output json

# Inspect
tmts config list
tmts config get serverUrl

# Remove a stored token
tmts config delete token