
Security News
White House Authorizes Private Companies to Conduct Offensive Cyber Operations
A new federal program will let vetted U.S. cybersecurity firms help investigate and disrupt foreign cybercrime groups under government direction.
sandbox-cli-detector
Advanced tools
Detect whether the current process is running inside a sandboxed developer environment.
Please open an issue if your sandbox is not properly detected.
npm install sandbox-cli-detector
import { detectSandbox } from "sandbox-cli-detector";
const result = detectSandbox();
if (result.detected && result.sandbox) {
console.log("The name of the sandbox is:", result.sandbox.name);
} else {
console.log("This program is not running inside a known sandbox");
}
Officially supported sandbox environments:
| Name | ID |
|---|---|
| Replit | replit |
| bolt.new | bolt |
| E2B | e2b |
| Vercel Sandbox | vercel-sandbox |
| Daytona | daytona |
| Modal | modal |
| Cloudflare Sandbox | cloudflare-sandbox |
| GitHub Codespaces | codespaces |
| CodeSandbox | codesandbox |
Detection is data-driven. The exact environment variables for each sandbox
live in src/sandboxes.ts.
detectSandbox(options?)Returns a detection result:
{
detected: true,
sandbox: {
id: "e2b",
name: "E2B"
}
}
When no sandbox is detected, it returns { detected: false }.
result.detectedA boolean that is true when the process is running inside a known sandbox and
false otherwise.
result.sandbox.idA stable identifier for the detected sandbox. Prefer comparing this value over
result.sandbox.name.
result.sandbox.nameThe display name of the detected sandbox. This may change without it being a breaking change.
isRunningInSandbox(options?)A convenience function that returns result.detected as a boolean:
import { isRunningInSandbox } from "sandbox-cli-detector";
if (isRunningInSandbox()) {
// Adjust CLI behavior for sandboxed execution.
}
Pass custom definitions when you need to detect an internal environment:
import { defaultSandboxes, detectSandbox } from "sandbox-cli-detector";
const result = detectSandbox({
sandboxes: [
{
id: "internal",
name: "Internal Sandbox",
env: [{ name: "INTERNAL_SANDBOX", value: "true" }],
},
...defaultSandboxes,
],
});
Each environment signal matches either an exact value or any non-empty value
when value is omitted. If multiple sandboxes match, the first definition is
returned.
The package also ships a CLI:
npx sandbox-cli-detector
npx sandbox-cli-detector --json
npx sandbox-cli-detector --quiet
It exits with 0 when a sandbox is detected and 1 otherwise.
Please include the platform name, a redacted env | sort captured inside the
platform, and the variables that identify it.
FAQs
Detect whether a CLI is running inside a sandboxed environment
We found that sandbox-cli-detector demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
A new federal program will let vetted U.S. cybersecurity firms help investigate and disrupt foreign cybercrime groups under government direction.

Research
/Security News
The campaign amassed more than 75,000 installs by targeting Russian-speaking users seeking access to blocked services.

Company News
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.