Extracting AI Rules from a Laravel Codebase with Boost | Mohamed Said       [Skip to content](#main)  [ ![](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MH.png) Mohamed SaidLaravel Backend Engineer ](https://www.msaied.com/public) - [Home](https://www.msaied.com/public)
- [Projects](https://www.msaied.com/public/projects)
- [Articles](https://www.msaied.com/public/articles)
- [Certificates](https://www.msaied.com/public/certificates)
- [About](https://www.msaied.com/public#about)

           [  Contact](https://www.msaied.com/public#contact) Menu 

Menu
----

Close 

 - [HomeStart here](https://www.msaied.com/public)
- [ProjectsCase studies](https://www.msaied.com/public/projects)
- [ArticlesEngineering notes](https://www.msaied.com/public/articles)
- [CertificatesCredentials](https://www.msaied.com/public/certificates)
- [AboutHow I work](https://www.msaied.com/public#about)
- [ContactGet in touch](https://www.msaied.com/public#contact)

  [Start a conversation](https://www.msaied.com/public#contact) [WhatsApp](https://wa.me/201094619204) [Email](mailto:hello@msaied.com) 

 1. [Home](https://www.msaied.com/public)
2. /
3. [Articles](https://www.msaied.com/public/articles)
4. /
5. [Laravel](https://www.msaied.com/public/articles?category=laravel)
6. /
7. Extracting AI Rules from an Existing Laravel Codebase with Laravel Boost

   [Laravel](https://www.msaied.com/public/articles?category=laravel) [AI](https://www.msaied.com/public/articles?category=ai) 

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

 Laravel Boost's infer-conventions skill scans your existing codebase, gathers evidence across 49 convention dimensions, and proposes scoped AI rules for developer approval — no hand-written detectors required.

 ![](https://cdn.msaied.com/01M22N44A70A5MC2S599JP0MPH.webp) [Mohamed Said](https://www.msaied.com/public#person) Published 31 Aug 2026 · Updated 31 Aug 2026 · 4 min read

ShareCopy linkCopied

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

  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)

 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)

- [Laravel Boost](https://www.msaied.com/public/articles?search=Laravel%20Boost)
- [AI Agents](https://www.msaied.com/public/articles?search=AI%20Agents)
- [Artisan](https://www.msaied.com/public/articles?search=Artisan)
- [Code Conventions](https://www.msaied.com/public/articles?search=Code%20Conventions)
- [MCP](https://www.msaied.com/public/articles?search=MCP)

 Frequently asked questions 
---------------------------

  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.

   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.

   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.

   ![Mohamed Said](https://cdn.msaied.com/01M22N44A70A5MC2S599JP0MPH.webp)About the author
----------------

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

[About](https://www.msaied.com/public#about) [GitHub ↗](https://github.com/EG-Mohamed) [LinkedIn ↗](https://www.linkedin.com/in/msaiedm/) [WhatsApp ↗](https://wa.me/201094619204) [Email Address ↗](mailto:hello@msaied.com) [My CV ↗](https://drive.google.com/file/u/0/d/1MF20IPRJyzfy32mhEutjL5EpSls0w2Q8/view)  

   [Previous articleLivewire v4.4.3 Released: Bug Fixes, Performance Improvements &amp; Alpine 3.17.1](https://www.msaied.com/public/articles/livewire-v443-released-bug-fixes-performance-improvements-alpine-3171) [Next articleCompoships: Eloquent Relationships on Multiple Columns in Laravel](https://www.msaied.com/public/articles/compoships-eloquent-relationships-on-multiple-columns-in-laravel)  

   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)

 ###  Have a technical challenge?

 Tell me what you’re building. I reply within two working days.

[Start a conversation](https://www.msaied.com/public#contact) 

   Related articles
-----------------

 [ ![](https://cdn.msaied.com/740/cce86edc21eddcbdd2f2454fadaf9c70.png)  · 3 min read### The Pipeline Pattern in Laravel: Custom Pipelines Beyond Middleware

5 Oct 2026 ](https://www.msaied.com/public/articles/the-pipeline-pattern-in-laravel-custom-pipelines-beyond-middleware-1) [ ![](https://cdn.msaied.com/739/2d6897fdcdcf090613f96f72a64b8a78.png)  · 4 min read### MySQL Full-Text Search in Laravel: Indexes, Relevance Scoring, and Boolean Mode

4 Oct 2026 ](https://www.msaied.com/public/articles/mysql-full-text-search-in-laravel-indexes-relevance-scoring-and-boolean-mode) [ ![](https://cdn.msaied.com/738/073696a3fefe18bec825beec5ac658f5.png)  · 4 min read### Laravel Queue Rate-Limited Middleware: Throttling Jobs Without Losing Work

4 Oct 2026 ](https://www.msaied.com/public/articles/laravel-queue-rate-limited-middleware-throttling-jobs-without-losing-work) 

  Have a technical challenge?
----------------------------

Tell me what you’re building. I reply within two working days.

 [Discuss your project ↗](https://www.msaied.com/public#contact) 

  © 2026 Mohamed Said · Built with Laravel, meant to last.Senior Backend Engineer specializing in Laravel, scalable SaaS platforms, APIs, and cloud infrastructure. I build secure, high-performance web applications that help businesses grow.

 - [Home](https://www.msaied.com/public)
- [Articles](https://www.msaied.com/public/articles)
- [Certificates](https://www.msaied.com/public/certificates)
- [GitHub](https://github.com/EG-Mohamed)
- [LinkedIn](https://www.linkedin.com/in/msaiedm/)
- [WhatsApp](https://wa.me/201094619204)
- [Email Address](mailto:hello@msaied.com)
- [My CV](https://drive.google.com/file/u/0/d/1MF20IPRJyzfy32mhEutjL5EpSls0w2Q8/view)
- [Sitemap](https://www.msaied.com/public/sitemap.xml)
