xata
Xataは、PostgreSQL、Elasticsearch、AI機能を統合したサーバーレスデータプラットフォームで、フルテキスト検索、類似性検索、ファイル添付、分岐などをTypeScript SDKで安全に開発できる環境構築を支援するSkill。
📜 元の英語説明(参考)
Expert guidance for Xata, the serverless data platform that combines PostgreSQL, Elasticsearch, and AI capabilities in a single API. Helps developers build applications with full-text search, vector similarity search, file attachments, and branching — all through a type-safe TypeScript SDK.
🇯🇵 日本人クリエイター向け解説
Xataは、PostgreSQL、Elasticsearch、AI機能を統合したサーバーレスデータプラットフォームで、フルテキスト検索、類似性検索、ファイル添付、分岐などをTypeScript SDKで安全に開発できる環境構築を支援するSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o xata.zip https://jpskill.com/download/15577.zip && unzip -o xata.zip && rm xata.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/15577.zip -OutFile "$d\xata.zip"; Expand-Archive "$d\xata.zip" -DestinationPath $d -Force; ri "$d\xata.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
xata.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
xataフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
Xata — サーバーレスデータプラットフォーム
概要
Xata は、PostgreSQL、Elasticsearch、および AI 機能を単一の API に組み合わせたサーバーレスデータプラットフォームです。開発者が、フルテキスト検索、ベクター類似性検索、ファイル添付、およびブランチングを使用してアプリケーションを構築するのを支援します。これらはすべて、型安全な TypeScript SDK を通じて行われます。
手順
セットアップとスキーマ
# Xata CLI をインストール
npm install -g @xata.io/cli
# 認証
xata auth login
# プロジェクト内で初期化
xata init --db https://your-workspace.xata.sh/db/my-app
# これにより、型付きクライアントが生成されます: src/xata.ts
// .xata/schema.json またはダッシュボードで定義されたスキーマ
// 例: フルテキスト検索とベクター埋め込みを持つ Articles
{
"tables": [
{
"name": "articles",
"columns": [
{ "name": "title", "type": "string" },
{ "name": "content", "type": "text" },
{ "name": "author", "type": "link", "link": { "table": "users" } },
{ "name": "tags", "type": "multiple" },
{ "name": "published", "type": "bool", "defaultValue": "false" },
{ "name": "publishedAt", "type": "datetime" },
{ "name": "embedding", "type": "vector", "vector": { "dimension": 1536 } },
{ "name": "cover", "type": "file" }
]
}
]
}
型安全な CRUD
// src/lib/db.ts — Xata クライアント (自動生成された型)
import { getXataClient } from "./xata";
const xata = getXataClient();
// 作成
async function createArticle(data: {
title: string;
content: string;
authorId: string;
tags: string[];
}) {
const article = await xata.db.articles.create({
title: data.title,
content: data.content,
author: data.authorId, // users テーブルへのリンク
tags: data.tags,
published: false,
});
return article; // 完全に型付けされています: article.id, article.title など
}
// 関係性を持つ読み取り
async function getArticle(id: string) {
const article = await xata.db.articles.read(id, [
"title", "content", "publishedAt",
"author.name", "author.email", // リンクされたレコードを解決
]);
return article;
}
// フィルターを使用したクエリ
async function getPublishedArticles(page = 1) {
const results = await xata.db.articles
.filter({
published: true,
publishedAt: { $ge: new Date("2026-01-01") },
})
.sort("publishedAt", "desc")
.getPaginated({
pagination: { size: 20, offset: (page - 1) * 20 },
});
return {
articles: results.records,
hasMore: results.hasNextPage(),
total: results.totalCount,
};
}
// 更新
async function publishArticle(id: string) {
await xata.db.articles.update(id, {
published: true,
publishedAt: new Date(),
});
}
// 削除
async function deleteArticle(id: string) {
await xata.db.articles.delete(id);
}
フルテキスト検索
// Xata には Elasticsearch が組み込まれています — 個別の検索サービスは不要です
// 基本的な検索
async function searchArticles(query: string) {
const results = await xata.db.articles.search(query, {
target: ["title", "content"], // 検索するカラム
fuzziness: 1, // 1つのタイプミスを許可
prefix: "phrase", // オートコンプリートのためのプレフィックスマッチング
filter: { published: true }, // 検索と組み合わせる
highlight: { enabled: true }, // ハイライトされたスニペットを返す
page: { size: 10 },
});
return results.records.map((record) => ({
id: record.id,
title: record.title,
snippet: record.getMetadata().highlight?.content ?? record.content?.slice(0, 200),
score: record.getMetadata().score,
}));
}
// 検索結果の集計
async function searchWithFacets(query: string) {
const results = await xata.db.articles.search(query, {
target: ["title", "content"],
filter: { published: true },
});
// タグで結果をグループ化
const tagCounts: Record<string, number> = {};
for (const record of results.records) {
for (const tag of record.tags ?? []) {
tagCounts[tag] = (tagCounts[tag] ?? 0) + 1;
}
}
return { articles: results.records, facets: tagCounts };
}
AI / ベクター検索
// ベクター類似性検索 (RAG、レコメンデーション)
async function findSimilar(articleId: string) {
const article = await xata.db.articles.read(articleId);
if (!article?.embedding) return [];
// 類似の埋め込みを持つ記事を検索
const results = await xata.db.articles.vectorSearch("embedding", article.embedding, {
size: 5,
filter: {
published: true,
id: { $isNot: articleId }, // ソース記事を除外
},
});
return results.records;
}
// AI に質問 (組み込みの RAG — 検索 + LLM 回答)
async function askQuestion(question: string) {
const result = await xata.db.articles.ask(question, {
searchType: "keyword", // "keyword" | "vector" | "hybrid"
rules: [
"Answer based only on the provided context",
"If uncertain, say you don't know",
"Keep answers under 3 sentences",
],
});
return {
answer: result.answer,
records: result.records, // 回答に使用されたソース記事
};
}
ファイル添付
// ファイルをレコードに直接アップロード
async function uploadCoverImage(articleId: string, file: File) {
const base64 = await fileToBase64(file);
await xata.db.articles.update(articleId, {
cover: {
name: file.name,
mediaType: file.type,
base64Content: base64,
},
});
}
// ファイル URL を取得
async function getCoverUrl(articleId: string) {
const article = await xata.db.articles.read(articleId);
return article?.cover?.url; // ファイルの署名付き URL
}
ブランチング
# ブランチを作成 (git のように — スキーマ + データの分離されたコピー)
xata branch create staging
# ブランチでスキーマを変更
xata schema edit --branch staging
# ブランチを main にマージ (スキーママイグレーションを適用)
xata branch merge staging
インストール
# CLI
npm install -g @xata.io/cli
# Client SD 📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Xata — Serverless Data Platform
Overview
Xata, the serverless data platform that combines PostgreSQL, Elasticsearch, and AI capabilities in a single API. Helps developers build applications with full-text search, vector similarity search, file attachments, and branching — all through a type-safe TypeScript SDK.
Instructions
Setup and Schema
# Install Xata CLI
npm install -g @xata.io/cli
# Authenticate
xata auth login
# Initialize in your project
xata init --db https://your-workspace.xata.sh/db/my-app
# This generates a typed client: src/xata.ts
// Schema defined in .xata/schema.json or via dashboard
// Example: Articles with full-text search and vector embeddings
{
"tables": [
{
"name": "articles",
"columns": [
{ "name": "title", "type": "string" },
{ "name": "content", "type": "text" },
{ "name": "author", "type": "link", "link": { "table": "users" } },
{ "name": "tags", "type": "multiple" },
{ "name": "published", "type": "bool", "defaultValue": "false" },
{ "name": "publishedAt", "type": "datetime" },
{ "name": "embedding", "type": "vector", "vector": { "dimension": 1536 } },
{ "name": "cover", "type": "file" }
]
}
]
}
Type-Safe CRUD
// src/lib/db.ts — Xata client (auto-generated types)
import { getXataClient } from "./xata";
const xata = getXataClient();
// Create
async function createArticle(data: {
title: string;
content: string;
authorId: string;
tags: string[];
}) {
const article = await xata.db.articles.create({
title: data.title,
content: data.content,
author: data.authorId, // Link to users table
tags: data.tags,
published: false,
});
return article; // Fully typed: article.id, article.title, etc.
}
// Read with relationships
async function getArticle(id: string) {
const article = await xata.db.articles.read(id, [
"title", "content", "publishedAt",
"author.name", "author.email", // Resolve linked records
]);
return article;
}
// Query with filters
async function getPublishedArticles(page = 1) {
const results = await xata.db.articles
.filter({
published: true,
publishedAt: { $ge: new Date("2026-01-01") },
})
.sort("publishedAt", "desc")
.getPaginated({
pagination: { size: 20, offset: (page - 1) * 20 },
});
return {
articles: results.records,
hasMore: results.hasNextPage(),
total: results.totalCount,
};
}
// Update
async function publishArticle(id: string) {
await xata.db.articles.update(id, {
published: true,
publishedAt: new Date(),
});
}
// Delete
async function deleteArticle(id: string) {
await xata.db.articles.delete(id);
}
Full-Text Search
// Xata has built-in Elasticsearch — no separate search service needed
// Basic search
async function searchArticles(query: string) {
const results = await xata.db.articles.search(query, {
target: ["title", "content"], // Which columns to search
fuzziness: 1, // Allow 1 typo
prefix: "phrase", // Prefix matching for autocomplete
filter: { published: true }, // Combined with search
highlight: { enabled: true }, // Return highlighted snippets
page: { size: 10 },
});
return results.records.map((record) => ({
id: record.id,
title: record.title,
snippet: record.getMetadata().highlight?.content ?? record.content?.slice(0, 200),
score: record.getMetadata().score,
}));
}
// Aggregate search results
async function searchWithFacets(query: string) {
const results = await xata.db.articles.search(query, {
target: ["title", "content"],
filter: { published: true },
});
// Group results by tag
const tagCounts: Record<string, number> = {};
for (const record of results.records) {
for (const tag of record.tags ?? []) {
tagCounts[tag] = (tagCounts[tag] ?? 0) + 1;
}
}
return { articles: results.records, facets: tagCounts };
}
AI / Vector Search
// Vector similarity search (RAG, recommendations)
async function findSimilar(articleId: string) {
const article = await xata.db.articles.read(articleId);
if (!article?.embedding) return [];
// Find articles with similar embeddings
const results = await xata.db.articles.vectorSearch("embedding", article.embedding, {
size: 5,
filter: {
published: true,
id: { $isNot: articleId }, // Exclude the source article
},
});
return results.records;
}
// Ask AI (built-in RAG — search + LLM answer)
async function askQuestion(question: string) {
const result = await xata.db.articles.ask(question, {
searchType: "keyword", // "keyword" | "vector" | "hybrid"
rules: [
"Answer based only on the provided context",
"If uncertain, say you don't know",
"Keep answers under 3 sentences",
],
});
return {
answer: result.answer,
records: result.records, // Source articles used for the answer
};
}
File Attachments
// Upload files directly to records
async function uploadCoverImage(articleId: string, file: File) {
const base64 = await fileToBase64(file);
await xata.db.articles.update(articleId, {
cover: {
name: file.name,
mediaType: file.type,
base64Content: base64,
},
});
}
// Get file URL
async function getCoverUrl(articleId: string) {
const article = await xata.db.articles.read(articleId);
return article?.cover?.url; // Signed URL for the file
}
Branching
# Create a branch (like git — isolated copy of schema + data)
xata branch create staging
# Make schema changes on the branch
xata schema edit --branch staging
# Merge branch to main (applies schema migration)
xata branch merge staging
Installation
# CLI
npm install -g @xata.io/cli
# Client SDK
npm install @xata.io/client
# Initialize in project (generates typed client)
xata init
Examples
Example 1: Setting up Xata with a custom configuration
User request:
I just installed Xata. Help me configure it for my TypeScript + React workflow with my preferred keybindings.
The agent creates the configuration file with TypeScript-aware settings, configures relevant plugins/extensions for React development, sets up keyboard shortcuts matching the user's preferences, and verifies the setup works correctly.
Example 2: Extending Xata with custom functionality
User request:
I want to add a custom type-safe crud to Xata. How do I build one?
The agent scaffolds the extension/plugin project, implements the core functionality following Xata's API patterns, adds configuration options, and provides testing instructions to verify it works end-to-end.
Guidelines
- Use the generated client —
xata initcreates a typed client; never construct queries manually - Search over queries — If users are looking for content, use
.search()instead of.filter(); it's faster and supports fuzzy matching - Vectors for recommendations — Store embeddings for semantic search and "similar articles" features; Xata handles the vector index
- Ask for RAG — The
.ask()method does retrieval + generation in one call; no need to build RAG from scratch - Branches for migrations — Test schema changes on a branch before merging to main; matches the git workflow developers already know
- File attachments vs external storage — Use Xata's file type for per-record files (avatars, covers); use S3 for bulk file storage
- Filters + search — Combine
.search()withfilterfor faceted search (search "react" filtered to "tutorial" tag) - Pagination with cursors — Use
getPaginated()for cursor-based pagination; more efficient than offset for large datasets