Unearth what AI needs to know about your Laravel app.

Laravel Necromancer scans your bootstrapped application and produces a structured manifest of 18 artifact types — routes, models, jobs, events, policies, and more — so AI coding agents always have an accurate picture of your application.

$ php artisan necromancer:doctor

  Laravel Necromancer — AI Readability Score
  ──────────────────────────────────────────
  Score: 74%

  Route Clarity          ████████░░  82%  (12/15 named · 14/15 controller-backed)
  Model Expressiveness   ██████░░░░  61%  (3/5 casts · 4/5 fillable · 2/5 relationships)
  Authorization Coverage ███████░░░  70%  (2/3 policies · 8/12 write routes with auth)
  Validation Coverage    ████████░░  80%  (8/10 write routes with FormRequest)
  Async Clarity          ████████░░  83%  (4/5 jobs configured · 4/4 events with listeners)
  Codebase Vocabulary    ██████░░░░  63%  (5/8 commands described · 1/1 backed enums)
  Test Presence          ████████░░  80%  (4/5 models · 3/3 jobs)

  Tip: run necromancer:audit for a detailed findings list.

What Necromancer Collects

The manifest covers 18 artifact types across the full Laravel application structure. Every artifact carries a source field with file, line, and hash for precise citations and stale detection.

01
routes
Name, method, URI, controller, action, middleware, authorization
02
models
Table, fillable, casts, relationships, scopes, observers, policy, factory
03
jobs
Queue, connection, tries, timeout, backoff, max_exceptions
04
events
Listeners, broadcastable channels
05
listeners
Handled events, queued status
06
commands
Signature, description, aliases
07
form_requests
Rules, stop_on_first_failure, error_bag
08
policies
Model, policy methods
09
enums
Backing type, cases
10
tests
File, type (unit/feature), subject class, test methods
11
observers
Model, lifecycle hooks, queued status
12
scheduled_tasks
Command, cron expression, human-readable schedule, flags
13
middleware
Alias, class, scope (global/group/alias), group name
14
livewire_components
View, public properties with types, action methods, listened events
15
gates
Ability, kind (closure/class/before_hook/after_hook), parameters
16
mailables
Subject, queued status, queue name, view/markdown template
17
validation_rules
Implicit flag, docblock description
18
service_providers
Deferred flag, source location

Commands

Necromancer follows a scan-first workflow — every other command reads the manifest produced by necromancer:scan.

necromancer:scan
--only=TYPE,TYPE --diff --fail-on-drift --output=PATH

Bootstraps the application and writes the necromancer.json manifest. Re-run whenever your application changes. Supports partial scans and CI drift detection.

php artisan necromancer:scan
php artisan necromancer:scan --only=routes,models
php artisan necromancer:scan --diff --fail-on-drift    # CI gate
necromancer:map
--type=TYPE

Terminal-based pretty-printer of the manifest inventory. Read-only; never writes to disk. Shows a stale-manifest warning if source files are newer than the manifest.

php artisan necromancer:map
php artisan necromancer:map --type=routes
php artisan necromancer:map --type=models
necromancer:audit
--format=text|json|markdown --output=PATH --fail-on=SEVERITY

Scored AI-readability report (0–100). Findings grouped by severity: error (−10), warning (−5), suggestion (−1). Checks unnamed routes, missing model casts, dead events, unconfigured jobs, and more.

php artisan necromancer:audit
php artisan necromancer:audit --format=markdown --output=audit.md
php artisan necromancer:audit --fail-on=error      # exit 1 on errors (CI)
php artisan necromancer:audit --fail-on=warning    # exit 1 on warnings or errors
necromancer:doctor
--json --min-score=N --only=KEYS

Seven-dimension AI readability percentage dashboard with progress bars. Dimensions: Route Clarity, Model Expressiveness, Authorization Coverage, Validation Coverage, Async Clarity, Codebase Vocabulary, Test Presence.

php artisan necromancer:doctor
php artisan necromancer:doctor --json
php artisan necromancer:doctor --min-score=80         # exit 1 when score < 80 (CI)
php artisan necromancer:doctor --only=route-clarity
necromancer:generate
--only=TYPE,TYPE --except=TYPE,TYPE --output=PATH --force

Produces NECROMANCER.md — a full Markdown context file for AI coding agents. When Laravel Boost is installed, writes to .ai/guidelines/necromancer.md automatically.

php artisan necromancer:generate
php artisan necromancer:generate --only=routes,models
php artisan necromancer:generate --except=listeners,validation_rules
php artisan necromancer:generate --output=.ai/context/app.md --force
necromancer:ask
--provider= --model=

Natural-language codebase Q&A. The manifest is injected verbatim into the AI's context — answers are grounded in your actual application, not the model's prior knowledge. Requires laravel/ai.

php artisan necromancer:ask "What routes require authentication?"
php artisan necromancer:ask                              # interactive prompt
php artisan necromancer:ask "..." --provider=anthropic --model=claude-sonnet-4-5
necromancer:prompt
--top=N --no-ai --output=PATH

