Communitygithub.com

ComeOnOliver/skillshub

驗證環境變數、設定檔,並確保所有必要設定都已記載。適用於處理 .env 檔案、設定檔或部署設定時使用。

skillshub 是什麼?

此技能旨在自動化驗證應用程式的設定檔與環境變數,藉此預防因缺少或錯誤設定而導致的執行階段錯誤。它能協助開發者與 AI Agent(如 Claude Code)系統化地檢查 .env 檔案、config 目錄下的設定,或是其他常見的設定檔格式。技能涵蓋從尋找設定檔、比對必填變數、驗證變數格式與型別、執行安全性檢查(例如確認 .env 是否已加入 .gitignore 防止誤提交機密),到產生設定範本與文件等完整流程。支援 Node.js 與 Python 等多種語言環境,並提供 Joi 等結構化驗證範例。此技能對於任何需要管理多個環境(開發、測試、生產)的專案特別有用,可確保每次部署都有正確且完整的設定,從而減少配置相關的線上事故。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/ComeOnOliver/skillshub/tree/HEAD/skills/aiskillstore/marketplace/crazydubya/configuration-validator

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

設定驗證器

驗證設定檔與環境變數,以防止執行階段錯誤與缺少設定。

使用時機

  • 處理環境變數或設定檔時
  • 遇到部署或設定問題時
  • 使用者提到「.env」、「config」、「環境變數」或「設定」時

操作說明

1. 尋找設定檔

搜尋以下檔案:

  • .env、.env.example、.env.local
  • config/、config.js、config.json
  • settings.py、application.yml
  • appsettings.json、.env.production

2. 偵測缺少的變數

比較 .env.example 與 .env:

# 在範例中有但 .env 中沒有的變數
comm -23 <(grep -o '^[A-Z_]*' .env.example | sort) <(grep -o '^[A-Z_]*' .env | sort)

常見必要變數:

DATABASE_URL
API_KEY
SECRET_KEY
NODE_ENV
PORT

3. 驗證變數格式

檢查常見問題:

// 包含空白的值缺少引號
DATABASE_URL=postgres://localhost/db name  // 錯誤
DATABASE_URL="postgres://localhost/db name"  // 正確

// 缺少通訊協定
API_URL=example.com  // 錯誤
API_URL=https://example.com  // 正確

// 布林值寫成字串
DEBUG=true  // 可能被解釋為字串
DEBUG=1  // 更明確

4. 在執行階段驗證必要變數

Node.js 範例:

const requiredEnvVars = [
  'DATABASE_URL',
  'API_KEY',
  'JWT_SECRET'
];

const missing = requiredEnvVars.filter(v => !process.env[v]);

if (missing.length > 0) {
  throw new Error(`缺少必要環境變數:${missing.join(', ')}`);
}

Python 範例:

import os

REQUIRED_ENV_VARS = [
    'DATABASE_URL',
    'SECRET_KEY',
    'ALLOWED_HOSTS'
]

missing = [var for var in REQUIRED_ENV_VARS if not os.getenv(var)]

if missing:
    raise EnvironmentError(f"缺少環境變數:{', '.join(missing)}")

5. 型別驗證

驗證型別:

const config = {
  port: parseInt(process.env.PORT || '3000', 10),
  debug: process.env.DEBUG === 'true',
  apiUrl: new URL(process.env.API_URL), // 無效時會拋出例外
  maxConnections: Number(process.env.MAX_CONNECTIONS),
};

// 驗證
if (isNaN(config.port) || config.port < 1 || config.port > 65535) {
  throw new Error('PORT 必須是有效的連接埠號碼');
}

6. 產生 .env.example

從實際的 .env 建立模板:

# 移除值,保留鍵
sed 's/=.*/=/' .env > .env.example

或使用預留位置:

DATABASE_URL=postgres://user:password@localhost:5432/dbname
API_KEY=your_api_key_here
SECRET_KEY=generate_random_secret
PORT=3000
NODE_ENV=development

7. 設定結構

定義結構(使用 Joi 範例):

const Joi = require('joi');

const envSchema = Joi.object({
  NODE_ENV: Joi.string()
    .valid('development', 'production', 'test')
    .required(),
  PORT: Joi.number()
    .port()
    .default(3000),
  DATABASE_URL: Joi.string()
    .uri()
    .required(),
  API_KEY: Joi.string()
    .min(32)
    .required(),
  DEBUG: Joi.boolean()
    .default(false),
}).unknown();

const { error, value } = envSchema.validate(process.env);

if (error) {
  throw new Error(`設定驗證錯誤:${error.message}`);
}

module.exports = value;

8. 安全性檢查

不要提交機密:

# 檢查 .env 是否在 .gitignore 中
if ! grep -q "^\.env$" .gitignore; then
  echo "警告:.env 未加入 .gitignore"
fi

# 檢查程式碼中是否有硬編碼的機密
grep -r "api_key.*=.*['\"]" --exclude-dir=node_modules

常見安全性問題:

  • 硬編碼的密碼/金鑰
  • 生產環境中的預設機密
  • 暴露的敏感設定
  • 未加密的機密

9. 依環境區分的設定

按環境組織:

.env.development
.env.staging
.env.production
.env.test

正確載入:

require('dotenv').config({
  path: `.env.${process.env.NODE_ENV || 'development'}`
});

10. 記錄所有變數

建立 CONFIG.md:

# 設定

## 環境變數

### 必要

- `DATABASE_URL`:PostgreSQL 連線字串
  - 格式:`postgres://user:pass@host:port/db`
  - 範例:`postgres://app:secret@localhost:5432/myapp`

- `API_KEY`:第三方 API 金鑰
  - 取得方式:https://dashboard.example.com
  - 必要權限:讀取、寫入

