moda CLI.
Prerequisites
@moda-ai/cliinstalled:npm install -g @moda-ai/cli(Node.js >= 18).- An API key for
syncandpromote: setMODA_API_KEY, or runmoda initonce to provision and store one.init,status,diff, andmigratework offline. - If you already have a key and no browser (CI, a coding agent),
moda auth login --api-keyvalidates and stores it non-interactively;moda auth whoamiconfirms it worked.
1
Create the manifest
manifestPath it wrote (and lists it under artifacts in agent mode), so you can verify the result without guessing where it landed.This writes .moda/prompts.yml if it does not exist (it never overwrites an existing manifest):.moda/prompts.yml
prompt_paths: fast-glob patterns, matched exactly and relative to the repository root. A pattern without glob characters is an exact file path, and the file must exist. Prefix a pattern with!to exclude matches.node_modules,.git,dist,build,.env*,*.pem, and*.keyare never matched, and symlinks are rejected.sources: prompts that live in code or config, mapped in place. See Map prompts defined in code.moda prompts syncadds the mappings its discovery verifies, and you can also write them by hand.
Manifests written by older CLIs say
version: 1. They keep working, but those CLIs discovered prompts by .prompt.* suffix anywhere in the repository, while patterns are now exact globs. If prompt files outside prompts/ stopped syncing, see Migrate a version 1 manifest.Although the default manifest lists
.prompt.yaml and .prompt.yml patterns, the CLI parses those files with the same frontmatter parser as .prompt.md. Write prompts as .prompt.md or .prompt.json.2
Write prompt files
Markdown format — optional frontmatter, then the prompt content as the body:Recognized frontmatter keys:Supported JSON fields:
prompts/support/triage.prompt.md
Frontmatter is parsed line by line as flat
key: value pairs — nested YAML structures and lists are not supported, and .prompt.md files cannot declare variables. Use .prompt.json for structured prompts.JSON format — supports the full schema, including messages, variables, and tool references:prompts/support/answer.prompt.json
key, name, description, category, content (defaults to the pretty-printed messages array when omitted), messages, systemPrompt, variables, variablesSchema, modelConfig, toolRefs, responseSchema. variables and variablesSchema are stored as declared metadata with each version; the CLI and registry do not render or substitute variables.Key derivation. When no explicit key is set, the key comes from the file path: strip a leading prompts/, strip the .prompt.<ext> extension, and replace slashes with dots. prompts/support/triage.prompt.md becomes support.triage.3
Check local state
status is local-only — no network call. It compares discovered files against .moda/prompts.lock.json:state is one of new (not in the lockfile), unchanged (hash matches), changed (hash differs), or deleted (in the lockfile but no longer on disk).status also checks the manifest itself:zeroMatchPatternslistsprompt_pathspatterns that match no file. A manifest whose patterns all match nothing, and that has nosources:, syncs nothing without reporting an error.legacyOnlyFileslists.prompt.*files that older CLIs discovered but the current patterns miss. When it is non-empty,statuswarns and points atmoda prompts migrate.
moda doctor runs the same check as prompts_discovered.moda prompts diff runs the same comparison but lists only prompts that are new, changed, or deleted. It compares hashes; it is not a textual diff of prompt content.4
Sync versions
discovery.pending and are not uploaded. Existing configured mappings remain
authoritative; no application modules are imported to extract prompt text.auto analyst uses an installed, authenticated CLI. Assistance uses
that CLI’s account and has no fixed wall-clock timeout; cancel the command to
stop it. If assistance is unavailable, configured sources and dedicated prompt
files still sync, while uncertain candidates remain pending. --assist=none
also disables assistance. Agent-generated prompt text is never uploaded.Successful sync saves new accepted source mappings in .moda/prompts.yml.
Runtime-composed prompts remain typed builder definitions with dependency
fingerprints and partial coverage, not rendered runtime text. Finding one
fragment does not mean every prompt in the repository has been found.Sync uploads all eligible prompts, not only changed ones. Because versions are content-addressed, unchanged prompts resolve to their existing version IDs and create nothing new. On success the CLI writes .moda/prompts.lock.json:.moda/prompts.lock.json
promote. It is rewritten wholesale on each sync; commit it alongside your prompt files.Every sync also moves the dev label to the just-synced version of each prompt, so every synced prompt carries dev: moda prompts list --label=dev lists them all, and --label=unlabeled matches none. In API responses the label pointers are devVersion (the same value as currentVersion), stagingVersion, and prodVersion, and each version’s labels lists every label pointing at it. A version’s releaseLabel holds at most one stored label, so read labels for the full set.Options:--dry-run— the server computes and returns the IDs without writing anything; the lockfile is not updated.--from-harness[=<report>]— first register the prompt mappings from a harness report (default.moda/harness-report.json). Reports from older CLIs are normalized, and prompts without apromptSourceare mapped from theirsourcePathwhen that is unambiguous. Prompts that still do not resolve against current source are listed inharnessImport.skippedwith a reason. The command fails only when none resolve; regenerate the report withmoda harness analyze --experimental --concern=prompts.--watch— re-check local files on an interval and re-sync when hashes change.--interval=<ms>sets the poll interval (default 2500, minimum 1000).
moda sync prompts is an alias for moda prompts sync.5
Promote a release label
--label accepts dev, staging, or prod; --version (alias --version-id) takes the version ID from the lockfile or from moda prompts status. The label moves atomically from whichever version held it to the target version.Promote to staging before prod if you validate releases in a pre-production environment. You can also promote from the dashboard: each version on the prompt’s Versions tab has staging and prod promote buttons.Verify in the dashboard
After the first sync, open Dashboard → Prompts. You should see each discovered prompt with one version, thedev label on that version, and the source path and commit you synced from. After a promote, the label badge moves to the target version on the prompt’s Versions tab.
Optional: sync automatically from CI
Add this GitHub Actions workflow to runmoda prompts sync (and moda skills sync) on every push to main — and only main, so unmerged versions are never published. It needs two repository secrets: MODA_API_KEY and MODA_TENANT_ID.
.github/workflows/moda-autosync.yml
<version> with an exact @moda-ai/cli release — the pin makes CLI upgrades explicit, reviewable diffs.
Map prompts defined in code
A prompt that lives in application code or config does not need its own file. Map it undersources: with a stable key, the file, and a selector:
.moda/prompts.yml
Python selectors need
python3. Modules are parsed, never imported. When a file is matched by both a glob and a sources: entry, the sources: entry owns it. Builders and templates are not plain prompt text: run the application’s builder and attribute the resulting model call to its registry version.
Migrate a version 1 manifest
The default manifest has not changed, but discovery has. The first CLIs matched any file ending in.prompt.md or .prompt.json anywhere in the repository. Patterns are now exact globs from the repository root, so with the default prompts/** patterns, files such as src/agents/support.prompt.md silently stopped syncing. moda prompts status reports them as legacyOnlyFiles.
migrate rewrites .moda/prompts.yml to version 2:
- Every existing pattern and
sources:entry is kept, and comments are preserved. - Each legacy-only file is added to
prompt_pathsas an explicit path. Its path-derived key, lockfile entry, and version history stay the same. - A
sources:list is added if missing.--discoverscans for code-defined prompts without agent calls. A code mapping needs independent verification before it is registered, so the scan adds only mappings that need none. It lists the other candidates underpendingSources. To map them, runmoda harness analyze --experimental --concern=promptswith an installed analyst, thenmoda prompts sync --from-harness, or add them undersources:yourself.
migrate on a version 2 manifest with nothing to add changes nothing. Patterns that still match nothing are kept and reported so you can fix or remove them.
How the content hash is computed
The lockfilecontentHash decides whether a prompt is changed and which registry version it maps to. To check a lockfile from your own tooling, use the published helper instead of reimplementing it:
PROMPT_HASH_VERSION is 1. The algorithm is:
stableJson is JSON.stringify after sorting every object’s keys, recursively, with String.prototype.localeCompare. Arrays keep their order. For sources: entries, sourceDefinition holds the mapping (kind, source) and the extracted sourceHash. Builders and templates also include dependencies, coverage, and unresolved, so editing a dependency or moving a selector mints a new version even when the text is identical. name, description, category, and sourcePath are not hashed. For sources: entries the registry recomputes the hash and rejects a mismatch.
Deleting a prompt
Delete the file from your repo.moda prompts status reports it as deleted, and the next sync drops it from the lockfile. The prompt and its versions remain in the registry — there is no delete or archive API — but they stop receiving new versions.
Troubleshooting
Next steps
- Prompt attribution — stamp the lockfile IDs on runtime calls so usage shows up per version.
- Prompt management overview — the versioning and label model in one page.
- CLI reference — output modes, exit codes, and environment variables shared by all CLI commands.