Overview
This skill performs an end-to-end privilege audit for Cortex Agents. It discovers every
agent in the account, reads each agent's live spec to build a dependency tree, then runs
parallel SHOW GRANTS checks to identify privilege gaps for a target role. Results are
presented per-agent with ✅ / ❌ status and a one-click remediation script is generated
for any gaps found.
When to Use
Use this skill when you need to:
- Verify that a role (e.g.
PUBLIC, READER, a custom app role) can call one or more Cortex Agents end-to-end.
- Identify missing
USAGE grants on agents, semantic views, Cortex Search services, UDFs, or warehouses.
- Generate a ready-to-run remediation script for access gaps.
- Audit a newly created agent before rolling it out to users.
When NOT to Use
| Topic |
Delegate to |
| Designing or refactoring a role hierarchy |
rbac |
| Writing masking / row access policies |
data-governance |
| Warehouse credit or cost analysis |
cost-intelligence |
Workflow
Discover agents — Run SHOW AGENTS IN ACCOUNT;. Fall back to
SELECT agent_catalog, agent_schema, agent_name FROM SNOWFLAKE.ACCOUNT_USAGE.CORTEX_AGENTS
if that errors. Present the list and confirm scope with the user (all agents or a subset).
Ask for the role — Ask: "Which role should I audit? (e.g. PUBLIC, READER, MY_CUSTOM_ROLE)"
Wait for the answer before proceeding.
Read agent specs in parallel — For every agent in scope call semantic_studio with
action: cortex_agent_read, source: snowflake, fqn: <DB.SCHEMA.AGENT>. Extract all
dependencies: semantic views, Cortex Search services, UDFs, warehouses, and any table
FQNs found in instructions.
⚠️ If a spec result is trimmed or unavailable, fall back to fetching that agent's spec
individually in a separate call rather than skipping it. Never assume an empty spec means
no dependencies.
Check grants in parallel — For each dependency run the matching
SHOW GRANTS ON <object_type> <fqn>:
| Object type |
Required privilege |
SQL |
| Agent |
USAGE |
SHOW GRANTS ON AGENT <fqn> |
| Semantic view |
SELECT |
SHOW GRANTS ON SEMANTIC VIEW <fqn> |
| Cortex Search service |
USAGE |
SHOW GRANTS ON CORTEX SEARCH SERVICE <fqn> |
| Function / UDF |
USAGE |
SHOW GRANTS ON FUNCTION <fqn>(<arg_types>) |
| Warehouse |
USAGE |
SHOW GRANTS ON WAREHOUSE <name> |
| Table |
SELECT |
SHOW GRANTS ON TABLE <fqn> |
Also run SHOW GRANTS TO ROLE <target_role> and recurse up parent roles via
SHOW GRANTS TO ROLE <parent_role>. Inherited grants are sufficient — only flag a gap
when neither the role itself nor any ancestor holds the required privilege.
Present the gap report — Produce a Markdown table grouped by agent with columns
Object | Type | Required Privilege | Status. Summarise: agents checked, dependencies
checked, gaps found. Stop here if there are no gaps.
Offer remediation — Generate one GRANT statement per gap. Ask:
"Found N gap(s) — execute the GRANTs now (Yes) or show for copy-paste (No)?"
On Yes, run each statement and confirm success or report the error. On failure,
suggest switching to SYSADMIN or ACCOUNTADMIN.
Common Mistakes
- Missing inherited grants — Always resolve the full role hierarchy before flagging a
gap; a privilege on any parent role is sufficient.
- Inventing FQNs — Only audit objects confirmed in the agent spec or via catalog search.
Never guess object names.
- Wrong role for GRANTs —
GRANT statements require SYSADMIN or ACCOUNTADMIN.
Remind the user to switch roles if a GRANT fails with an insufficient-privileges error.
- SELECT vs REFERENCES on semantic views — Both privileges appear in grants output;
either counts as sufficient read access.
Examples
Audit all agents for PUBLIC:
"Check which Cortex Agents the PUBLIC role can access."
Expected output: a gap table grouped by agent showing ✅ / ❌ for every dependency
(agent USAGE, semantic view SELECT, search service USAGE, function USAGE, warehouse USAGE),
followed by a remediation script for any gaps.
Audit a single agent for a custom role:
"Can the ANALYST role call the FUNDRAISING_ANALYST agent?"
Expected output: single-agent gap table; if all grants are present, reports no gaps and stops.
Execute remediation:
"Fix the missing grants for PUBLIC on CONSUME.ELTERNBRIEF.ELTERNBRIEF_ANALYST."
Expected output: targeted GRANT statements executed one by one, each confirmed or the error reported.
Stopping Points
⚠️ STOPPING POINT — After presenting the agent list (Step 1), confirm scope before proceeding.
⚠️ STOPPING POINT — After the role is confirmed (Step 2), wait for explicit approval before reading any agent specs.
⚠️ STOPPING POINT — After presenting the gap report (Step 5), wait for explicit user
confirmation before executing any GRANT statements. RBAC changes are easy to apply but
can inadvertently expose sensitive data if the wrong role is targeted.
1---2name: check-agent-access3description: Audits all (or selected) Cortex Agents in a Snowflake account. For each agent the skill reads the live specification, extracts every dependency (semantic views, Cortex Search services, UDFs, warehouses, tables), then checks whether a user-supplied role holds the required privilege on each object — including inherited grants via role hierarchy. Results are presented as a gap table grouped by agent, followed by an optional one-click remediation script. Triggers: check agent access, audit agent privileges, who can use my agents, role access to agents, missing agent grants, grant agent usage, agent USAGE check, PUBLIC can't call agent, fix agent permissions, check role permissions for Cortex Agent. Do NOT use for: general RBAC design (use `rbac`), warehouse credit audits, or auditing non-agent Snowflake objects.4---56## Overview78This skill performs an end-to-end privilege audit for Cortex Agents. It discovers every9agent in the account, reads each agent's live spec to build a dependency tree, then runs10parallel `SHOW GRANTS` checks to identify privilege gaps for a target role. Results are11presented per-agent with ✅ / ❌ status and a one-click remediation script is generated12for any gaps found.1314## When to Use1516Use this skill when you need to:1718- Verify that a role (e.g. `PUBLIC`, `READER`, a custom app role) can call one or more Cortex Agents end-to-end.19- Identify missing `USAGE` grants on agents, semantic views, Cortex Search services, UDFs, or warehouses.20- Generate a ready-to-run remediation script for access gaps.21- Audit a newly created agent before rolling it out to users.2223## When NOT to Use2425| Topic | Delegate to |26|---|---|27| Designing or refactoring a role hierarchy | `rbac` |28| Writing masking / row access policies | `data-governance` |29| Warehouse credit or cost analysis | `cost-intelligence` |3031## Workflow32331. **Discover agents** — Run `SHOW AGENTS IN ACCOUNT;`. Fall back to34 `SELECT agent_catalog, agent_schema, agent_name FROM SNOWFLAKE.ACCOUNT_USAGE.CORTEX_AGENTS`35 if that errors. Present the list and confirm scope with the user (all agents or a subset).36372. **Ask for the role** — Ask: *"Which role should I audit? (e.g. PUBLIC, READER, MY_CUSTOM_ROLE)"*38 Wait for the answer before proceeding.39403. **Read agent specs in parallel** — For every agent in scope call `semantic_studio` with41 `action: cortex_agent_read, source: snowflake, fqn: <DB.SCHEMA.AGENT>`. Extract all42 dependencies: semantic views, Cortex Search services, UDFs, warehouses, and any table43 FQNs found in `instructions`.4445 ⚠️ If a spec result is trimmed or unavailable, fall back to fetching that agent's spec46 individually in a separate call rather than skipping it. Never assume an empty spec means47 no dependencies.48494. **Check grants in parallel** — For each dependency run the matching50 `SHOW GRANTS ON <object_type> <fqn>`:5152 | Object type | Required privilege | SQL |53 |---|---|---|54 | Agent | `USAGE` | `SHOW GRANTS ON AGENT <fqn>` |55 | Semantic view | `SELECT` | `SHOW GRANTS ON SEMANTIC VIEW <fqn>` |56 | Cortex Search service | `USAGE` | `SHOW GRANTS ON CORTEX SEARCH SERVICE <fqn>` |57 | Function / UDF | `USAGE` | `SHOW GRANTS ON FUNCTION <fqn>(<arg_types>)` |58 | Warehouse | `USAGE` | `SHOW GRANTS ON WAREHOUSE <name>` |59 | Table | `SELECT` | `SHOW GRANTS ON TABLE <fqn>` |6061 Also run `SHOW GRANTS TO ROLE <target_role>` and recurse up parent roles via62 `SHOW GRANTS TO ROLE <parent_role>`. Inherited grants are sufficient — only flag a gap63 when neither the role itself nor any ancestor holds the required privilege.64655. **Present the gap report** — Produce a Markdown table grouped by agent with columns66 **Object | Type | Required Privilege | Status**. Summarise: agents checked, dependencies67 checked, gaps found. Stop here if there are no gaps.68696. **Offer remediation** — Generate one `GRANT` statement per gap. Ask:70 *"Found N gap(s) — execute the GRANTs now (Yes) or show for copy-paste (No)?"*71 On **Yes**, run each statement and confirm success or report the error. On failure,72 suggest switching to `SYSADMIN` or `ACCOUNTADMIN`.7374## Common Mistakes7576- **Missing inherited grants** — Always resolve the full role hierarchy before flagging a77 gap; a privilege on any parent role is sufficient.78- **Inventing FQNs** — Only audit objects confirmed in the agent spec or via catalog search.79 Never guess object names.80- **Wrong role for GRANTs** — `GRANT` statements require `SYSADMIN` or `ACCOUNTADMIN`.81 Remind the user to switch roles if a GRANT fails with an insufficient-privileges error.82- **SELECT vs REFERENCES on semantic views** — Both privileges appear in grants output;83 either counts as sufficient read access.8485## Examples8687**Audit all agents for PUBLIC:**88> "Check which Cortex Agents the PUBLIC role can access."8990Expected output: a gap table grouped by agent showing ✅ / ❌ for every dependency91(agent USAGE, semantic view SELECT, search service USAGE, function USAGE, warehouse USAGE),92followed by a remediation script for any gaps.9394**Audit a single agent for a custom role:**95> "Can the ANALYST role call the FUNDRAISING_ANALYST agent?"9697Expected output: single-agent gap table; if all grants are present, reports no gaps and stops.9899**Execute remediation:**100> "Fix the missing grants for PUBLIC on CONSUME.ELTERNBRIEF.ELTERNBRIEF_ANALYST."101102Expected output: targeted GRANT statements executed one by one, each confirmed or the error reported.103104---105106## Stopping Points107108⚠️ **STOPPING POINT** — After presenting the agent list (Step 1), confirm scope before proceeding.109110⚠️ **STOPPING POINT** — After the role is confirmed (Step 2), wait for explicit approval before reading any agent specs.111112⚠️ **STOPPING POINT** — After presenting the gap report (Step 5), wait for explicit user113confirmation before executing any `GRANT` statements. RBAC changes are easy to apply but114can inadvertently expose sensitive data if the wrong role is targeted.