Token导航 LogoToken导航

Agent Skill · 研究检索

twelve-factor(十二因数)

twelve-factor 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

twelve-factor 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为接触敏感数据;许可证信息还不明确,第三方扫描已通过,按安装量在研究检索类的 73,675 个 Skill 里排第 66,724。

总安装 259周安装 11GitHub Stars 17下载 91核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:twelve-factor(十二因数)
来源仓库:https://github.com/vinnie357/claude-skills
仓库路径:skills/twelve-factor
安装命令:
npx skills add https://github.com/vinnie357/claude-skills --skill twelve-factor
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/vinnie357/claude-skills --skill twelve-factor

这个 Skill 是做什么的

研究检索类 Skill 主要解决「找资料、核对事实、把来源整理清楚」的问题,通常会让助手先检索再总结。

twelve-factor 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中快速定位候选结果。适用于关键词搜索、任务场景匹配和来源线索筛选等研究检索场景。通过 npx skills add 命令从 GitHub 仓库安装,需指定技能名称和仓库地址。

安装前建议确认权限范围、维护状态,以及是否会触发联网或文件读写操作。适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

来源仓库内路径:skills/twelve-factor

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/vinnie357/claude-skills --skill twelve-factor;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要接触敏感数据,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

twelve-factor 怎么安装?

在终端执行 npx skills add https://github.com/vinnie357/claude-skills --skill twelve-factor。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

twelve-factor 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

twelve-factor 需要什么权限?

权限级别是接触敏感数据。该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

twelve-factor 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

twelve-factor 用的人多吗?

公开数据是累计安装 259 次,近一周安装 11 次,下载 91 次,GitHub 17 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

twelve-factor 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

  • 需要接触敏感数据,装到常用环境前要先评估影响面。
  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理研究检索类任务、又不想每次都手写提示词的人。

不太适合

  • 环境里有大量密钥、凭证,不方便给第三方 Skill 读取的人。
  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

研究检索类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
find-skills

寻找技能 · Codex、Claude

31,199,81316,486操作浏览器MIT有提醒
self-improving-agent

自我改进 Agent · OpenClaw

16,464,0023,396接触敏感数据MIT-0通过
soultrace

灵魂追踪 · Codex、Claude

7,588,94412需要联网未明确有提醒
self-improving

自我完善 · OpenClaw

6,829,2841,046需要联网MIT-0通过
microsoft-foundry

微软代工厂 · Codex、Claude

6,614,144764调用外部服务未明确有提醒
twelve-factor

十二因数 · 本页

25917接触敏感数据未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

12-Factor App Methodology

Guide for building scalable, maintainable, and portable cloud-native applications following the 12-Factor App principles and modern extensions.

When to Activate

Use this skill when:

  • Designing or refactoring cloud-native applications
  • Building applications for Kubernetes deployment
  • Setting up CI/CD pipelines
  • Implementing microservices architecture
  • Migrating applications to containers
  • Reviewing architecture for cloud readiness
  • Troubleshooting deployment or scaling issues
  • Working with environment configuration

The 12 Factors

I. Codebase

One codebase tracked in revision control, many deploys

myapp-repo/
├── src/
├── config/
├── deploy/
│   ├── staging/
│   ├── production/
│   └── development/
└── Dockerfile

Key principles:

  • Single Git repository for the application
  • Multiple environments deploy from same codebase
  • Environment-specific config separate from code
  • Use GitOps (ArgoCD, Flux) for deployment automation

Anti-patterns:

  • ❌ Multiple repositories for the same application
  • ❌ Different codebases for different environments
  • ❌ Copying code between repositories

II. Dependencies

Explicitly declare and isolate dependencies

Declare all dependencies explicitly using package managers:

# Multi-stage build for dependency isolation
FROM node:18-alpine AS dependencies
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production

FROM node:18-alpine AS runtime
WORKDIR /app
COPY --from=dependencies /app/node_modules ./node_modules
COPY . .
CMD ["node", "index.js"]

