Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

twelve-factor

БесплатноБез исполняемых скриптовНе проверен

Twelve-Factor App patterns for software-as-a-service and long-running process applications. Use when configuring deploy-time environment, backing services…

citypaulот citypaul★ 764 звезды на GitHub

Об этом скилле

Twelve-Factor App Patterns

The original methodology targets software-as-a-service applications. Its principles can inform other deployables, but port binding, concurrency, process disposability, runtime config, and artifact parity do not map literally to every frontend, serverless function, or CLI.

Based on 12factor.net. All 12 factors are covered below: rules, anti-patterns, and code-level implications live here; Node/TypeScript implementation examples live in resources/.

See the typescript-strict skill for schema-first patterns at trust boundaries. See the testing skill for how to TDD these patterns — config validation, shutdown behavior, and backing service integration are all testable through behavior-driven tests.

Deep-dive resources are in the resources/ directory. Load them on demand:

Resource Load when...
node-patterns.md Implementing any factor in Node/TypeScript — config schema validation, options-object injection, .env.example, system dependency checks, backing service factories, Redis session store, web/worker entry points, health checks, graceful shutdown, structured logger, admin scripts

When to Apply

  • Greenfield SaaS/process applications: assess all twelve factors and adopt the ones that fit the runtime and platform.
  • Brownfield applications: adopt improvements incrementally from observed risk. A common starting order is:
    1. Config (Factor III) — add env var validation without restructuring
    2. Logs (Factor XI) — switch to structured process-stream logging
    3. Disposability (Factor IX) — add graceful shutdown handlers
    4. Backing services (Factor IV) — inject platform-appropriate resource bindings
    5. Stateless processes (Factor VI) — migrate in-memory state to backing services

Codebase (Factor I)

One codebase tracked in revision control, many deploys. A codebase can be a repository or a clearly owned part of a monorepo; do not split repositories merely to satisfy the label. Share code through an explicit owned package or module rather than copy-paste.

In a monorepo, each service should have its own entry point, its own deploy pipeline, and its own set of backing service connections. A single repo is fine as long as each service deploys independently.

Config (Factor III)

Store deploy-varying configuration outside the build. Environment variables are the Twelve-Factor default; use an equivalent platform-native secret or configuration injection mechanism when the runtime requires it. Never hardcode credentials or environment-specific endpoints.

Rules:

  • Validate config at startup with a schema — fail fast (exit non-zero, clear error) if config is invalid
  • Inject config via options objects — never import process.env deep in the call tree
  • When you introduce or change a config module, move every process.env read in the application into it in the same change — including settings the reported problem never named, such as a log level, an output path or a feature toggle. A config module that leaves other env reads scattered through request handlers, domain modules and start-up code has relocated the drift, not removed it. Finish by grepping the source for process.env and confirming the only hits are the config module and the process entry points that call it.
  • Document required configuration for the operator, not only in code. Where environment variables are the configuration interface, write or update .env.example in the same change as the schema: one line per setting the schema requires, placeholder values only, never a real credential, and never a committed .env. A validation schema tells the process what is wrong at boot; it does not tell a person what to put on the container — ship both. Where the platform's own manifest or secret-declaration format is the configuration interface, update that instead, by the same rule.

See resources/node-patterns.md for the Zod config schema, options-object injection, and .env.example examples.

Config Anti-Patterns

const DB_HOST = 'prod-db.internal.example.com';

if (process.env.NODE_ENV === 'production') {
  connectTo('prod-db');
} else {
  connectTo('localhost');
}

const config = require(`./config.${process.env.NODE_ENV}.json`);

Why these are wrong: Config that varies by deploy belongs outside source and build artifacts, supplied through the runtime's supported injection mechanism. Environment-name branching creates combinatorial explosion and breaks dev/prod parity.

The fix: name the thing the branch was actually deciding and make it its own validated setting — SECURE_COOKIES=true, DATABASE_URL=... — then delete the branch. Remove every environment-name comparison in the files you touch, not only the ones covering the settings you were asked about: two deploys given identical settings must behave identically, and one surviving NODE_ENV comparison i

Полный SKILL.md на GitHub

Установить twelve-factor в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

resources/node-patterns.md

FAQ

Что делает скилл twelve-factor?

Twelve-Factor App patterns for software-as-a-service and long-running process applications. Use when configuring deploy-time environment, backing services, process startup/shutdown, or operational parity. Apply individual principles to frontends, serverless functions, and CLIs only where their runtime and platform make them relevant.

Как установить скилл twelve-factor?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл twelve-factor запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить twelve-factor с