### 選用

- `PORT`:伺服器連接埠(預設:3000)
- `DEBUG`:啟用除錯記錄(預設:false)
- `MAX_CONNECTIONS`:資料庫連線池大小(預設:10)

## 設定步驟

1. 將 `.env.example` 複製為 `.env`
2. 填入所有必要值
3. 執行 `npm run validate-config` 進行驗證

11. 驗證腳本

建立 scripts/validate-config.js:

const fs = require('fs');

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

  if (missing.length > 0) {
    console.error(`❌ 缺少:${missing.join(', ')}`);
    process.exit(1);
  }

  console.log('✓ 所有必要設定變數均已存在');
}

validateConfig();

12. 最佳實務

  • 絕不提交 .env:永遠將其加入 gitignore
  • 維護 .env.example:保持更新
  • 啟動時驗證:設定錯誤時盡早失敗
  • 使用強健的預設值:合理的備援值
  • 記錄一切:說明每個變數
  • 輪換機密:定期更新金鑰
  • 使用機密管理工具:生產環境使用 Vault、AWS Secrets Manager
  • 型別檢查:驗證型別而不僅是存在與否

支援檔案

  • templates/config-validator.js
  • templates/.env.example
  • scripts/generate-env-example.sh

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

ComeOnOliver/skillshub

Create stunning, animation-rich HTML presentations from scratch or by converting PowerPoint files. Use when the user wants to build a presentation, convert a PPT/PPTX to web, or create slides for a talk/pitch. Helps non-designers discover their aesthetic through visual exploration rather than abstract choices.

ComeOnOliver/skillshub

Next.js 16+ 和 Turbopack — 增量打包、文件系统缓存、开发速度,以及何时使用 Turbopack 与 webpack。

ComeOnOliver/skillshub

SwiftUI architecture patterns, state management with @Observable, view composition, navigation, performance optimization, and modern iOS/macOS UI best practices.

ComeOnOliver/skillshub

See, Understand, Act on video and audio. See- ingest from local files, URLs, RTSP/live feeds, or live record desktop; return realtime context and playable stream links. Understand- extract frames, build visual/semantic/temporal indexes, and search moments with timestamps and auto-clips. Act- transcode and normalize (codec, fps, resolution, aspect ratio), perform timeline edits (subtitles, text/image overlays, branding, audio overlays, dubbing, translation), generate media assets (image, audio, video), and create real time alerts for events from live streams or desktop capture.

ComeOnOliver/skillshub

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

ComeOnOliver/skillshub

Next.js 15 애플리케이션을 위한 프론트엔드 개발 가이드라인. React 19, TypeScript, Shadcn/ui, Tailwind CSS를 사용한 모던 패턴. Server Components, Client Components, App Router, 파일 구조, Shadcn/ui 컴포넌트, 성능 최적화, TypeScript 모범 사례 포함. 컴포넌트, 페이지, 기능 생성, 데이터 페칭, 스타일링, 라우팅, 프론트엔드 코드 작업 시 사용.

ComeOnOliver/skillshub

Provides Tamagui patterns for config v4, compiler optimization, styled context, and cross-platform styling. Must use when working with Tamagui projects (tamagui.config.ts, @tamagui imports).

ComeOnOliver/skillshub

Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.

ComeOnOliver/skillshub

Create high-converting, visually distinctive landing pages. Use when building marketing pages, product launches, SaaS homepages, or any single-page conversion-focused website. Guides section-by-section composition with anti-AI-slop principles.

ComeOnOliver/skillshub

Auto-loaded context for Portfolio Buddy 2 development. Use for ANY task involving: React 19 development, TypeScript, portfolio analysis features, metrics calculations, trading strategy comparison, or working with the Portfolio Buddy 2 codebase. Contains tech stack, known issues, and architectural constraints.

ComeOnOliver/skillshub

Next.js development tooling via MCP. Inspect routes, components, build info, and debug Next.js apps. Use when working on Next.js applications, debugging routing, or inspecting app structure. NOT for general React or non-Next.js projects.

ComeOnOliver/skillshub

Implement UI using Shadcn MCP (atoms/theme) and 21st.dev MCP (complex sections). Use when adding buttons, layouts, or generating landing pages.

ComeOnOliver/skillshub

A conceptual skill for building an API client in Next.js that handles JWT tokens

ComeOnOliver/skillshub

Best practices and patterns for Next.js App Router, Server Actions, and Routing in this project.

ComeOnOliver/skillshub

The Design System, Theme, and UX rules for the Physical AI Hub.

ComeOnOliver/skillshub

Comprehensive frontend development skill for building modern, performant web applications using ReactJS, NextJS, TypeScript, Tailwind CSS. Includes component scaffolding, performance optimization, bundle analysis, and UI best practices. Use when developing frontend features, optimizing performance, implementing UI/UX designs, managing state, or reviewing frontend code.

ComeOnOliver/skillshub

This document captures learnings from fixing keyboard navigation issues when floating components (Select, DropdownMenu, Popover) have CSS open/close animations.

ComeOnOliver/skillshub

Build Next.js 16 applications with correct patterns and distinctive design. Use when creating pages, layouts, dynamic routes, upgrading from Next.js 15, or implementing proxy.ts. Covers breaking changes (async params/searchParams, Turbopack, cacheComponents) and frontend aesthetics. NOT when building non-React or backend-only applications.

ComeOnOliver/skillshub

Comprehensive Framer Motion animation library for React. Covers motion components, variants, gestures, page transitions, and scroll animations. Use when adding animations to React/Next.js applications.

ComeOnOliver/skillshub

Build interfaces that resonate, not just render. This skill enforces bold, intentional

相關技能