db-context

Provides database conventions for Laravel projects covering MySQL, SQLite, and transactions.

Updated Aug 25, 2017
One-click install
npx skills add https://github.com/loki495/dotfiles --skill db-context-loki495
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: db-context
Source: https://github.com/loki495/dotfiles/tree/main/ai/skills/db-context
Command: npx skills add https://github.com/loki495/dotfiles --skill db-context-loki495

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Developers working across multiple Laravel projects often guess wrong about which database driver a project uses and fall into recurring traps like N+1 queries or unhandled multi-write failures. This Skill supplies the project's database context so DB-related code and tests follow the right conventions from the start. ## Core Features & Use Cases - Driver Conventions: Clarifies the general pattern that live ecommerce/work projects typically run MySQL/MariaDB while personal projects typically run SQLite, with a reminder to always verify the actual project's .env or config. - N+1 Query Prevention: Flags eager loading with with() and load() as the main recurring trap when looping over collections of relationships. - Transaction Handling: Directs that actions performing multiple related writes be wrapped in a DB transaction with failures reported clearly. - Use Case: When writing a Laravel feature that loops over orders and their line items, apply this context to eager load relationships and wrap the writes in a transaction instead of shipping an N+1 query bug. ## Quick Start Ask the AI to review this Laravel code for N+1 queries and confirm whether the project should use MySQL or SQLite.

Frequently Asked Questions about db-context

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I avoid N+1 queries in Laravel?▼

Avoid N+1 queries in Laravel by eager loading relationships with with() or load() whenever code loops over a collection. This is the main recurring trap in these projects, so be deliberate about eager loading in anything that iterates over related models.

Should I use MySQL or SQLite for a Laravel project?▼

Live ecommerce and work projects typically run MySQL/MariaDB, while personal projects typically run SQLite, though smaller work projects may also use SQLite. Always check the actual project's .env or config rather than assuming from the project type.

When should Laravel actions use database transactions?▼

Use a DB transaction whenever an action performs multiple related writes, so partial failures cannot leave inconsistent data. Failures should be reported clearly rather than silently swallowed.

Do MySQL and SQLite behave identically in Laravel?▼

No specific driver gotchas are currently flagged for enums, JSON columns, or full-text search in these projects, but behavior is not guaranteed to be identical. Treat any driver-specific quirk as worth a quick check rather than assuming parity.

Does this database guidance apply to OpenCart projects?▼

No, OpenCart follows its own conventions documented separately in opencart-legacy.md. This context applies across Laravel projects only.