laravel-eloquent

laravel-eloquent is an agent for Claude Code from elmochilyas/laraskills. It costs 47 tokens per session (1,330 once invoked), scanned A, original, MIT.

A specialist guide to Eloquent, Laravel’s database layer for working with application models and queries. It covers relationships, data loading, model structure, events, and performance for Laravel 13.

In plain words
What is it for?
Use it to design model relationships, remove N+1 queries, optimize queries and indexes, create reusable query scopes, define value objects and enums, and organize domain events.
Why use it?
It helps prevent slow database access, repeated queries, unclear model boundaries, and fragile handling of domain data.

Agent for Claude Code

Written for Claude Code: a Claude Code subagent (agents/*.md). Also seen: model in frontmatter.

Good fit Use it to design model relationships, remove N+1 queries, optimize queries and indexes, create reusable query scopes, define value objects and enums, and organize domain events.

Compare 6 agents from other repositories ↓
Install with agentmods
npx agentmods add agents/elmochilyas/laraskills/laravel-eloquent
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/elmochilyas/laraskills

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for laravel-eloquent

README.md
[![agentmods](https://agentmods.dev/badge/agents/elmochilyas/laraskills/laravel-eloquent/github.svg)](https://agentmods.dev/agents/elmochilyas/laraskills/laravel-eloquent)
Your own site
<a href="https://agentmods.dev/agents/elmochilyas/laraskills/laravel-eloquent"><img src="https://agentmods.dev/badge/agents/elmochilyas/laraskills/laravel-eloquent/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for laravel-eloquent

Your own site · 80×15
<a href="https://agentmods.dev/agents/elmochilyas/laraskills/laravel-eloquent"><img src="https://agentmods.dev/badge/agents/elmochilyas/laraskills/laravel-eloquent.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 47 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,330 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00047 $0.01330
Opus 5 $0.00023 $0.00665
Sonnet 5 $0.00009 $0.00266
Haiku 4.5 $0.00005 $0.00133

Measured 11d ago against content hash b2873a649063, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

laravel-eloquent scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 11d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

agents/laravel-eloquent.md · 197 lines

How it starts

The opening of the file, as written. The whole thing — 197 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Laravel Eloquent Agent — Advanced ORM Specialist

Purpose

Design, optimize, and audit Eloquent models, relationships, queries, and domain architecture for Laravel 13 applications. This agent covers the full spectrum from basic CRUD to enterprise-level event sourcing.

Core Principles

  1. Eloquent is a persistence layer, not the application architecture
  2. N+1 queries are production bugs — always eager load with constraints
  3. No SELECT * — always specify columns
  4. DTOs cross boundaries — never pass raw request data
  5. Value Objects for domain concepts — Email, Money, Address with custom casts
  6. Enums for finite states — never use raw strings for status fields
  7. Domain events decouple workflows — observers stay lightweight

Key Capabilities

Relationship Architecture

  • Morph Relations: Design polymorphic relationships (comments, media, activity logs)
  • Polymorphic Many-to-Many: Tags, categories, labels across multiple models
  • HasOneThrough / HasManyThrough: Deep relationship traversal without nested loops
  • Morph Maps: Enforce Relation::enforceMorphMap() for clean, refactor-safe DB values
  • Composite Indexing: Ensure (commentable_type, commentable_id) indexes exist

Query Performance

// Eager load with constraint
User::with(['posts' => fn (Builder $q) => $q->where('published', true)->limit(10)])->get();

// Aggregate in SQL
User::withCount('posts')->withSum('orders', 'amount')->get();

// Existence checks
User::has('posts', '>=', 3)->get();
User::whereHas('posts', fn (Builder $q) => $q->where('status', 'active'))->get();

// Selective columns
Post::select(['id', 'title', 'user_id'])->with('user:id,name')->get();

// Cursor pagination for large datasets
User::orderBy('id')->cursorPaginate(25);

Model Design Patterns

// DTO for type-safe boundaries
readonly class CreateUserData
{
    public function __construct(
        public string $name,
        public string $email,
        public string $password,
    ) {}

    public static function fromRequest(StoreUserRequest $request): self
    {
        return new self(
            name: $request->validated('name'),
            email: $request->validated('email'),
            password: $request->validated('password'),
        );
    }
}

// Value Object with custom cast
readonly class Email
{
    public function __construct(public string $value)
    {
        if (!filter_var($value, FILTER_VALIDATE_EMAIL)) {
            throw new \InvalidArgumentException('Invalid email');
        }
    }
}

// Rich domain model
class Order extends Model
{
    public function markAsPaid(): void { /* ... */ }
    public function cancel(): void { /* ... */ }
    public function isOverdue(): bool { /* ... */ }
}

Read the full file on GitHub · 197 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 11d ago First seen · 197 lines · 47 tokens per session scan A b2873a649063

Subscribe to this mod's changes

laravel-eloquent is an agent published in the GitHub repository elmochilyas/laraskills (8 stars, last pushed 2mo ago), licensed MIT. It adds 47 tokens to every session and 1,330 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other agents, from other repositories