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://www.msaied.com) [ Home ](https://www.msaied.com) [ Projects ](https://www.msaied.com/projects) [ Articles  ](https://www.msaied.com/articles) [ Certificates ](https://www.msaied.com/certificates) [ Contact ](https://www.msaied.com#contact-section) 

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

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

  [ home ](https://www.msaied.com)    [ articles ](https://www.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://www.msaied.com/articles?category=laravel) [  AI ](https://www.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%2Fwww.msaied.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%2Fwww.msaied.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://www.msaied.com/articles) 

 [ ![Laravel New in 13: Features, Helpers, and Upgrade Notes](https://cdn.msaied.com/625/629cfac34ade7206a215809c0438c5ae.png) laravel php upgrade 

### Laravel New in 13: Features, Helpers, and Upgrade Notes

Laravel 13 ships with async-first primitives, tightened type contracts, and quality-of-life helpers that rewar...

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

 3 Sep 2026     3 min read  

  Read    

 ](https://www.msaied.com/articles/laravel-new-in-13-features-helpers-and-upgrade-notes) [ ![Statamic Sidecar: Edit Markdown Sites from the Control Panel Without Migration](https://cdn.msaied.com/624/6df15b406d700ea26fb98c6ad4779195.png) Statamic Markdown CMS 

### Statamic Sidecar: Edit Markdown Sites from the Control Panel Without Migration

Statamic's new Sidecar product lets you manage any static site generator's Markdown files through the Statamic...

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

 2 Sep 2026     3 min read  

  Read    

 ](https://www.msaied.com/articles/statamic-sidecar-edit-markdown-sites-from-the-control-panel-without-migration) [ ![Laravel Macro-Free Extensibility: Extending Eloquent Builder with Custom Query Objects](https://cdn.msaied.com/621/b0c176a363378658e83bb44ed379879b.png) laravel eloquent clean-architecture 

### Laravel Macro-Free Extensibility: Extending Eloquent Builder with Custom Query Objects

Skip global macros and reach for typed, testable query objects that encapsulate reusable Eloquent constraints...

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

 2 Sep 2026     1 min read  

  Read    

 ](https://www.msaied.com/articles/laravel-macro-free-extensibility-extending-eloquent-builder-with-custom-query-objects) 

   [  ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MH.png)   Mohamed Said Laravel Backend Engineer  ](https://www.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://www.msaied.com)
- [Projects](https://www.msaied.com/projects)
- [Articles](https://www.msaied.com/articles)
- [Certificates](https://www.msaied.com/certificates)
- [Contact](https://www.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)
