DevBoxerDevBoxer Docs
DevBoxerDevBoxer Docs
Back to App

Introduction

WelcomeQuick StartCommon Workflows

Using DevBoxer

Tasks
AutomationsGitHub IntegrationSlack IntegrationDevBoxer CLI & MCPMobile

Agents

Claude CodeOpenAI CodexOpenCodeGemini CLIAmp

Configuration

Environment Setup
Sandbox EnvironmentSetup ScriptsEnvironment Variables
MCP SetupCustom System PromptsGit Checkpointing

Help & Resources

Get HelpCommon IssuesBilling OverviewPrompt ExamplesEarly access featuresRelease NotesSecurity & PermissionsDevBoxer App
Environment Setup

Environment Variables

Configure secrets and environment variables for your DevBoxer sandboxes.

Open as Markdown

All environment variables are encrypted at rest and in transit for optimal security.

Environment variables allow you to add secrets and configuration values that will be available in your sandbox. You can configure environment variables at two levels:

  • Global Environment: Variables that apply to all your repositories
  • Repository-Specific Environment: Variables scoped to individual repositories

Repository-specific variables take precedence over global variables when both define the same key. This allows you to set common defaults globally while overriding them per repository as needed.

Common Use Cases

Environment variables are perfect for:

  • API Keys: Store credentials for third-party services
  • Database URLs: Connection strings for databases
  • Feature Flags: Toggle features on/off
  • Configuration Values: Any settings that vary between environments
  • Webhook URLs: Endpoints for external services
  • SDK Keys: Authentication for various SDKs

Adding Environment Variables

Click Add Variable
Enter the variable name and value
Click Save Environment Variables

Importing from .env File

You can quickly import multiple environment variables from a .env file:

Click the Import from .env button
Paste the contents of your .env file
Review the parsed variables
Click Import to add them all at once

Example .env Format

# API Keys
OPENAI_API_KEY=sk-...
ANTHROPIC_API_KEY=sk-ant-...

# Database Configuration
DATABASE_URL=postgresql://user:password@localhost:5432/mydb
REDIS_URL=redis://localhost:6379

# Feature Flags
ENABLE_NEW_FEATURE=true
DEBUG_MODE=false

# External Services
WEBHOOK_URL=https://api.example.com/webhook
SLACK_TOKEN=xoxb-...

Default Environment Variables

DevBoxer automatically sets the following environment variables in your sandbox:

NameDescription
devboxerAlways set to true when running in a DevBoxer sandbox. You can use this variable to differentiate when the agent/code is running in a DevBoxer sandbox versus locally.
GH_TOKENGitHub access token for the gh CLI. You can override this by setting your own GH_TOKEN environment variable.

Custom GitHub Token: If you need to use a different GitHub token (e.g., for accessing private packages or repositories), you can add your own GH_TOKEN environment variable. Your custom token will take precedence over the default token provided by DevBoxer.

Using Environment Variables

In Setup Scripts

Environment variables are automatically available in your devboxer-setup.sh script:

devboxer-setup.sh
#!/bin/bash
echo "API Key: $MY_API_KEY"
echo "Database URL: $DATABASE_URL"

# Configure application with environment variables
export NODE_ENV=production
export API_ENDPOINT=$API_URL

In Your Code

Access environment variables as you normally would in your application:

// Node.js/JavaScript
const apiKey = process.env.OPENAI_API_KEY;
const dbUrl = process.env.DATABASE_URL;
# Python
import os
api_key = os.environ.get('OPENAI_API_KEY')
db_url = os.environ.get('DATABASE_URL')
# Shell scripts
echo "Using API key: $OPENAI_API_KEY"
psql "$DATABASE_URL"

Setup Scripts

Configure custom setup scripts that run when your DevBoxer sandbox starts.

MCP Setup

Configure Model Context Protocol (MCP) servers to give DevBoxer access to external tools, databases, and services.

On this page

Common Use CasesAdding Environment VariablesImporting from .env FileExample .env FormatDefault Environment VariablesUsing Environment VariablesIn Setup ScriptsIn Your Code