plugins/laravel-expert/skills/laravel-vector-search/SKILL.md
Use when implementing semantic / vector search in Laravel 13 with PostgreSQL + pgvector. Covers schema setup, embedding workflow, and the new query builder methods (`whereVectorSimilarTo`, `selectVectorDistance`, etc.).
npx skillsauth add fusengine/agents laravel-vector-searchInstall 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.
Before ANY implementation, use TeamCreate to spawn 3 agents:
laravel.com/docs/13.x/search + queries examplesAfter implementation, run fuse-ai-pilot:sniper for validation.
| Feature | Description |
|---------|-------------|
| PostgreSQL only | Requires pgvector extension; not available on MySQL/SQLite |
| Schema helper | Schema::ensureVectorExtensionExists() enables the extension |
| Query builder | whereVectorSimilarTo(), selectVectorDistance(), whereVectorDistanceLessThan(), orderByVectorDistance() |
| Auto-embedding | Pass a raw string and Laravel generates the embedding via AI SDK |
| Cosine similarity | Default distance; threshold via minSimilarity (0.0 - 1.0) |
pgsql connections - no fallback to MySQL/SQLitedatabase/migrations/
└── XXXX_create_documents_table.php # Schema::ensureVectorExtensionExists(), vector(1536) col, HNSW index
app/Models/
└── Document.php # casts embedding to array, uses whereVectorSimilarTo
app/Ai/Services/
└── VectorSearchService.php # encapsulates query + threshold logic
→ See Document-model.php.md for full example
| Topic | Reference | When to Consult |
|-------|-----------|-----------------|
| pgvector setup | pgvector-setup.md | Migrations + index creation |
| Embedding workflow | embeddings-workflow.md | Generating + persisting vectors |
| Query patterns | queries.md | whereVectorSimilarTo and friends |
| Template | When to Use | |----------|-------------| | Document-model.php.md | Eloquent model with vector column | | VectorSearchService.php.md | Reusable service |
Schema::ensureVectorExtensionExists();
Schema::create('documents', function (Blueprint $table) {
$table->id();
$table->text('content');
$table->vector('embedding', 1536);
$table->timestamps();
$table->vectorIndex('embedding', algorithm: 'hnsw');
});
$documents = Document::query()
->whereVectorSimilarTo('embedding', 'best wineries in Napa Valley', minSimilarity: 0.4)
->limit(10)
->get();
→ See VectorSearchService.php.md for complete example
minSimilarity 0.3-0.5 as a starting threshold; tune empiricallywhere() for hybrid filtering (date ranges, tenancy)Embeddings::for([...])vector column type for index supporttesting
Copy self-audit and ban-lists — filler verbs/hype adjectives, slop placeholder names, fake-precise numbers, Title Case headlines, humor in error copy ('Oops!'), em-dash crutch, one copy register per page.
development
Logged-in web apps — dashboards, auth flows, settings, onboarding, data tables, command palettes, modals, toasts. Register `product`: density and glance-speed over marketing polish, no hero/CTA-tricks, every data surface covers empty/loading/error explicitly, tables and dataviz follow preattentive-processing rules.
development
Marketing sites, landing pages, campaign pages — register `brand` (design IS the product). Structure comes from the register's POV + a macrostructure pick, never from copying an inspiration site's section flow. Hero discipline, deviated section order, asymmetric grids, and a silhouette lookalike-test gate before ship.
development
Token-strategy core — OKLCH color rules, neutral tinting, accent-commitment levels, type scale, 8pt spacing grid, touch targets, and the canonical output format of design-system.md (the file the harness gates on). This is routing step 1 of design-method/SKILL.md — read it before design-web/design-webapp/design-ios/design-android, before picking or auditing a single color/type/spacing value.