Code Is Open, Secrets Aren't: Organizing Your Project for AI Agents
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…
This article discusses how to organize a project for AI agents while keeping sensitive information secure. Any information exposed in the frontend or accessible through routes can be seen by users and AI agents. However, secrets such as API keys and credentials should remain on the server-side. The suggested project structure includes separate folders for different environment variables and build scripts.
The project directory is organized as follows:
- ~/projects
- my-project
- back-env
- .env
- .env.prod
- .env.prod.pc
- builder
- build.sh
- front-env
- .env
- .env.dev
- .env.dev.pc
- .env.prod
- repos
- my-project-back
- .env.example
- src
- my-project-front
- .env.example
- src
The main concept is to grant AI agents access to the code repositories while keeping the .env files in higher-level directories to maintain their privacy. Frontend files require building, necessitating multiple .env files depending on the deployment environment. To address this, environment files are organized in their respective folders. Additionally, a build.sh script is used to build the project using the appropriate .env file.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.