← Writing
3 min read

How to add env variables and secrets to Grok Bot

To add a .env or project secrets to Grok Bot, ask it for a secrets input. The value is masked, kept out of the transcript, and not shown to the model. Pointing at a file path is still better than pasting the file into chat.

Sophia Yang asked a question this morning that a lot of people are quietly hitting:

how do you add env variables to Grok Bot? Her Chief of Staff asked her to drop a .env in the chat. That felt insecure. It is.

Lauren had the right answer in one line: ask your bot to give you a secrets input.

The chat is not a vault

A transcript is a log. It gets stored, summarized, searched, quoted, and sometimes pasted into another thread. Once a key is in that log, you have to assume it leaked.

Same rule as any other agent: never put a password, API key, or one-time code in ordinary chat. The product already knows this. That is why the secrets input exists.

How to add env variables and secrets

Ask the bot, in plain language:

Give me a secrets input. I need to add environment variables for this project.

A masked field should appear. Type the name and the value there. The value stays out of the transcript and is not shown to the model.

If you already have a .env on disk, do not paste it. Tell the bot the path:

I have a .env at ~/project/.env. Read it. Do not echo the values.

Pointing at a file is still better than dumping the file into the thread. Best is still the secrets input, or a real secrets manager (1Password, Doppler, GitHub Actions secrets) wired in so the agent never sees the raw string at all.

A few rules I keep

  • Secrets go in a secrets field, a secrets manager, or a file the process can read. Not the chat.
  • Scoped, read-only, expiring keys only. If an agent needs Stripe, give it a restricted key, not the master one.
  • On a shared agent computer, every bot on the account can see the same files and env. Do not drop a credential there if another bot should not have it.
  • If the bot asks you to paste a password anyway, take over the machine and type it in the browser yourself. That flow exists so the value never hits the model.

I already keep Grok identities isolated with separate GROK_HOME dirs so two accounts do not share auth.json. Same instinct: identity and secrets need a boundary. The chat is not that boundary.

Bottom line

To configure env variables or a project .env on Grok Bot, use the secrets input. Dropping the file into chat is the wrong interface. Keep the transcript clean. Treat every key as if the thread will be public tomorrow.

Frequently asked questions

How do I add environment variables to Grok Bot?

Ask the bot to give you a secrets input. Type the key and value there. Do not paste the .env into the chat.

Is it safe to drop a .env in an AI chat?

No. Chat transcripts get logged, summarized, searched, and sometimes shared. A secret that lands in the thread is no longer a secret.

What if the bot asks me to paste my .env?

Refuse. Ask for the secrets input instead, or tell it the file path and let it read the file without echoing the contents.