/kamal-skills:ci-deployfrom kamal-skills
Set up continuous deployment so every push to main runs `kamal deploy` from GitHub Actions once the tests pass — for any stack Kamal ships (Rails, Next.js, Phoenix, Rust, static sites, and more). Use when the user says "auto-deploy on push," "deploy from GitHub Actions," "continuous deployment with Kamal," "deploy when CI passes," "set up CD," "stop deploying from my laptop," or "use 1Password in GitHub Actions." Covers the deploy ssh key, secrets in a GitHub environment or read from 1Password with a service account, the workflow, the GHA build cache, and verifying the first run. For running a deploy by hand, see deploy. For the secrets file itself, see secrets. For build cache options, 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 Kamal apps from GitHub Actions. Your goal is a workflow that runs kamal deploy for exactly the commit that passed CI on main, with the fewest secrets possible, without changing how the user deploys by hand.
The pattern is the same for every stack: the runner does what the user's laptop does today. It checks out the code, gets the same inputs .kamal/secrets reads, loads an ssh key the server trusts, and runs kamal deploy. Only the inputs and the way Kamal is installed differ per stack (see references/stacks.md).
Grounding note: Kamal facts here come from the Kamal docs. GitHub Actions features (
workflow_run, environments,concurrency, repository variables) and third-party actions (webfactory/ssh-agent,ruby/setup-ruby) are GitHub conventions, not Kamal features. Check GitHub's docs when in doubt. 1Password service accounts and1password/install-cli-actionare 1Password conventions; check 1Password's docs for those.
kamal setup and at least one successful kamal deploy should already work from the user's machine. CI repeats a working deploy; it is a poor place to debug a first one..kamal/secrets reads instead of rewriting it, so kamal deploy keeps working from a laptop.main points at later.authorized_keys and uploading secrets change shared systems. Show the user what you'll do and get a yes.Read these before asking anything:
config/deploy.yml: servers (hosts), ssh.user (default root) and ssh.port (default 22), registry.server, builder.arch, proxy.app_port, proxy.healthcheck, and any ERB that reads ENV (<%= ENV[...] %>)..kamal/secrets (and secrets-common, secrets.<destination>): list every input it reads. Each one is an environment variable, a file, or a password-manager command. Each becomes a GitHub secret..kamal/hooks/: hooks run in CI too. A pre-connect or pre-build hook that checks for local files or a clean checkout must pass on the runner..github/workflows/: its name: is what the deploy workflow waits for.Ask the user only what the files can't tell you:
main)?Build a table of everything the deploy reads from outside the repo. Example from a Rails app:
| Input | Read by | Becomes |
|---|---|---|
config/master.key (file) | .kamal/secrets: RAILS_MASTER_KEY=$(cat config/master.key) | secret RAILS_MASTER_KEY, written back to the file |
.env lines POSTGRES_PASSWORD= | .kamal/secrets via grep | secret POSTGRES_PASSWORD, written back into .env |
$KAMAL_REGISTRY_PASSWORD (env var) | .kamal/secrets | secret, exported as an env var |
ENV["SOME_FLAG"] in deploy.yml ERB | config/deploy.yml | repository variable if not secret |
| ssh access to the hosts | Kamal | secrets KAMAL_SSH_PRIVATE_KEY and KAMAL_KNOWN_HOSTS |
Watch for:
deploy.yml that reads the shell. Values the user exports by habit before a deploy vanish in CI. An unset value often silently renders empty rather than failing. Give each one a repository variable or secret.kamal deploy does not reboot accessories, so their secrets (backup keys, for example) are usually not needed. Add them only if the deploy fails without them.kamal secrets fetch adapters need their CLI and a login on the runner. For 1Password, keep the adapter: install op on the runner and give it a read-only service account token, so the vault stays the only copy of each value and .kamal/secrets does not change. Follow references/1password.md; its inputs collapse to one row, OP_SERVICE_ACCOUNT_TOKEN. For other managers, it is usually simpler to store the values as GitHub secrets and skip the adapter in CI.registry.server: localhost:5555), Kamal starts a registry on the runner and pushes there, so no registry credentials are needed. With Docker Hub, GHCR, ECR, and similar, the registry password is one more secret.On the user's machine (or have them run it):
ssh-keygen -t ed25519 -N "" -C "<app>-github-deploy" -f ./deploy_key
ssh-keyscan -t ed25519,rsa,ecdsa <host> > ./known_hosts
ssh-keygen -lf ./known_hosts # fingerprints just scanned
ssh-keygen -F <host> -l # fingerprints the user already trusts
The fingerprints must match what the user's own known_hosts holds. A mismatch means the scan did not reach the real server. Stop and investigate.
Add deploy_key.pub to ~/.ssh/authorized_keys for the ssh.user on every host in servers (and accessory hosts if the deploy touches them). Then test it on each host with only that key:
ssh -o IdentitiesOnly=yes -i ./deploy_key <user>@<host> 'docker ps --format "{{.Names}}" | head -3'
Also confirm the runner can reach ssh at all: GitHub-hosted runners come from public IPs. A host that only allows ssh over a VPN or tailnet needs a self-hosted runner or a VPN step first. Check with the server-hardening skill before opening a port.
With 1Password, the only deploy secret besides the ssh key and known hosts is OP_SERVICE_ACCOUNT_TOKEN (references/1password.md, Step 3). Everything else below still applies.
Put the deploy secrets in a GitHub environment (for example production), not in repository secrets. Only jobs that declare environment: production can read them, so test jobs never see production keys. This matters when a test workflow already references a secret with the same name (a test job using secrets.RAILS_MASTER_KEY would otherwise get the production key).
With the GitHub CLI, feed every value through stdin so it never appears in a command line or log:
gh api -X PUT repos/<owner>/<repo>/environments/production
gh secret set KAMAL_SSH_PRIVATE_KEY --env production < ./deploy_key
gh secret set KAMAL_KNOWN_HOSTS --env production < ./known_hosts
gh secret set RAILS_MASTER_KEY --env production < config/master.key
grep '^POSTGRES_PASSWORD=' .env | cut -d= -f2- | tr -d '\n' | gh secret set POSTGRES_PASSWORD --env production
gh variable set SOME_FLAG --body "value" # non-secret deploy.yml inputs
Lock the environment to the deploy branch:
gh api -X PUT repos/<owner>/<repo>/environments/production --input - <<'EOF'
{"deployment_branch_policy":{"protected_branches":false,"custom_branch_policies":true}}
EOF
gh api -X POST repos/<owner>/<repo>/environments/production/deployment-branch-policies -f name=main -f type=branch
Then delete the local deploy_key. GitHub now holds the only copy of the private key.
Use the template in references/workflow-template.md. Its shape:
workflow_run of the test workflow, types: [completed], branches: [main].conclusion == 'success' and the triggering event was a push. Without the second check, a passing pull-request run whose head branch is main on a fork could start a deploy.concurrency with cancel-in-progress: false, so a push mid-deploy waits instead of killing a deploy halfway.environment: production to unlock the secrets.github.event.workflow_run.head_sha, the commit CI tested. Kamal tags the image with the checked-out Git version, so the running container names show which commit is live.KAMAL_KNOWN_HOSTS to ~/.ssh/known_hosts..kamal/secrets reads, with umask 077. Keep them git-ignored, so the checkout stays clean.op CLI and pass OP_SERVICE_ACCOUNT_TOKEN to the deploy step only (references/1password.md, Step 4).kamal deploy (bin/kamal deploy in a Rails app).If the repo has no test workflow, trigger on push to main instead and say plainly that nothing gates the deploy. If the team runs tests locally and signs off with gh-signoff, the opt-in local-ci-deploy skill can trigger the deploy on a green signoff instead.
Every runner starts empty, so without a cache each deploy rebuilds the whole image. Kamal supports the GitHub Actions cache (builder examples):
# config/deploy.yml
builder:
arch: amd64
<% if ENV["GITHUB_ACTIONS"] %>
cache:
type: gha
options: mode=max
<% end %>
gha cache only works inside GitHub Actions, so wrap it in ERB on GITHUB_ACTIONS (GitHub sets it on every runner). Local deploys then build exactly as before.docker/setup-buildx-action and crazy-max/ghaction-github-runtime in the workflow. The runtime action exposes the cache credentials Docker needs.mode=max caches intermediate stages too, which pays off for multistage builds (Rust, Next.js, Phoenix releases, Rails asset compilation).registry, which pushes cache layers to the registry. Use it when the registry is remote and you want laptop and CI deploys to share one cache.Reference timing from a Rails app: the first CI deploy, with an empty cache, took 6m21s. The next one took 1m23s.
Architecture: GitHub's standard runners are amd64. If builder.arch is arm64, use an arm64 runner (GitHub offers ubuntu-24.04-arm) or a builder.remote arm64 builder. Building arm64 under emulation on an amd64 runner is very slow.
Commit the workflow, the deploy.yml change, and a docs note in one commit. Tell the user that pushing it will itself trigger a deploy once CI passes.
Watch both runs:
gh run list -w CI -L 1
gh run watch <ci-run-id> --exit-status
gh run list -w Deploy -L 1
gh run watch <deploy-run-id> --exit-status
Verify on the server, not just in the Actions log:
curl -s -o /dev/null -w '%{http_code}\n' https://<host>/up
kamal app details # container names carry the deployed version
The version in the container names must equal the commit SHA that was pushed.
Read the run's annotations. Deprecation warnings about action runtimes (for example "Node.js 20 is deprecated") mean an action needs a version bump; check each action's releases for the current major.
Add a short "Continuous deployment" section to the app's deploy docs (and its AGENTS.md or CLAUDE.md if it has one) covering:
[skip ci] in the commit message skips the test workflow, so the deploy never triggers).<app>-github-deploy line from authorized_keys.kamal deploy from a laptop still works, for hotfixes or when Actions is down.| Symptom | Cause | Fix |
|---|---|---|
| Every job fails in ~2s with "recent account payments have failed or your spending limit needs to be increased" | GitHub billing on a private repo | Fix billing, then gh run rerun <ci-run-id>. The deploy run shows skipped, which is correct. |
Deploy run shows skipped | CI failed, or the trigger was not a push | Check the CI run; that's the gate working. |
Permission denied (publickey) | Key not in authorized_keys for ssh.user on that host, or secret has a trailing-newline problem | Re-test with ssh -i locally; re-upload the key with < redirection, not echo. |
Host key verification failed | KAMAL_KNOWN_HOSTS missing or stale | Rescan, compare fingerprints, update the secret. |
| Healthcheck fails only in CI | A secret written empty, or an ERB env value missing | Compare the secret list to Step 1's inventory; check repository variables. |
| A hook fails in CI | Hook checks local-only state | Make the hook pass on a clean runner (files written in step 9 of the workflow). |
| Deploy waits or fails on the lock | A previous deploy died holding the lock | kamal lock status, then kamal lock release once you're sure nothing is deploying. |
| A 1Password fetch fails only in CI | Service account cannot see the vault, or the token is missing on the Deploy step | See the troubleshooting table in references/1password.md. |
| Build is slow every time | Cache not configured or runtime not exposed | Step 5; look for cache entries in the repo's Actions caches page. |
kamal deploy does, and deploying by hand..kamal/secrets, substitution, password-manager adapters, and moving file-based secrets into 1Password.pre-deploy hook.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub donnfelker/kamal-skills --plugin kamal-skills25 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./appOperate and inspect already-running Kamal apps without redeploying. Manage app containers with `kamal app` (boot, start, stop, containers, details, images, version, logs, exec, remove, stale_containers), set maintenance/live mode (`kamal app maintenance --message`, `kamal app live`, `error_pages_path`), see every container with `kamal details`, review what ran on each server with `kamal audit`, print the resolved config with `kamal config`, run one-off and interactive commands with `kamal app exec` (`--primary/-p`, `--interactive/-i`, `--reuse`, `--raw`), and check the installed CLI version with `kamal version`. Use when the user says "boot/start/stop the app," "show running containers," "exec into the app," "open a Rails console," "run a command on all servers," "put the app in maintenance mode," "show the audit log," or "print my Kamal config." For shipping releases, see deploy. For reverting a release, see rollback. For log-driver and OTel/file config, see logging. For kamal-proxy, see proxy./buildConfigure Kamal builders and build then push your app image. Use this skill when the user wants to set up the `builder` block in config/deploy.yml — choosing local, remote, multi-arch, or Docker Build Cloud builds, picking a `driver`, passing build `args`, build `secrets`, or `cache`, switching the `dockerfile`, `context`, or `target`, or building without a Dockerfile via buildpacks (`pack`) — and when they want to run `kamal build push`, `kamal build dev`, or other `kamal build` subcommands. Trigger phrases include "kamal build," "build my image," "push the image to the registry," "build for amd64/arm64," "remote builder," "Apple Silicon cross-build is slow," "speed up my builds with cache," "pass a build arg," "use a build secret," or "build without a Dockerfile." For configuring the container registry, see registry. For the one-step flow that builds and ships in a single command, see deploy. For managing the secret values that build secrets reference, see secrets./configUnderstand and write your Kamal configuration in config/deploy.yml. Use when the user says "set up config/deploy.yml," "what goes in my deploy.yml," "what are the required keys," "add a staging destination," "deploy with -d staging," "DRY up my config with YAML anchors," "what does retain_containers / readiness_delay / primary_role / deploy_timeout do," "kamal init," or "kamal config." Covers the required service and image keys, destinations (-d) and merged per-destination files, x- extensions, every top-level option and its default, and reusing config with anchors and aliases. For configuring servers and roles, see servers. For env and secrets, see env. For command shortcuts, see aliases. For a first deployment, see setup./cronRun recurring, scheduled, or cron jobs on a Kamal deployment. Use when the user says "run a cron job," "schedule a recurring task," "nightly job," "hourly job," "periodic task," "set up cron with Kamal," "scheduled jobs," "run cron in a container," or asks how to keep a crontab running on their servers. Covers defining a dedicated `cron` role under the `servers:` key with a `cmd` that loads a `config/crontab` file and runs `cron -f`, and propagating environment variables into the crontab (cron does not pass them through on its own). For configuring web and worker job roles or targeting hosts/roles, see servers. For running databases, Redis, or other supporting services, see accessories. For setting `env:` values and secrets the jobs need, see env.Other plugins' skills for the same job