Token导航 LogoToken导航

Agent Skill · 研究检索

create-agent-with-sanity-context(创建具有理智上下文的 Agent)

create-agent-with-sanity-context 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

create-agent-with-sanity-context 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为接触敏感数据;许可证信息还不明确,第三方扫描有提醒项,按安装量在研究检索类的 73,675 个 Skill 里排第 13,673。

总安装 9,180周安装 375GitHub Stars 4下载 2,970核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:create-agent-with-sanity-context(创建具有理智上下文的 Agent)
来源仓库:https://github.com/sanity-io/agent-context
仓库路径:skills/create-agent-with-sanity-context
安装命令:
npx skills add https://github.com/sanity-io/agent-context --skill create-agent-with-sanity-context
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/sanity-io/agent-context --skill create-agent-with-sanity-context

这个 Skill 是做什么的

研究检索类 Skill 主要解决「找资料、核对事实、把来源整理清楚」的问题,通常会让助手先检索再总结。

create-agent-with-sanity-context 赋予 AI Agent 有感知的 Sanity 内容访问能力,支持结构感知查询。适用于需要理解内容模型、字段关系与引用链的智能内容操作场景。区别于纯嵌入检索,Agent 可使用真实 schema 字段做精确过滤与语义混合搜索。

需配置 Sanity 项目与 API 密钥,确保 Agent 操作符合内容安全与权限策略。适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

来源仓库内路径:skills/create-agent-with-sanity-context

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/sanity-io/agent-context --skill create-agent-w…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要接触敏感数据,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

create-agent-with-sanity-context 怎么安装?

在终端执行 npx skills add https://github.com/sanity-io/agent-context --skill create-agent-with-sanity…。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

create-agent-with-sanity-context 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

create-agent-with-sanity-context 需要什么权限?

权限级别是接触敏感数据。该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

create-agent-with-sanity-context 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

create-agent-with-sanity-context 用的人多吗?

公开数据是累计安装 9,180 次,近一周安装 375 次,下载 2,970 次,GitHub 4 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

create-agent-with-sanity-context 安全吗?

第三方扫描有提醒项,说明存在需要人工确认的行为。安装前请打开源码看清它读了什么、联网到哪里。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。

先想清楚的地方

  • 需要接触敏感数据,装到常用环境前要先评估影响面。
  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方扫描存在提醒项或未通过项,需要人工逐条确认。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理研究检索类任务、又不想每次都手写提示词的人。

不太适合

  • 环境里有大量密钥、凭证,不方便给第三方 Skill 读取的人。
  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

研究检索类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
find-skills

寻找技能 · Codex、Claude

31,199,81316,486操作浏览器MIT有提醒
self-improving-agent

自我改进 Agent · OpenClaw

16,464,0023,396接触敏感数据MIT-0通过
soultrace

灵魂追踪 · Codex、Claude

7,588,94412需要联网未明确有提醒
self-improving

自我完善 · OpenClaw

6,829,2841,046需要联网MIT-0通过
microsoft-foundry

微软代工厂 · Codex、Claude

6,614,144764调用外部服务未明确有提醒
create-agent-with-sanity-context

创建具有理智上下文的 Agent · 本页

9,1804接触敏感数据未明确有提醒

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Build an Agent with Sanity Context

Give AI agents intelligent access to your Sanity content. Unlike embedding-only approaches, Agent Context is schema-aware—agents can reason over your content structure, query with real field values, follow references, and combine structural filters with semantic search.

What this enables:

  • Agents understand the relationships between your content types
  • Queries use actual schema fields, not just text similarity
  • Results respect your content model (categories, tags, references)
  • Semantic search is available when needed, layered on structure

Agent Context gives agents your schema and teaches them GROQ, but it can't know your domain. You close that gap through the Instructions field (dataset-specific query guidance) and optionally the system prompt (agent behavior and tone).

Three actors in this workflow:

  • You — the agent executing this skill, helping the user set things up
  • The user — the human you're working with, who knows their domain and data
  • The production agent — the agent being built, which will serve end users

What You'll Need

Before starting, gather these credentials:

CredentialWhere to get it
Sanity Project IDYour sanity.config.ts or sanity.io/manage
Dataset nameUsually production — check your sanity.config.ts
Sanity API read tokenRun npx sanity tokens add "Agent Context" --role=viewer --yes --json from the project directory (or pass --project-id=<id>). Alternatively, create at sanity.io/manage → Project → API → Tokens with Viewer role.
LLM API keyFrom your LLM provider (Anthropic, OpenAI, etc.) — any provider works

