Laravel database expert
Skill ComeOnOliver/skillshub/skills/HoangNguyen0403/agent-skills-standard/laravel-database-expert
π§ The right skill, one API call. AI agent skills registry with token-efficient skill resolution. 5,000+ skills from 500+ top repos.
npx -y skills add ComeOnOliver/skillshub --skill laravel-database-expertAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
What its author says it does
Copied from the file, not written here
Expert patterns for advanced queries, Redis caching, and database scalability. Use when optimizing Laravel queries, implementing Redis caching, or scaling databases. (triggers: config/database.php, database/migrations/*.php, join, aggregate, subquery, selectRaw, Cache)
SKILL.md
2.3 KB, as published. Nobody here has run it
Laravel Database Expert
Priority: P1 (HIGH)
Structure
config/
βββ database.php # Connection & Cluster config
app/
βββ Http/
βββ Controllers/ # Query logic entry points
Implementation Guidelines
Advanced Query Builder
- Complex Joins: Prefer
joinSub($subquery, 'alias', ...)andwhereExists(fn($q) => $q->select(DB::raw(1))...)over raw SQL orwhereInfor correlated subqueries. - Subqueries: Use
addSelectwith aDB::rawsubquery to avoid N+1 issues. - Aggregates: Use
withCount(),withSum(), andwithAvg()directly via Eloquent for optimized column-based aggregation. - Raw Expressions: Always use
selectRaworwhereRawwith 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 useCache::flush()globally in production.
Scalability & Infrastructure
- Read/Write Splitting: Configure 'read' and 'write' keys in
config/database.phpmysql/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.