Skip to content

Add support for global .env.schema file for commonly used environment variables #572

@sanathusk

Description

@sanathusk

Summary

Add the ability to define a global .env.schema file in folder say in ~/.varlock that contains commonly used global environment variables (like API keys, tokens, etc.) that can be used across all projects when running varlock run.

Motivation

When using varlock run to execute commands in an agentic context (e.g., running varlock run pi), the command may be launched from any folder and requires certain environment variables like OPENAI_API_KEY to be set.

Currently, users must define these variables in each project's .env.schema file, which is:

  1. Repetitive - Same variables need to be defined in every project
  2. Error-prone - Easy to forget to add them to a new project
  3. Inconvenient - Can't use global tools like varlock run pi without project-specific setup

Proposed Solution

Introduce a global .env.schema file (e.g., at ~/.varlock/global.env.schema or similar) that:

  • Contains commonly used environment variables accessible across all projects
  • Is automatically loaded when running varlock run or varlock load
  • Contains sensitive variables like API keys, tokens, etc.

Precedence/Override Behavior

When both global and local .env.schema files define the same variable:

  • Local project .env.schema takes precedence for the variable definition
  • This allows projects to customize or override global defaults as needed

Example:

# Global (~/.varlock/global.env.schema)
OPENAI_API_KEY=@required @sensitive
ANTHROPIC_API_KEY=@required @sensitive

# Project (.env.schema)
OPENAI_API_KEY=@required @sensitive @example("sk-proj-...")

In this case, the project's local definition would override the global one.

Use Cases

  1. Agentic tools: Running tools like pi that need OPENAI_API_KEY set from any directory
  2. Common credentials: API keys, tokens, secrets used across multiple projects
  3. Developer convenience: Avoiding duplicate configuration across projects

Additional Considerations

  • The global schema file location should be configurable
  • Users should be able to disable global schema loading if needed
  • Security: ensure the global file is properly secured (permissions, etc.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions