Getting started with the CLI
The luna CLI is Luna's developer tool for running operational commands against the platform — copying data between environments, seeding databases, running migrations, backfilling records, and similar recurring tasks. Set it up once and use it for the rest of your Luna work.
What it's for
Commands are generic and reusable, modelled on the AWS CLI (luna <command> <subcommand> [options]) rather than one-off scripts. It's a Node/TypeScript project built with Commander — unlike services and clients it isn't deployed, it's built locally and linked as a global luna binary.
Every command run goes through the same lifecycle: the CLI resolves your target environment, checks your AWS credentials, assumes the right role for that environment, runs your command, and records an audit entry — all automatically, so individual commands don't need to handle any of that themselves. See Patterns & conventions for how this lifecycle works under the hood.
Install and set up
Prerequisites: Node >=24 and Yarn 1.22.22 (see Getting Started if you haven't cloned the repo yet).
From the repo root:
cd cli
yarn run setupThis installs dependencies, builds the CLI, and links it globally as the luna command. Verify it worked:
luna --version
luna --helpNeeds review
cli/README.md's "Global Installation" section says a plain yarn install automatically builds and links luna via postinstall/postbuild scripts. cli/package.json doesn't define either script, so that doesn't happen — yarn run setup (which wraps yarn install --ignore-scripts + build + a manual link) is the install path that actually works today. Doc owner: update cli/README.md's Global Installation section, or reinstate the postinstall/postbuild scripts, so the two agree.
If you change CLI source later, rebuild and relink with yarn run update, or use yarn run dev for a watch mode that rebuilds on save (see cli/README.md for both).
Configure AWS access
Every command except those run with -e local needs AWS credentials — the CLI checks for them before doing anything else. Set up AWS setup & CLI auth first if you haven't.
The CLI then needs to know which environment to target — local, staging, polaris, pulsar, sol, or production. It resolves this in order:
- the
-e/--environmentflag, - the
ENVIRONMENTenvironment variable, - an interactive prompt, if neither is set.
For anything other than local, it assumes the ${environment}-iam-role-luna-cli role for you — you don't assume it by hand — and creates an audit record for the command before it runs. local skips all of this (no credentials, no role, no audit), which makes it the quickest way to try a command out.
Run your first commands
Check the CLI is linked and see what's available:
luna --help
luna --versionTry a real command without needing any AWS credentials, using the built-in example command and the local environment:
luna -e local example run
luna -e local example stopEach just prints a line to confirm it ran — a safe way to check your setup works end-to-end before touching a real environment. Once you're ready to target a real one, pass -e (or export ENVIRONMENT) and get the environment's AWS credentials first:
export ENVIRONMENT=polaris
luna datacopyback copy --helpGet help for any command or subcommand with --help:
luna <command> --help
luna <command> <subcommand> --helpWhat you can run
The current top-level commands (luna <command> ...):
| Command | What it does |
|---|---|
ai | AI tooling: embeddings and AI token usage tracking |
assessments | Assessment-related operations |
aurora | Manage Serverless Aurora databases |
bulkhead | Update bulkheaded data for domain entities |
data-retention | Data retention operations for managing ANDi PII data |
datacopyback | Copy DynamoDB data between AWS environments |
dynamodb | DynamoDB operations for data management |
example | A harmless example command — a safe way to try the CLI |
expenses | Manage expense categories |
feedback-analysis | Analyse feedback data via embeddings |
harness-agents | Register, update, suspend, resume and list the and-harness agents allowed to call the Luna MCP gateway |
invoices | Read Luna invoices: invoices amounts totals the amount, days and number of invoices by readiness for a period |
invoicing-calendar | Write (put, validated) and read (get) the invoicing calendar the Luna MCP gateway serves to agents |
mfa | Manage microfrontend client development (install, dev server) |
performance-review | Performance review operations |
public-holidays | Import public holiday templates into the system |
schedule | Schedule service operations |
script | Run a one-off .js/.ts script with full CLI context |
user-roles | Create role rows (with --dry-run to preview) in the user roles table |
xero-sync | Sync Xero accounts and tracking categories via JSON files |
This list grows over time — luna --help always reflects what's actually registered.
Next steps
- Running a one-off task rather than a repeatable command? See Run one-off scripts.
- Adding a new command to the CLI? See Add a command.
- Understanding the CLI's structure and conventions? See Patterns & conventions.
Troubleshooting
- Install/link issues,
command not found, or credential errors — see the Troubleshooting section ofcli/README.md. luna script runerrors (module not found,ENOENT, AWS calls failing) — see the Troubleshooting section of Run one-off scripts.
