{"slug": "code-is-open-secrets-aren-t-organizing-your-project-for-ai-agents", "title": "Code Is Open, Secrets Aren't: Organizing Your Project for AI Agents", "summary": "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.", "body_md": "This Article is also found in\n\n[Web-Warrior-Toolbox]\n\nAnything 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.\n\nIn 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.\n\nI used this folder structure\n\n```\n⋊> ~/projects tree my-project  -la                                                                                                                                                                                                    09:36:59\nmy-project\n├── back-env\n│   ├── .env\n│   ├── .env.prod\n│   └── .env.prod.pc\n├── builder\n│   └── build.sh\n├── front-env\n│   ├── .env\n│   ├── .env.dev\n│   ├── .env.dev.pc\n│   ├── .env.prod\n│   └── .env.stagging\n|-------------------------------------------------------------\n| AI Agents have access to repos and all its contents\n|-------------------------------------------------------------\n└── repos\n    ├── my-project-back\n    │   ├── .env.example\n    │   └── src\n    └── my-project-front\n        ├── .env.example\n        └── src\n```\n\nThe main idea is to provide access to code repositories to AI agents but keep .env files on higher folders to keep them private.\n\nFrontend 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.\n\nFinally I considered a `build.sh`\n\nscript that runs something like this to build the project with the selected .env file.", "url": "https://wpnews.pro/news/code-is-open-secrets-aren-t-organizing-your-project-for-ai-agents", "canonical_source": "https://dev.to/ralvaracode/code-is-open-secrets-arent-organizing-your-project-for-ai-agents-30h0", "published_at": "2026-08-27 16:31:26+00:00", "updated_at": "2026-08-27 16:49:01.492155+00:00", "lang": "en", "topics": ["developer-tools", "ai-agents"], "entities": [], "alternates": {"html": "https://wpnews.pro/news/code-is-open-secrets-aren-t-organizing-your-project-for-ai-agents", "markdown": "https://wpnews.pro/news/code-is-open-secrets-aren-t-organizing-your-project-for-ai-agents.md", "text": "https://wpnews.pro/news/code-is-open-secrets-aren-t-organizing-your-project-for-ai-agents.txt", "jsonld": "https://wpnews.pro/news/code-is-open-secrets-aren-t-organizing-your-project-for-ai-agents.jsonld"}}