/db-context-engineering:context-engineering-evaluatefrom db-context-engineering
Executes Evalbench evaluation of a ContextSet against golden NLQ+SQL datasets. Used standalone or within hill-climbing optimization loops to score accuracy and identify failure categories.
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.
Load
context-engineering-workflowfirst for shared terminology, the Context Set MCP Protocol, and safety protocol.
Score a ContextSet against a dataset by running Evalbench, and return a scored result — overall accuracy, raw passed / total counts, the report directory, plus dominant failure categories.
[!IMPORTANT] Evaluate is a pure function over its inputs. It reads whatever the caller hands it, writes only under the caller's
output_dir, and never modifiesexperiment_state.md. The caller (hillclimb, the holdout step, or the user) records the returned numbers. This keeps one writer per field and lets evaluate be used on any file or resource without side effects on an experiment.
Read .context-engineering/experiments/<experiment_name>/hillclimb/experiment_state.md and take:
| Input | From |
|---|---|
| Toolbox source | ## Active Database → Source Name (must exist in the shared .context-engineering/tools.yaml, which is the toolbox_config_path passed to generate_evalbench_configs). If its <source>-* tools are not visible, the toolbox MCP server is stale — tell the user to restart it (see context-engineering-init). |
| Dataset | Hillclimb dataset by default; Holdout dataset only when the caller is the holdout step; Golden dataset only if the user explicitly asks for a full-set score. All three live under <experiment>/dataset/. Never offer the holdout split as a casual choice — it must stay unseen during optimization. |
| ContextSet resource | The caller names it: the working copy during the loop and for the holdout step (the bare <context_set_id> in the fresh case, <context_set_id>_draft in the existing case — per Draft Context Set resource in experiment_state.md), or a resource the user names. |
output_dir | Supplied by the caller: <experiment>/hillclimb/vN/eval/ during the loop, <experiment>/hillclimb/holdout_eval/ for the holdout step. |
| GCP project / location | Parsed from the resource name above (Resource naming rule) — never from workspace_state.md, which only seeds init. |
If there is no experiment_state.md for the experiment the user is talking about, route to context-engineering-init rather than collecting the values inline. If experiment_state.md contains ## Generalizability, the experiment is finished: evaluating its published resource read-only is fine, but never upload into it.
Ask only for what is missing:
A working DB connection (tools.yaml configured for the Toolbox MCP server — see context-engineering-init if missing).
ADC configured and the Gemini Data Analytics + Dataplex APIs enabled on the project (see context-engineering-init for preflight).
A dataset (absolute path) in the simplified user-facing format — a JSON list of objects, each with:
id: unique identifier (e.g., eval_001).database: target database name.nlq: natural language question.golden_sql: correct reference SQL query.Example:
[
{
"id": "eval_001",
"database": "my_db",
"nlq": "Count users",
"golden_sql": "SELECT COUNT(*) FROM users"
}
]
A ContextSet, supplied as exactly one of:
An output_dir (absolute or workspace-relative) where the eval configs and reports should live. If the user hasn't specified one, suggest ./eval-runs/<name>/.
Collect inputs per the applicable Prerequisites table. Trust tools.yaml values as-is — don't ask the user to re-verify them.
Prepare the ContextSet resource name.
projectId after projects, location after locations, contextSetId = last segment; accept any collection segment — contextSets, entryGroups, …), confirm it exists with get_context_set(projectId, location, contextSetId) (if NOT_FOUND, tell the user explicitly that context set <contextSetId> does not exist in location <location> — do not probe other locations), and pass the unchanged string to generate_evalbench_configs(context_set_id=…) in step 4.experiment_state.md and Inputs & resolution rules in ctxset-mcp-protocol.md: the bare <context_set_id> (Final Context Set resource) when Draft Context Set resource is (none …) — a fresh context set — otherwise the Draft Context Set resource (<context_set_id>_draft). If Auto-approve uploads is true the question above is informational and you proceed, otherwise wait for approval. Never write to an existing context set's bare id from evaluate — that only happens in hillclimb's Finalize HITL.projectId and location from .context-engineering/workspace_state.md when it exists (show them; ask only if missing or the user wants different ones), ask for a contextSetId (do not guess); call list_context_set_locations(projectId) and make sure location is in the list; show the exact resource name; warn that if a context set with this name already exists the upload overwrites it irrecoverably; proceed only on explicit consent.validate_context_set on the file first; then read the file and call upload_context_set(projectId=<project_id>, location=<location>, contextSetId=<context_set_id>, contextPayload=<exact file contents>, databases=<Database when targeting a primary <context_set_id>; omit databases when targeting <context_set_id>_draft>) — the three identity parts come from the resource name above (contextSetId is its last path segment; inside an experiment, the working copy's id); <Database> is derived at upload time from the ## Active Database Source Name in experiment_state.md (standalone: the selected source) and that source's block in tools.yaml, per the Database association table in ctxset-mcp-protocol.md.get_operation(projectId, location, operationId) on the returned operation (≥5 s between polls, 5-minute ceiling), logging each response, until done: true — see the Context Set MCP Protocol in ctxset-mcp-protocol.md. Do not call generate_evalbench_configs until done: true is observed; evaluating before the upload has landed scores a missing or stale context set.error, surface it verbatim and stop.Select the DB source. Inside an experiment it is the Source Name under ## Active Database in experiment_state.md (confirm it still exists in the shared .context-engineering/tools.yaml; if not, stop and ask the user to restore it or re-run context-engineering-init). Standalone: find all kind: source blocks in .context-engineering/tools.yaml whose type is a supported evaluation engine (alloydb-postgres, cloud-sql-postgres, cloud-sql-mysql, spanner [GoogleSQL and PostgreSQL], bigquery, bigtable, firestore, or custom; consult generate_evalbench_configs for details); auto-select if exactly one, otherwise list name + type and let the user pick.
Generate the Evalbench configs. Call generate_evalbench_configs(output_dir, dataset_path, context_set_id=<resource>, toolbox_config_path=.context-engineering/tools.yaml, toolbox_source_name=<source>). The tool writes configs under <output_dir>/eval_configs/. This is the only supported way to produce Evalbench configs — never author them by hand.
Run Evalbench.
export EVAL_GCP_PROJECT_ID="<project_id>"
export EVAL_GCP_PROJECT_REGION="global"
uvx [email protected] --experiment_config=<output_dir>/eval_configs/run_config.yaml<output_dir>/eval_reports/<job_id>/ (the job_id appears in the tool's stdout). Initial uv package resolution and downloads on a cold cache or evaluation of larger datasets can take several minutes — let the command run to completion and do not kill or restart it on apparent stalls (killing uv during initial dependency resolution discards download progress). Treat a non-zero exit code as a hard failure and surface stderr verbatim.Read and return results. Call read_evaluation_result on <output_dir>/eval_reports/<job_id>/. Return to the caller:
{passed, total, accuracy, job_id, eval_dir: "<output_dir>/eval_reports/<job_id>/"}
plus the dominant failure categories and the absolute path to the full reports.
experiment_state.md. The workflow's Master Loop Control supersedes any "next steps" summary here.Handling QueryData API errors: if the evaluation results or failure cases show an API error under SQL Generator Error:
experiment_state.md. Return results; the caller records them.done: true.ctxset MCP tools (upload_context_set, get_context_set, get_operation, list_context_set_locations) by calling https://dataplex.googleapis.com/mcp/managed-context-sets via curl, Python HTTP clients, or shell scripts. If the ctxset MCP tools are not visible in your tool list, stop immediately and route to context-engineering-init.experiment_state.md; never write to an existing context set's bare id.generate_evalbench_configs errors, surface the error and stop; do not retry blindly.tools.yaml without confirmation.MCP:
validate_context_set — check a local file before uploading it.list_context_set_locations (remote Context Set server) — confirm the upload location; standalone local-file path only.upload_context_set (remote Context Set server) — used only when the caller supplies a local file instead of a resource name; takes the file contents inline in contextPayload; returns an operation.get_operation (remote Context Set server) — poll the upload operation until done: true before evaluating.generate_evalbench_configs — produces Evalbench YAML configs on disk.read_evaluation_result — parses scores.csv / summary.csv into a markdown summary.Shell:
uvx [email protected] --experiment_config=<path> — runs the eval job against the published release.References:
references/<db_type>.md — per-engine schema examples for fixing tools.yaml source blocks if generate_evalbench_configs reports a validation failure, and the extra experiment_state.md inputs some engines need: AlloyDB Postgres, BigQuery (Table Ids), Cloud Bigtable (Table Ids optional), Cloud SQL MySQL, Cloud SQL Postgres, Firestore (Table Ids optional for collection scoping), Spanner GoogleSQL (Graph Ids), Spanner PostgreSQL, Custom / Pluggable Engine.references/alloydb-postgres.md (opens in a new tab)references/bigquery.md (opens in a new tab)references/cloud-bigtable.md (opens in a new tab)references/cloud-sql-mysql.md (opens in a new tab)references/cloud-sql-postgres.md (opens in a new tab)references/custom-engine.md (opens in a new tab)references/firestore.md (opens in a new tab)references/spanner-googlesql.md (opens in a new tab)references/spanner-postgresql.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
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-generation-guideOther plugins' skills for the same job