Help · Using Morie
Secrets
Give a command your key without writing it into a file.
Checked against Morie 0.51.0.
- Add a key once in Settings → Secrets, kept in Morie’s store on this Mac or in 1Password.
- Scripts and rigs get it where they write
${NAME}; a chat asks before its command gets it. - Chats, transcripts and logs show
[secret:NAME], never the value.
The payment tests on ticket #12 need STRIPE_KEY, a secret already added for shop-api with Agent commands set to Ask.
- A Claude Code chat on #12 runs the payment tests. A card appears in the chat: Claude Code asks for STRIPE_KEY to run a command. It names the reference, its scope and the command.
- Press Allow once. The command runs with the key, and only that command has it.
- The chat, its transcript and the screen show
[secret:STRIPE_KEY]. The key itself is never in them.
What secrets are for
Some commands need a key: a payment test, a deploy, a database password. Writing the key into a file puts it in your code, your history and your chats. A secret keeps it out. You add it once, give it a name such as STRIPE_KEY, and from then on you and your chats use the name. Only the command that runs receives the value.
Settings → Secrets is where you add, test, change and remove them. This article is about using them day to day.
Where a secret goes
- A script or a rig. Write
${NAME}where the value belongs, for exampleSTRIPE_KEY=${STRIPE_KEY} npm run dev. The script gets the key each time it starts. The secret’s row in Settings → Secrets then lists the script under Used by. A rig's service can also be given a secret by name, with no change to its Compose file: Change… → Secrets for services (see How a rig gets secrets in The Morie Box and Rigs). - A terminal you open. It follows Secrets set to Ask in Settings → Secrets: it gets its secrets at once, asks when the terminal starts, or starts without them. New terminal in… lets you choose for one terminal.
- A chat’s command. The secret’s Agent commands setting decides, and it is the one that matters most. Always gives the key without asking. Ask puts a card in the chat. Off never gives it. A rig's
${NAME}is separate: it gets Always and Ask secrets, never Off (see Secrets in a rig).
When a chat asks
A card in the chat says which chat asks, for which secret, and for what. It also shows the reference, the scope and the command. Three buttons answer it:
- Allow once gives the key to that one command.
- Always allow sets the secret to Always for every chat in the project. The card then says so, with Undo to go back to Ask.
- Deny… refuses. You may type a reason first.
Esc never answers the card for you. If you ignore it, nothing is given, and after a while the card says it was not answered.
What the chat sees
The chat sees [secret:STRIPE_KEY] in place of the value. So do its transcript, its logs and any export. A terminal that is still open shows whatever its command prints, so be careful with a command that prints its own key.
Secrets in a rig
How it works. (This part is about a secret a rig's Compose files name; a secret given to a service in Secrets for services follows the same scope and Agent commands rules and is listed on the same line: see How a rig gets secrets in The Morie Box and Rigs.) A rig receives a secret when its Compose files name it as ${NAME} (or $NAME) with no default, the secret's scope covers the rig's repository, and Agent commands is Always or Ask. Off reaches nothing. A rig never asks: an Ask secret is read at Start without a card, because a rig is not a chat's command. The value goes only into the process that runs Compose, never into the rig's saved record, History or what a chat reads. A name starting DOCKER_, COMPOSE_, BUILDKIT_ or DYLD_, ending _PROXY, or SSL_CERT_FILE is never given. A secret that arrives with a set-up file (see the set-up file in Settings → Repositories and worktrees) is created as Ask, scoped to that repository, with no value: give it its value (Give value… or Settings → Secrets) and the next Start of the rig receives it, with no further setting. A rig already running keeps the value it started with: Restart it after a change. Because a rig's commands and logs are reachable by a chat that works in it, a chat that runs commands in a rig or reads its logs can see an Ask secret's value without a card; keep a key no chat should reach Off, or out of the Compose file.
Set it up. Example: shop-api's rig needs DB_PASSWORD and STRIPE_KEY.
- In shop-api's Compose file, write
${DB_PASSWORD}and${STRIPE_KEY}where the values go, with no:-default. On the ticket's Rigs, the card's Secrets foot now lists both names as red missing chips; No secret named DB_PASSWORD in this repository's scope. - Open Settings → Secrets (the card's Add a secret… link goes there) and press Add a secret…. Name
DB_PASSWORD, keep the reference, type the value. Scope Project-wide or Repositories with shop-api. Agent commands: Always or Ask. Press Add secret. Do the same forSTRIPE_KEY. - Back on Rigs, the chips are green, resolved; their tip reads DB_PASSWORD → morie://project/DB_PASSWORD: passed to compose at Start; the value is never shown.
- Press Start (or Restart if it runs). If every value arrived there is no amber line. If one did not, the card says Started without 1 value your Compose files ask for. with the rows below and Open Secrets.
The amber line's rows, each only when it has names (up to 6, then and N more): No reference for this repository: (add the secret, or widen its scope to this repository), Set to Off: (set it to Ask or Always), Couldn’t be read: NAME (message) (unlock the store or 1Password, or fix the value), Kept out of Compose by Morie: (NAME is not given: Morie keeps names that start with DOCKER_, COMPOSE_, BUILDKIT_ or DYLD_, names that end in _PROXY, and SSL_CERT_FILE out of the Compose process; rename the secret.). The line is written by each Start and cleared by Stop. A name with a default, or one the rig's .env file or the repository's env really gives a value, is not listed; an env entry that only passes the name on (NAME: ${NAME}, $NAME, ${NAME:?error}) gives nothing, so that name still counts. Morie also leaves such an entry out of what it hands Compose: with no secret the name is simply not set, and Compose treats it as any name that is not set. The Compose files' ${NAME} becomes empty (Compose warns The "NAME" variable is not set. Defaulting to a blank string.), ${NAME:-default} and ${NAME-default} take their default, ${NAME:?error} stops the Start with that error, a value in the rig's .env file is used, and a bare - NAME in a service's environment is then not set in the container. A secret you only just imported, with no value yet, can show green until Start lists it under Couldn’t be read.
A grey line also shows when the rig names a volume or network of a fixed name: Volume pgdata (shop_db_data) has a fixed name: it is shared with every other rig that names it, on any ticket. (the name in brackets is the fixed name, shown when it differs from the file's key; is external for an external one). Nothing is refused; two tickets' rigs would share that data.
If the rig's .env file setting names a file the worktree lacks, the rig cannot start: The .env file .env.docker-compose isn’t in this worktree. The rig’s .env file setting (Change…, services.envFile) names it. When a .env.template, .env.example or .env.sample sits beside it, Create it from .env.example copies it as it is (no overwrite, mode 0600, inside the worktree only); fill in the values after, and put real secrets in Settings → Secrets. A refused copy says Couldn’t create .env: a file of that name is there now. Nothing was copied.
From a chat. tickets.services.start and tickets.services.status answer with the lines Started without 2 values: STRIPE_KEY (no reference), DB_PASSWORD (Off). (also (couldn’t be read: message) and (kept out of Compose by Morie)), Shared with every other rig that names it, on any ticket: volume pgdata (shop_db_data)., and in JSON secretsLeftOut (name, why: none, off, unreadable or kept-out, message) and sharedNames. No value ever appears. A chat cannot add a secret or change a scope: the way forward is to tell the owner which name and which reason, and to ask for it in Settings → Secrets; then tickets.services.start again. For a missing .env file the answer reads cannot start: The .env file .env.docker-compose isn’t in this worktree. … Copy .env.example to .env.docker-compose, then start again. A chat copies the template itself in the worktree, or asks the owner to press Create it from …. Rebuild refuses when a needed name cannot be read: I couldn’t get DB_PASSWORD for this Rig, so I haven't rebuilt it. Check them in Settings → Secrets.
Finding the names in a project's .env files
How it works. In the Morie chat's setup walkthrough, in its Secrets step, Morie can list the names in a project's .env files so you can turn them into secrets without copying values by hand. It reads the files as plain NAME=value lines and never runs anything in them: no $VAR or $(...) is expanded. It returns names, the repository and the file, never a value. A name must be capitals, digits and _ (at most 128 characters). A name is left out when: the file is a template (.env.example, .sample, .template, .dist, .default, .defaults) or encrypted (.enc, .encrypted, .vault, or an encrypted: value); the name is listed twice in the file; its value has an unquoted # (quote it first); the name is 20 or more characters with no _ (it looks like a token itself); or a secret of that name already exists with a different reference or scope than the one a new one would get (edit that secret in Settings → Secrets instead). Limits: 1 MiB per file, 100 files, 8 MiB in all, 500 names, 8 folders deep, 10,000 entries and 2 seconds; a folder that is a link is not entered. A read is shared for 60 seconds. It opens no card and changes nothing.
Set it up. Example: shop-api has shop-api/.env holding STRIPE_KEY=... and DB_PASSWORD=.... 1. Take the Morie chat's setup walkthrough. At its Secrets step it opens Settings → Secrets and says I found 2 secrets in your environment files (.env). Want them in here? with the answers Show me and Not now. 2. Press Show me. The card Secrets from environment files opens, with the number of files, a What Morie found list for anything it could not use, and Bring in? · names only with one row per name: STRIPE_KEY From shop-api/.env. and DB_PASSWORD From shop-api/.env. 3. Answer each row Yes or No (a name the Morie store already has asks Keep Morie’s or Use the file’s), or press Import none. A Yes reads that one value straight into the Morie store, locked with this Mac’s keychain; it never shows on the card and the file stays as it is. If it could not be saved the card says That was not saved. Read the names again and try again. Not now closes the step and brings in nothing. If the list may be incomplete the chat says some files could not be fully read, and still offers Show me.
From a chat. secrets.env.names (only for the setup's Secrets step), with repositories (names or ids, 1 to 100; left out, all of the project's). It answers {count, incomplete, names: [{name, repository, file}]} and lines like - STRIPE_KEY · shop-api/.env; with none, No secrets found in the environment files. When a file could not be fully read, or the limits were hit, it adds Some environment files could not be fully read, so this list may be missing names. and incomplete is true: it never says none were found then. A project with no repository answers This project has no repositories. Refusals: Unknown repository "<name>". (a name that is not one of the project's repositories), Choose repositories in this project., Wait for this answer to finish. (another read or an import is under way) and Read the names again before answering. (the project changed during the read). The way forward: use the project's repository names, wait for the other answer to finish and call again, or read the names again. The chat never reads an .env file itself.
Which setting to pick
- Ask is the safe start. You see each use, and the cards teach you which commands need which key.
- Always suits a key a chat uses all day, such as a test key. Pick it for keys with little to lose.
- Off suits a key no chat should touch, such as a production password. Scripts can still use it; a rig cannot.
When something is off
- The card says the secret is off for agents? Agent commands is Off. Press Open Settings → Secrets on the card, or open the page, and set it to Ask or Always.
- Pressed Always allow by mistake? Press Undo on the card, or Revoke on the secret’s row in Settings → Secrets. Both put it back to Ask. If the chat already had the value from that request, Undo changes only the setting.
- A script started without its key? Check that the name in
${NAME}matches the secret exactly, then press Test on its row. If 1Password did not answer in time, the command starts without the value. - A change to a secret seems ignored? Scripts, rigs and terminals already running keep the value they started with. Start them again.
See also: Settings → Secrets · Settings → Repositories