phoenix-ops — скилл для Claude Code: деплой Phoenix на BEAM
Скилл для подготовки Phoenix-приложения к продакшену: релизы, runtime-конфиг, кластеризация, телеметрия и защита эндпоинтов.
npx skills add bobmatnyc/claude-mpm-skills --skill phoenix-ops -a claude-codeЧто делает phoenix-ops
Скилл собирает в одном месте операции, которые обычно распиханы по вики и чужим блогам: сборка релиза, настройки через config/runtime.exs, libcluster для обнаружения нод, телеметрия и структурные логи, фоновые задачи на Oban, hardening HTTP. Внутри — готовые сниппеты: команды mix assets.deploy и mix release, конфиг репозитория с DATABASE_URL и pool_size, топология Cluster.Strategy.DNSPoll для application.ex, список зависимостей вроде opentelemetry_phoenix и opentelemetry_ecto.
Отдельный блок про грабли. Сборка релиза без PHX_SERVER=true даёт эндпоинт, который не стартует, а разные secret_key_base на нодах ломают сессии после деплоя. Если кластер не настроен, Presence начинает расходиться между нодами — это повод проверить топологию до того, как включать фичи на Presence.
Скилл не запускает ничего сам: user-invocable: false и disable-model-invocation: true, то есть модель не дёрнет его по своей инициативе. Секреты советует держать в переменных окружения или в KMS/Vault, а не в конфигах, а SECRET_KEY_BASE получать через mix phx.gen.secret. Есть разделы про контейнеры, systemd, blue/green и эндпоинты /health и /ready.
Какие задачи решает
- собрать релиз Phoenix и запустить его как сервис
- вынести настройки БД и эндпоинта в runtime-конфиг
- настроить libcluster, чтобы PubSub и Presence работали на нескольких нодах
- подключить телеметрию и структурные логи для прода
- закрыть эндпоинт HTTPS, CORS и ограничением частоты запросов
Примеры запросов агенту
- помоги настроить config/runtime.exs для продакшен-релиза Phoenix
- добавь libcluster с DNS-стратегией и подключи Phoenix.PubSub
- проверь мой application.ex на типичные ошибки при деплое на BEAM
Как установить phoenix-ops
1Через Skills CLI (Vercel)
npx skills add bobmatnyc/claude-mpm-skills --skill phoenix-ops -a claude-code2Вручную: положить файлы
~/.claude/skills/phoenix-ops/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/phoenix-ops/
1Через Skills CLI (Vercel)
npx skills add bobmatnyc/claude-mpm-skills --skill phoenix-ops -a codex2Вручную: положить файлы
.agents/skills/phoenix-ops/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add bobmatnyc/claude-mpm-skills --skill phoenix-ops -a cursor2Вручную: положить файлы
.cursor/skills/phoenix-ops/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install bobmatnyc/claude-mpm-skills phoenix-ops2Вручную: положить файлы
.github/skills/phoenix-ops/SKILL.md1Через Skills CLI (Vercel)
npx skills add bobmatnyc/claude-mpm-skills --skill phoenix-ops -a gemini-cli2Командой платформы
gemini skills install https://github.com/bobmatnyc/claude-mpm-skills --path toolchains/elixir/ops/phoenix-opsВручную: положить файлы
.devin/skills/phoenix-ops/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Через Skills CLI (Vercel)
npx skills add bobmatnyc/claude-mpm-skills --skill phoenix-ops -a opencodeClaude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Из того же набора65
Похожие
Рядом в теме «DevOps и инфраструктура»
Всё по теме «DevOps и инфраструктура» →Вопросы о phoenix-ops
Как установить phoenix-ops в Claude?
Выполните npx skills add bobmatnyc/claude-mpm-skills --skill phoenix-ops -a claude-code. После этого файл скилла появится по пути ~/.claude/skills/phoenix-ops/SKILL.md.
Что делает phoenix-ops?
Описывает продакшен-операции для Phoenix: релизы, runtime-конфигурацию, кластеризацию, телеметрию, секреты, ассеты, фоновые задачи и защиту эндпоинтов.
Скилл вызывает модель сам?
Нет. В нём стоит user-invocable: false и disable-model-invocation: true, поэтому вызывать его нужно вручную.
Исходный текст
SKILL.md · MIT
---
name: phoenix-ops
description: "Phoenix operations and deployment: releases, runtime configuration, clustering, libcluster, telemetry/logging, secrets, assets, background jobs, and production hardening on the BEAM."
user-invocable: false
disable-model-invocation: true
version: 1.0.0
category: toolchain
author: Claude MPM Team
license: MIT
progressive_disclosure:
entry_point:
summary: "Phoenix production ops: releases, runtime config, libcluster, telemetry/logging, secrets, assets, jobs, and hardening on the BEAM."
when_to_use:
- "Preparing Phoenix apps for production deployment or CI/CD"
- "Configuring clustering/libcluster for multi-node PubSub/Presence"
- "Setting up telemetry/logging and runtime configuration for releases"
- "Hardening endpoints (HTTPS, rate limiting, CORS, secrets)"
quick_start:
- 'Set env: MIX_ENV=prod PHX_SERVER=true SECRET_KEY_BASE=... DATABASE_URL=...'
- "mix assets.deploy && MIX_ENV=prod mix release"
- "Configure runtime in config/runtime.exs (DB, cache, endpoints, Oban)"
- "Add libcluster + DNS/epmd strategy; enable OpentelemetryPhoenix/Ecto"
token_estimate:
entry: 180
full: 5600
---
# Phoenix Operations and Deployment (Elixir/BEAM)
Production-ready Phoenix apps rely on releases, runtime configuration, telemetry, clustering, and secure endpoints. The BEAM enables rolling restarts and supervision resilience when configured correctly.
## Releases and Runtime Config
```bash
MIX_ENV=prod PHX_SERVER=true mix assets.deploy
MIX_ENV=prod mix release
_build/prod/rel/my_app/bin/my_app eval "IO.puts(:os.type())"
_build/prod/rel/my_app/bin/my_app start
```
`config/runtime.exs` for env-driven settings:
```elixir
config :my_app, MyApp.Repo,
url: System.fetch_env!("DATABASE_URL"),
pool_size: String.to_integer(System.get_env("POOL_SIZE", "10")),
ssl: true
config :my_app, MyAppWeb.Endpoint,
url: [host: System.fetch_env!("PHX_HOST"), port: 443, scheme: "https"],
http: [ip: {0,0,0,0}, port: String.to_integer(System.get_env("PORT", "4000"))],
secret_key_base: System.fetch_env!("SECRET_KEY_BASE"),
server: true
```
**Secrets**
- Prefer env vars or secret stores (AWS/GCP KMS, Vault); avoid embedding in configs.
- Generate `SECRET_KEY_BASE` with `mix phx.gen.secret`.
## Clustering and PubSub/Presence
Add `libcluster` for automatic node discovery:
```elixir
# mix.exs deps
{:libcluster, "~> 3.3"},
{:phoenix_pubsub, "~> 2.1"},
# application.ex
topologies = [
dns_poll: [
strategy: Cluster.Strategy.DNSPoll,
config: [poll_interval: 5_000, query: "my-app.internal"],
connect: {:net_adm, :ping}
]
]
children = [
{Cluster.Supervisor, [topologies, [name: MyApp.ClusterSupervisor]]},
{Phoenix.PubSub, name: MyApp.PubSub},
MyAppWeb.Endpoint
]
```
**Guidelines**
- Share `secret_key_base` across nodes for consistent session signing.
- Use distributed PubSub for Presence; ensure node connectivity before enabling Presence-heavy features.
- For blue/green, keep cookies compatible between versions.
## Telemetry, Logging, and Metrics
- Install `opentelemetry_phoenix` and `opentelemetry_ecto` for traces/metrics.
- Add `Plug.Telemetry` and `LoggerJSON` or structured logging.
- Export metrics (Prometheus/OpenTelemetry) via `:telemetry_poller` for VM stats (reductions, memory, schedulers).
- Set `LOGGER_LEVEL=info` in prod; use `:debug` only for troubleshooting.
## HTTP and Network Hardening
- Enforce HTTPS (`force_ssl`), HSTS, secure cookies (`same_site`, `secure`), and proper `content_security_policy`.
- CORS: configure `cors_plug` for API origins.
- Rate limiting: apply plugs (ETS/Cachex token bucket) or edge (NGINX/Cloudflare).
- Uploads: prefer presigned URLs; limit request body size (`:max_request_line_length`, `:max_header_value_length`).
## Assets and Static Delivery
- `mix assets.deploy` runs npm/tailwind/esbuild and digests assets.
- Serve static files via CDN/reverse proxy; ensure `cache-control` headers set in Endpoint.
- Disable unused watchers in production to trim image size.
## Background Jobs
- Oban recommended for retries/backoff, scheduled jobs, and isolation; supervise in `application.ex`.
- Configure queues via runtime env; monitor with Oban Web/Pro or telemetry.
- For CPU-heavy tasks, consider pooling or external workers to avoid blocking schedulers.
## Deployment Patterns
- **Containers**: multi-stage builds; run `mix deps.get --only prod`, `mix compile`, `mix assets.deploy`, then `mix release`.
- **Systemd**: run release binary as service with `Environment=` secrets; add `Restart=on-failure`.
- **Fly/Gigalixir/Render**: supply env vars, attach Postgres/Redis, open long-lived WebSocket ports.
- **Blue/green or canary**: keep DB migrations compatible; deploy code first, then run migrations; keep feature flags for schema changes.
## Observability and Health
- Add `/health` and `/ready` endpoints (Repo check + PubSub/Presence check).
- Export VM metrics: run `:telemetry_poller` for scheduler utilization and memory.
- Alert on error rates, DB timeouts, queue depths, and VM memory.
## Common Pitfalls
- Building releases without `PHX_SERVER=true` (endpoint won’t start).
- Missing runtime config in `config/runtime.exs`; relying on compile-time config for secrets.
- No cluster discovery configured → Presence inconsistencies across nodes.
- Leaving default `secret_key_base` or per-node keys → invalid sessions after deploy.
- Large assets without digests/CDN → slow cold loads.
© Claude MPM Team · MIT · bobmatnyc/claude-mpm-skills