cd /news/developer-tools/code-is-open-secrets-aren-t-organizi… · home topics developer-tools article
[ARTICLE · art-113274] src=dev.to ↗ pub= topic=developer-tools verified=true sentiment=· neutral

Code Is Open, Secrets Aren't: Organizing Your Project for AI Agents

A developer proposed organizing projects with clear boundaries between exposed code and hidden secrets to prevent AI agents from leaking sensitive data. The approach separates .env files into dedicated folders outside the repositories that AI agents can access, and includes a build script to select the appropriate environment configuration.

read1 min views2 publishedAug 27, 2026

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.

── more in #developer-tools 4 stories · sorted by recency
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/code-is-open-secrets…] indexed:0 read:1min 2026-08-27 ·