Organizing an AI-Built Project: Folder Structure That Works
I tested this.
What folder structure works best for AI projects?
Best structure: /core (hand-written, reviewed), /features (AI-generated, faster iteration), /shared (utility code used by both), /tests (all tests). This separation lets the AI work freely in /features while protecting /core from accidental modifications.
How do you separate AI-generated from hand-written code?
Separate by adding /core to the AI ignore list in .cursorrules. The AI can read /core for context but cannot modify it. I specify: “Never modify files in /core. You can reference them for types and imports.” This prevents the AI from changing auth or payment code.
What files should AI never touch?
AI should never touch: auth middleware, payment processing, encryption utilities, database migration files, and deployment configuration. Mark these directories as read-only in your AI configuration. I learned this after an AI rewrote my Stripe webhook handler with a bug that cost me $58 in failed payments.
Structure: /core (protected), /features (AI zone), /shared, /tests. Mark /core as read-only in .cursorrules. AI never touches: auth, payments, encryption, migrations, deployment config.
The separation between AI-allowed and AI-forbidden code is the most important architectural decision for AI-built projects. Without it, the AI will eventually modify something it should not. The Stripe webhook incident taught me this lesson. Five minutes of setup would have prevented a $58 mistake. Set the boundaries before you start.
Give me steps and mistakes.
AI tools are powerful but require human judgment. Review every output before merging. Test every feature with edge cases. Never trust AI code in production without verification. These habits prevent production incidents. The extra minutes spent on review pay for themselves many times over in prevented issues and cleaner codebases that are easier to maintain long term.
Leave a Reply