Extracting AI Rules from a Laravel Codebase with Boost | Mohamed Said        [  ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MH.png)   Mohamed Said Laravel Backend Engineer  ](https://msaied.com) [ Home ](https://msaied.com) [ Projects ](https://msaied.com/projects) [ Articles  ](https://msaied.com/articles) [ Certificates ](https://msaied.com/certificates) [ Contact ](https://msaied.com#contact-section) 

       [  ](https://github.com/EG-Mohamed)       

 [ Home ](https://msaied.com) [ Projects ](https://msaied.com/projects) [ Articles ](https://msaied.com/articles) [ Certificates ](https://msaied.com/certificates) [ Contact ](https://msaied.com#contact-section) 

  [ home ](https://msaied.com)    [ articles ](https://msaied.com/articles)    Extracting AI Rules from an Existing Laravel Codebase with Laravel Boost        On this page       1. [  Why Existing Codebases Need AI Context ](#why-existing-codebases-need-ai-context)
2. [  Approach 1: Deterministic Artisan Command ](#approach-1-deterministic-artisan-command)
3. [  Approach 2: The infer-conventions Skill ](#approach-2-the-infer-conventions-skill)
4. [  What the Skill Looks For ](#what-the-skill-looks-for)
5. [  What the Skill Deliberately Skips ](#what-the-skill-deliberately-skips)
6. [  Recording Approved Rules ](#recording-approved-rules)
7. [  Guidelines, Skills, and Rules — Three Layers ](#guidelines-skills-and-rules-three-layers)
8. [  Key Takeaways ](#key-takeaways)

  ![Extracting AI Rules from an Existing Laravel Codebase with Laravel Boost](https://cdn.msaied.com/615/60aa9079953ed56554726c93cca8ebd6.png)

 [  Laravel ](https://msaied.com/articles?category=laravel) [  AI ](https://msaied.com/articles?category=ai)  #Laravel Boost   #AI Agents   #Artisan   #Code Conventions   #MCP  

 Extracting AI Rules from an Existing Laravel Codebase with Laravel Boost 
==========================================================================

     31 Aug 2026      4 min read    ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MJ.jpg)  Mohamed Said  

       Table of contents

1. [  01   Why Existing Codebases Need AI Context  ](#why-existing-codebases-need-ai-context)
2. [  02   Approach 1: Deterministic Artisan Command  ](#approach-1-deterministic-artisan-command)
3. [  03   Approach 2: The infer-conventions Skill  ](#approach-2-the-infer-conventions-skill)
4. [  04   What the Skill Looks For  ](#what-the-skill-looks-for)
5. [  05   What the Skill Deliberately Skips  ](#what-the-skill-deliberately-skips)
6. [  06   Recording Approved Rules  ](#recording-approved-rules)
7. [  07   Guidelines, Skills, and Rules — Three Layers  ](#guidelines-skills-and-rules-three-layers)
8. [  08   Key Takeaways  ](#key-takeaways)

 Why Existing Codebases Need AI Context
--------------------------------------

A brand-new Laravel application can record [project rules](https://laravel.com/docs/13.x/boost#project-rules) as the team makes decisions. An established application already has years of conventions baked into its controllers, models, tests, and directory structure. When a team installs [Laravel Boost](https://laravel.com/framework/docs/13.x/boost), something has to supply that historical context to the AI agent — either the codebase itself or the humans who built it.

The Laravel team tried two approaches before settling on the one that ships today.

Approach 1: Deterministic Artisan Command
-----------------------------------------

The first attempt was an Artisan command called `boost:infer-conventions`. It used a file sampler, an inspector, and five hand-written detectors covering patterns such as enum key casing, `guarded` vs `fillable`, query-scope style, and validation-rule syntax. Each detector returned a confidence score, and Laravel Prompts presented the results in a multiselect.

The command spent zero model tokens — but it was never merged. Two problems killed it:

- **Scalability**: every new convention required a new hand-tuned PHP class covering discovery, evidence, confidence, and output.
- **Signal quality**: high-frequency patterns (e.g., anonymous migration classes) are framework defaults, not meaningful project decisions. Recording them teaches the agent very little.

Choosing *useful* rules requires judgment about framework defaults, enforcement tooling, architecture, and project history. That judgment is better delegated to a model.

Approach 2: The infer-conventions Skill
---------------------------------------

The replacement is an agent skill that audits roughly **49 convention dimensions across 10 groups**. Adding a new dimension takes one line in a Markdown checklist.

### What the Skill Looks For

**Project decisions, not framework defaults.** A useful rule carries information specific to *this* application. The skill asks: could a future agent reasonably choose a different implementation? If yes, the convention earns its place.

> "Store money as integer cents" changes how the agent models, validates, serializes, and tests a value. "Use anonymous migration classes" repeats the framework default.

**Deliberate absences.** A missing abstraction can be part of the architecture. For example:

```php
"Controllers and actions query Eloquent directly;
this application has no repository layer."

```

Writing that down keeps the agent within the application's existing shape.

**Evidence threshold.** A rule is proposed only when there are at least three consistent examples with no meaningful rival. The skill presents each candidate with the supporting files so the developer can reject, rescope, or reword it before anything is recorded.

### What the Skill Deliberately Skips

Pint, Rector, linters, and static analyzers already enforce mechanical style choices. Repeating those in prose wastes context on work the tool will perform anyway. Project rules are for decisions that deterministic guards cannot cover — with one exception: if a project *consistently* preserves a form that Rector would rewrite, that may signal an architectural or compatibility decision worth surfacing.

Recording Approved Rules
------------------------

After the developer approves a finding, the agent calls Boost's `record-rule` MCP tool with three values:

- `glob` — the files covered by the rule
- `title` — the project decision
- `note` — context the agent needs while working

`RuleRepository::write()` derives an area from the glob, finds or creates the appropriate Markdown file, merges the path into its frontmatter, appends the rule, and rebuilds the generated index. The resulting files live under `.ai/rules`, are version-controlled, and appear in pull-request review.

Guidelines, Skills, and Rules — Three Layers
--------------------------------------------

| Layer | Contents | Loading | Owner | |---|---|---|---| | **Guidelines** | Laravel-wide conventions | Always loaded | Laravel Boost | | **Skills** | Package knowledge and guided workflows | Loaded for relevant tasks | Laravel or package author | | **Rules** | Decisions from one application | Loaded by path or concept | The application team |

Keeping the always-loaded layer small and scoping application knowledge to path-matched rules reduces the context overhead on every agent turn.

Key Takeaways
-------------

- Deterministic detectors are fast but don't scale and can't judge convention value.
- The `infer-conventions` skill covers 49 dimensions; adding one takes a single Markdown line.
- Rules require at least three consistent examples and explicit developer approval before being written.
- Enforcement tools (Pint, Rector) own style; project rules own decisions those tools can't encode.
- Rule files live in `.ai/rules`, travel with the repo, and pass through normal PR review.
- A future staleness audit could flag rules whose cited examples no longer exist.

---

Source: [Extracting AI rules from an existing codebase — Laravel Blog](https://laravel.com/blog/extracting-ai-rules-from-an-existing-codebase)

 Found this useful?

          [  ](https://twitter.com/intent/tweet?url=https%3A%2F%2Fmsaied.com%2Farticles%2Fextracting-ai-rules-from-an-existing-laravel-codebase-with-laravel-boost&text=Extracting+AI+Rules+from+an+Existing+Laravel+Codebase+with+Laravel+Boost) [  ](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fmsaied.com%2Farticles%2Fextracting-ai-rules-from-an-existing-laravel-codebase-with-laravel-boost) 

 Frequently Asked Questions 
----------------------------

  3 questions  

     Q01  Why was the deterministic `boost:infer-conventions` Artisan command abandoned?        It was not scalable — each new convention required a hand-tuned PHP detector class — and it could not judge whether a pattern was a meaningful project decision or simply a framework default. High-frequency defaults like anonymous migration classes added noise without teaching the agent anything useful. 

      Q02  What evidence threshold does the infer-conventions skill require before proposing a rule?        The skill requires at least three consistent examples with no meaningful rival pattern before proposing a rule. Each proposal is shown to the developer along with the supporting files, and recording only begins after explicit approval. 

      Q03  Where are Boost project rules stored and how are they shared across the team?        Approved rules are written to `.ai/rules` as Markdown files. They are version-controlled, visible in pull-request review, and loaded by path or concept so every agent used by the team has access to the same current version. 

  Continue reading

 More Articles 
---------------

 [ View all    ](https://msaied.com/articles) 

 [ ![Livewire v4.4.3 Released: Bug Fixes, Performance Improvements & Alpine 3.17.1](https://cdn.msaied.com/616/ce49bf9badea064015ade0ed0c208d1a.png) Livewire Laravel PHP 

### Livewire v4.4.3 Released: Bug Fixes, Performance Improvements &amp; Alpine 3.17.1

Livewire v4.4.3 ships 24 changes including wire:loading attribute restoration, URL property fixes, script modu...

  ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MJ.jpg)  Mohamed Said 

 31 Aug 2026     4 min read  

  Read    

 ](https://msaied.com/articles/livewire-v443-released-bug-fixes-performance-improvements-alpine-3171) [ ![Laravel 12: New Features, Helpers, and Practical Upgrade Notes](https://cdn.msaied.com/613/3ae9f2d6a41ea381d43aeed4c462ae97.png) laravel laravel-12 upgrade 

### Laravel 12: New Features, Helpers, and Practical Upgrade Notes

Laravel 12 ships with streamlined application scaffolding, first-class support for typed route model binding i...

  ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MJ.jpg)  Mohamed Said 

 31 Aug 2026     3 min read  

  Read    

 ](https://msaied.com/articles/laravel-12-new-features-helpers-and-practical-upgrade-notes-2) [ ![Laravel Octane + FrankenPHP: Persistent Services, Shared State, and Safe Singletons](https://cdn.msaied.com/612/2bd17daafd0c48a0aa824a6d744fb403.png) laravel octane frankenphp 

### Laravel Octane + FrankenPHP: Persistent Services, Shared State, and Safe Singletons

Running Laravel under FrankenPHP workers means your service container lives across requests. Learn which singl...

  ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MJ.jpg)  Mohamed Said 

 31 Aug 2026     4 min read  

  Read    

 ](https://msaied.com/articles/laravel-octane-frankenphp-persistent-services-shared-state-and-safe-singletons) 

   [  ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MH.png)   Mohamed Said Laravel Backend Engineer  ](https://msaied.com)Senior Backend Engineer specializing in Laravel, scalable SaaS platforms, APIs, and cloud infrastructure. I build secure, high-performance web applications that help businesses grow.

Explore

- [Home](https://msaied.com)
- [Projects](https://msaied.com/projects)
- [Articles](https://msaied.com/articles)
- [Certificates](https://msaied.com/certificates)
- [Contact](https://msaied.com#contact-section)

Connect

- [   hello@msaied.com ](mailto:hello@msaied.com)
- [   +20 109 461 9204 ](tel:+201094619204)

© 2026 Mohamed Said. All rights reserved.

 [  ](https://github.com/EG-Mohamed) [  ](https://www.linkedin.com/in/msaiedm/) [  ](https://wa.me/201094619204) [  ](mailto:hello@msaied.com) [  ](https://drive.google.com/file/u/0/d/1MF20IPRJyzfy32mhEutjL5EpSls0w2Q8/view)