How Agent Context Works

An MCP server that gives AI agents structured access to Sanity content. The core integration pattern:

  1. MCP Connection: HTTP transport to the Agent Context URL
  2. Authentication: Bearer token using Sanity API read token
  3. Tool Discovery: Get available tools from MCP client, pass to LLM
  4. System Prompt: Tell the production agent its role, tone, and boundaries

MCP URL formats:

  • https://api.sanity.io/v2026-03-03/agent-context/:projectId/:dataset — Base URL. No document needed, configure via query params or use as-is.
  • https://api.sanity.io/v2026-03-03/agent-context/:projectId/:dataset/:slug — Document URL. Applies the configuration from an Agent Context document.

Agent Context documents (type sanity.agentContext) are created in Sanity Studio and configure the MCP endpoint. They have three fields:

FieldSchema fieldPurpose
SlugslugUnique URL identifier — becomes the :slug in the MCP URL
InstructionsinstructionsDomain-specific guidance for the agent, injected into tool descriptions
Content FiltergroqFilterA GROQ expression scoping which documents the agent can access

This means Studio users can manage agent behavior without touching code — updating instructions or narrowing the content filter takes effect immediately.

URL query params override the document's configuration (useful for testing and development):

  • ?instructions=<content> — Override instructions (use ?instructions="" for a blank slate)
  • ?groqFilter=<expression> — Override the content filter

The integration is simple: Connect to the MCP URL, get tools, use them. The reference implementation shows one way to do this—adapt to your stack and LLM provider.

Available MCP Tools

ToolPurpose
initial_contextGet compressed schema overview (types, fields, document counts)
groq_queryExecute GROQ queries with optional semantic search
schema_explorerGet detailed schema for a specific document type

For development and debugging: The general Sanity MCP provides broader access to your Sanity project (schema deployment, document management, etc.). Useful during development but not intended for customer-facing applications.

Before You Start: Understand the User's Situation

A complete integration has three distinct components that may live in different places:

ComponentWhat it isExamples
1. Studio SetupConfigure the context plugin and create agent context documentsSanity Studio (separate repo or embedded)
2. Agent ImplementationCode that connects to Agent Context and handles LLM interactionsNext.js API route, Express server, Python service, or any MCP-compatible client
3. Frontend (optional)UI for users to interact with the agentChat widget, search interface, CLI—or none for backend services

A deployed Studio (v5.1.0+) is always required. Not every integration needs the agent context plugin or document—the base MCP URL works without them, so users can start with just agent implementation and add document configuration later—or vice versa. Frontend depends on the use case (many agents run as backend services or integrate into existing UIs).

Ask the user which part they need help with:

  • Components in different repos (most common): You may only have access to one component. Complete what you can, then tell the user what steps remain for the other repos.
  • Co-located components: All three in the same project—work through them based on what the user wants to tackle first.
  • No Studio in the codebase? Ask the user if Studio setup is done elsewhere, or if they want to skip the agent context plugin and document for now—the base URL works without them.

Also understand:

  1. Their stack: What framework/runtime? (Next.js, Remix, Node server, Python, etc.)
  2. Their AI library: Vercel AI SDK, LangChain, direct API calls, etc.
  3. Their domain: What will the agent help with? (Shopping, docs, support, search, etc.)

The reference patterns use Next.js + Vercel AI SDK, but adapt to whatever the user is working with.

Workflow

Quick Validation (Optional)

Before building the production agent, validate that the MCP endpoint is reachable. If the user doesn't have a read token yet, offer to create one from the terminal — detect the projectId from sanity.config.ts or sanity.cli.ts if available:

npx sanity tokens add "Agent Context" --role=viewer --yes --json

This outputs JSON with the token value. If not inside a Sanity project directory, pass --project-id=<id> explicitly.

Then test the endpoint:

curl -X POST https://api.sanity.io/v2026-03-03/agent-context/:projectId/:dataset \
  -H "Authorization: Bearer $SANITY_API_READ_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc": "2.0", "method": "tools/list", "id": 1}'

This confirms the token works and the endpoint is reachable. The base URL (no slug) works without an Agent Context document—add a slug to apply a document's configuration.