Builds a ready-to-paste AI prompt grounded in the most relevant manifest entries for your question. Keyword-searches the manifest, ranks artifacts by relevance, and outputs a prompt block with file:line citations.

php artisan necromancer:prompt "Where is tenant isolation enforced?"
php artisan necromancer:prompt "billing" --top=5
php artisan necromancer:prompt "auth" --no-ai --output=prompt.txt
necromancer:infer
--locale= --temperature= --max-critic-rounds=N --dry-run --fresh

Generates Architecture Decision Records (ADRs) from the manifest using AI. Evaluates nine architectural dimensions (async-processing, authorization, event-driven, api-design, data-modeling, command-scheduling, form-validation, external-services, architecture-pattern). A critic agent reviews and filters the initial ADRs. Requires laravel/ai.

php artisan necromancer:infer
php artisan necromancer:infer --dry-run             # print without writing files
php artisan necromancer:infer --temperature=0 --max-critic-rounds=2
php artisan necromancer:infer --locale=it           # add Italian translation
php artisan necromancer:infer --fresh               # clear cache and re-infer
necromancer:diff
--base-manifest=PATH --review --format=markdown --output=PATH

Compares the current manifest against a branch or snapshot. Shows added, removed, and modified routes, models, jobs, events, listeners, policies, and other artifacts. With --review, an AI agent summarises the architectural impact and surfaces risks.

php artisan necromancer:diff main
php artisan necromancer:diff main --review --format=markdown
php artisan necromancer:diff --base-manifest=snapshots/before.json
necromancer:benchmark
--generate-suite --suite-output=PATH --no-judge --format=markdown --output=PATH

Measures how much Necromancer's generated context improves AI accuracy, hallucination rate, and token cost. Runs a task suite in three conditions — no context, manual AGENTS.md, and Necromancer-generated NECROMANCER.md — and reports results side by side. Use --generate-suite to scaffold a grounded task suite from the current manifest before running the benchmark.

php artisan necromancer:benchmark
php artisan necromancer:benchmark --generate-suite   # scaffold tasks from manifest → config/benchmark-tasks.php
php artisan necromancer:benchmark --generate-suite --suite-output=custom/tasks.php
php artisan necromancer:benchmark --no-judge        # automated checks only
php artisan necromancer:benchmark --format=markdown --output=benchmark.md

Getting Started

Three steps from zero to AI-readable codebase.

1 Install
composer require --dev robertogallea/laravel-necromancer

The service provider is auto-discovered — no manual registration needed. Optionally publish the configuration:

php artisan vendor:publish --tag=necromancer-config
2 Scan

Build the manifest. Re-run whenever your application changes.

php artisan necromancer:scan
3 Audit & Generate

Check AI-readability and generate the Markdown context file.

php artisan necromancer:audit
php artisan necromancer:generate
PHP ≥ 8.3
Laravel 13.x

CI Integration

Add these steps to your pipeline to enforce manifest freshness and AI-readability quality gates.

- name: Check manifest is up to date
  run: php artisan necromancer:scan --diff --fail-on-drift

- name: Fail on AI-readability errors
  run: php artisan necromancer:audit --fail-on=error

- name: Enforce minimum AI readability score
  run: php artisan necromancer:doctor --min-score=80

MCP Tools

When laravel/mcp is installed, Necromancer exposes the manifest as read-only tools via a laravel-necromancer MCP server handle — auto-configured in .mcp.json on first run.

query_routes

List routes, optionally filtered by method or name/URI pattern.

query_models

List Eloquent models, optionally filtered by class name.

query_artifacts

List artifacts of any type, optionally filtered by JSON substring. Use when you know the artifact type.

search_artifacts

Full-text search across all artifact types. Use when you need to search across types.

{
  "mcpServers": {
    "laravel-necromancer": {
      "command": "php",
      "args": ["artisan", "mcp:start", "necromancer"]
    }
  }
}

PHP Attribute Support

Necromancer reads PHP 8 attributes as primary data sources alongside class properties. Codebases using the attribute-based API introduced in Laravel 11+ are fully supported.

Subsystem Attributes Manifest fields
Routing #[Authorize] authorization
Eloquent #[ObservedBy] #[UsePolicy] #[ScopedBy] #[UseFactory] #[UseEloquentBuilder] #[Scope] observers, policy, global_scopes, factory, custom_builder, scopes
Queue #[Queue] #[Connection] #[Tries] #[Timeout] #[Backoff] #[MaxExceptions] all job queue config fields
Console #[Aliases] aliases
FormRequest #[StopOnFirstFailure] #[ErrorBag] stop_on_first_failure, error_bag

Privacy & Exclusions

  • Never reads .env or raw configuration values
  • Never collects or stores application secrets
  • Horizon, Telescope, and Debugbar routes excluded by default
  • Exclusions apply to every downstream command (map, audit, generate) — excluded artifacts never appear in results
// config/necromancer.php
'exclude' => [
    'routes' => ['horizon.*', 'telescope.*', 'debugbar.*'],
    'models' => [],
    'tests'  => [],
],