Language-specific examples:

  • Node.js: package.json and package-lock.json
  • Python: requirements.txt or Pipfile.lock
  • Java: pom.xml or build.gradle
  • Go: go.mod and go.sum
  • Elixir: mix.exs and mix.lock
  • Rust: Cargo.toml and Cargo.lock

Key principles:

  • Never rely on system-wide packages
  • Use lock files for reproducible builds
  • Vendor dependencies when possible
  • Multi-stage builds for smaller images

III. Config

Store config in the environment

All configuration should come from environment variables:

# Elixir - config/runtime.exs
import Config

config :my_app, MyApp.Repo,
  database: System.get_env("DATABASE_NAME") || "my_app_dev",
  username: System.get_env("DATABASE_USER") || "postgres",
  password: System.fetch_env!("DATABASE_PASSWORD"),
  hostname: System.get_env("DATABASE_HOST") || "localhost",
  pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10")
// Node.js
const config = {
  database: {
    url: process.env.DATABASE_URL,
    pool: {
      min: parseInt(process.env.DB_POOL_MIN || '2'),
      max: parseInt(process.env.DB_POOL_MAX || '10')
    }
  },
  cache: {
    ttl: parseInt(process.env.CACHE_TTL || '3600')
  }
};

Kubernetes ConfigMaps:

apiVersion: v1
kind: ConfigMap
metadata:
  name: app-config
data:
  DATABASE_HOST: "postgres-service"
  CACHE_TTL: "3600"
  LOG_LEVEL: "info"

Kubernetes Secrets:

apiVersion: v1
kind: Secret
metadata:
  name: app-secrets
type: Opaque
data:
  DATABASE_PASSWORD: <base64-encoded>
  JWT_SECRET: <base64-encoded>
  API_KEY: <base64-encoded>

Anti-patterns:

  • ❌ Hardcoded configuration values
  • ❌ Configuration files committed to version control
  • ❌ Different code paths for different environments

IV. Backing Services

Treat backing services as attached resources

Connect to all backing services (databases, queues, caches, APIs) via URLs in environment variables:

// Treat all backing services uniformly
const services = {
  database: createConnection(process.env.DATABASE_URL),
  cache: createRedisClient(process.env.REDIS_URL),
  queue: createQueueClient(process.env.RABBITMQ_URL),
  storage: createS3Client(process.env.S3_ENDPOINT)
};

Kubernetes Service Discovery:

apiVersion: v1
kind: Service
metadata:
  name: redis-service
spec:
  selector:
    app: redis
  ports:
  - port: 6379
    targetPort: 6379

Key principles:

  • No distinction between local and third-party services
  • Swappable via configuration change only
  • No code changes to swap backing services
  • Connection via URL in environment

V. Build, Release, Run

Strictly separate build and run stages

Three distinct stages:

  1. Build: Convert code to executable bundle
  2. Release: Combine build with config
  3. Run: Execute in target environment
# GitHub Actions CI/CD Pipeline
name: Build and Deploy
on:
  push:
    branches: [main]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Build Docker image
        run: docker build -t myapp:${{ github.sha }} .
      - name: Push to registry
        run: docker push myapp:${{ github.sha }}

  deploy:
    needs: build
    runs-on: ubuntu-latest
    steps:
      - name: Deploy to Kubernetes
        run: kubectl set image deployment/myapp myapp=myapp:${{ github.sha }}

Key principles:

  • Immutable releases (never modify, only deploy new)
  • Unique release identifiers (git SHA, semver)
  • Rollback by redeploying previous release
  • Separate build artifacts from runtime config

VI. Processes

Execute the app as one or more stateless processes

Application processes should be stateless and share-nothing. Store persistent state in backing services.

// ❌ Bad: In-memory session store
app.use(session({
  secret: process.env.SESSION_SECRET,
  resave: false
  // Uses memory store by default
}));

// ✓ Good: Store session in Redis
app.use(session({
  store: new RedisStore({
    client: redisClient,
    prefix: 'sess:'
  }),
  secret: process.env.SESSION_SECRET,
  resave: false,
  saveUninitialized: false
}));

