xiaohongshu
xiaohongshu
env-var-manager
Manages environment variable additions and updates across all project files. Use when adding new environment variables, updating PORT configuration, modifying deployment configurations, or documenting configuration requirements.
Full skill instructions
This skill ensures environment variables are properly added, documented, and configured across all project files and deployment platforms.
When adding a new environment variable, the following files must be updated in this order:
.env.example (Required)Add the variable with a descriptive comment explaining its purpose and expected format.
Format:
# Description of what this variable does
# Options: value1, value2, value3 (if applicable)
# Default: default_value (if applicable)
VARIABLE_NAME=example_value
Example:
# Server port - useful for local development or platform-specific configs
# Default: 3000
PORT=3000
# Node environment - affects Express server optimization
# Options: development, production, test
# Default: (unset)
NODE_ENV=production
server.js (Required)Implement the variable usage in the application code.
Pattern:
// Read from environment with fallback default
const variableName = process.env.VARIABLE_NAME || 'default_value';
// For required variables (no default)
const requiredVar = process.env.REQUIRED_VAR;
if (!requiredVar) {
console.error('ERROR: REQUIRED_VAR environment variable is not set');
process.exit(1);
}
Examples:
// Optional with default
const port = process.env.PORT || 3000;
// Optional with default
const nodeEnv = process.env.NODE_ENV || 'development';
// Required variable
const apiKey = process.env.API_KEY;
if (!apiKey) {
console.error('ERROR: API_KEY environment variable must be set');
process.exit(1);
}
docs/ENVIRONMENT-VARIABLES.md (Required)Add comprehensive documentation in the "Currently Supported Variables" section.
Format:
### VARIABLE_NAME
**Purpose**: Brief description of what this variable controls
**Required**: Yes/No
**Default**: `default_value` (or "None - must be set" for required vars)
**Valid Values**:
- `value1`: Description
- `value2`: Description
**Example**:
```bash
VARIABLE_NAME=example_value
Platform Notes:
### 4. `CLAUDE.md` (Required)
Update the "Environment Variables" section to include the new variable in the list.
**Format**:
```markdown
**Currently Supported Variables:**
- `PORT` (optional, defaults to 3000) - Server port. Useful for local development or platform-specific configurations
- `NODE_ENV` (optional) - Node environment: `development`, `production`, or `test`
- `NEW_VARIABLE` (required/optional, defaults to X) - Brief description
docker-compose.yml (If Applicable)Add to the environment section if the variable should be set in Docker containers.
Format:
services:
usa-spending-app:
environment:
- NODE_ENV=production
- PORT=3000
- NEW_VARIABLE=value
Dockerfile (If Applicable)Add ENV directive if the variable needs a build-time or runtime default.
Format:
# For build-time variables
ARG VARIABLE_NAME=default_value
# For runtime variables with defaults
ENV VARIABLE_NAME=default_value
Note: Only add to Dockerfile if a default is truly needed. Prefer runtime configuration via docker-compose.yml or deployment platform.
Update docs/DEPLOYMENT.md if the variable requires special handling on specific platforms.
Use this checklist to ensure all steps are completed:
.env.example with descriptive comment and example valueserver.js with appropriate default or required checkdocs/ENVIRONMENT-VARIABLES.md with full detailsCLAUDE.md "Environment Variables" sectiondocker-compose.yml environment section (if applicable)Dockerfile ENV/ARG (if applicable)docs/DEPLOYMENT.md with platform-specific instructions (if needed).env file (verify defaults work).env file (verify variable is read correctly).env is in .gitignore (should already be there).env file to repositoryCHANGELOG.md under [Unreleased] > Added sectionAPI Keys, Passwords, Secrets, Tokens:
.env.example with real values (use placeholders)Port numbers, feature flags, public URLs:
.env.exampleRequired Variables (no safe default):
const apiKey = process.env.API_KEY;
if (!apiKey) {
console.error('ERROR: API_KEY is required but not set');
process.exit(1);
}
Optional Variables (with safe defaults):
const port = process.env.PORT || 3000;
const logLevel = process.env.LOG_LEVEL || 'info';
process.env.PORT.gcloud run deploy with --set-secretsprocess.env.PORT.ebextensions or set via consolecontainerDefinitions[].environmentsecrets field in task definition to pull from Secrets Manager or Parameter Storeprocess.env.PORTheroku config:set VARIABLE=value or dashboarddocker-compose.yml under environment or via .env fileconst featureEnabled = process.env.FEATURE_NAME === 'true';
if (featureEnabled) {
// Feature-specific code
}
const apiBaseUrl = process.env.API_BASE_URL || 'https://api.example.com';
const apiTimeout = parseInt(process.env.API_TIMEOUT || '5000', 10);
const dbConfig = {
host: process.env.DB_HOST || 'localhost',
port: parseInt(process.env.DB_PORT || '5432', 10),
database: process.env.DB_NAME || 'myapp',
user: process.env.DB_USER,
password: process.env.DB_PASSWORD
};
// Validate required fields
if (!dbConfig.user || !dbConfig.password) {
console.error('ERROR: DB_USER and DB_PASSWORD must be set');
process.exit(1);
}
const isDevelopment = process.env.NODE_ENV === 'development';
const isProduction = process.env.NODE_ENV === 'production';
const isTest = process.env.NODE_ENV === 'test';
if (isDevelopment) {
// Development-specific settings
}
# Test that defaults work
npm start
# Verify application starts successfully
# Check that default values are used
# Create .env file
cp .env.example .env
# Edit .env with test values
# Run application
npm start
# Verify variables are read correctly
# Test that application fails gracefully when required var is missing
# Remove required variable from .env
npm start
# Should see error message and exit with code 1
# ============================================
# Server Configuration
# ============================================
# Server port
# Default: 3000
PORT=3000
# ============================================
# Application Settings
# ============================================
# Node environment (development, production, test)
# Default: (unset)
NODE_ENV=production
# ============================================
# API Configuration
# ============================================
# External API base URL
# Required: Yes
API_BASE_URL=https://api.example.com
# API timeout in milliseconds
# Default: 5000
API_TIMEOUT=5000
Follow the existing structure in docs/ENVIRONMENT-VARIABLES.md:
.env file matches code exactly.env file is in project root (same directory as server.js).env file.env (no quotes needed, no spaces around =)dotenv package is installed if using: npm install dotenvdocker-compose.yml environment sectiondocker compose up --builddocker exec container_name env | grep VARIABLEprocess.env.VAR || 'default'process.env.VAR || 'default' (empty string is falsy)parseInt(process.env.VAR || '100', 10)Reference: See docs/ENVIRONMENT-VARIABLES.md for the authoritative list.
Currently Configured:
PORT - Server port (default: 3000)NODE_ENV - Node environment (default: unset).env.example - Never commit actual .envAPI_TIMEOUT not TIMEOUT, DB_HOST not HOST.env file# Create .env from example
cp .env.example .env
# View current environment variables (local)
printenv | grep -E '(PORT|NODE_ENV)'
# Set variable temporarily (bash/zsh)
export VARIABLE_NAME=value
npm start
# Set variable inline (bash/zsh)
VARIABLE_NAME=value npm start
# Docker Compose with custom env file
docker compose --env-file .env.production up
# Check variable in Docker container
docker exec usa-spending-search env | grep VARIABLE_NAME
# AWS EB set variable
eb setenv VARIABLE_NAME=value
# Heroku set variable
heroku config:set VARIABLE_NAME=value
# GCP Cloud Run set variable
gcloud run services update SERVICE_NAME --set-env-vars="VARIABLE_NAME=value"
docs/ENVIRONMENT-VARIABLES.mddocs/DEPLOYMENT.mddocs/quick-start-guide.md.env.examplexiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience