Workflow
File Organization

File Organization

🚫

Critical Rule: AI defaults to putting files at project root. Fight this constantly.

The Standard Structure

project/
β”œβ”€β”€ docs/           # Documentation only
β”œβ”€β”€ scripts/        # Utility scripts  
β”œβ”€β”€ tests/          # All test files
β”œβ”€β”€ src/            # Source code
β”‚   β”œβ”€β”€ components/ # UI components
β”‚   β”œβ”€β”€ utils/      # Helper functions
β”‚   β”œβ”€β”€ services/   # Business logic
β”‚   β”œβ”€β”€ hooks/      # React hooks
β”‚   β”œβ”€β”€ types/      # TypeScript types
β”‚   └── lib/        # Third-party wrappers
β”œβ”€β”€ public/         # Static assets
β”œβ”€β”€ .gitignore      
└── README.md

The Right Way to Prompt

βœ… Good: Specify the path

"Create the UserService class in `/src/services/UserService.ts`"

❌ Bad: Let AI decide

"Create the UserService class"

AI will likely put it at root or in a random location.

Creating Folders First

Before asking AI to create files, create the folders:

mkdir -p src/services src/components src/utils

Then prompt:

"Create a new service in /src/services/ for handling payments"

Fixing Misplaced Files

When AI puts a file in the wrong place:

  1. Stop immediately β€” Don't continue building on wrong structure
  2. Move the file β€” Use your IDE or terminal
  3. Tell AI β€” "From now on, all services go in /src/services/"

Import Path Discipline

Bad AI output often has broken imports:

// AI might generate:
import { User } from '../../../models/User'  // Fragile relative path
 
// Better:
import { User } from '@/models/User'  // Path alias

Set up path aliases in tsconfig.json:

{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "@/*": ["src/*"]
    }
  }
}

The Rule

Every file has ONE correct location. Know it. Enforce it. Don't let AI decide.