返回 Skill 列表
extension
分类: 开发与工程无需 API Key

config-setup

设置配置文件、环境变量和项目配置。在设置项目配置、环境搭建或配置管理时使用。创建配置文件、.env示例和配置文档。

person作者: jakexiaohubgithub

Config Setup Skill

Instructions

  1. Analyze configuration requirements from task
  2. Identify what needs to be configured (database, API keys, environment, etc.)
  3. Create configuration files
  4. Set up environment variable management
  5. Create .env.example file
  6. Document configuration
  7. Return implementation with:
    • Configuration files
    • Environment variable setup
    • .env.example file
    • Configuration documentation

Examples

Input: "Set up environment configuration" Output:

// config/index.js
require('dotenv').config();

module.exports = {
    port: process.env.PORT || 3000,
    database: {
        host: process.env.DB_HOST || 'localhost',
        port: process.env.DB_PORT || 5432,
        name: process.env.DB_NAME,
        user: process.env.DB_USER,
        password: process.env.DB_PASSWORD
    },
    jwt: {
        secret: process.env.JWT_SECRET,
        expiresIn: process.env.JWT_EXPIRES_IN || '24h'
    },
    nodeEnv: process.env.NODE_ENV || 'development'
};
# .env.example
PORT=3000
NODE_ENV=development

DB_HOST=localhost
DB_PORT=5432
DB_NAME=myapp
DB_USER=postgres
DB_PASSWORD=

JWT_SECRET=your-secret-key-here
JWT_EXPIRES_IN=24h

Configuration Areas

  • Environment Variables: .env files, environment setup
  • Application Config: App configuration, feature flags
  • Database Config: Database connection, migration config
  • API Config: External API keys, endpoints
  • Build Config: Build tools, bundlers, compilers
  • Deployment Config: Deployment-specific settings
  • Development Config: Local development setup

Best Practices

  • No Secrets in Code: Use environment variables for secrets
  • .env.example: Provide example file with all required variables
  • Documentation: Document all configuration options
  • Validation: Validate configuration on startup
  • Defaults: Provide sensible defaults where appropriate
  • Environment-Specific: Different configs for dev/staging/prod