> laravel-database-expert

Optimize Laravel queries with subqueries, joinSub, Redis cache-aside patterns, and read/write connection splitting. Use when writing complex joins, implementing Cache::remember with tags, or configuring database read replicas. (triggers: config/database.php, database/migrations/*.php, join, aggregate, subquery, selectRaw, Cache)

fetch
$curl "https://skillshub.wtf/HoangNguyen0403/agent-skills-standard/laravel-database-expert?format=md"
SKILL.mdlaravel-database-expert

Laravel Database Expert

Priority: P1 (HIGH)

Workflow: Optimize a Slow Query

  1. Profile the query — Use DB::enableQueryLog() or Laravel Debugbar.
  2. Add missing indexes — Create a migration for join/where columns.
  3. Replace N+1 — Use withCount(), withSum(), or addSelect subqueries.
  4. Cache results — Apply Cache::remember() with tags for frequently accessed data.
  5. Split reads/writes — Configure read/write keys in config/database.php.

Cache-Aside with Tags Example

See implementation examples for cache-aside pattern with tag-based invalidation.

Implementation Guidelines

Advanced Query Builder

  • Complex Joins: Prefer joinSub($subquery, 'alias', ...) and whereExists(fn($q) => $q->select(DB::raw(1))...) over raw SQL or whereIn for correlated subqueries.
  • Subqueries: Use addSelect with a DB::raw subquery to avoid N+1 issues.
  • Aggregates: Use withCount(), withSum(), and withAvg() directly via Eloquent for optimized column-based aggregation.
  • Raw Expressions: Always use selectRaw or whereRaw with bindings; never use string concatenation in raw queries.

Caching Strategy (Redis/Memcached)

  • Cache-Aside: Utilize Cache::remember('key', $ttl, $closure) for frequently accessed data (e.g., posts.all).
  • Redis Tagging: Group related keys using Cache::tags(['posts', 'user:1']) for grouped invalidation.
  • Invalidation: Call Cache::tags(['posts'])->flush() to clear specific subsets; never use Cache::flush() globally in production.

Scalability & Infrastructure

  • Read/Write Splitting: Configure 'read' and 'write' keys in config/database.php mysql/pgsql connections. Laravel automatically routes SELECT to read and INSERT/UPDATE/DELETE to write; no code changes needed.
  • Indices: Ensure correct database indexes are present on all join and aggregate columns.

Anti-Patterns

  • No string SQL concatenation: Use bindings or Query Builder.
  • No queries in loops: Use subqueries, joins, or aggregates.
  • No Cache::flush(): Use tags to target specific cache groups.
  • No direct Redis calls: Use Laravel Cache wrappers consistently.

References

> related_skills --same-repo

> common-store-changelog

Generate user-facing release notes for the Apple App Store and Google Play Store by collecting git history, triaging user-impacting changes, and drafting store-compliant changelogs. Enforces character limits (App Store ≤4000, Google Play ≤500), tone, and bullet format. Use when generating release notes, app store changelog, play store release, what's new, or version release notes for any mobile app. (triggers: generate changelog, app store notes, play store release, what's new, release notes, ve

> golang-tooling

Go developer toolchain — gopls LSP diagnostics, linting, formatting, and vet. Use when setting up Go tooling, running linters, or integrating gopls with Claude Code. (triggers: gopls, golangci-lint, golangci.yml, go vet, goimports, staticcheck, go tooling, go lint)

> common-ui-design

Design distinctive, production-grade frontend UI with bold aesthetic choices. Use when building web components, pages, interfaces, dashboards, or applications in any framework (React, Next.js, Angular, Vue, HTML/CSS). (triggers: build a page, create a component, design a dashboard, landing page, UI for, build a layout, make it look good, improve the design, build UI, create interface, design screen)

> common-owasp

OWASP Top 10 audit checklist for Web Applications (2021) and APIs (2023). Load during any security review, PR review, or codebase audit touching web, mobile backend, or API code. (triggers: security review, OWASP, broken access control, IDOR, BOLA, injection, broken auth, API review, authorization, access control)

┌ stats

installs/wk0
░░░░░░░░░░
github stars452
██████████
first seenMar 17, 2026
└────────────

┌ repo

HoangNguyen0403/agent-skills-standard
by HoangNguyen0403
└────────────

┌ tags

└────────────