Loading...
Loading...
Security rules for code generation including secret handling, credential storage, and environment files. Follow when generating code that handles secrets, credentials, or environment configuration.
npx skill4agent add loxosceles/ai-dev security-checklist.env
.env.local
.env.development
.env.production
.env.test
.env.*.env_TEMPLATE
.env.example# Environment files
.env
.env.*
!.env_TEMPLATE
!.env.example
# AWS credentials
.aws/credentials
.aws/config
# SSH keys
*.pem
id_rsa
id_ed25519const apiKey = 'sk-1234567890abcdef';
const dbPassword = 'mypassword123';
const awsAccessKey = 'AKIAIOSFODNN7EXAMPLE';// Runtime: Load from environment
const apiKey = process.env.API_KEY;
if (!apiKey) throw new Error('API_KEY not set');
// Infrastructure: Reference from Secrets Manager/SSM
const secret = secretsmanager.Secret.fromSecretNameV2(
this, 'ApiKey',
'/project/prod/api-key'
);// Don't put backend API keys in frontend code
const token = 'secret-backend-token';// Use public API keys or user-specific tokens
const publicKey = process.env.NEXT_PUBLIC_API_KEY; // Public, safe to expose
const userToken = cookies.get('auth-token'); // User-specific, from auth flow// At application startup
const required = ['DATABASE_URL', 'API_KEY', 'JWT_SECRET'];
const missing = required.filter(key => !process.env[key]);
if (missing.length > 0) {
throw new Error(`Missing required secrets: ${missing.join(', ')}`);
}.env