/kamal-skills:secretsfrom kamal-skills
Manage secrets for a Kamal deployment — the `.kamal/secrets` file, dotenv variable and command substitution, and the `kamal secrets` vault helpers (1Password, Bitwarden, LastPass, Bitwarden Secrets Manager, AWS Secrets Manager, Doppler, GCP Secret Manager, Passbolt). Use when the user says "kamal secrets," "where do I put my registry password," "manage secrets," "pull secrets from 1Password/Bitwarden/LastPass/Doppler," "kamal secrets fetch/extract/print," "secrets-common," "secrets.<destination>," "secrets_path," "secret vs clear env keys," "RAILS_MASTER_KEY," or "migrate from .env / kamal envify," "migrate local or file-based secrets into 1Password / a vault," or "move plaintext secret files into a password manager." Covers wiring secrets into `env.secret`/`env.clear` in deploy.yml, per-destination secrets files, and aliased secrets. For setting plain non-secret env values, see env. For registry login and KAMAL_REGISTRY_PASSWORD, see registry. For build-time secrets and args, see build.
Ships in kamal-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
You are an expert in deploying applications with Kamal. Your goal is to help the user store deployment secrets safely, wire them into config/deploy.yml, and — when they use a password manager — pull them with the kamal secrets helpers instead of pasting plaintext.
In Kamal 2, secrets live in .kamal/secrets. Kamal uses dotenv to load that file automatically whenever a command needs the values, so there is no separate "generate secrets" step.
Before asking the user questions, read what already exists:
.kamal/secrets (and .kamal/secrets-common, .kamal/secrets.<destination> if present) — what secrets are already defined and how they are sourced.config/deploy.yml — the env block, especially which keys are listed under secret vs clear, and the registry block..kamal/secrets is git-ignored.This tells you whether the user needs to add a new secret, move a plaintext value out of deploy.yml, switch to a vault helper, or set up per-environment secrets.
.kamal/secrets File.kamal/secrets is a dotenv file. Each line defines an environment variable that Kamal can reference. The right-hand side supports two kinds of substitution, evaluated on demand when you run a Kamal command:
| Technique | Syntax | Use it for |
|---|---|---|
| Variable substitution | NAME=$NAME | Pulling a value already in your shell/CI environment |
| Command substitution | NAME=$(command) | Reading from a file or a CLI (e.g. a password manager) |
# .kamal/secrets
# Pass a value through from the surrounding environment (e.g. set in CI)
KAMAL_REGISTRY_PASSWORD=$KAMAL_REGISTRY_PASSWORD
# Read a value by running a command
RAILS_MASTER_KEY=$(cat config/master.key)
Do not commit real secret values. If you store secrets directly in .kamal/secrets, make sure the file is not checked into version control. Prefer variable substitution (from CI/your shell) or command substitution (from a password manager) so the file holds references, not plaintext.
KAMAL_REGISTRY_PASSWORD is the variable Kamal reads for registry authentication. For registry login itself, see the registry skill.
Defining a variable in .kamal/secrets does not, by itself, send it to your containers. You declare which variables are secret in the env block of config/deploy.yml.
List secret variable names under the secret key, and move any plain values under the clear key:
env:
clear:
DB_USER: app
secret:
- DB_PASSWORD
The names under secret must match variables defined in .kamal/secrets.
Behavior: Unlike clear values, secrets are not passed directly to the container. Kamal writes them to an env file on the host instead. For the full breakdown of clear, secret, and tags, see the env skill.
When the environment variable name your app expects differs from the secret name, alias it with a : separator (ENV_NAME:SECRET_NAME). This is useful when the same ENV name needs different values in different contexts:
env:
secret:
- DB_PASSWORD:MAIN_DB_PASSWORD
tags:
secondary_db:
secret:
- DB_PASSWORD:SECONDARY_DB_PASSWORD
# .kamal/secrets
SECRETS=$(kamal secrets fetch ...)
MAIN_DB_PASSWORD=$(kamal secrets extract MAIN_DB_PASSWORD $SECRETS)
SECONDARY_DB_PASSWORD=$(kamal secrets extract SECONDARY_DB_PASSWORD $SECRETS)
kamal secretsIf the user keeps secrets in a password manager, use the kamal secrets helpers inside .kamal/secrets via command substitution. The helpers handle signing in, prompting for passwords, and efficiently fetching the secrets.
| Command | What it does |
|---|---|
kamal secrets fetch [SECRETS...] --adapter=ADAPTER --account=ACCOUNT | Fetch secrets from a vault |
kamal secrets extract | Extract a single secret from the results of a fetch call |
kamal secrets print | Print the secrets (for debugging) |
kamal secrets help [COMMAND] | Describe subcommands or one specific subcommand |
Key options on fetch: --adapter (-a) selects the password manager, --account selects the account, and --from scopes where to look (vault, folder, item, or project) depending on the adapter.
Call fetch once to pull every secret in a single sign-in, then extract each value out of that result. This avoids re-authenticating for every variable:
# .kamal/secrets
SECRETS=$(kamal secrets fetch ...)
REGISTRY_PASSWORD=$(kamal secrets extract REGISTRY_PASSWORD $SECRETS)
DB_PASSWORD=$(kamal secrets extract DB_PASSWORD $SECRETS)
1password adapter, pointing --from at a Vault/Item:# .kamal/secrets
SECRETS=$(kamal secrets fetch --adapter 1password --account myaccount \
--from MyVault/MyItem REGISTRY_PASSWORD DB_PASSWORD)
REGISTRY_PASSWORD=$(kamal secrets extract REGISTRY_PASSWORD $SECRETS)
DB_PASSWORD=$(kamal secrets extract DB_PASSWORD $SECRETS)
extract accepts either the short secret name or a fully-qualified path, so all three of these resolve the same value:
kamal secrets extract REGISTRY_PASSWORD $SECRETS
kamal secrets extract MyItem/REGISTRY_PASSWORD $SECRETS
kamal secrets extract MyVault/MyItem/REGISTRY_PASSWORD $SECRETS
The op desktop-app integration authorizes reads transparently, but writes — creating
a vault or item — prompt for Touch ID / approval and will time out in non-interactive,
CI, or background contexts. For unattended deploys, authenticate op with a 1Password
service account by setting OP_SERVICE_ACCOUNT_TOKEN in the environment (a 1Password
convention, not a Kamal feature). .kamal/secrets does not change: keep --account, since
the 1password adapter refuses to fetch without it (kamal secrets fetch ... --account=ACCOUNT).
A service account only sees vaults explicitly granted to it, and 1Password does not allow
granting the built-in Personal, Private, or Employee vault, or the default Shared vault. Grant it read access to a dedicated
deploy vault first, or fetch fails. For the full GitHub Actions setup, see the ci-deploy
skill's references/1password.md.
Field references and extract: op item create "LABEL[password]=..." files the field under
an auto-generated section, so its reference becomes op://MyVault/MyItem/Section_xxxx/LABEL.
That still resolves — the adapter fetches by label=, and kamal secrets extract LABEL matches
on the key suffix (/LABEL), so neither depends on the section name.
Kamal ships helpers for several password managers and secret stores:
| Adapter | Service | Uses --account? |
|---|---|---|
1password | 1Password | Yes |
lastpass | LastPass | Yes (email) |
bitwarden | Bitwarden | Yes (email) |
bitwarden-sm | Bitwarden Secrets Manager | No (fetch all or ProjectID/all) |
aws_secrets_manager | AWS Secrets Manager | Yes (AWS CLI profile, usually default) |
doppler | Doppler | Ignored if given |
gcp | GCP Secret Manager | Yes (gcloud account) |
passbolt | Passbolt | Ignored if given |
Each adapter has its own --from semantics (vaults, folders, items, projects, GCP project IDs) and prefix conventions. For per-adapter fetch examples and the full options reference, see references/vault-adapters.md.
When you deploy to multiple destinations, split secrets across files. Kamal looks for the -common file first, then the environment-specific file, with later values overriding earlier ones:
| Scenario | Files read (in order) |
|---|---|
| No destination | .kamal/secrets-common, then .kamal/secrets |
Destination <dest> | .kamal/secrets-common, then .kamal/secrets.<dest> |
When a destination is selected, the plain .kamal/secrets file is not read. Put values shared across every destination in .kamal/secrets-common, and per-environment values in .kamal/secrets.<destination>.
secrets_pathsecrets_path sets the base path to your secrets files. It defaults to .kamal/secrets. Kamal applies the same -common / .<destination> lookup relative to whatever you set:
# config/deploy.yml
secrets_path: /user_home/kamal/secrets
Use kamal secrets print to print the resolved secrets when something is not being picked up. Treat its output as sensitive — it reveals secret values.
kamal secrets print
When secrets currently live in git-ignored files (or as plaintext in .kamal/secrets) and the
user wants them in a password manager, move them without changing what gets deployed (the
op commands below are 1Password; other managers use their own item-creation commands):
Create the vault if it doesn't exist yet. Writes may need interactive approval (see the 1Password auth note above); a service-account or API token avoids the prompt.
op vault create MyVault
Create the item, loading each value straight from its file — so the plaintext never
lands in your shell output, and trailing newlines are stripped exactly as $(cat file)
already does:
op item create --vault MyVault --title MyItem --category "Secure Note" \
"REGISTRY_PASSWORD[password]=$(cat .kamal/REGISTRY_PASSWORD)" \
"DB_PASSWORD[password]=$(cat .kamal/DB_PASSWORD)"
Rewire .kamal/secrets to the fetch → extract pattern, and keep the old file-based lines
commented out for a quick rollback.
Verify without revealing values — fetch once, then compare checksums, not plaintext:
SECRETS=$(kamal secrets fetch --adapter 1password --from MyVault/MyItem DB_PASSWORD)
diff <(printf %s "$(kamal secrets extract DB_PASSWORD "$SECRETS")" | shasum) \
<(printf %s "$(cat .kamal/DB_PASSWORD)" | shasum)
Confirm the whole config resolves with kamal config (expect exit code 0), then delete
the now-redundant files. Keep config/credentials/*.key if you still edit Rails credentials
locally.
If the user is upgrading from Kamal 1, secrets have moved out of .env / .env.rb into .kamal/secrets:
kamal envify and kamal env have been removed. Secrets no longer have a separate lifecycle — substitution happens on demand. Replace envify with dotenv's variable and command substitution directly in .kamal/secrets..env is no longer auto-loaded into the environment, and values in .kamal/secrets are not loaded into the environment for use in deploy.yml either. If your deploy.yml referenced ENV[...] via ERB, load .env yourself:# config/deploy.yml
<% require "dotenv"; Dotenv.load(".env") %>
servers:
- <%= ENV["SERVER_IP"] %>
clear / secret keys in detail, and tags.KAMAL_REGISTRY_PASSWORD secret it consumes.Official docs: Secrets command · Secrets changes (upgrading) · Environment variables
What SKILL.md sets; muted values are Claude Code's defaults
25 skills in this plugin
/accessoriesRun and manage accessory services — databases, Redis, search, and other long-lived dependencies your app needs — through Kamal's `accessories:` configuration and the `kamal accessory` command. Use this when the user says things like "add a MySQL/Postgres/Redis accessory," "run a database with Kamal," "kamal accessory boot," "set up a sidecar/companion service," "my app needs a cache or search container," "persist accessory data with volumes," or "reboot/restart/remove an accessory." Covers defining the accessory (image, host/hosts/role/roles/tag/tags, port, env, files, directories, volumes, network, options, registry, proxy) and operating it with boot, reboot, restart, start, stop, details, logs, exec, and remove. For passing configuration and credentials into accessories, see env and secrets. For scheduled jobs, see cron./aliasesDefine custom command aliases under the top-level `aliases` key in `config/deploy.yml` so a long, repeated `kamal` invocation becomes a single `kamal <name>`. Use it when the user says "add a Kamal alias," "shortcut kamal app exec," "make `kamal console` open a Rails console," "create a one-liner to deploy staging," "I keep retyping the same kamal command," or asks about the `aliases` config key, alias naming rules, or a `deploy -d staging` shortcut. Covers how an alias expands into a `kamal` subcommand, the lowercase letters/numbers/dashes/underscores naming rule, and the documented examples `console: app exec -i --reuse "bin/rails console"`, `uname: app exec -p -q -r web "uname -a"`, and `staging_deploy: deploy -d staging`. For the rest of `config/deploy.yml` and DRYing it up with YAML anchors, see config. For the underlying app exec / console / logs commands the aliases wrap, see app.Other plugins' skills for the same job
npx claudepluginhub donnfelker/kamal-skills --plugin kamal-skills