Cortex Sense
Cortex Sense is how Cortex Code and Snowflake Intelligence understand your data and business. This skill is the builder experience: it captures the domain (named, persistent), assembles the domain context (scope + dashboards + instructions), and hands that context off to the offline build. See reference/USE_CASE_AND_CONTEXT.md for the vocabulary.
Builder principle. CoCo proposes; the builder steers; the build does the heavy lifting. Don't ask the builder to do work CoCo can do, and don't ask CoCo to do work the build is meant to do.
Eight intents
| Intent |
Triggers |
Sub-skill |
| list |
"list cortex sense", "show all domains", "what cortex sense do I have", "list all contexts", "what domains exist", "show my contexts", "which cortex senses are set up" |
query/SKILL.md — list-only path (see below) |
| setup |
"set up cortex sense", "build context for ", "I want context for sales" |
setup/SKILL.md |
| test |
"test the context", "run questions against sales", "what does the context know about ", "check build", "is the build done?", "@cortex-sense resume " + a query |
test/SKILL.md |
| query |
"query about ", "search contexts for ", "search across contexts for ", "what does cortex sense know about " (no use case named), "which of my contexts know about ", "@cortex-sense query about " |
query/SKILL.md |
| refine |
"refine sales", "the agent picked the wrong table", "DAU is wrong", "exclude staging", "add another schema", "@cortex-sense resume " + a correction |
refine/SKILL.md |
| eval |
"generate eval", "run eval", "diff eval", "score the context", "check answer correctness", "create eval set", "evaluate the context", reply to the setup confirm block with 5–10 test questions, "@cortex-sense resume " + any eval verb |
eval/SKILL.md |
| feedback (work in progress) |
"@cortex-sense feedback ", "record feedback", "log a correction", "give feedback on ", "@cortex-sense resume " + "feedback" |
feedback/SKILL.md |
| agent |
"create an agent for ", "create a cowork agent for ", "deploy as an agent", "make an agent from this context", "add cortex sense to ", "wire to cortex sense", "enable cortex_sense on ", "@cortex-sense resume " + an agent verb |
agent/SKILL.md |
list-only path: When the intent is purely to list existing domains (no query or domain name given), route to query/SKILL.md. That file's "List-only path" section handles it: it calls list-contexts and renders the domain list, then stops. Do not route to setup, refine, or any stage path — SYSTEM$CORTEX_AGENT_CORTEX_CONTEXT_BUILDER list-contexts is the single authoritative source for registered domains.
Re-entry verb is @cortex-sense resume <domain>. CoCo loads the domain's manifest and routes to test, refine, eval, feedback, or agent based on what the builder says next. If the domain doesn't exist yet, route to setup.
The query intent is for cross-context search — use it when the builder wants to search across all contexts or query without the full test workflow.
The agent intent is the hand-off to consumers: it turns a built context into a CoWork / Snowflake Intelligence agent, or adds Cortex Sense to an agent that already exists. It is the only sub-skill that creates objects outside the context's own storage, so it always confirms the spec before any DDL.
The feedback path is a work in progress. Recording is durable, but nothing consumes a stored correction yet and it cannot list or edit them. It says so to the builder on the way in; do not oversell it here either.
The feedback intent needs the verb. A correction reaches it only when the builder explicitly asks to record feedback; the same words without the verb go to refine. The difference is what is being corrected: refine changes what is in scope and writes the manifest, feedback corrects an answer and writes a separate file. Scope changes are never feedback — the storage layer rejects them outright. When a report is ambiguous between the two, feedback/SKILL.md asks once and routes on the answer.
If the user's intent is ambiguous, default to setup when no manifest is found, refine when one exists and the message reads like a correction, eval when one exists and the message reads like validation or scoring, and agent when the message names an agent or asks to deploy.
Skill structure
Top-down map. The router (this file) plus seven sub-skills route conversation; reference files are loaded on demand by the sub-skills; scripts/ is the only load-bearing code.
cortex-sense/
├── SKILL.md # router (this file) — eight intents
├── pyproject.toml # uv-managed deps for scripts/
│
├── setup/SKILL.md # name → scan → draft → confirm → save
├── test/SKILL.md # spot-check the active context (ad hoc lookup)
├── query/SKILL.md # cross-context search (query all or specific contexts)
├── refine/SKILL.md # corrections, expansions, updates (folds in the old "debug" flow)
├── eval/SKILL.md # generate / run / diff — answer-correctness eval sets (+ efficiency metrics)
├── feedback/SKILL.md # one correction: draft → confirm card → record (work in progress)
├── agent/SKILL.md # built context → CoWork agent; or add cortex_sense to an existing agent
│
├── reference/ # loaded on demand by the sub-skills
│ ├── USE_CASE_AND_CONTEXT.md # vocabulary: use case / domain context / build
│ ├── DISCOVERY.md # parallel-discovery contract + verbatim SQL
│ ├── DASHBOARDS.md # Dashboards row + External tables row (Horizon Context mapping)
│ ├── SCOPE_MANIFEST.md # manifest YAML shape (sources, concepts/relationships/associations, pending_asks, …)
│ ├── INSTRUCTIONS.md # internal NL → concepts / relationships / instructions classification
│ ├── SUMMARY_FORMAT.md # exact narrative summary (rows, order, confirm block)
│ ├── STORAGE.md # storage contract: SYSTEM$CORTEX_AGENT_CORTEX_CONTEXT_BUILDER, doctor, persistence registration
│ ├── CONTEXT_LOOKUP.md # context lookup contract: MCP tool + SQL fallback, rendering, error handling
│ ├── AGENT_SPEC.md # agent spec contract: the one experimental flag, provisioned tools, doc_types, DDL, CoWork, smoke test
│ ├── ONTOLOGY_DISCOVERY.md # contract for ontology-aware discovery: matching, script invocation, manifest output
│ ├── ACCESS_PREFLIGHT.md # build-role read-access preflight (visibility probe + grant remediation)
│ ├── BUILD_STATUS.md # best-effort `check build` status inference (no true state field yet)
│ ├── LOCAL_FILES.md # local files & Workspace-backed Streamlit apps → stage
│ ├── EVAL_FORMAT.md # eval.yaml schema, answer-grading contract, metrics, generation rules
│ ├── FEEDBACK_RECORD.md # feedback record form, the six types, indexed_text rules, error map
│ └── NOT_YET_IMPLEMENTED.md # placeholder copy + when each is surfaced
│
└── scripts/ # invoked by the markdown sub-skills
├── persist_state.py # YAML validation, dedup (merge subcommand), doctor pre-flight
├── feedback_record.py # feedback record: validate, and summarise for the confirm card
├── discover_usage.py # deep-pass: hot tables + Streamlits + SVs from ACCOUNT_USAGE (SQL-only, 3 parallel queries)
└── discover_ontology_domains.py # fast-pass: fetch registered ontology sources for a matched domain
A new conversation walks: SKILL.md → one of setup / test / query / refine / eval / feedback / agent → relevant reference/*.md for the contract → SQL (SYSTEM$CORTEX_AGENT_CORTEX_CONTEXT_BUILDER put-stage-file) to persist. persist_state.py merge runs dedup in-process before the SQL call for scope manifests. Nothing else is in the scope save path; feedback writes a separate file through record-feedback and does not touch the manifest.
agent is the one sub-skill whose output is not a stage file — it writes a Snowflake AGENT object via DDL. It reads the manifest but never writes one; scope changes still flow through refine.
Out of scope (deliberately)
Activate / draft / share-for-review verbs. The builder confirms a scope; the build runs. Internal versioning is not a builder concern.
Picking a routing bucket (concepts vs relationships vs additional_instructions). The builder writes natural language; CoCo classifies internally.
Operator diagnostics (Cortex search-service previews, task DAG resume). Wrong-answer reports flow through refine.
Delete / remove a context. SYSTEM$CORTEX_AGENT_CORTEX_CONTEXT_BUILDER delete-context is available (see reference/STORAGE.md) but is irreversible and must never be triggered from normal refine or setup flows.
⚠️ MANDATORY CHECKPOINT before delete-context: surface the exact command that will be run and ask:
"This will permanently delete the <domain> context and its manifest. Type the domain name to confirm, or say cancel."
Wait for the builder to type the domain name back verbatim. If the response does not match the domain name exactly, stop and do not run the command.
Persistence
The manifest is persisted as YAML in a Snowflake stage (storage details are intentionally not surfaced to the builder). See reference/STORAGE.md for the full contract: location resolution, the doctor pre-flight, stage layout, and the post-save persistence-layer registration call.
Recorded feedback is a separate file in the same stage (feedback.json, a sibling of the manifest) written through the record-feedback action. It never touches scope.yaml. See reference/FEEDBACK_RECORD.md.
Ontology as a discovery source
During setup, Cortex Sense checks whether any Business Ontology domains are relevant to the current domain. If a match is found, it adds the domain plus its registered stage sources as a single business_ontology source; the build then reaches the domain's nodes, relationships, and stage-file contents behind the scenes. See reference/ONTOLOGY_DISCOVERY.md for the full contract: matching rules, script invocation, and output shape.
The Ontology is a consumer dependency at discovery time — Cortex Sense reads from it; Business Ontology owns all writes. The reverse direction (Cortex Sense proposing improvements back to the Ontology) is the steward-driven business-ontology/workflow/phase-2-enrich path; see the enrichment-handoff section of reference/ONTOLOGY_DISCOVERY.md.
Not yet implemented
The skill ships several capabilities as explicit placeholders, surfaced to the builder the first time they would otherwise mislead. The full list is in reference/NOT_YET_IMPLEMENTED.md. Major ones:
- Build orchestration & the true in-flight build state field (running/done/failed). The
check build verb gives best-effort status today by inference — see reference/BUILD_STATUS.md.
- Correction propagation across similar tables/metrics
- Native use-case object (replacement for stage-backed YAML)
- Content search of BI objects & external tables (discovery via search is supported; reading their internal queries/fields/row data is not — see
reference/DISCOVERY.md)
- Horizon Context connector enablement (a platform must be connected to appear in search — Tableau / Power BI / Databricks / SQL Server / Postgres)
Output
A persisted, versioned manifest for the domain context. See reference/SCOPE_MANIFEST.md.
<WORKSPACE_DIR> and <SKILL_DIR> are placeholders the agent resolves from CoCo's working directory and the current skill location respectively.
1---2name: cortex-sense3description: "Set up, test, query, and refine Cortex Sense contexts, and turn a built context into a CoWork agent. CoCo runs a background scan of the account the moment the use case is named, proposes a scoped domain context, accepts edits in plain English, and persists a manifest the offline build consumes. Use when: starting a new use case for Cortex Sense, validating a built context with real questions, querying across multiple contexts, listing all available Cortex Sense domains, correcting a wrong / missing / stale answer, recording a correction to a wrong answer (work in progress), or creating an agent grounded in a context. Triggers: set up cortex sense, build cortex sense for <use case>, test the <use case> context, query about <X>, search contexts for <X>, search across contexts for <X>, what does cortex sense know about <X>, which of my contexts know about <X>, refine cortex sense, the agent picked the wrong table, DAU is wrong, exclude staging, add another schema, @cortex-sense resume <use case>, @cortex-sense query <use case> about <X>, list cortex sense, show all domains, what cortex sense do I have, list all contexts, what domains exist, record feedback, log a correction, give feedback on <domain>, create an agent for <domain>, create a cowork agent, deploy <domain> as an agent, add cortex sense to <agent>, enable cortex_sense on <agent>."4metadata:5 source: https://skillmd.com/skills/s-14-h/cortex-sense6---78# Cortex Sense910Cortex Sense is how Cortex Code and Snowflake Intelligence understand your data and business. This skill is the **builder experience**: it captures the **domain** (named, persistent), assembles the **domain context** (scope + dashboards + instructions), and hands that context off to the offline **build**. See `reference/USE_CASE_AND_CONTEXT.md` for the vocabulary.1112**Builder principle.** CoCo proposes; the builder steers; the build does the heavy lifting. Don't ask the builder to do work CoCo can do, and don't ask CoCo to do work the build is meant to do.1314## Eight intents1516| Intent | Triggers | Sub-skill |17|---|---|---|18| **list** | "list cortex sense", "show all domains", "what cortex sense do I have", "list all contexts", "what domains exist", "show my contexts", "which cortex senses are set up" | `query/SKILL.md` — list-only path (see below) |19| **setup** | "set up cortex sense", "build context for <use case>", "I want context for sales" | `setup/SKILL.md` |20| **test** | "test the <use case> context", "run questions against sales", "what does the <use case> context know about <table>", "check build", "is the build done?", "@cortex-sense resume <use case>" + a query | `test/SKILL.md` |21| **query** | "query about <X>", "search contexts for <X>", "search across contexts for <X>", "what does cortex sense know about <X>" (no use case named), "which of my contexts know about <X>", "@cortex-sense query <use-case> about <X>" | `query/SKILL.md` |22| **refine** | "refine sales", "the agent picked the wrong table", "DAU is wrong", "exclude staging", "add another schema", "@cortex-sense resume <use case>" + a correction | `refine/SKILL.md` |23| **eval** | "generate eval", "run eval", "diff eval", "score the context", "check answer correctness", "create eval set", "evaluate the context", reply to the setup confirm block with 5–10 test questions, "@cortex-sense resume <use case>" + any eval verb | `eval/SKILL.md` |24| **feedback** *(work in progress)* | "@cortex-sense feedback <domain>", "record feedback", "log a correction", "give feedback on <domain>", "@cortex-sense resume <domain>" + "feedback" | `feedback/SKILL.md` |25| **agent** | "create an agent for <domain>", "create a cowork agent for <domain>", "deploy <domain> as an agent", "make an agent from this context", "add cortex sense to <agent>", "wire <agent> to cortex sense", "enable cortex_sense on <agent>", "@cortex-sense resume <use case>" + an agent verb | `agent/SKILL.md` |2627**list-only path:** When the intent is purely to list existing domains (no query or domain name given), route to `query/SKILL.md`. That file's "List-only path" section handles it: it calls `list-contexts` and renders the domain list, then stops. Do **not** route to setup, refine, or any stage path — `SYSTEM$CORTEX_AGENT_CORTEX_CONTEXT_BUILDER list-contexts` is the single authoritative source for registered domains.2829Re-entry verb is `@cortex-sense resume <domain>`. CoCo loads the domain's manifest and routes to **test**, **refine**, **eval**, **feedback**, or **agent** based on what the builder says next. If the domain doesn't exist yet, route to **setup**.3031The **query** intent is for cross-context search — use it when the builder wants to search across all contexts or query without the full test workflow.3233The **agent** intent is the hand-off to consumers: it turns a built context into a CoWork / Snowflake Intelligence agent, or adds Cortex Sense to an agent that already exists. It is the only sub-skill that creates objects outside the context's own storage, so it always confirms the spec before any DDL.3435**The feedback path is a work in progress.** Recording is durable, but nothing consumes a stored correction yet and it cannot list or edit them. It says so to the builder on the way in; do not oversell it here either.3637The **feedback** intent needs the verb. A correction reaches it only when the builder explicitly asks to record feedback; the same words without the verb go to **refine**. The difference is what is being corrected: **refine** changes what is in scope and writes the manifest, **feedback** corrects an answer and writes a separate file. Scope changes are never feedback — the storage layer rejects them outright. When a report is ambiguous between the two, `feedback/SKILL.md` asks once and routes on the answer.3839If the user's intent is ambiguous, default to **setup** when no manifest is found, **refine** when one exists and the message reads like a correction, **eval** when one exists and the message reads like validation or scoring, and **agent** when the message names an agent or asks to deploy.4041## Skill structure4243Top-down map. The router (this file) plus seven sub-skills route conversation; reference files are loaded on demand by the sub-skills; `scripts/` is the only load-bearing code.4445```46cortex-sense/47├── SKILL.md # router (this file) — eight intents48├── pyproject.toml # uv-managed deps for scripts/49│50├── setup/SKILL.md # name → scan → draft → confirm → save51├── test/SKILL.md # spot-check the active context (ad hoc lookup)52├── query/SKILL.md # cross-context search (query all or specific contexts)53├── refine/SKILL.md # corrections, expansions, updates (folds in the old "debug" flow)54├── eval/SKILL.md # generate / run / diff — answer-correctness eval sets (+ efficiency metrics)55├── feedback/SKILL.md # one correction: draft → confirm card → record (work in progress)56├── agent/SKILL.md # built context → CoWork agent; or add cortex_sense to an existing agent57│58├── reference/ # loaded on demand by the sub-skills59│ ├── USE_CASE_AND_CONTEXT.md # vocabulary: use case / domain context / build60│ ├── DISCOVERY.md # parallel-discovery contract + verbatim SQL61│ ├── DASHBOARDS.md # Dashboards row + External tables row (Horizon Context mapping)62│ ├── SCOPE_MANIFEST.md # manifest YAML shape (sources, concepts/relationships/associations, pending_asks, …)63│ ├── INSTRUCTIONS.md # internal NL → concepts / relationships / instructions classification64│ ├── SUMMARY_FORMAT.md # exact narrative summary (rows, order, confirm block)65│ ├── STORAGE.md # storage contract: SYSTEM$CORTEX_AGENT_CORTEX_CONTEXT_BUILDER, doctor, persistence registration66│ ├── CONTEXT_LOOKUP.md # context lookup contract: MCP tool + SQL fallback, rendering, error handling67│ ├── AGENT_SPEC.md # agent spec contract: the one experimental flag, provisioned tools, doc_types, DDL, CoWork, smoke test68│ ├── ONTOLOGY_DISCOVERY.md # contract for ontology-aware discovery: matching, script invocation, manifest output69│ ├── ACCESS_PREFLIGHT.md # build-role read-access preflight (visibility probe + grant remediation)70│ ├── BUILD_STATUS.md # best-effort `check build` status inference (no true state field yet)71│ ├── LOCAL_FILES.md # local files & Workspace-backed Streamlit apps → stage72│ ├── EVAL_FORMAT.md # eval.yaml schema, answer-grading contract, metrics, generation rules73│ ├── FEEDBACK_RECORD.md # feedback record form, the six types, indexed_text rules, error map74│ └── NOT_YET_IMPLEMENTED.md # placeholder copy + when each is surfaced75│76└── scripts/ # invoked by the markdown sub-skills77 ├── persist_state.py # YAML validation, dedup (merge subcommand), doctor pre-flight78 ├── feedback_record.py # feedback record: validate, and summarise for the confirm card79 ├── discover_usage.py # deep-pass: hot tables + Streamlits + SVs from ACCOUNT_USAGE (SQL-only, 3 parallel queries)80 └── discover_ontology_domains.py # fast-pass: fetch registered ontology sources for a matched domain81```8283A new conversation walks: `SKILL.md` → one of `setup` / `test` / `query` / `refine` / `eval` / `feedback` / `agent` → relevant `reference/*.md` for the contract → SQL (`SYSTEM$CORTEX_AGENT_CORTEX_CONTEXT_BUILDER put-stage-file`) to persist. `persist_state.py merge` runs dedup in-process before the SQL call for scope manifests. Nothing else is in the scope save path; `feedback` writes a separate file through `record-feedback` and does not touch the manifest.8485`agent` is the one sub-skill whose output is not a stage file — it writes a Snowflake `AGENT` object via DDL. It reads the manifest but never writes one; scope changes still flow through `refine`.8687## Out of scope (deliberately)8889- **Activate / draft / share-for-review verbs.** The builder confirms a scope; the build runs. Internal versioning is not a builder concern.90- **Picking a routing bucket** (`concepts` vs `relationships` vs `additional_instructions`). The builder writes natural language; CoCo classifies internally.91- **Operator diagnostics** (Cortex search-service previews, task DAG resume). Wrong-answer reports flow through **refine**.92- **Delete / remove a context.** `SYSTEM$CORTEX_AGENT_CORTEX_CONTEXT_BUILDER delete-context` is available (see `reference/STORAGE.md`) but is irreversible and must never be triggered from normal refine or setup flows.9394 **⚠️ MANDATORY CHECKPOINT before delete-context:** surface the exact command that will be run and ask:95 > "This will permanently delete the `<domain>` context and its manifest. Type the domain name to confirm, or say cancel."9697 Wait for the builder to type the domain name back verbatim. If the response does not match the domain name exactly, stop and do not run the command.9899## Persistence100101The manifest is persisted as YAML in a Snowflake stage (storage details are intentionally not surfaced to the builder). See `reference/STORAGE.md` for the full contract: location resolution, the doctor pre-flight, stage layout, and the post-save persistence-layer registration call.102103Recorded feedback is a **separate file in the same stage** (`feedback.json`, a sibling of the manifest) written through the `record-feedback` action. It never touches `scope.yaml`. See `reference/FEEDBACK_RECORD.md`.104105## Ontology as a discovery source106107During setup, Cortex Sense checks whether any Business Ontology domains are relevant to the current domain. If a match is found, it adds the domain plus its registered stage sources as a single `business_ontology` source; the build then reaches the domain's nodes, relationships, and stage-file contents behind the scenes. See `reference/ONTOLOGY_DISCOVERY.md` for the full contract: matching rules, script invocation, and output shape.108109The Ontology is a **consumer dependency at discovery time** — Cortex Sense reads from it; Business Ontology owns all writes. The reverse direction (Cortex Sense proposing improvements back to the Ontology) is the steward-driven `business-ontology/workflow/phase-2-enrich` path; see the enrichment-handoff section of `reference/ONTOLOGY_DISCOVERY.md`.110111## Not yet implemented112113The skill ships several capabilities as **explicit placeholders**, surfaced to the builder the first time they would otherwise mislead. The full list is in `reference/NOT_YET_IMPLEMENTED.md`. Major ones:114115- Build orchestration & the true in-flight build *state field* (running/done/failed). The `check build` verb gives **best-effort** status today by inference — see `reference/BUILD_STATUS.md`.116- Correction propagation across similar tables/metrics117- Native use-case object (replacement for stage-backed YAML)118- Content search of BI objects & external tables (discovery via search is supported; reading their internal queries/fields/row data is not — see `reference/DISCOVERY.md`)119- Horizon Context connector enablement (a platform must be connected to appear in search — Tableau / Power BI / Databricks / SQL Server / Postgres)120121## Output122123A persisted, versioned manifest for the domain context. See `reference/SCOPE_MANIFEST.md`.124125`<WORKSPACE_DIR>` and `<SKILL_DIR>` are placeholders the agent resolves from CoCo's working directory and the current skill location respectively.