This Article is also found in Web-Warrior-Toolbox
Anything you put in the frontend or expose through routes is visible to users and AI agents, while secrets like API keys and credentials must stay serverβside.
In this article I propose organizing your project with clear boundaries to make it obvious whatβs safe to expose and what must be hidden, reducing the chance of leaking sensitive data.
I used this folder structure
β> ~/projects tree my-project -la 09:36:59
my-project
βββ back-env
β βββ .env
β βββ .env.prod
β βββ .env.prod.pc
βββ builder
β βββ build.sh
βββ front-env
β βββ .env
β βββ .env.dev
β βββ .env.dev.pc
β βββ .env.prod
β βββ .env.stagging
|-------------------------------------------------------------
| AI Agents have access to repos and all its contents
|-------------------------------------------------------------
βββ repos
βββ my-project-back
β βββ .env.example
β βββ src
βββ my-project-front
βββ .env.example
βββ src
The main idea is to provide access to code repositories to AI agents but keep .env files on higher folders to keep them private.
Frontend needs to be build so that means that we need multiple .env files depending of where we deploy the dist folder. For this reason I considered organizing the .env files in folders.
Finally I considered a build.sh script that runs something like this to build the project with the selected .env file.