Kubernetes Deployment:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: myapp
spec:
  replicas: 3  # Can scale horizontally
  selector:
    matchLabels:
      app: myapp
  template:
    spec:
      containers:
      - name: myapp
        image: myapp:latest
        resources:
          requests:
            memory: "128Mi"
            cpu: "100m"
          limits:
            memory: "256Mi"
            cpu: "200m"

Key principles:

  • Stateless processes enable horizontal scaling
  • No sticky sessions
  • No local filesystem for persistent data
  • Shared state goes in databases, caches, or queues

VII. Port Binding

Export services via port binding

Applications are self-contained and bind to a port:

const express = require('express');
const app = express();
const port = process.env.PORT || 3000;

app.listen(port, '0.0.0.0', () => {
  console.log(`Server running on port ${port}`);
});
# Phoenix endpoint config
config :my_app, MyAppWeb.Endpoint,
  http: [port: String.to_integer(System.get_env("PORT") || "4000")],
  server: true

Kubernetes Service:

apiVersion: v1
kind: Service
metadata:
  name: myapp-service
spec:
  selector:
    app: myapp
  ports:
  - port: 80
    targetPort: 3000
  type: LoadBalancer

Key principles:

  • Bind to 0.0.0.0, not localhost
  • Port number from environment variable
  • No reliance on runtime injection (e.g., Apache, Nginx)
  • HTTP server library embedded in app

VIII. Concurrency

Scale out via the process model

Scale by adding more processes (horizontal scaling), not by making processes larger (vertical scaling):

# Horizontal Pod Autoscaler
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: myapp-hpa
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: myapp
  minReplicas: 2
  maxReplicas: 10
  metrics:
  - type: Resource
    resource:
      name: cpu
      target:
        type: Utilization
        averageUtilization: 70

Process types (Procfile concept):

web: node server.js
worker: node worker.js
scheduler: node scheduler.js

Key principles:

  • Different process types for different workloads
  • Processes can scale independently
  • OS process manager handles processes
  • Never daemonize or write PID files

IX. Disposability

Maximize robustness with fast startup and graceful shutdown

const server = app.listen(port, () => {
  console.log('Server started');
});

// Graceful shutdown
process.on('SIGTERM', () => {
  console.log('SIGTERM received, shutting down gracefully');

  server.close(() => {
    // Close database connections
    db.close();

    // Close other connections
    redis.quit();

    console.log('Process terminated');
    process.exit(0);
  });
});

Kubernetes lifecycle hooks:

spec:
  containers:
  - name: myapp
    image: myapp:latest
    lifecycle:
      preStop:
        exec:
          command: ["/bin/sh", "-c", "sleep 15"]
    terminationGracePeriodSeconds: 30

Key principles:

  • Minimize startup time (< 10 seconds ideal)
  • Handle SIGTERM for graceful shutdown
  • Finish in-flight requests before shutting down
  • Robust against sudden death
  • Fast startup enables rapid scaling

X. Dev/Prod Parity

Keep development, staging, and production as similar as possible

Docker Compose for local development:

version: '3.8'
services:
  app:
    build: .
    ports:
      - "3000:3000"
    environment:
      - DATABASE_URL=postgresql://user:pass@db:5432/myapp
      - REDIS_URL=redis://redis:6379
    depends_on:
      - db
      - redis

  db:
    image: postgres:15
    environment:
      POSTGRES_DB: myapp
      POSTGRES_USER: user
      POSTGRES_PASSWORD: pass

  redis:
    image: redis:7-alpine

Key principles:

  • Use same backing services in dev and prod
  • Containers ensure environment consistency
  • Infrastructure as code for reproducibility
  • Minimize time gap between dev and production
  • Same deployment process for all environments

XI. Logs

Treat logs as event streams

Write all logs to stdout/stderr, let the environment handle aggregation:

// Structured logging to stdout
const winston = require('winston');

