std-env
Runtime-agnostic JS utils for detecting environments, runtimes, CI providers, and AI coding agents.
Runtime Detection
Detects the current JavaScript runtime based on global variables, following the WinterCG Runtime Keys proposal .
import { runtime, runtimeInfo } from "std-env" ;
console. log (runtime); // "" | "node" | "deno" | "bun" | "workerd" ...
console. log (runtimeInfo); // { name: "node" } copy
Individual named exports: isNode, isBun, isDeno, isNetlify, isEdgeLight, isWorkerd, isFastly, isNub
[!NOTE]
isNode is also true in Bun/Deno with Node.js compatibility mode. Use runtime === "node" for strict checks.
isNub detects Nub , which augments Node.js rather than replacing it. It is additive: isNode is also true and runtime stays "node".
See ./src/runtimes.ts for the full list.
Provider Detection
Detects the current CI/CD provider based on environment variables.
import { isCI, provider, providerInfo } from "std-env" ;
console. log ({ isCI, provider, providerInfo });
// { isCI: true, provider: "github_actions", providerInfo: { name: "github_actions", ci: true } } copy
Use detectProvider() to re-run detection. See ./src/providers.ts for the full list.
Agent Detection
Detects if the environment is running inside an AI coding agent.
import { isAgent, agent, agentInfo } from "std-env" ;
console. log ({ isAgent, agent, agentInfo });
// { isAgent: true, agent: "claude", agentInfo: { name: "claude" } } copy
Set the AI_AGENT env var to explicitly specify the agent name. GitHub Copilot aliases github_copilot_vscode_agent and github_copilot_cloud_agent are normalized to copilot. Use detectAgent() to re-run detection.
Supported agents: cursor, claude, copilot, devin, replit, gemini, codex, auggie, opencode, kiro, goose, pi, junie
Flags
import { env, isDevelopment, isProduction } from "std-env" ; copy
Export Description hasTTYstdout TTY is available hasWindowGlobal window is available isCIRunning in CI isColorSupportedTerminal color output supported isDebugDEBUG env var is setisDevelopmentNODE_ENV is dev/development or MODE is developmentisLinuxLinux platform isMacOSmacOS (darwin) platform isMinimalMINIMAL env is set, CI, test, or no TTY
See ./src/flags.ts for details.
Environment
Export Description envUniversal process.env (works across all runtimes) processUniversal process shim (works across all runtimes) nodeENVCurrent NODE_ENV value (undefined if unset)
License
MIT