/vtex-ai-skills:vtex-io-masterdatafrom vtex-ai-skills
Guides VTEX IO developers on using MasterData v2 for custom persistence, covering JSON Schema, CRUD, triggers, search/scroll, schema lifecycle, and decision rules to avoid misuse. Prompts critical evaluation of Master Data vs. Catalog, OMS, or external databases.
Ships in vtex-ai-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Use this skill when your VTEX IO app needs to store custom data (reviews, wishlists, form submissions, configuration records), query or filter that data, or set up automated workflows triggered by data changes—and when you must justify Master Data versus other VTEX or external stores.
masterdata builderctx.clients.masterdata)Do not use this skill for:
vtex-io-service-apps instead)vtex-io-graphql-api instead)vtex-io-app-structure instead)Architects, developers, and anyone designing or implementing a solution should think deeply and treat this section as a checklist to critique the default: double-check that Master Data is the right persistence layer—not an automatic pick. The skill is written to question convenience-driven choices.
Before creating a new entity or extending an existing one, understand the landscape:
CL (clients), AD (addresses), OD (orders), BK (bookmarks), AU (auth), and others. Never create custom entities that duplicate native entity purposes. Know which entities exist before adding new ones.REST-Content-Range headers from GET /search?_fields=id with REST-Range: resources=0-0 to efficiently count documents without fetching them. Large entities (100k+ docs) need scrollDocuments, pagination strategy, and potentially a BFF caching layer.When importing, exporting, or migrating large datasets:
.jsonl file for bulk imports. This enables resumable, line-by-line processing.p-queue with concurrency 5-10) for parallel POST or PATCH operations. Too much parallelism triggers rate limits; too little is slow.masterdata builder, entities are defined by folder structure: masterdata/{entityName}/schema.json. The builder creates entities named {vendor}_{appName}_{entityName}.ctx.clients.masterdata or masterDataFor from @vtex/clients for all CRUD operations — never direct REST calls.where clauses MUST be declared in the schema's v-indexed array for efficient querying.searchDocuments for bounded result sets (known small size, max page size 100). Use scrollDocuments for large/unbounded result sets.masterdata builder creates a new schema per app version. Clean up unused schemas to avoid the 60-schema-per-entity hard limit.v-* schema extensions (v-indexed, v-cache, v-security, v-triggers, etc.)Master Data v2 extends standard JSON Schema with v-* properties that control indexing, caching, security, defaults, triggers, and schema inheritance. For the complete reference on each extension—when to use, when not to, and detailed configuration—see the vtex-io-masterdata-strategy skill.
The essentials for IO app development:
v-indexed — All fields used in where clauses must be listed here. Don't over-index; each index increases write latency.v-cache — Leave true (default) for read-heavy entities. Set false for high-write entities needing immediate read consistency.v-default-fields — Keep minimal. Controls what's returned when the caller omits fields.v-security — Set allowGetAll: false and never expose PII in publicRead/publicFilter.v-triggers — For simple automated actions (email, webhook). Use IO events for complex orchestration.MasterDataClient methods:
| Method | Description |
|---|---|
getDocument | Retrieve a single document by ID |
createDocument | Create a new document, returns generated ID |
createOrUpdateEntireDocument | Upsert a complete document |
createOrUpdatePartialDocument | Upsert partial fields (patch) |
updateEntireDocument | Replace all fields of an existing document |
updatePartialDocument | Update specific fields only |
deleteDocument | Delete a document by ID |
searchDocuments | Search with filters, pagination, and field selection |
searchDocumentsWithPaginationInfo | Search with total count metadata |
scrollDocuments | Iterate over large result sets |
Search where clause syntax:
where: "productId=12345 AND approved=true"
where: "rating>3"
where: "createdAt between 2025-01-01 AND 2025-12-31"
Architecture:
VTEX IO App (node builder)
│
├── ctx.clients.masterdata.createDocument()
│ │
│ ▼
│ Master Data v2 API
│ │
│ ├── Validates against JSON Schema
│ ├── Indexes declared fields
│ └── Fires triggers (if conditions match)
│ │
│ ▼
│ HTTP webhook / Email / Action
│
└── ctx.clients.masterdata.searchDocuments()
│
▼
Master Data v2 (reads indexed fields for efficient queries)
All Master Data operations in VTEX IO apps MUST go through the MasterDataClient (ctx.clients.masterdata) or the masterDataFor factory from @vtex/clients. You MUST NOT make direct REST calls to /api/dataentities/ endpoints.
Why this matters
The MasterDataClient handles authentication token injection, request routing, retry logic, caching, and proper error handling. Direct REST calls bypass all of these, requiring manual auth headers, pagination, and retry logic. When the VTEX auth token format changes, direct calls break while the client handles it transparently.
Detection
If you see direct HTTP calls to URLs matching /api/dataentities/, api.vtex.com/api/dataentities, or raw fetch/axios calls targeting Master Data endpoints, warn the developer to use ctx.clients.masterdata instead.
Correct
// Using MasterDataClient through ctx.clients
export async function getReview(ctx: Context, next: () => Promise<void>) {
const { id } = ctx.query;
const review = await ctx.clients.masterdata.getDocument<Review>({
dataEntity: "reviews",
id: id as string,
fields: [
"id",
"productId",
"author",
"rating",
"title",
"text",
"approved",
],
});
ctx.status = 200;
ctx.body = review;
await next();
}
Wrong
// Direct REST call to Master Data — bypasses client infrastructure
import axios from "axios";
export async function getReview(ctx: Context, next: () => Promise<void>) {
const { id } = ctx.query;
// No caching, no retry, no proper auth, no metrics
const response = await axios.get(
`https://api.vtex.com/api/dataentities/reviews/documents/${id}`,
{
headers: {
"X-VTEX-API-AppKey": process.env.VTEX_APP_KEY,
"X-VTEX-API-AppToken": process.env.VTEX_APP_TOKEN,
},
},
);
ctx.status = 200;
ctx.body = response.data;
await next();
}
Every data entity your app uses MUST have a corresponding JSON Schema, either via the masterdata builder (recommended) or created via the Master Data API before the app is deployed.
Why this matters
Without a schema, Master Data stores documents as unstructured JSON. This means no field validation, no indexing (making search extremely slow on large datasets), no type safety, and no trigger support. Queries on unindexed fields perform full scans, which can time out or hit rate limits.
Detection
If the app creates or searches documents in a data entity but no JSON Schema exists for that entity (either in the masterdata/ builder directory or via API), warn the developer to define a schema.
Correct
{
"$schema": "http://json-schema.org/schema#",
"title": "review-schema-v1",
"type": "object",
"properties": {
"productId": {
"type": "string"
},
"author": {
"type": "string"
},
"rating": {
"type": "integer",
"minimum": 1,
"maximum": 5
},
"title": {
"type": "string",
"maxLength": 200
},
"text": {
"type": "string",
"maxLength": 5000
},
"approved": {
"type": "boolean"
},
"createdAt": {
"type": "string",
"format": "date-time"
}
},
"required": ["productId", "rating", "title", "text"],
"v-default-fields": [
"productId",
"author",
"rating",
"title",
"approved",
"createdAt"
],
"v-indexed": ["productId", "author", "approved", "rating", "createdAt"]
}
Wrong
// Saving documents without any schema — no validation, no indexing
await ctx.clients.masterdata.createDocument({
dataEntity: "reviews",
fields: {
productId: "12345",
rating: "five", // String instead of number — no validation!
title: 123, // Number instead of string — no validation!
},
});
// Searching on unindexed fields — full table scan, will time out on large datasets
await ctx.clients.masterdata.searchDocuments({
dataEntity: "reviews",
where: "productId=12345", // productId is not indexed — very slow
fields: ["id", "rating"],
pagination: { page: 1, pageSize: 10 },
});
Master Data v2 data entities have a limit of 60 schemas per entity. When using the masterdata builder, each app version linked or installed creates a new schema. You MUST delete unused schemas regularly.
Why this matters
Once the 60-schema limit is reached, the masterdata builder cannot create new schemas, and linking or installing new app versions will fail. This is a hard platform limit that cannot be increased.
Detection
If the app has been through many link/install cycles, warn the developer to check and clean up old schemas using the Delete Schema API.
Correct
# Periodically clean up unused schemas
# List schemas for the entity
curl -X GET "https://{account}.vtexcommercestable.com.br/api/dataentities/reviews/schemas" \
-H "X-VTEX-API-AppKey: {appKey}" \
-H "X-VTEX-API-AppToken: {appToken}"
# Delete old schemas that are no longer in use
curl -X DELETE "https://{account}.vtexcommercestable.com.br/api/dataentities/reviews/schemas/old-schema-name" \
-H "X-VTEX-API-AppKey: {appKey}" \
-H "X-VTEX-API-AppToken: {appToken}"
Wrong
Never cleaning up schemas during development.
After 60 link cycles, the builder fails:
"Error: Maximum number of schemas reached for entity 'reviews'"
The app cannot be linked or installed until old schemas are deleted.
Entities used for application logging, caching (IO app state, query results), or temporary staging data do not belong in Master Data. Use ctx.vtex.logger for logs, VBase for app-specific caches and temp state, and external log aggregation for audit trails.
Why this matters — Log and cache entities accumulate millions of documents, hit rate limits, make the entity unusable for legitimate queries, and waste storage. MD is not designed for high-write, high-volume, disposable data.
Detection — Entities with names like LOG, cache, temp, staging, debug, or entities whose document count grows unboundedly with traffic volume rather than business events.
Correct
// Logs: use structured logger
ctx.vtex.logger.info({ action: "priceUpdate", skuId, newPrice });
// Cache: use VBase
await ctx.clients.vbase.saveJSON("my-cache", cacheKey, data);
Wrong
// Using MD as a log store — creates millions of documents
await ctx.clients.masterdata.createDocument({
dataEntity: "appLogs",
fields: {
level: "info",
message: `Price updated for ${skuId}`,
timestamp: new Date(),
},
});
Using Master Data to mirror data that already has a system of record in OMS, Catalog, or an external ERP—for example order headers for a custom list view, or SKU attributes that belong in catalog specifications—creates drift, reconciliation cost, and incident risk.
Why this matters
Two sources of truth disagree after partial failures, retries, or manual edits. Teams spend capacity syncing and debugging instead of customer outcomes.
Detection
New MD entities whose fields duplicate OMS order fields “for performance” without a BFF cache plan; product attributes stored in MD when Catalog specs would suffice; scheduled jobs to “fix” MD from OMS because they diverged.
Correct
1. Identify the authoritative system (OMS, Catalog, partner API).
2. Read from that source via BFF or IO, with caching (application + HTTP semantics) as needed.
3. Use MD only for data without a native home or after explicit architecture sign-off.
Wrong
"We store order snapshots in MD so the storefront is faster" while OMS remains canonical
and no reconciliation strategy exists — eventual inconsistency is guaranteed.
Add the masterdata builder and policies:
{
"builders": {
"node": "7.x",
"graphql": "1.x",
"masterdata": "1.x"
},
"policies": [
{
"name": "outbound-access",
"attrs": {
"host": "api.vtex.com",
"path": "/api/*"
}
},
{
"name": "ADMIN_DS"
}
]
}
Define data entity schemas:
{
"$schema": "http://json-schema.org/schema#",
"title": "review-schema-v1",
"type": "object",
"properties": {
"productId": {
"type": "string"
},
"author": {
"type": "string"
},
"email": {
"type": "string",
"format": "email"
},
"rating": {
"type": "integer",
"minimum": 1,
"maximum": 5
},
"title": {
"type": "string",
"maxLength": 200
},
"text": {
"type": "string",
"maxLength": 5000
},
"approved": {
"type": "boolean"
},
"createdAt": {
"type": "string",
"format": "date-time"
}
},
"required": ["productId", "rating", "title", "text"],
"v-default-fields": [
"productId",
"author",
"rating",
"title",
"approved",
"createdAt"
],
"v-indexed": ["productId", "author", "approved", "rating", "createdAt"],
"v-cache": false
}
Set up the client with masterDataFor:
// node/clients/index.ts
import { IOClients } from "@vtex/api";
import { masterDataFor } from "@vtex/clients";
interface Review {
id: string;
productId: string;
author: string;
email: string;
rating: number;
title: string;
text: string;
approved: boolean;
createdAt: string;
}
export class Clients extends IOClients {
public get reviews() {
return this.getOrSet("reviews", masterDataFor<Review>("reviews"));
}
}
Implement CRUD operations:
// node/resolvers/reviews.ts
import type { ServiceContext } from "@vtex/api";
import type { Clients } from "../clients";
type Context = ServiceContext<Clients>;
export const queries = {
reviews: async (
_root: unknown,
args: { productId: string; page?: number; pageSize?: number },
ctx: Context,
) => {
const { productId, page = 1, pageSize = 10 } = args;
const results = await ctx.clients.reviews.search(
{ page, pageSize },
[
"id",
"productId",
"author",
"rating",
"title",
"text",
"createdAt",
"approved",
],
"", // sort
`productId=${productId} AND approved=true`,
);
return results;
},
};
export const mutations = {
createReview: async (
_root: unknown,
args: {
input: { productId: string; rating: number; title: string; text: string };
},
ctx: Context,
) => {
const { input } = args;
const email = ctx.vtex.storeUserEmail ?? "[email protected]";
const response = await ctx.clients.reviews.save({
...input,
author: email.split("@")[0],
email,
approved: false,
createdAt: new Date().toISOString(),
});
return ctx.clients.reviews.get(response.DocumentId, [
"id",
"productId",
"author",
"rating",
"title",
"text",
"createdAt",
"approved",
]);
},
deleteReview: async (_root: unknown, args: { id: string }, ctx: Context) => {
await ctx.clients.reviews.delete(args.id);
return true;
},
};
Configure triggers (optional):
{
"name": "notify-moderator-on-new-review",
"active": true,
"condition": "approved=false",
"action": {
"type": "email",
"provider": "default",
"subject": "New review pending moderation",
"to": ["[email protected]"],
"body": "A new review has been submitted for product {{productId}} by {{author}}."
},
"retry": {
"times": 3,
"delay": { "addMinutes": 5 }
}
}
Wire into Service:
// node/index.ts
import type { ParamsContext, RecorderState } from "@vtex/api";
import { Service } from "@vtex/api";
import { Clients } from "./clients";
import { queries, mutations } from "./resolvers/reviews";
export default new Service<Clients, RecorderState, ParamsContext>({
clients: {
implementation: Clients,
options: {
default: {
retries: 2,
timeout: 5000,
},
},
},
graphql: {
resolvers: {
Query: queries,
Mutation: mutations,
},
},
});
axios or fetch to call Master Data endpoints bypasses the client infrastructure — no auth, no caching, no retries. Use ctx.clients.masterdata or masterDataFor instead.where clause fields are in the schema's v-indexed array.scrollDocuments for large result sets.masterdata builder declared in manifest.json?where clause fields declared in v-indexed?ctx.clients.masterdata or masterDataFor (no direct REST calls)?outbound-access, ADMIN_DS) declared in the manifest?v-* schema extensions reference, indexing strategy, triggers, capacity planningWhat SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub vtex/skills --plugin vtex-ai-skills46 skills in this plugin
/architecture-well-architected-commerceApply when scoping, reviewing, or documenting cross-cutting VTEX commerce architecture across storefront, IO, headless, marketplace, payments, or any other VTEX module. Grounds work in the Well-Architected Commerce framework—Technical Foundation (reliability, trust, integrity; security, infrastructure, compliance), Future-proof (innovation, simplicity, efficiency; scalable and adaptable solutions), and Operational Excellence (accuracy, accountability, data-driven improvement; process and customer experience). Routes implementation detail to product tracks (IO caching and paths, Master Data strategy, marketplace integrations). Use for solution design, architecture reviews, and RFP-level technical structure./faststore-storefrontCore coding rules and workflow for developing VTEX FastStore storefronts. Use when starting any FastStore development task, writing TypeScript/React components, creating section overrides, extending the BFF, or styling. Covers all primary conventions, safety rules, and the development workflow used across every FastStore project./headless-bff-architectureApply when designing or modifying a BFF (Backend-for-Frontend) layer, middleware, or API proxy for a headless VTEX storefront. Covers BFF middleware architecture, public vs private API classification, VtexIdclientAutCookie management, API key protection, and secure request proxying. Use for any headless commerce project that must never expose VTEX_APP_KEY or call private VTEX APIs from the browser.Other plugins' skills for the same job