Introduction: Challenges in Environment Variable Management

In development environments, it is common to store sensitive information such as API keys and database credentials in environment variables. However, committing these values in plain text to a Git repository significantly increases the risk of data leaks. By combining mise and age, developers can manage environment variables per directory while encrypting them for safe sharing.

📑Table of Contents
  1. Introduction: Challenges in Environment Variable Management
  2. Roles and Benefits of mise and age
  3. Installation and Initial Setup Steps
  4. Practical Encryption of Environment Variable Files
  5. Decryption Workflows and CI/CD Integration
  6. Security Considerations and Limitations
  7. Frequently Asked Questions (FAQ)
  8. Summary and Next Actions

Exposure of environment variables often occurs due to accidental commits or log output in CI/CD pipelines. age is a lightweight public-key encryption tool written in Go that can encrypt entire files. mise automates the loading of environment variables associated with specific directories. This combination allows developers to maintain security without sacrificing productivity.


Roles and Benefits of mise and age

mise works similarly to direnv by automatically loading .env files when entering a directory. age provides simple public-key encryption using a pair of secret and public keys to protect files.

Key benefits include:

  • Encrypted files can be safely committed to Git, simplifying team sharing
  • Decryption happens locally with the private key only, avoiding server-side secrets
  • Automatic context switching between directories

This approach reduces the costs associated with plain-text .env management or adopting complex secret management tools.

Aspect mise + age Plain-text .env sops
Git commit safety Encrypted & safe High exposure risk Encryption possible
Setup complexity Two tool installs Minimal Additional config
Directory support Automatic switching Manual Manual
Decryption speed Fast Slightly slower

Source: blog.miguelgrinberg.com (independent verification as of 2026)


Installation and Initial Setup Steps

Install mise and age using Homebrew on macOS for simplicity.

Generate an age key pair next.

Extract the public key from the output and share it with team members. Create a file in the project root to define environment variable loading behavior.

These steps follow official documentation and guidance from Miguel Grinberg’s post. Remember to back up your keys securely.


Practical Encryption of Environment Variable Files

Create a file in the project directory with sensitive values, then encrypt it with age.

Commit the resulting file to Git. Add the original to to keep it local only.

Decryption uses the private key:

Configure mise to automatically load the decrypted file so daily development remains seamless.


Decryption Workflows and CI/CD Integration

In CI/CD pipelines, register the age private key in the platform’s secret store and add a decryption step during builds. GitHub Actions can use for this purpose.

Leverage mise hooks to automate decryption. This ensures consistent configuration between development and production environments.


Security Considerations and Limitations

Managing age keys is critical. Losing the private key means permanent loss of access to encrypted data. While the encrypted file itself can be public, the key distribution process requires care.

Limitations include age’s focus on single-file encryption; managing multiple files requires additional scripting. CI/CD key injection depends on the platform’s secret management features.


Frequently Asked Questions (FAQ)

Q: How should the age key be shared within a team?

Publish the public key in the repository README while keeping the private key securely on each developer’s local machine. Regular key rotation is recommended.

Q: Can I use age without mise?

Yes, but you lose the automatic per-directory loading, requiring manual decryption each time.

Q: What to do when decryption errors occur?

Check file permissions and paths for the key file. Refer to error messages from the command for guidance.


Summary and Next Actions

The mise + age combination offers a practical method to improve security for environment variable management. Start with a small project to establish key management workflows.

For further details, refer to these independent sources: – https://blog.sh1ma.dev/articles/20260706_mise_age_encrypt_env/https://blog.miguelgrinberg.com/post/how-to-securely-store-secrets-in-environment-variables

Related articles:

Related new article:

krona23

Author

krona23

Over 20 years in the IT industry, serving as Division Head and CTO at multiple companies running large-scale web services in Japan. Experienced across Windows, iOS, Android, and web development. Currently focused on AI-native transformation. At DevGENT, sharing practical guides on AI code editors, automation tools, and LLMs in three languages.

DevGENT about →

Leave a Reply

Trending

Discover more from DevGENT

Subscribe now to keep reading and get access to the full archive.

Continue reading