The Deska blog

1Password CLI vs Plain env Vars for Developer Secrets

Compare 1Password CLI vs plain env vars for managing developer secrets. Learn how to secure your workflow and integrate with tools like Deska.

· 10 min read

Managing sensitive credentials effectively is a foundational skill for modern software engineers. When choosing between 1Password CLI vs plain env vars for developer secrets, the decision impacts both your personal security posture and the friction in your daily coding routine. Plain environment variables are the historical standard because of their simplicity, yet they introduce risks regarding persistence and accidental exposure. The 1Password CLI provides a structured alternative by pulling secrets directly from a secure vault into your runtime environment.

The Traditional Approach: Plain Environment Variables

Plain environment variables usually live in .env files or shell configuration scripts like .zshrc or .bash_profile. They are natively supported by almost every language and framework. You define a key, assign a value, and the application reads it from the process environment.

Why Developers Use Plain Env Vars

The primary advantage is zero overhead. You do not need to install additional binary tools to read a variable that is already present in the shell. For local development, this is often the fastest way to get a project running. Most deployment platforms also use environment variables as the standard injection method for production secrets.

The Risks of Persistence

The main drawback of plain environment variables is their persistence on disk. If you store secrets in a .env file, that file exists in plain text on your machine. While you can add it to .gitignore, it only takes one accidental commit to leak your production database password or API keys to a public repository. Furthermore, if you export variables in your shell profile, they remain in memory for the duration of the session, making them accessible to any script or process running in that shell.

1Password CLI: The Vaulted Alternative

The 1Password CLI (op) changes the workflow by acting as a bridge between your encrypted vault and your execution environment. Instead of storing a secret in a text file, you store it in 1Password and reference it using a specific URI or alias.

Dynamic Injection

The CLI allows you to run commands with secrets injected only at the moment of execution. By using op run -- command, the utility looks for secret references, fetches them from the vault, and provides them to the subprocess. Once the process terminates, the secrets vanish from the environment. This minimizes the window of exposure and ensures that no sensitive data is written to your local storage in an unencrypted state.

Biometric Authentication

One significant benefit of this approach is the integration with system level security. You can configure the CLI to require biometric authentication (Touch ID or Windows Hello) before it releases secrets to a command. This adds a layer of physical security that plain environment variables cannot provide. Even if a malicious actor gains remote access to your terminal, they cannot fetch the secrets without your physical presence.

Comparing the Two Workflows

Choosing between these methods involves weighing convenience against security requirements.

FeaturePlain Env Vars1Password CLI
StorageLocal plain text filesEncrypted cloud vault
Access SpeedInstantRequires authentication
SecurityLow (accidental leaks)High (biometrics)
PortabilityHigh (universal)Requires 1Password app
RotationManualCentralized in vault

Handling Multiple Environments

Managing secrets for staging, production, and local development becomes complex with plain files. You often end up with multiple files like .env.local or .env.prod. With the 1Password CLI, you can organize secrets into different vaults. You can then use the CLI to toggle between these contexts without manually swapping file contents.

Integrating Secrets into Modern Workspaces

Modern development environments often involve many moving parts: multiple terminals, browsers, and AI assistants. Managing secrets across all these panels can become a bottleneck. This is where a unified workspace like Deska can help streamline the process.

Deska provides an infinite canvas where you can arrange terminals and other tools side by side. When you use 1Password CLI within a Deska terminal, the secrets are available to that specific session. Because Deska is local-first, your session data and the way you handle these secrets stay on your machine rather than being synced to a third party server.

Using Secrets with AI Agents

When working with coding agents like Claude Code or Codex CLI, you often need to provide API keys for the LLMs. Deska allows you to run these agents as panels within your workspace. If you follow the 1Password CLI approach, you can launch your agent threads by passing the keys directly through the CLI. This ensures that your high value AI keys are never sitting in a plain text file on your drive.

If you have a lifetime license for Deska, you use your own API keys (BYOK). Using a secret manager ensures these keys remain secure while you interact with the Ask Deska assistant or manage your agent threads.

Secure Remote Access and Mobile Monitoring

A common concern with secret management is what happens when you are away from your primary machine. Plain environment variables are stuck on the host. 1Password syncs across devices, which is a major advantage.

Deska offers a mobile app that allows you to monitor your workspace through a secure relay. Since the devices pair directly and no ports are exposed, you can check on a long running process that is using secrets injected via the CLI. You can see the output in the terminal panel on your phone without having to worry about your secrets being exposed through an insecure network connection.

Best Practices for Secret Hygiene

Regardless of the tool you choose, follow these principles:

  • Never commit files containing secrets to version control.
  • Use a .env.example file with dummy values to show other developers what keys are needed.
  • Frequently rotate your API keys, especially those with administrative privileges.
  • Use the principle of least privilege: give your local keys only the permissions they need for development.
  • Regularly audit your shell history to ensure no secrets were passed as plain command line arguments.

FAQ: Common Questions on Secret Management

How do I hide secrets in shell history?

When using the 1Password CLI, you should use environment variable templates or the op run command rather than passing secrets as direct flags. Most shells also ignore commands that start with a leading space, though this is not a guaranteed security feature. The best method is using a tool that injects variables directly into the process environment.

Can 1Password CLI work with Docker?

Yes, you can use the CLI to inject secrets into Docker containers at runtime. Instead of hardcoding variables in your docker-compose.yml file, you can use the CLI to populate them when you start the containers. This keeps your configuration files clean and secure for sharing with teammates.

Is it safe to store secrets in a local workspace?

In a local-first environment like Deska, your workspace configuration and terminal sessions are stored on your hard drive. This is safer than cloud based IDEs where your data lives on someone else's server. However, you should still use a tool like 1Password CLI to ensure the actual values of your secrets are encrypted at rest.

Enhance Your Workflow with Deska

Securing your developer secrets is just one part of building an efficient technical workflow. By moving away from plain environment variables and adopting the 1Password CLI, you reduce the risk of accidental exposure.

To see how a secure, local-first workspace can improve your productivity, you can download Deska for free. It allows you to organize your terminals, AI agents, and documentation in a single canvas, making it easier to manage complex projects while keeping your sensitive data under your control. Whether you are running agents or monitoring work from the mobile app, Deska provides the flexibility that modern developers need.

💡 Ideas+🐛 BugsSuggest a feature or report a bug