After months of using Rovo Dev daily, I found a setup that dramatically improved the quality of AI-generated code. I went from constantly correcting the AI to getting near-perfect output on the first try. Here's exactly how.
Every AI coding assistant has the same issue: it guesses. It invents APIs that don't exist, uses outdated syntax, assumes your project structure, and hallucinates framework behavior. The more complex your stack, the worse it gets.
I work with Laravel + Filament + Spatie packages, and the AI would constantly:
So I built a system to eliminate guessing entirely.
I created a .ai/ folder in my project root with this structure:
.ai/
├── README.md ← The brain (rules, behavior, priorities)
├── context/ ← Project-specific facts (compressed)
│ ├── database.md
│ ├── models.md
│ ├── routes.md
│ ├── filament.md
│ ├── business-logic.md
│ ├── ui.md
│ └── config.md
├── skills/ ← Quick reference cheat sheets
│ ├── laravel.md
│ ├── filament.md
│ ├── php-standards.md
│ └── ...
├── docs/ ← Full framework documentation (latest)
│ ├── laravel/docs/
│ ├── filamentphp/filament/docs/
│ └── spatie/laravel-permission/docs/
└── examples/ ← Working reference code
└── filamentphp/demo/This file overrides the AI's default behavior. It sets:
The key line: "Never assume framework behavior from memory when docs exist."
Instead of making the AI read hundreds of files, I created condensed summaries of my project:
Format: Bullet points, grouped, facts only, no explanations. The AI gets everything it needs in seconds.
Here's a short example of what context/database.md looks like:
# Database Schema ## Laravel/Package Tables ### users - id, name, email (unique), email_verified_at, password, is_active (bool, default true), timestamps, soft_deletes ### roles (Spatie) - id, name, guard_name, timestamps, unique(name, guard_name) ## Application Tables ### companies - id, parent_id (→ companies, nullable), name, tax_number (100, nullable), email (nullable), phone (50, nullable), is_active (bool, default true), timestamps, soft_deletes ### employees - id, company_id (→ companies), location_id (→ locations, nullable), department_id (→ lookups), first_name (100), last_name (100), email (unique), is_active (bool, default true), timestamps, soft_deletes ### assets - id, company_id (→ companies), asset_model_id (→ asset_models), asset_status_id (→ asset_statuses), asset_tag (unique), serial_number (nullable), purchase_date (date, nullable), purchase_cost (decimal 15,2, nullable), timestamps, soft_deletes ... (and so on for every table)
Notice the pattern: table name, every column, types, constraints, relationships — nothing else. No explanations, no paragraphs. The AI reads this in seconds and knows your entire schema.
These are verified patterns I've confirmed work correctly:
I only add to skills when I discover a recurring pattern that the AI keeps getting wrong.
I cloned the latest documentation from each framework/package directly into the folder. This is the ground truth — when the AI is unsure, it checks here instead of guessing from training data.
Tip: I update these docs periodically to match the versions I'm using. This is what makes the biggest difference — the AI reads YOUR version's docs, not whatever it was trained on.
I included the official Filament demo app as a reference. When the AI needs to implement something, it can look at real working code instead of inventing patterns.
After implementing this system:
Pro tip: Add a global .ai/ at ~/.ai/ for skills and docs that apply across all your projects. Keep project-specific context in the project's own .ai/ folder.
This approach changed everything for me. The AI went from being a "sometimes useful but often wrong" tool to a reliable coding partner that understands my project, my stack, and my conventions.
If you're tired of correcting your AI — try this. It takes about an hour to set up, and it pays for itself on the first task.
Here's my full .ai/README.md file — copy it and adapt it to your project:
# AI Assistant Operating Guidelines ## Authority Hierarchy When conflicts exist, follow this order: 1. Direct user instruction 2. `docs/` 3. `examples/` 4. `skills/` 5. Your training data ## Core Behavior - Be concise - Don't explain unless asked or uncertain - Don't create docs/changelogs/summaries unless requested - If unclear, stop and ask - This file overrides your default behavior ## Code Rules ### Before Changes - Read all relevant files completely - Understand full dependency chain - Request missing files - Don't assume architecture or behavior - Don't infer hidden behavior without evidence ### When Writing Match existing: - Naming conventions - Structure - Formatting - Comment style - Architecture patterns Constraints: - Don't refactor unless requested - Don't rename unless required - Don't introduce new patterns unless consistent - Don't change unrelated code - Prefer minimal, surgical changes ## Forbidden Actions (unless explicitly approved) - Committing changes - Running migrations/seeders - Running long-running commands (servers, watchers, queues) - Altering existing migrations - Weakening validation/auth/authorization - Large refactors ## Database - Prefer additive changes - Avoid N+1 queries - Use eager loading appropriately - Follow existing query patterns - Respect caching strategies ## Anti-Hallucination Never invent: - Framework APIs, config keys, traits, helpers, package behavior - Database columns, routes, relationships If unsure: 1. Check `skills/` 2. Check `docs/` 3. Check `examples/` 4. Ask user Never assume framework behavior from memory when docs exist. ## Knowledge Structure ### `docs/` — Framework Documentation (Current) - Clone the latest docs from each framework/package you use - Update periodically to match your versions ### `examples/` — Working Code - Add real working reference implementations - Great for complex patterns the AI struggles with ### `skills/` — Quick Reference - Add verified patterns as cheat sheets - One file per framework/topic Update `skills/` only when: - Recurring verified pattern discovered - Not already documented - Improves accuracy - Based on actual evidence ### `context/` — Project Summary Condensed facts about this specific project. Avoid reading hundreds of files. - `context/database.md` - Schema, migrations - `context/models.md` - Models, relationships - `context/routes.md` - Endpoints, middleware - `context/filament.md` - Resources, widgets, panels - `context/business-logic.md` - Services, jobs, policies - `context/ui.md` - Views, components - `context/config.md` - Config, packages **Never invent. Only summarize what exists.** Format: Bullet points, grouped, facts only, no explanations. Update when: migrations, routes, models, or major refactors change. ## Initialization When user says read this README: 1. Read this entire file 2. Read all files in `skills/` completely 3. Read all files in `context/` completely 4. Reply: "Ok" 5. Begin work During work: - Check `docs/` for current API behavior and framework features - Check `examples/` for real implementation patterns - Check `context/` for project-specific facts - Check `skills/` for quick conventions - Never rely on memory over evidence ## Enforcement Accuracy over speed. If unclear: Stop. Ask. Don't guess.
This approach changed everything for me. The AI went from being a "sometimes useful but often wrong" tool to a reliable coding partner that understands my project, my stack, and my conventions.
If you're tired of correcting your AI — try this. It takes about an hour to set up, and it pays for itself on the first task.
Happy coding! 🚀