skills/laravel/laravel-database-expert/SKILL.md
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.
npx skillsauth add hoangnguyen0403/agent-skills-standard laravel-database-expertInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
DB::enableQueryLog() or Laravel Debugbar.withCount(), withSum(), or addSelect subqueries.Cache::remember() with tags for frequently accessed data.read/write keys in config/database.php.See implementation examples for cache-aside pattern with tag-based invalidation.
joinSub($subquery, 'alias', ...) and whereExists(fn($q) => $q->select(DB::raw(1))...) over raw SQL or whereIn for correlated subqueries.addSelect with DB::raw subquery to avoid N+1 issues.withCount(), withSum(), and withAvg() directly via Eloquent for optimized column-based aggregation.selectRaw or whereRaw with bindings; never use string concatenation in raw queries.Cache::remember('key', $ttl, $closure) for frequently accessed data (e.g., posts.all).Cache::tags(['posts', 'user:1']) for grouped invalidation.Cache::tags(['posts'])->flush() to clear specific subsets; never use Cache::flush() globally in production.config/database.php mysql/pgsql connections. Laravel automatically routes SELECT to read and INSERT/UPDATE/DELETE to write; no code changes needed.Cache::flush(): Use tags to target specific cache groups.testing
Infer the requesting operator's technical fluency from message content (never ask directly) and adapt register — business, hybrid, or technical — across SDLC workflow output. Use when starting sdlc, brainstorm-feature, plan-feature, verify-work, publish-notes, or session-report, or whenever a request's phrasing signals a non-technical or cross-stack operator.
documentation
Define transaction boundaries, locking, and consistency guarantees for multi-step writes. Use when designing atomic operations, retries, idempotency, or concurrent write behavior.
development
Design relational or document schemas from access patterns, cardinality, and lifecycle. Use when modeling entities, choosing embed vs normalize, or shaping schema boundaries before implementation.
data-ai
Diagnose database latency with explain plans, index ownership, and query-shape review. Use when a query is slow, an index is missing, or scans and N+1 patterns appear.