/db-context-engineering:context-engineering-generation-guidefrom db-context-engineering
Guides creation of context items (Templates, Facets, Value Searches) for bridging LLMs with structured databases. Use when authoring SQL/GQL context for database enrichment.
Ships in db-context-engineering. 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.
Read when SKILL.md points to them.
Note: This skill covers manual authoring standards and syntax rules for individual context items. If the user asks to optimize, tune, evaluate, or run the end-to-end workflow for a database or project (e.g., from a design doc or database schema), use the context-engineering-workflow skill instead.
This skill provides the agent with the necessary information, concepts, and best practices to generate high-quality context items for the "Context Engineering Agent". This context bridges the gap between LLMs and structured databases, enabling accurate Natural Language to SQL and GQL generation.
Context generation allows you to create specific, high-value items in three forms:
WHERE clause, specialized join, or graph MATCH pattern). They are dynamically injected filters linked to specific vocabulary or terminology.When asked to generate context items:
references/ for specific syntax and patterns.mutate_context_set) to save or update the context set.validate_context_set on the file you just modified. If invalid, fix each issue via mutate_context_set and re-validate until clean. Stop after two failed attempts and surface remaining issues to the user.Note: Use the mutate_context_set tool for all ContextSet changes. It supports granular additions, updates, and deletions of ContextSet items without replacing the whole file. Pass mutation payloads directly — the tool handles all file I/O internally, so the agent should not read the target file beforehand.
A ContextSet is the central artifact managed by the Context Engineering Agent, containing structured knowledge to help the Gemini Data Analytics API understand your database and business logic.
The following are the currently supported context types:
Templates and Facets act as structural blueprints that use the pattern of ML tool selection and tool calling to constrain SQL generation. By providing the model with these pre-defined patterns, you ensure that generated queries are highly predictable, structurally sound, and adhere to established database join structures.
$1, $2 for PostgreSQL / AlloyDB / Spanner PostgreSQL / Cloud Bigtable BTQL / Firestore MQL, or ? in both parameterized_sql and parameterized_intent for Spanner GoogleSQL, BigQuery GoogleSQL, and MySQL — see Phrase Extraction and Parameterization Guidelines) to match query variations.{
"templates": [
{
"nl_query": "How many accounts are in London?",
"sql": "SELECT count(*) FROM account WHERE account.city = 'London'",
"intent": "How many accounts are in London?",
"manifest": "How many accounts are in a given city?",
"parameterized": {
"parameterized_sql": "SELECT count(*) FROM account WHERE account.city = $1",
"parameterized_intent": "How many accounts are in $1?"
}
}
]
}
table_name.column_name).{
"facets": [
{
"sql_snippet": "products.rating > 4.5",
"intent": "highly rated products (above 4.5)",
"manifest": "highly rated products (above a given number)",
"parameterized": {
"parameterized_sql_snippet": "products.rating > $1",
"parameterized_intent": "highly rated products (above $1)"
}
}
]
}
When executing blueprint-driven SQL generation, the model inevitably runs into the value linking problem—where values in a user's natural language query (e.g., "Heathrow", "Lndn", "active") do not match the exact spelling, case, or formatting of stored records in the database (e.g., "London Heathrow", "London", "ACTIVE_STATUS").
Value Search Queries are the developer-defined mechanism used to resolve the value linking problem, mapping user-supplied terms to their precise schema locations and database records using exact, trigram, or semantic match functions.
{
"value_searches": [
{
"query": "SELECT T.\"name\" AS value, 'airports.name' AS columns, 'Airport Name' AS concept_type, (T.\"name\" <-> $value::text) AS distance, '{}'::text AS context FROM \"airports\" T WHERE T.\"name\" % $value::text",
"concept_type": "Airport Name",
"description": "Fuzzy match using standard trigram for partial airport names"
}
]
}
table.column) in both the literal and parameterized SQL snippets. A facet is injected into a larger query that may join multiple tables, so unqualified column names risk ambiguity errors or silently binding to the wrong column. Do not use aliases — the surrounding query controls them.value_searches entry per ContextSet for Bigtable. GDAToolService combines multiple value_searches entries into a single query using UNION ALL (SetOperationScan), which fails on BTQL (BTQL Version does not support SetOperationScan); see Bigtable Value Search.For specific SQL/NoSQL templates, examples, and performance recommendations, refer to the subdirectories in references/:
references/facet/bigquery.md (opens in a new tab)references/facet/bigtable.md (opens in a new tab)references/facet/firestore.md (opens in a new tab)references/facet/googlesql.md (opens in a new tab)references/facet/mysql.md (opens in a new tab)references/facet/postgresql.md (opens in a new tab)references/facet/spanner-postgresql.md (opens in a new tab)references/phrase_extraction/guidelines.md (opens in a new tab)references/template/bigquery.md (opens in a new tab)references/template/bigtable.md (opens in a new tab)references/template/firestore.md (opens in a new tab)references/template/googlesql.md (opens in a new tab)references/template/mysql.md (opens in a new tab)references/template/postgresql.md (opens in a new tab)references/template/spanner-postgresql.md (opens in a new tab)references/value_search/bigquery.md (opens in a new tab)references/value_search/bigtable.md (opens in a new tab)references/value_search/firestore.md (opens in a new tab)references/value_search/googlesql.md (opens in a new tab)references/value_search/mysql.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Generated from the plugin's indexed repository (googlecloudplatform/db-context-enrichment) — no native marketplace selected
npx claudepluginhub p/googlecloudplatform-db-context-engineering-plugin7 skills in this plugin
/context-engineering-bootstrapGenerate a baseline ContextSet (Templates, Facets, Value Searches) from a target database's schema (and optional design docs / application code) and save to a caller-specified path. Optionally upload to the Context Set server. Don't use when a user asks to build, validate, or improve a context set from scratch end-to-end (use `context-engineering-workflow` instead)./context-engineering-dataset-generationGenerate or expand a golden evaluation dataset of SQL/Question (NLQ+SQL) pairs for evaluating NL-to-SQL translation accuracy on a target database. Don't use for generating context items (Templates, Facets, Value Searches) or running Evalbench evaluations./context-engineering-Other plugins' skills for the same job