Provides guidance on configuring CrestApps.Core YesSql persistence: registering data stores, collections, index providers, scoped sessions, schema migrations, and troubleshooting missing tables or uncommitted writes.
Ships in crestapps-core. 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.
You are a CrestApps.Core expert. Generate accurate YesSql persistence code with CrestApps.Core.Data.YesSql.
.AddYesSqlDataStore(configuration => configuration.UseSqLite(...)) on the root builder (or services.AddCoreYesSqlDataStore(...)). On first resolution it creates the singleton IStore, initializes the AI, AIDocs, AIMemory and default collections plus any collection an index provider names, and registers every IIndexProvider in DI. It also registers scoped ISession, scoped YesSqlStoreCommitter as IStoreCommitter, and AddCatalogManagers().AddYesSqlStores() on a feature builder only selects stores and index providers. Without AddYesSqlDataStore(...) nothing can resolve ISession.IIndexProvider implementations before the IStore is first resolved, or they are never registered with the store.Create*IndexSchemaAsync extensions once per database before serving requests (the samples' InitializeYesSqlSchemaAsync() is sample code).YesSqlStoreOptions to the schema extensions. They read collection names from it; passing null creates the tables in the root collection while the index providers query the AI collection.YesSqlStoreCommitter flushes the scoped ISession. Add the MVC, hub or endpoint commit filter, or commit explicitly in background scopes..ExclusiveToDocumentType() and .SingleRecordPerDocument() on context.For<TIndex>() when they are true (only the provider's document type maps to the index, and each document has at most one record). The built-in CrestApps.Core index providers do not declare them. IQuery<T>.NoDuplicates() is obsolete; use SkipDeduplication().using CrestApps.Core;
using CrestApps.Core.AI;
using CrestApps.Core.AI.Chat;
using CrestApps.Core.AI.Documents;
using CrestApps.Core.Data.YesSql;
using YesSql.Provider.Sqlite;
builder.Services.AddControllersWithViews()
.AddCrestAppsStoreCommitterFilter();
builder.Services.AddCrestAppsCore(crestApps => crestApps
.AddAISuite(ai => ai
.AddYesSqlStores()
.AddChatInteractions(chat => chat.AddYesSqlStores())
.AddDocumentProcessing(documents => documents.AddYesSqlStores())
.AddAIMemory(memory => memory.AddYesSqlStores())
.AddPersonas(personas => personas.AddYesSqlStores())
.AddToolInstances(tools => tools.AddYesSqlStores()))
.AddIndexingServices(indexing => indexing.AddYesSqlStores())
.AddYesSqlDataStore(configuration => configuration
.UseSqLite("Data Source=App_Data/crestapps.db;Cache=Shared")));
builder.Services.AddCoreWebCrawlerStoresYesSql();
builder.Services.AddCoreFileSourceStoresYesSql();
AddYesSqlStores() also exists on CrestAppsA2AClientBuilder, CrestAppsMcpClientBuilder and CrestAppsMcpServerBuilder.
YesSqlStoreOptions property | Default | Indexes stored there |
|---|---|---|
AICollectionName | "AI" | profiles, templates, personas, connections, deployments, chat sessions, prompts, metrics, completion usage, extracted data, chat interactions, data sources, tool instances, A2A and MCP records, file sources, ingestion item state, web crawlers, crawl state, knowledge objects |
AIDocsCollectionName | "AIDocs" | AIDocument, AIDocumentChunk |
AIMemoryCollectionName | "AIMemory" | AIMemoryEntry |
DefaultCollectionName | null (root) | SearchIndexProfile, and custom catalogs registered without a collection |
Change them with builder.Services.Configure<YesSqlStoreOptions>(...) before the store is first resolved, and use the same options when creating tables.
using CrestApps.Core.Data.YesSql;
using CrestApps.Core.Data.YesSql.Indexes.A2A;
using CrestApps.Core.Data.YesSql.Indexes.AI;
using CrestApps.Core.Data.YesSql.Indexes.AIChat;
using CrestApps.Core.Data.YesSql.Indexes.AIMemory;
using CrestApps.Core.Data.YesSql.Indexes.ChatInteractions;
using CrestApps.Core.Data.YesSql.Indexes.DataSources;
using CrestApps.Core.Data.YesSql.Indexes.FileSources;
using CrestApps.Core.Data.YesSql.Indexes.Indexing;
using CrestApps.Core.Data.YesSql.Indexes.Knowledge;
using CrestApps.Core.Data.YesSql.Indexes.Mcp;
using CrestApps.Core.Data.YesSql.Indexes.Tooling;
using CrestApps.Core.Data.YesSql.Indexes.WebCrawlers;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using YesSql;
using YesSql.Sql;
namespace MyApp.Data;
public sealed class CrestAppsYesSqlSchema
{
private readonly IStore _store;
private readonly YesSqlStoreOptions _storeOptions;
private readonly AIChatSessionMetricsIndexSchemaOptions _metricsOptions;
private readonly ILogger<CrestAppsYesSqlSchema> _logger;
public CrestAppsYesSqlSchema(
IStore store,
IOptions<YesSqlStoreOptions> storeOptions,
IOptions<AIChatSessionMetricsIndexSchemaOptions> metricsOptions,
ILogger<CrestAppsYesSqlSchema> logger)
{
_store = store;
_storeOptions = storeOptions.Value;
_metricsOptions = metricsOptions.Value;
_logger = logger;
}
public async Task CreateAsync()
{
await using var connection = _store.Configuration.ConnectionFactory.CreateConnection();
await connection.OpenAsync();
await using var transaction = await connection.BeginTransactionAsync();
var schema = new SchemaBuilder(_store.Configuration, transaction);
var options = _storeOptions;
Func<Task>[] steps =
[
() => schema.CreateAIProviderConnectionIndexSchemaAsync(options),
() => schema.CreateAIDeploymentIndexSchemaAsync(options),
() => schema.CreateAIProfileIndexSchemaAsync(options),
() => schema.CreateAIProfileTemplateIndexSchemaAsync(options),
() => schema.CreateAIPersonaIndexSchemaAsync(options),
() => schema.CreateAIProfileVersionIndexSchemaAsync(options),
() => schema.CreateAIChatSessionIndexSchemaAsync(options),
() => schema.CreateAIChatSessionPromptIndexSchemaAsync(options),
() => schema.CreateAIChatSessionMetricsSchemaAsync(options, _metricsOptions),
() => schema.CreateAICompletionUsageIndexSchemaAsync(options),
() => schema.CreateAIChatSessionExtractedDataIndexSchemaAsync(options),
() => schema.CreateChatInteractionIndexSchemaAsync(options),
() => schema.CreateChatInteractionPromptIndexSchemaAsync(options),
() => schema.CreateAIDocumentIndexSchemaAsync(options),
() => schema.CreateAIDocumentChunkIndexSchemaAsync(options),
() => schema.CreateAIDataSourceIndexSchemaAsync(options),
() => schema.CreateSearchIndexProfileIndexSchemaAsync(options),
() => schema.CreateAIMemoryEntryIndexSchemaAsync(options),
() => schema.CreateAIToolInstanceIndexSchemaAsync(options),
() => schema.CreateA2AConnectionIndexSchemaAsync(options),
() => schema.CreateMcpConnectionIndexSchemaAsync(options),
() => schema.CreateMcpPromptIndexSchemaAsync(options),
() => schema.CreateMcpResourceIndexSchemaAsync(options),
() => schema.CreateWebCrawlerIndexSchemaAsync(options),
() => schema.CreateWebCrawlStateIndexSchemaAsync(options),
() => schema.CreateFileSourceIndexSchemaAsync(options),
() => schema.CreateIngestionItemStateIndexSchemaAsync(options),
() => schema.CreateKnowledgeObjectIndexSchemaAsync(options),
];
foreach (var step in steps)
{
try
{
await step();
}
catch (Exception ex)
{
// The table usually exists already. Track a schema version in production instead.
_logger.LogDebug(ex, "Skipped a CrestApps YesSql index table.");
}
}
await transaction.CommitAsync();
}
}
builder.Services.AddSingleton<CrestAppsYesSqlSchema>();
var app = builder.Build();
await app.Services.GetRequiredService<CrestAppsYesSqlSchema>().CreateAsync();
Keep only the steps for the features you registered. The skip-on-error loop mirrors the SQLite sample; on PostgreSQL or SQL Server a failed statement aborts the transaction, so record a schema version and run each step once instead. For existing databases, the column-upgrade extensions AddAIProfileIndexTypeColumnAsync, AddAIDocumentIndexExtensionColumnAsync, AddAIChatSessionMetricsCompletionCountColumnAsync and AddAIChatSessionIndexClientIdColumnAsync add later columns.
ClientIdAIChatSessionIndex stores the anonymous visitor who owns a session (ClientId), and AIChatSessionQueryContext.ClientId lists one visitor's sessions (YesSql and EntityCore managers). A new database gets the column from CreateAIChatSessionIndexSchemaAsync; an existing one needs a migration:
// Idempotent on SQLite, SQL Server, PostgreSQL and MySQL (checks the column and the index separately).
await schemaBuilder.AddAIChatSessionIndexClientIdColumnAsync(storeOptions, store.Configuration.Schema);
// Once, from a migration or one-off job: index the anonymous sessions saved before the upgrade.
var count = await session.BackfillAIChatSessionIndexClientIdAsync(storeOptions); // pages of batchSize (500)
await session.SaveChangesAsync();
Pass store.Configuration.Schema on SQL Server and PostgreSQL so the check looks in the tables' schema. On other providers the method has no existence check, so a second run fails. Sessions saved before the backfill are missing from ClientId listings until they are saved again.
| Method | Stores and index providers |
|---|---|
AddCoreAIServicesStoresYesSql() | YesSqlAIProfileStore; AIProviderConnection and AIDeployment binding sources; AIProfileIndexProvider, AIProviderConnectionIndexProvider, AIDeploymentIndexProvider |
AddCoreAIProfileTemplateStoresYesSql() | AIProfileTemplate catalog, AIProfileTemplateIndexProvider |
AddCoreAIPersonaStoresYesSql() | AIPersona named catalog, AIPersonaIndexProvider |
AddCoreAIProfileVersionStoresYesSql() | YesSqlAIProfileVersionStore as IAIProfileVersionStore, AIProfileVersionIndexProvider (also AddProfileVersions(v => v.AddYesSqlStores())) |
AddCoreAIChatSessionStoresYesSql() | runs the base, metrics, completion usage and extracted data methods below |
AddCoreAIChatSessionBaseStoresYesSql() | YesSqlAIChatSessionManager, YesSqlAIChatSessionStore, YesSqlAIChatSessionPromptStore; session and prompt index providers |
AddCoreAIChatSessionMetricsStoresYesSql() | YesSqlAIChatSessionEventStore, AIChatSessionMetricsIndexProvider |
AddCoreAICompletionUsageStoresYesSql() | YesSqlAICompletionUsageStore, AICompletionUsageIndexProvider |
AddCoreAIChatSessionExtractedDataStoresYesSql() | YesSqlAIChatSessionExtractedDataStore, extracted data recorder and index provider |
AddCoreAIChatInteractionStoresYesSql() | ChatInteraction catalog, YesSqlChatInteractionPromptStore, both index providers |
AddCoreAIDocumentProcessingStoresYesSql() | YesSqlAIDocumentStore, YesSqlAIDocumentChunkStore, both index providers |
AddCoreAIDataSourceStoresYesSql() | YesSqlAIDataSourceStore, AIDataSourceIndexProvider |
AddCoreAIMemoryStoresYesSql() | YesSqlAIMemoryStore, AIMemoryEntryIndexProvider |
AddCoreIndexingStoresYesSql() | YesSqlSearchIndexProfileStore, SearchIndexProfileIndexProvider |
AddCoreAIToolInstanceStoresYesSql() | AIToolInstance catalog, AIToolInstanceIndexProvider |
AddCoreAIA2AClientStoresYesSql() | A2AConnection catalog, A2AConnectionIndexProvider |
AddCoreAIMcpClientStoresYesSql() | McpConnection catalog, McpConnectionIndexProvider |
AddCoreAIMcpServerStoresYesSql() | McpPrompt and McpResource catalogs and index providers |
AddCoreKnowledgeStoresYesSql() | YesSqlKnowledgeObjectStore, KnowledgeObjectIndexProvider |
AddCoreIngestionItemStateStoreYesSql() | YesSqlIngestionItemStateStore, IngestionItemStateIndexProvider |
AddCoreWebCrawlerStoresYesSql() | YesSqlWebCrawlerStore, YesSqlWebCrawlStateStore, their index providers, plus knowledge and ingestion item state |
AddCoreFileSourceStoresYesSql() | YesSqlFileSourceStore, FileSourceIndexProvider, plus knowledge and ingestion item state |
Each index type and its provider live in separate files under Indexes/{Feature} (namespace CrestApps.Core.Data.YesSql.Indexes.{Feature}), with a matching *IndexSchemaBuilderExtensions class. INameAwareIndex, IDisplayTextAwareIndex and ISourceAwareIndex mark the lookup columns DocumentCatalog filters on; CatalogItemIndex (with ItemId) is the shared base.
using CrestApps.Core.Data.YesSql;
using CrestApps.Core.Data.YesSql.Indexes;
using Microsoft.Extensions.Options;
using YesSql.Indexes;
namespace MyApp.Data;
public sealed class TicketCategoryIndex : CatalogItemIndex, INameAwareIndex
{
public string Name { get; set; }
}
public sealed class TicketCategoryIndexProvider : IndexProvider<TicketCategory>
{
public TicketCategoryIndexProvider(IOptions<YesSqlStoreOptions> options)
{
CollectionName = options.Value.AICollectionName;
}
public override void Describe(DescribeContext<TicketCategory> context)
{
// Only TicketCategory documents map to this index, one record each.
context.For<TicketCategoryIndex>()
.ExclusiveToDocumentType()
.SingleRecordPerDocument()
.Map(category => new TicketCategoryIndex
{
ItemId = category.ItemId,
Name = category.Name,
});
}
}
builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IIndexProvider, TicketCategoryIndexProvider>());
builder.Services.AddYesSqlNamedDocumentCatalog<TicketCategory, TicketCategoryIndex>("AI");
Create the table with schema.CreateMapIndexTableAsync<TicketCategoryIndex>(table => table.Column<string>("ItemId", c => c.WithLength(26)).Column<string>("Name", c => c.WithLength(255)), collection: "AI"). The catalog, index provider and table must name the same collection, or writes and queries silently miss each other. The other helpers are AddYesSqlDocumentCatalog, AddYesSqlSourceDocumentCatalog, AddYesSqlNamedSourceDocumentCatalog, and the binding-source helpers AddYesSqlNamedSourceBindingSource<TModel, TIndex>() and AddYesSqlNamedBindingSource<TModel, TIndex>(); each has a parameterless overload that uses DefaultCollectionName.
PageAsync(page, pageSize, new QueryContext { Name = search, Source = source, Sorted = true }) filters on the concrete index's Name (or DisplayText) and Source columns and translates to SQL OFFSET/LIMIT.
AIProfileVersionIndex table (ItemId, ProfileId, Version, CreatedUtc, in the AI collection). Create it with CreateAIProfileVersionIndexSchemaAsync(options) when you call AddProfileVersions(v => v.AddYesSqlStores()).YesSqlAIChatSessionStore implements the new IAIChatSessionStore.ListByLastActivityAsync and DeleteAsync over the existing AIChatSessionIndex and AIChatSessionPromptIndex; no new columns.YesSqlAIChatSessionManager.PageAsync filters by AIChatSessionQueryContext.UserId when set, and new sessions record the profile's AIProfileVersionMetadata.AIChatSessionIndex gained ClientId. Run AddAIChatSessionIndexClientIdColumnAsync(storeOptions, store.Configuration.Schema) on existing databases and BackfillAIChatSessionIndexClientIdAsync(storeOptions) once.YesSqlAICompletionUsageStore writes and commits each usage record at once in a session of its own (IStore.CreateSession()), bounded to 30 seconds, instead of staging it in the caller's scoped session. The record is kept when the caller rolls back and is not dropped by a cancelled caller token; reads still use the scoped session. Code that constructs the store passes the new IStore argument.DocumentCatalog.PageAsync with a name or source filter used to throw no such table: INameAwareIndex_Document; it now builds the filter against the concrete index. Remove any workaround that avoided QueryContext filters.AIPersonaIndex, FileSourceIndex, IngestionItemStateIndex, KnowledgeObjectIndex, WebCrawlerIndex, WebCrawlStateIndex. A host with web crawlers but no file sources still needs IngestionItemStateIndex.FileSourceIndex records, not as web crawlers; a host that ran a preview build moves those records itself.What SKILL.md sets; muted values are Claude Code's defaults
/crestapps-core:crestapps-core-yessql-storesfrom crestapps-core
npx claudepluginhub crestapps/crestapps.agentskills --plugin crestapps-core51 skills in this plugin
/crestapps-core-a2aSkill for Agent-to-Agent (A2A) protocol support in CrestApps.Core on the A2A 1.0 SDK. Covers AddA2AClient and AddCoreAIA2AClient with Entity Framework Core or YesSql connection stores, A2AConnection and A2AConnectionMetadata authentication, AIProfileA2AMetadata, the agent card cache and A2AToolRegistryProvider, the listAvailableAgents, findAgentForTask and findToolsForTask tools, building an A2A host with IAgentHandler, A2AServer, ITaskStore and MapA2A, A2A 1.0 agent cards with supportedInterfaces published at /.well-known/agent-card.json, A2AHostOptions authentication and ExposeAgentsAsSkill, system agents exposed through the host, and upgrading from the 0.3 SDK./crestapps-core-ag-uiSkill for running the CrestApps.Core 2.0 AI chat as an AG-UI agent. Covers the CrestApps.Core.AI.AGUI package (AGUIRunEventWriter, AGUIRunRequest, AGUIJson), AIChatHubCore.RunAgent over SignalR and MapAGUIChat with Server-Sent Events, the RunAgentInput members and streamed events, tool approvals with RequireApproval or an approval tool kind, ApprovalRequiredAIFunction, interrupts and resume, approvals inside agents, page context with crestAppsAGUI.registerContextProvider, shared state with registerStateProvider and update_shared_state, frontend tools, stored tool calls (ChatTurnToolActivity), runs that continue on the next page, AGUIChatOptions.DisconnectedRunTimeout, the protocol and sendPageContext chat options, and the AICompletionContextKeys and ChatResponseHandlerContext members. Use it when showing tool calls in the chat, asking a person before a tool runs, sharing page state with the agent, connecting CopilotKit or another AG-UI client, or troubleshooting approvals and continued runs./crestapps-core-ai-agentsSkill for AI agents in CrestApps.Core 2.0, specialized AIProfile records of type Agent that the primary model invokes as tools. Covers creating agent profiles with AgentMetadata availability (OnDemand or AlwaysAvailable), linking them with AgentInvocationMetadata, how AgentProxyTool runs an agent with tools disabled or through the orchestrator when AllowToolInvocation is set, the AgentInvocationDepth recursion guard, never offering an agent to itself (RunningAgentName), tools of an agent that require an approval and pause the agent, deployment inheritance and the chat slot, code-defined and system agents through IAIProfileProvider including the Tabular Data, PDF, Presentation and Word agents, chat-specific agents that read AIInvocationScope, exposing agents to MCP clients with McpServerOptions Agents and ExposeAllAgents, and SubAgent usage labels. Use it when delegating work to sub-agents, adding a framework-managed agent, publishing an agent over MCP, or troubleshooting an agent the model does not call./crestapps-core-ai-markdownSkill for Markdig-backed Markdown normalization in CrestApps.Core 2.0 AI document, data source and RAG flows. Covers the CrestApps.Core.AI.Markdown package, AddMarkdown on the AI suite builder and AddCoreAIMarkdown on IServiceCollection, MarkdownAITextNormalizer replacing the default IAITextNormalizer, RagTextNormalizer content, chunk and title normalization with HTML stripping and Microsoft.Extensions.DataIngestion.Markdig parsing, the gpt-4o tokenizer chunker with 500 tokens per chunk and 50 tokens of overlap, the plain-text fallback for unsupported inline types, where the normalizer is used (data source indexing, preemptive retrieval, reference titles), and pairing it with document processing. Use it when indexing Markdown-heavy content for retrieval, replacing the text normalizer, or troubleshooting chunk sizes and leftover markup in retrieved text./crestapps-core-ai-memorySkill for AI memory in CrestApps.Core. Covers AddAIMemory, AddCoreAIMemory and AddCoreAIMemoryIndexing, Entity Framework Core and YesSql memory stores, the AIMemory index profile on the Elasticsearch, Azure AI Search and PostgreSQL backends, AIMemoryOptions, the store fallback when no index is usable, background memory indexing, the three kinds of memory (session memory with AIConversationMemory summaries and search_conversation, past conversations with search_past_conversations and list_recent_conversations, durable user memory) switched by MemoryMetadata and ChatInteractionMemoryOptions, preemptive memory retrieval and RunsWhenPreemptiveRagIsDisabled, owner-only chat sessions, the user memory tools, IAIMemorySafetyService validation, and custom IMemoryVectorSearchService implementations./crestapps-core-ai-model-capabilitiesSkill for metadata-driven deployment capabilities in CrestApps.Core 2.0. Covers trained model features such as textGeneration, toolCalling, streaming, reasoning, realtime, textEmbedding, speechToText and textToSpeech, model parameters such as reasoningEffort, declaring them with AIDeploymentMetadata or the Features and Parameters configuration shorthand for Azure App Service settings, registering custom features, parameters and slots with AddAIDeploymentFeature, AddAIDeploymentParameter, AddAIDeploymentSlot and AIDeploymentCapabilityOptions, IAIDeploymentCapabilityService, deployment slots and their resolution chain, AIDeploymentParametersMetadata chat and utility values, IAIDeploymentParameterBinder, UseModelParameters, capability enforcement, the ChatApi Responses routing for reasoning with tools, capability-aware chat UIs, and migrating from AIDeploymentPurpose. Use it when declaring what a model supports, adding a new knob, or fixing stripped tools, missing pickers, or reasoning-effort errors.Other plugins' skills for the same job