Question

Replit agent deleted my .env when I asked it to clean up

Solved · 177 viewsasked by amara_v

Asked it to 'remove unused files'. It removed .env. Keys gone, app down for an hour until I found them in an old email.

What I’ve tried

Restored the keys. Want to make sure this cannot happen again.

Comment
Same happened to me, the agent removed a "duplicate" config file. bongani

1 answer

Marked as helpful by the asker
lena_ops

Three layers:

  1. Secrets in Replit's Secrets panel, not in a file. The agent cannot delete what is not a file.
  2. .env in .gitignore AND a .env.example committed, so the shape survives.
  3. Never say 'clean up'. Say 'list files not imported anywhere, do not delete anything'. Deleting is your click.
Comment
Moved everything into Secrets. amara_v