# Environment variable

Canonical page: /glossary/environment-variable

API keys & secrets glossary, Keys & secrets. Environment Variable: The Basics for Non-Programmers

**Short answer:** An environment variable is a named value that is available to a running program, set either by the shell that launched it, a config file, or another program that started it. Programs read environment variables instead of hardcoding values, so the same code can run with different settings or credentials.

## Why it matters

Environment variables are visible to the process they are set for, and to anything that process explicitly passes them to. Running printenv or echo $SOME_KEY in a terminal will print any variable set in that session, including secrets.

## In Claude Keychain

Claude Keychain sets an environment variable only inside the one subprocess it launches for a command, for the length of that command, rather than in your shell, so it does not linger in a place you could accidentally print.

## Common questions

**Are environment variables encrypted?**

No, they are held in the process's own memory in plain text. Anything with permission to inspect that process's environment can read them.

**Do environment variables survive a restart?**

Only if something sets them again, either your shell profile, a .env file, or a tool like Claude Keychain injecting them at launch.

## Related

[.env file](/glossary/env-file), [Subprocess](/glossary/subprocess), [Shell history leak](/glossary/shell-history-leak)
