cross-env-setup
npx machina-cli add skill a5c-ai/babysitter/cross-env-setup --openclawCross-Env Setup
Configure cross-env for cross-platform environment variables.
Capabilities
- Set up cross-env in package.json
- Configure environment variable scripts
- Handle platform-specific vars
- Integrate with npm scripts
Generated Patterns
{
"scripts": {
"dev": "cross-env NODE_ENV=development tsx watch src/index.ts",
"build": "cross-env NODE_ENV=production tsc",
"test": "cross-env NODE_ENV=test vitest",
"start:prod": "cross-env NODE_ENV=production node dist/index.js"
},
"devDependencies": {
"cross-env": "^7.0.3"
}
}
Target Processes
- cross-platform-cli-compatibility
- configuration-management-system
- cli-application-bootstrap
Source
git clone https://github.com/a5c-ai/babysitter/blob/main/plugins/babysitter/skills/babysit/process/specializations/cli-mcp-development/skills/cross-env-setup/SKILL.mdView on GitHub Overview
This skill configures cross-env to set environment variables in npm scripts and CLI commands across platforms. It ensures consistent NODE_ENV values on Windows, macOS, and Linux, avoiding shell syntax differences. The approach mirrors the provided patterns for dev, build, test, and production start scripts.
How This Skill Works
Install cross-env as a devDependency and prefix commands in package.json scripts with cross-env and key=value pairs (e.g., NODE_ENV=development). cross-env translates these assignments so the subsequent command runs with the correct environment on all platforms. The generated patterns demonstrate typical usage in dev, build, test, and start:prod scripts.
When to Use It
- When you need consistent environment variables across Windows and Unix-like shells
- When scripting npm commands for development, builds, tests, or production runs
- When integrating with a configuration-management system or CLI bootstrap that relies on env vars
- When avoiding Windows-specific syntax like set VAR=value or VAR=value; and using cross-platform scripts
- When you primarily set NODE_ENV values (development, production, test) in npm scripts
Quick Start
- Step 1: Add cross-env as a devDependency (e.g., npm i -D cross-env@^7.0.3)
- Step 2: Update package.json scripts to use cross-env with NODE_ENV values (dev, build, test, start:prod)
- Step 3: Run npm install and execute scripts like npm run dev, npm run build, npm run test, npm run start:prod
Best Practices
- Add cross-env as a devDependency and pin a version (e.g., ^7.0.3)
- Use NODE_ENV with standard values: development, production, test
- Prefix environment-variable-dependent commands in npm scripts with cross-env
- Document environment variable names and intended values for the team
- Test scripts on both Windows and Unix-like environments to ensure compatibility
Example Use Cases
- dev script: cross-env NODE_ENV=development tsx watch src/index.ts
- build script: cross-env NODE_ENV=production tsc
- test script: cross-env NODE_ENV=test vitest
- start:prod script: cross-env NODE_ENV=production node dist/index.js
- package.json includes devDependencies: { "cross-env": "^7.0.3" }