configuration-validator
Validates environment variables, config files, and ensures all required settings are documented. Use when working with .env files, configs, or deployment settings.
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o configuration-validator.zip https://jpskill.com/download/18103.zip && unzip -o configuration-validator.zip && rm configuration-validator.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/18103.zip -OutFile "$d\configuration-validator.zip"; Expand-Archive "$d\configuration-validator.zip" -DestinationPath $d -Force; ri "$d\configuration-validator.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
configuration-validator.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
configuration-validatorフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
Configuration Validator
設定ファイルと環境変数を検証し、ランタイムエラーや設定の欠落を防ぎます。
どのような時に使うか
- 環境変数または設定ファイルを扱う場合
- デプロイまたは設定に関する問題が発生した場合
- ユーザーが ".env"、"config"、"environment variables"、または "settings" について言及した場合
手順
1. 設定ファイルを探す
以下を検索します。
.env,.env.example,.env.localconfig/,config.js,config.jsonsettings.py,application.ymlappsettings.json,.env.production
2. 欠落している変数を検出する
.env.example と .env を比較:
# .env.example に存在するが .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 required env vars: ${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"Missing env vars: {', '.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 must be a valid port number');
}
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(`Config validation error: ${error.message}`);
}
module.exports = value;
8. セキュリティチェック
.env をコミットしない:
# .env が gitignore されているか確認
if ! grep -q "^\.env$" .gitignore; then
echo "Warning: .env not in .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 を作成:
# Configuration
## Environment Variables
### Required
- `DATABASE_URL`: PostgreSQL 接続文字列
- Format: `postgres://user:pass@host:port/db`
- Example: `postgres://app:secret@localhost:5432/myapp`
- `API_KEY`: サードパーティ API キー
- Obtain from: https://dashboard.example.com
- Required scopes: read, write
### Optional
- `PORT`: サーバーポート (default: 3000)
- `DEBUG`: デバッグログを有効にする (default: false)
- `MAX_CONNECTIONS`: データベースプールサイズ (default: 10)
## Setup
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: ${missing.join(', ')}`);
process.exit(1);
}
console.log('✓ All required config variables present');
}
validateConfig();
12. ベストプラクティス
- .env をコミットしない: 常に gitignore する
- .env.example を維持: 最新の状態に保つ
- 起動時に検証: 設定が誤っている場合はすぐに失敗させる
- 強力なデフォルトを使用: 適切なフォールバック
- すべてをドキュメント化: 各変数を説明する
- シークレットをローテーション: 定期的にキーを更新する
- シークレットマネージャーを使用: 本番環境では Vault、AWS Secrets Manager を使用する
- 型チェック: 存在だけでなく型も検証する
サポートファイル
templates/config-validator.jstemplates/.env.examplescripts/generate-env-example.sh
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Configuration Validator
Validates configuration files and environment variables to prevent runtime errors and missing settings.
When to Use
- Working with environment variables or config files
- Deployment or configuration issues
- User mentions ".env", "config", "environment variables", or "settings"
Instructions
1. Find Configuration Files
Search for:
.env,.env.example,.env.localconfig/,config.js,config.jsonsettings.py,application.ymlappsettings.json,.env.production
2. Detect Missing Variables
Compare .env.example vs .env:
# Variables in example but not in .env
comm -23 <(grep -o '^[A-Z_]*' .env.example | sort) <(grep -o '^[A-Z_]*' .env | sort)
Common required variables:
DATABASE_URL
API_KEY
SECRET_KEY
NODE_ENV
PORT
3. Validate Variable Format
Check for common issues:
// Missing quotes for values with spaces
DATABASE_URL=postgres://localhost/db name // Bad
DATABASE_URL="postgres://localhost/db name" // Good
// Missing protocol
API_URL=example.com // Bad
API_URL=https://example.com // Good
// Boolean as string
DEBUG=true // Might be interpreted as string
DEBUG=1 // More explicit
4. Validate Required Variables at Runtime
Node.js example:
const requiredEnvVars = [
'DATABASE_URL',
'API_KEY',
'JWT_SECRET'
];
const missing = requiredEnvVars.filter(v => !process.env[v]);
if (missing.length > 0) {
throw new Error(`Missing required env vars: ${missing.join(', ')}`);
}
Python example:
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"Missing env vars: {', '.join(missing)}")
5. Type Validation
Validate types:
const config = {
port: parseInt(process.env.PORT || '3000', 10),
debug: process.env.DEBUG === 'true',
apiUrl: new URL(process.env.API_URL), // Throws if invalid
maxConnections: Number(process.env.MAX_CONNECTIONS),
};
// Validate
if (isNaN(config.port) || config.port < 1 || config.port > 65535) {
throw new Error('PORT must be a valid port number');
}
6. Generate .env.example
Create template from actual .env:
# Remove values, keep keys
sed 's/=.*/=/' .env > .env.example
Or with placeholders:
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. Configuration Schema
Define schema (using Joi example):
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(`Config validation error: ${error.message}`);
}
module.exports = value;
8. Security Checks
Don't commit secrets:
# Check if .env is gitignored
if ! grep -q "^\.env$" .gitignore; then
echo "Warning: .env not in .gitignore"
fi
# Check for hardcoded secrets in code
grep -r "api_key.*=.*['\"]" --exclude-dir=node_modules
Common security issues:
- Hardcoded passwords/keys
- Default secrets in production
- Exposed sensitive configs
- Unencrypted secrets
9. Environment-Specific Configs
Organize by environment:
.env.development
.env.staging
.env.production
.env.test
Load appropriately:
require('dotenv').config({
path: `.env.${process.env.NODE_ENV || 'development'}`
});
10. Document All Variables
Create CONFIG.md:
# Configuration
## Environment Variables
### Required
- `DATABASE_URL`: PostgreSQL connection string
- Format: `postgres://user:pass@host:port/db`
- Example: `postgres://app:secret@localhost:5432/myapp`
- `API_KEY`: Third-party API key
- Obtain from: https://dashboard.example.com
- Required scopes: read, write
### Optional
- `PORT`: Server port (default: 3000)
- `DEBUG`: Enable debug logging (default: false)
- `MAX_CONNECTIONS`: Database pool size (default: 10)
## Setup
1. Copy `.env.example` to `.env`
2. Fill in all required values
3. Run `npm run validate-config` to verify
11. Validation Script
Create 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: ${missing.join(', ')}`);
process.exit(1);
}
console.log('✓ All required config variables present');
}
validateConfig();
12. Best Practices
- Never commit .env: Always gitignore
- Maintain .env.example: Keep it updated
- Validate on startup: Fail fast if misconfigured
- Use strong defaults: Sensible fallbacks
- Document everything: Explain each variable
- Rotate secrets: Regularly update keys
- Use secret managers: Vault, AWS Secrets Manager for production
- Type check: Validate types, not just presence
Supporting Files
templates/config-validator.jstemplates/.env.examplescripts/generate-env-example.sh