const logger = winston.createLogger({
  format: winston.format.combine(
    winston.format.timestamp(),
    winston.format.json()
  ),
  transports: [
    new winston.transports.Console()
  ]
});

logger.info('User logged in', {
  userId: 123,
  ip: '192.168.1.1',
  userAgent: 'Mozilla/5.0...'
});
# Elixir structured logging
require Logger

Logger.info("User logged in",
  user_id: 123,
  ip: "192.168.1.1"
)

Key principles:

  • Never manage log files
  • Write unbuffered to stdout
  • Use structured logging (JSON)
  • Let platform route logs (Fluentd, Logstash)
  • Include correlation IDs for tracing

Anti-patterns:

  • ❌ Writing to log files
  • ❌ Log rotation within the app
  • ❌ Sending logs directly to aggregation service

XII. Admin Processes

Run admin/management tasks as one-off processes

Database migrations, console, one-time scripts:

# Kubernetes Job for database migration
apiVersion: batch/v1
kind: Job
metadata:
  name: db-migration
spec:
  template:
    spec:
      containers:
      - name: migrate
        image: myapp:latest
        command: ["npm", "run", "migrate"]
        env:
        - name: DATABASE_URL
          valueFrom:
            secretKeyRef:
              name: app-secrets
              key: DATABASE_URL
      restartPolicy: OnFailure
# CronJob for scheduled cleanup
apiVersion: batch/v1
kind: CronJob
metadata:
  name: data-cleanup
spec:
  schedule: "0 2 * * *"
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: cleanup
            image: myapp:latest
            command: ["npm", "run", "cleanup"]
          restartPolicy: OnFailure

Key principles:

  • Same environment as regular processes
  • Same codebase and config
  • Run against release, not development code
  • Use scheduler for recurring tasks
  • Ship admin code with application code

Modern Extensions (Beyond 12)

XIII. API First

Design and document APIs before implementation:

# OpenAPI specification
openapi: 3.0.0
info:
  title: My API
  version: v1
paths:
  /users:
    get:
      summary: List users
      responses:
        '200':
          description: Success

Key principles:

  • OpenAPI/Swagger specifications
  • API versioning (URL or header)
  • API gateway pattern
  • Contract-first development

XIV. Telemetry

Comprehensive observability with metrics, tracing, and monitoring:

# Prometheus ServiceMonitor
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: myapp-monitor
spec:
  selector:
    matchLabels:
      app: myapp
  endpoints:
  - port: metrics
    path: /metrics

Key principles:

  • Expose /metrics endpoint (Prometheus format)
  • Distributed tracing (OpenTelemetry)
  • Application Performance Monitoring (APM)
  • Custom business metrics
  • Health check endpoints

XV. Security

Authentication, authorization, and security by design:

// JWT authentication middleware
function authenticateToken(req, res, next) {
  const authHeader = req.headers['authorization'];
  const token = authHeader && authHeader.split(' ')[1];

  if (!token) return res.sendStatus(401);

  jwt.verify(token, process.env.JWT_SECRET, (err, user) => {
    if (err) return res.sendStatus(403);
    req.user = user;
    next();
  });
}

Key principles:

  • OAuth 2.0 / OpenID Connect
  • RBAC (Role-Based Access Control)
  • Secrets in environment, never in code
  • TLS everywhere
  • Security scanning in CI/CD

Common Patterns

Configuration Validation

Validate required configuration at startup:

function validateConfig() {
  const required = ['DATABASE_URL', 'JWT_SECRET', 'REDIS_URL'];
  const missing = required.filter(key => !process.env[key]);

  if (missing.length > 0) {
    throw new Error(`Missing required environment variables: ${missing.join(', ')}`);
  }
}

// Call before starting server
validateConfig();

Health Checks

Implement health and readiness endpoints:

// Liveness probe
app.get('/health', (req, res) => {
  res.status(200).json({
    status: 'healthy',
    timestamp: new Date().toISOString()
  });
});

