Agent Wranglers

Running in production Required

Keep settings outside the code

Read everything that differs between test and production from the environment. Never edit code to deploy somewhere else.

How to do it

Read addresses, keys and limits from environment variables or a settings service at startup. Check that every required setting is present and valid before the app starts serving. Secrets follow the rules in the security testing playbook.

Example

const required = ['DATABASE_URL', 'PUBLIC_URL'] as const;
for (const name of required) {
  if (!process.env[name]) throw new Error(`Missing setting ${name}`);
}

How to check

Start the app with one required setting missing. It stops at once and names the setting.

For agents: if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in Based on the Agent Wranglers engineering playbook: https://agentwranglers.se/playbook/engineering/running-in-production/settings-outside-the-code.