std-env

February 17, 2026 ยท View on GitHub

npm version npm downloads bundle size

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" }

Individual named exports: isNode, isBun, isDeno, isNetlify, isEdgeLight, isWorkerd, isFastly

Note

isNode is also true in Bun/Deno with Node.js compatibility mode. Use runtime === "node" for strict checks.

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 } }

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" } }

Set the AI_AGENT env var to explicitly specify the agent name. Use detectAgent() to re-run detection.

Supported agents: cursor, claude, devin, replit, gemini, codex, auggie, opencode, kiro, goose, pi

Flags

import { env, isDevelopment, isProduction } from "std-env";
ExportDescription
hasTTYstdout TTY is available
hasWindowGlobal window is available
isCIRunning in CI
isColorSupportedTerminal color output supported
isDebugDEBUG env var is set
isDevelopmentNODE_ENV is dev/development or MODE is development
isLinuxLinux platform
isMacOSmacOS (darwin) platform
isMinimalMINIMAL env is set, CI, test, or no TTY
isProductionNODE_ENV or MODE is production
isTestNODE_ENV is test or TEST env is set
isWindowsWindows platform
platformValue of process.platform
nodeVersionNode.js version string (e.g. "22.0.0")
nodeMajorVersionNode.js major version number (e.g. 22)

See ./src/flags.ts for details.

Environment

ExportDescription
envUniversal process.env (works across all runtimes)
processUniversal process shim (works across all runtimes)
nodeENVCurrent NODE_ENV value (undefined if unset)

License

MIT