// Readiness probe
app.get('/ready', async (req, res) => {
  try {
    await db.ping();
    await redis.ping();
    res.status(200).json({ status: 'ready' });
  } catch (err) {
    res.status(503).json({ status: 'not ready', error: err.message });
  }
});

Kubernetes probes:

livenessProbe:
  httpGet:
    path: /health
    port: 3000
  initialDelaySeconds: 10
  periodSeconds: 10

readinessProbe:
  httpGet:
    path: /ready
    port: 3000
  initialDelaySeconds: 5
  periodSeconds: 5

Graceful Degradation

Handle backing service failures gracefully:

async function getCachedData(key) {
  try {
    return await redis.get(key);
  } catch (err) {
    logger.warn('Redis unavailable, falling back to database', { error: err.message });
    return await db.query('SELECT data FROM cache WHERE key = ?', [key]);
  }
}

Anti-Patterns to Avoid

❌ Environment-Specific Code Paths

// DON'T
if (process.env.NODE_ENV === 'production') {
  // Different behavior
} else {
  // Different behavior
}

// DO: Use configuration
const timeout = parseInt(process.env.TIMEOUT || '5000');

❌ Local File Storage

// DON'T: Write to local filesystem
fs.writeFile('/tmp/uploads/' + filename, data);

// DO: Use object storage
await s3.putObject({
  Bucket: process.env.S3_BUCKET,
  Key: filename,
  Body: data
});

❌ In-Memory State

// DON'T: Store state in memory
const sessions = new Map();

// DO: Use external store
const session = await redis.get(`session:${sessionId}`);

❌ Hardcoded Dependencies

// DON'T: Hardcode service locations
const db = connect('localhost:5432');

// DO: Use environment variables
const db = connect(process.env.DATABASE_URL);

Troubleshooting Guide

Application Won't Start

  1. Check required environment variables are set
  2. Validate configuration at startup
  3. Check backing service connectivity
  4. Review logs for initialization errors

Application Won't Scale

  1. Identify stateful operations
  2. Move state to backing services
  3. Remove file system dependencies
  4. Eliminate sticky sessions

Inconsistent Behavior Across Environments

  1. Ensure same backing service types (not SQLite in dev, Postgres in prod)
  2. Use containers for dev environment
  3. Check for environment-specific code paths
  4. Verify configuration is environment-only

Logs Not Appearing

  1. Ensure writing to stdout/stderr
  2. Avoid buffering log output
  3. Check log aggregation configuration
  4. Verify Kubernetes logging sidecar/daemonset

Best Practices Summary

  1. Environment variables for all configuration
  2. Stateless processes that can scale horizontally
  3. Structured logging to stdout
  4. Containers for development parity
  5. Automated CI/CD pipelines
  6. Health checks for orchestration
  7. Graceful shutdown handling
  8. Fast startup times (< 10s)
  9. Immutable releases with unique IDs
  10. Comprehensive monitoring and telemetry

Kubernetes-Specific Best Practices

Resource Limits

resources:
  requests:
    memory: "128Mi"
    cpu: "100m"
  limits:
    memory: "256Mi"
    cpu: "200m"

Init Containers

initContainers:
- name: wait-for-db
  image: busybox
  command: ['sh', '-c', 'until nc -z postgres-service 5432; do sleep 1; done']

Pod Disruption Budgets

apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
  name: myapp-pdb
spec:
  minAvailable: 1
  selector:
    matchLabels:
      app: myapp

Resources

Key Insights

"The twelve-factor methodology can be applied to apps written in any programming language, and which use any combination of backing services (database, queue, memory cache, etc)."
"A twelve-factor app never relies on implicit existence of state on the filesystem. Even if a process has written something to disk, it must assume that file won't be available on the next request."

Design applications from day one to be cloud-native, scalable, and maintainable. The investment in following these principles pays dividends in operational simplicity and development velocity.

平台分布

Codex

32.58%
按下载量换算30

Claude

27.72%
按下载量换算25

Cursor

19.99%
按下载量换算18

Gemini CLI

9.87%
按下载量换算9

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

接触敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills