Use this skill when creating or reviewing Next.js Route Handlers (app/api), adding rate limiting, input validation, or auth to API endpoints. Trigger words: API ルート, Route Handler, app/api, エンドポイント, レート制限, 入力検証, CORS, ヘッダー, 認証付き API, hardening.
atlas-search-vector
Use this skill when implementing full-text search, autocomplete, or vector/semantic search and RAG with MongoDB Atlas. Trigger words: 全文検索, あいまい検索, オートコンプリート, ベクトル検索, セマンティック検索, 類似検索, Atlas Search, $search, $vectorSearch, RAG, embedding.
含まれるファイル(1)
- SKILL.md2.2 KB
SKILL.md(原文)
インストールする前に、エージェントに与えられる指示の中身を確認できます。
Atlas Search & Vector Search
いつ使うか
- 全文検索・あいまい検索・オートコンプリートを実装するとき。
- 埋め込み(embedding)を使ったベクトル/セマンティック検索や RAG を作るとき。
findの正規表現検索が遅い・精度不足なとき。
やること
- 全文検索は Atlas Search Index を作り、
$searchステージで使う。 - ベクトル検索は Vector Search Index を作り、
$vectorSearchで近傍探索する。 - 埋め込みは AI SDK 6 経由で生成し、次元数をインデックス定義と一致させる。
- ハイブリッド検索(全文 + ベクトル)はスコア結合で精度を上げる。
- 検索クエリ文字列も Zod で長さ・型を検証する。
守るルール
- ✅ Search / Vector Index は Atlas 側で明示定義(コードと次元・パスを一致)。
- ✅
$vectorSearchにはnumCandidatesとlimitを適切に設定。 - ✅ 埋め込み生成のモデル/次元を ADR に記録する。
- ❌ 正規表現
$regexで全件スキャンの代替にしない(遅い)。 - ❌ API キー(埋め込み生成用)をクライアントへ露出しない。
典型例(コード片)
// ベクトル検索(セマンティック近傍)
const queryVector = await embed(queryText); // AI SDK 6, server-only
const hits = await DocModel.aggregate([
{
$vectorSearch: {
index: 'doc_vector_index',
path: 'embedding',
queryVector,
numCandidates: 200,
limit: 10,
},
},
{ $project: { title: 1, score: { $meta: 'vectorSearchScore' } } },
]);
アンチパターン
- インデックス未作成のまま
$searchを呼びエラー/低速になる。 - 埋め込み次元の不一致(例:1536 で作って 768 を投げる)。
- 埋め込み生成をクライアント側で行い API キーを漏らす。
レビュー
まだレビューはありません。使ってみた感想をお寄せください。
同じリポジトリのスキル
概要と使いどころ
Use this skill when implementing sign-in, sessions, authorization checks, or protecting routes and Server Actions. Trigger words: 認証, ログイン, サインイン, セッション, 認可, 権限チェック, Better Auth, Auth.js, 保護, ミドルウェア, getSession.
Use this skill when starting a new session, opening this project for the first time, or when you need to recall the project's tech stack, hard rules, and which other skills exist. Trigger words: セッション開始, このプロジェクト, 全体像, どのスキル, 何から, getting started, overview.
Use this skill when setting up or modifying CI pipelines, GitHub Actions workflows, or automated checks (lint, typecheck, test, build) for this project. Trigger words: CI, GitHub Actions, ワークフロー, パイプライン, 自動テスト, lint チェック, typecheck, ビルド検証, .github/workflows.
Use this skill when writing end-to-end tests, browser automation, or verifying user flows in a real browser. Trigger words: E2E, Playwright, ブラウザテスト, ユーザーフロー, 結合テスト, シナリオテスト, ログインテスト, getByRole, expect.
Use this skill when handling runtime errors, adding error.tsx or not-found.tsx, designing fallback UI, or deciding what to surface to users vs logs. Trigger words: エラー処理, error.tsx, not-found, 例外, フォールバック, エラーバウンダリ, try catch, ユーザー向けエラー, ログ.