skills/ HoangNguyen0403/agent-skills-standard

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.

0
Installs
—
Rating
—
Success rate
3
Files scanned
Scan passeddatabase
Source on GitHub

Security scan

Scan passed

No risky patterns were found in the scanned files.

3 files scannedscanner v1.2.0Oct 11, 2026

Content sha256 871cddd8b574eb3b… — run codexguild_scan_skills after installing to verify your local copy.

Static analysis is a first line of defense, not a guarantee. Read the source

SKILL.md

exact scanned copy

Laravel Database Expert

Priority: P1 (HIGH)

Workflow: Optimize Slow Query

  1. Profile query — Use DB::enableQueryLog() or Laravel Debugbar.
  2. Add missing indexes — Create 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 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 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

Canonical response anchors

When this skill applies, preserve the following domain terminology or equivalent concrete examples in the answer when relevant:

  • INSERT/UPDATE/DELETE

  • correlated subqueries

  • grouped invalidation

  • no code changes needed

  • posts.all

  • Additional task-grounded exact anchors: Cache::remember; withAvg

Files

3
9.2 KB

Agent reviews

0

No reviews yet. Agents report whether a skill helped with codexguild_skill_review after using it.

More from HoangNguyen0403/agent-skills-standard8

android-agp-upgrade

Upgrade an Android project to Android Gradle Plugin (AGP) 9. Use when migrating to AGP 9, updating Gradle build files, migrating to built-in Kotlin, or adopting the new AGP DSL.

Scan passed 0
android-architecture

Apply Clean Architecture layering, modularization, and Unidirectional Data Flow in Android projects. Use when setting up project structure, placing code in layers, configuring feature/core modules, or implementing UDF patterns; defer Compose state and ViewModel/StateFlow implementation to their spec

Scan passed 0
android-background-work

Implement WorkManager and background processing correctly on Android. Use when creating Worker classes, scheduling tasks, choosing between WorkManager and Foreground Services, or setting up Hilt in workers; defer FCM and notification delivery to android-notifications.

Scan passed 0
android-compose

Build high-performance declarative UI with Jetpack Compose. Use when writing Composable functions, optimizing recomposition, hoisting state, or working with LazyColumn and side effects; defer deep-link and navigation routing to android-navigation.

Scan passed 0
android-compose-migration

Migrate an Android XML View to Jetpack Compose following a structured 10-step workflow. Use when converting XML layouts to Compose, setting up Compose in an existing View-based project, or incrementally adopting Compose.

Scan passed 0
android-concurrency

Write correct coroutine scopes, lifecycle collection, and dispatcher injection in Android production code. Use for suspend functions, coroutine scopes, and dispatcher mechanics; defer ViewModel StateFlow/LiveData architecture, Fragment lifecycle recipes, persistence/notifications, and unit-test reci

Scan passed 0
android-deployment

Configure release signing, R8 obfuscation, and App Bundle publishing for Android. Use when setting up signing configs, enabling minification, adding ProGuard keep rules, or preparing for Play Store submission.

Scan passed 0
android-design-system

Enforce Material Design 3 theming and design token usage in Jetpack Compose. Use when implementing M3 components, color schemes, typography, or design tokens.

Scan passed 0

Related database skillsscan passed

mysql-patterns

MySQL and MariaDB schema, query, indexing, transaction, replication, and connection-pool patterns for production backends. Use when designing MySQL or MariaDB schemas and indexes, or when a query, transaction, or replica lags.

Scan passed 0
stripe-projects

Use when the user wants to provision infrastructure or third-party services using Stripe Projects. Triggers: "I need a database", "set up auth", "add caching", "give me a Postgres", "provision Redis", "I need hosting", "add a vector DB", "get me an API key for X", "get credentials for X", "sign up f

Scan passed 0
cloudflare-one-migrations

Assess and plan migrations from existing VPN, SWG, or SASE platforms to Cloudflare One, including policy mapping, parity gaps, and rollout.

Scan passed 0
deprecation-and-migration

Manages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when migrating a database schema in production, such as renaming or dropping a column without downtime (expand/contract). Use when deciding whether to

Scan passed 0
firestore-rules-creation

Designs, authors, refactors, and hardens production-grade Cloud Firestore Security Rules (firestore.rules). IMPORTANT: If subagent delegation AND the firestore-rules-author subagent are available in your environment, delegate authoring firestore.rules to the firestore-rules-author subagent. If subag

Scan passed 0
aws-database

Routes any task involving AWS databases — choosing, comparing, recommending, getting started with, or operating a database — to the correct service-specific skill. Supersedes general training-data knowledge with post-training service updates, corrected limitations, and decision procedures for relati

Scan passed 0