When implementing environment variable configuration:

  1. Follow standard environment variable conventions:
  2. Document environment variables clearly:

Example:

// Bad - No validation or documentation
if std::env::var_os("FORCE_COLOR").is_some() {
    ColorChoice::Always
}

// Good - Validates non-empty value and documents behavior
/// Controls color output. When set to a non-empty value, forces color output
/// regardless of terminal capabilities.
/// Takes precedence over NO_COLOR and --color settings.
if let Some(force_color) = std::env::var_os("FORCE_COLOR") {
    if !force_color.is_empty() {
        ColorChoice::Always
    }
}
  1. Establish clear precedence rules:
  2. Provide validation and feedback: