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★ 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:
- Config (Factor III) — add env var validation without restructuring
- Logs (Factor XI) — switch to structured process-stream logging
- Disposability (Factor IX) — add graceful shutdown handlers
- Backing services (Factor IV) — inject platform-appropriate resource bindings
- 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.envdeep in the call tree - When you introduce or change a config module, move every
process.envread 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 forprocess.envand 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.examplein 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
Установить twelve-factor в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
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), без исполняемых скриптов.
Похожие скиллы
ci-review
The scan that the plugin's GitHub Action runs.
от Anthropicazure-static-web-apps
Helps create, configure, and deploy Azure Static Web Apps using the SWA CLI. Use when deploying static sites to Azure, setting up SWA local development…
от GitHubai-ready
Make any repo AI-ready — analyzes your codebase and generates AGENTS.md, copilot-instructions.md, CI workflows, issue templates, and more. Mines your PR…
от GitHubaws-cdk-python-setup
Setup and initialization guide for developing AWS CDK (Cloud Development Kit) applications in Python. This skill enables users to configure environment…
от GitHub