Step 1: Build the Agent (Adapt to user's stack)

The user already has an agent or MCP client? They just need to connect it to their Agent Context URL with a Bearer token. The tools will appear automatically.

Building from scratch? Help the user set up the MCP connection and LLM integration. The reference implementations use Vercel AI SDK with Anthropic, but the pattern works with any LLM provider (OpenAI, local models, etc.). Start with the basics and add advanced patterns as needed.

Framework-specific guides:

System prompts (applies to all frameworks): See references/system-prompts.md for structure and domain-specific examples (e-commerce, docs, support, content curation).

The framework guides cover:

  • Core setup (required): MCP connection, authentication, basic chat route
  • Frontend (optional): Chat component for the framework, including markdown rendering (LLM responses are markdown — a renderer like react-markdown or marked is needed to display formatted output)
  • Advanced patterns (optional): Client-side tools, auto-continuation, custom directive rendering

Step 2: Set up Sanity Studio

Help the user configure the @sanity/agent-context/studio plugin in their Studio and create an Agent Context document. This document controls what the production agent can see (via groqFilter) and what guidance it receives (via instructions).

See references/studio-setup.md

Step 3: Conversation Classification (Optional)

Track and analyze agent conversations using Sanity Functions. Useful for analytics, debugging, and understanding user interactions.

See references/conversation-classification.md.

Step 4: Tune Your Agent (Recommended)

Once the production agent works:

  1. Tune the Instructions field using the dial-your-context skill — an interactive session where you explore the user's dataset together, verify findings, and produce concise Instructions that teach the production agent what the schema alone doesn't make obvious: counter-intuitive field names, second-order reference chains, data quality issues, required filters, and query patterns. The skill can also help configure a groqFilter to scope what content the production agent sees.
  2. Shape the system prompt (optional) using the shape-your-agent skill — if the user controls the production agent's system prompt, this helps define tone, boundaries, and guardrails. Skip this if the user doesn't control the system prompt.

GROQ with Semantic Search

Agent Context supports text::semanticSimilarity() for semantic ranking:

*[_type == "article" && category == "guides"]
  | score(text::semanticSimilarity("getting started tutorial"))
  | order(_score desc)
  { _id, title, summary }[0...10]

Always use order(_score desc) when using score() to get best matches first.

Adapting to Different Stacks

The MCP connection pattern is framework and LLM-agnostic. Whether Next.js, Remix, Express, or Python FastAPI—the HTTP transport works the same. Any LLM provider that supports tool calling will work.

See references/adapting-to-stacks.md for:

  • Framework-specific route patterns (Express, Remix, Python)
  • AI library integrations (LangChain, direct API calls)

See references/system-prompts.md for domain-specific examples (e-commerce, docs, support, content curation).

Best Practices

  • Start simple: Build the basic integration first, then add advanced patterns as needed
  • Schema design: Use descriptive field names—agents rely on schema understanding
  • GROQ queries: Always include _id in projections so agents can reference documents
  • Content filters: Use groqFilter to scope what the production agent sees — start broad, then narrow based on what it actually needs. The filter is a full GROQ expression (e.g., _type in ["product", "article"])
  • Instructions field: Keep it concise — only include what the auto-generated schema doesn't make obvious. Don't duplicate schema information. See the dial-your-context skill.
  • System prompts: Be explicit about forbidden behaviors and formatting rules. Less is more — an over-engineered prompt can interfere with the Instructions content. See the shape-your-agent skill.
  • Package versions: Always check the reference package.json files or use npm info <package> version rather than guessing. AI SDK and Sanity packages update frequently, and using outdated versions will cause errors that are hard to debug.

Troubleshooting

Agent Context returns errors or no schema

Agent Context requires a deployed Studio. See Deploy Your Studio for instructions.

"401 Unauthorized" from MCP

The SANITY_API_READ_TOKEN is missing or invalid. Generate a new token from the terminal:

npx sanity tokens add "Agent Context" --role=viewer --yes --json

Or create one at sanity.io/manage → Project → API → Tokens with Viewer role.

"No documents found" / Empty results

Check the Agent Context document's content filter (groqFilter):

  • Is the GROQ filter correct?
  • Are the document types spelled correctly?
  • Are there published documents matching the filter?

Tools not appearing

  1. Check that mcpClient.tools() returns tools (log it)
  2. Ensure the MCP URL is correct (project ID, dataset, and optionally slug)
  3. If using a slug-based URL, verify the agent context document is published

平台分布

Codex

38.23%
按下载量换算1,135

Claude

28.99%
按下载量换算861

Cursor

18.92%
按下载量换算562

Gemini CLI

9.57%
按下载量换算284

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

接触敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在提醒或未通过项,安装前请自行复核。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills