.cortex/skills/routing-agent/SKILL.md
Create Snowflake Intelligence agent for OpenRouteService routing functions. Use when: setting up ORS demo, creating route planning agent, integrating directions/isochrones/optimization with Cortex. Do NOT use for: deploying fleet intelligence demos, route deviation analysis, or changing ORS configuration. Triggers: openrouteservice demo, routing agent, ORS agent, routing intelligence.
npx skillsauth add snowflake-labs/sfguide-create-a-route-optimisation-and-vehicle-route-plan-simulator routing-agentInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Create a Snowflake Intelligence agent that provides AI-powered route planning using OpenRouteService functions with natural language geocoding.
| Parameter | Default | Description |
|-----------|---------|-------------|
| DATABASE | FLEET_INTELLIGENCE | Target database for all objects |
| SCHEMA | ROUTING_AGENT | Schema for agent procedures and agent definition |
| WAREHOUSE | ROUTING_ANALYTICS | Warehouse for geocoding and routing queries |
| AGENT_NAME | ROUTING_AGENT | Name of the Cortex Agent to create |
DIRECTIONS, ISOCHRONES, OPTIMIZATION| Privilege | Scope | Reason | |-----------|-------|--------| | CREATE DATABASE | Account | Creates FLEET_INTELLIGENCE database | | CREATE WAREHOUSE | Account | Creates ROUTING_ANALYTICS warehouse | | USAGE ON DATABASE FLEET_INTELLIGENCE | Database | Uses the setup database | | CREATE SCHEMA | Database (FLEET_INTELLIGENCE) | Creates ROUTING_AGENT schema | | CREATE PROCEDURE | Schema (FLEET_INTELLIGENCE.ROUTING_AGENT) | Creates TOOL_DIRECTIONS, TOOL_ISOCHRONE, TOOL_OPTIMIZATION | | CREATE CORTEX AGENT | Schema (FLEET_INTELLIGENCE.ROUTING_AGENT) | Creates ROUTING_AGENT | | USAGE ON DATABASE OPENROUTESERVICE_NATIVE_APP | Database | Calls ORS DIRECTIONS, ISOCHRONES, OPTIMIZATION functions | | SNOWFLAKE.CORTEX_USER | Database role | Enables AI_COMPLETE calls for geocoding |
Note: ACCOUNTADMIN is NOT required. Create a custom role with the above privileges, or use any role that has them.
Follow the Error Logging convention in AGENTS.md. Log file prefix:
routing-agent.
snowflake_sql_execute tool call.SET session variables.No seed data or pre-computed tables required. The routing agent consists of stored procedures and a Cortex Agent definition. Run the SQL from references/agent-definitions.md to create all objects, then proceed to Step 1.
All stored procedure and agent SQL definitions are in references/agent-definitions.md.
Set session query tag for attribution tracking.
ALTER SESSION SET query_tag = '{"origin":"sf_sit-is-fleet","name":"oss-deploy-snowflake-intelligence-routing-agent","version":{"major":1, "minor":0},"attributes":{"is_quickstart":1, "source":"sql"}}';
2a. Check functions exist:
SHOW USER FUNCTIONS IN SCHEMA OPENROUTESERVICE_NATIVE_APP.CORE;
Verify: DIRECTIONS(VARCHAR, VARIANT), ISOCHRONES(VARCHAR, FLOAT, FLOAT, NUMBER), OPTIMIZATION(VARIANT, VARIANT). If missing, install the OpenRouteService Native App.
2b. Check services are running (CRITICAL):
SHOW SERVICES IN SCHEMA OPENROUTESERVICE_NATIVE_APP.CORE;
Required services (all must be RUNNING): ORS_SERVICE, VROOM_SERVICE, ROUTING_GATEWAY_SERVICE. If any is SUSPENDED, resume with CALL OPENROUTESERVICE_NATIVE_APP.CORE.RESUME_ALL_SERVICES(); and verify with SELECT OPENROUTESERVICE_NATIVE_APP.CORE.CHECK_HEALTH();.
Create dedicated objects for the routing agent.
CREATE DATABASE IF NOT EXISTS FLEET_INTELLIGENCE
COMMENT = '{"origin":"sf_sit-is-fleet", "name":"oss-deploy-snowflake-intelligence-routing-agent", "version":{"major":1, "minor":0}, "attributes":{"is_quickstart":1, "source":"sql"}}';
CREATE SCHEMA IF NOT EXISTS FLEET_INTELLIGENCE.ROUTING_AGENT
COMMENT = '{"origin":"sf_sit-is-fleet", "name":"oss-deploy-snowflake-intelligence-routing-agent", "version":{"major":1, "minor":0}, "attributes":{"is_quickstart":1, "source":"sql"}}';
CREATE WAREHOUSE IF NOT EXISTS ROUTING_ANALYTICS
WAREHOUSE_SIZE = 'XSMALL' AUTO_SUSPEND = 60 AUTO_RESUME = TRUE
COMMENT = '{"origin":"sf_sit-is-fleet", "name":"oss-deploy-snowflake-intelligence-routing-agent", "version":{"major":1, "minor":0}, "attributes":{"is_quickstart":1, "source":"sql"}}';
Wraps ORS DIRECTIONS with AI geocoding (claude-sonnet-4-5) so users can describe locations in natural language. Returns distance_km, duration_mins, segments, and geometry on success; structured error on failure.
CREATE OR REPLACE PROCEDURE FLEET_INTELLIGENCE.ROUTING_AGENT.TOOL_DIRECTIONS(...)
-- Full definition: see references/agent-definitions.md
Full SQL: references/agent-definitions.md § TOOL_DIRECTIONS
Wraps ORS ISOCHRONES with AI geocoding. Accepts a location description and range in minutes; returns area_km2 and geometry polygon on success.
CREATE OR REPLACE PROCEDURE FLEET_INTELLIGENCE.ROUTING_AGENT.TOOL_ISOCHRONE(...)
-- Full definition: see references/agent-definitions.md
Full SQL: references/agent-definitions.md § TOOL_ISOCHRONE
Python procedure wrapping ORS OPTIMIZATION. Geocodes delivery locations and depot, builds VROOM-compatible jobs/vehicles arrays, and returns optimized routes with unassigned-job detection.
CREATE OR REPLACE PROCEDURE FLEET_INTELLIGENCE.ROUTING_AGENT.TOOL_OPTIMIZATION(...)
-- Full definition: see references/agent-definitions.md
Full SQL: references/agent-definitions.md § TOOL_OPTIMIZATION
Create a Cortex Agent (ROUTING_AGENT) with three tool bindings pointing to the procedures above.
CREATE OR REPLACE AGENT FLEET_INTELLIGENCE.ROUTING_AGENT.ROUTING_AGENT
-- Full definition: see references/agent-definitions.md
Full SQL: references/agent-definitions.md § CREATE AGENT
Note: This step requires Snowflake Intelligence to be configured on the account. The agent is fully functional via direct
INVOKE_AGENTcalls without SI registration.
Check if Snowflake Intelligence is available:
SHOW SNOWFLAKE INTELLIGENCE;
If this returns an error or no results, skip the rest of this step.
Register the agent:
ALTER SNOWFLAKE INTELLIGENCE SNOWFLAKE_INTELLIGENCE_OBJECT_DEFAULT
ADD AGENT FLEET_INTELLIGENCE.ROUTING_AGENT.ROUTING_AGENT;
Test queries must use locations within the ORS-configured region. To determine the region:
DESCRIBE SERVICE OPENROUTESERVICE_NATIVE_APP.CORE.ORS_SERVICE;
Parse the spec to find the configured region name from /home/ors/files/<REGION_NAME>.osm.pbf.
Before testing, verify all services are RUNNING (see Step 2b).
Sample queries by region:
| Region | Directions | Isochrone | Optimization | |--------|-----------|-----------|--------------| | San Francisco | "Driving directions from Union Square to Fisherman's Wharf" | "Areas reachable within 15 min by car from Union Square" | "Optimize deliveries to Ferry Building, Pier 39, Ghirardelli Square — 2 vehicles from Union Square" | | New York | "Driving directions from Times Square to Central Park" | "Areas reachable within 15 min by car from Grand Central" | "Optimize deliveries to Empire State, Rockefeller Center, Times Square — 2 vehicles from Grand Central" | | London | "Driving directions from Tower Bridge to Buckingham Palace" | "Areas reachable within 15 min by car from King's Cross" | "Optimize deliveries to British Museum, Tower of London, Westminster Abbey — 2 vehicles from Trafalgar Square" | | Berlin | "Driving directions from Brandenburg Gate to Alexanderplatz" | "Areas reachable within 15 min by car from Hauptbahnhof" | "Optimize deliveries to Reichstag, Checkpoint Charlie, East Side Gallery — 2 vehicles from Alexanderplatz" |
Use central city locations as depots.
Get org/account names, then open the UI:
SELECT CURRENT_ORGANIZATION_NAME() AS org_name, CURRENT_ACCOUNT_NAME() AS account_name;
Open: https://ai.snowflake.com/<org_name>/<account_name>/#/ai
User says: "Create a routing agent" Actions:
User says: "Test the routing agent with London locations" Actions:
DESCRIBE SERVICE check)FLEET_INTELLIGENCEFLEET_INTELLIGENCE.ROUTING_AGENTROUTING_ANALYTICS| Issue | Solution |
|-------|----------|
| Agent not visible in UI | Run ALTER SNOWFLAKE INTELLIGENCE ... ADD AGENT |
| Geocoding fails | Check Cortex AI access and model availability |
| Empty directions | Verify ORS map data covers the requested region |
| Routing functions fail | Check service status with SHOW SERVICES IN SCHEMA OPENROUTESERVICE_NATIVE_APP.CORE; and resume suspended services |
To remove all objects created by this skill:
-- Reverse dependency order: agent first, then procedures, schema, warehouse, database
DROP CORTEX AGENT IF EXISTS FLEET_INTELLIGENCE.ROUTING_AGENT.ROUTING_AGENT;
DROP PROCEDURE IF EXISTS FLEET_INTELLIGENCE.ROUTING_AGENT.TOOL_OPTIMIZATION(VARCHAR, VARCHAR, NUMBER);
DROP PROCEDURE IF EXISTS FLEET_INTELLIGENCE.ROUTING_AGENT.TOOL_ISOCHRONE(VARCHAR, NUMBER);
DROP PROCEDURE IF EXISTS FLEET_INTELLIGENCE.ROUTING_AGENT.TOOL_DIRECTIONS(VARCHAR, VARCHAR);
DROP SCHEMA IF EXISTS FLEET_INTELLIGENCE.ROUTING_AGENT;
DROP WAREHOUSE IF EXISTS ROUTING_ANALYTICS;
Tip: Use the
cleanupskill to auto-discover all tagged objects via COMMENT tracking.
tools
Optimize, audit, create, and improve Cortex Code skills following official best practices from the Anthropic skill-building guide. Use when: creating a new skill, reviewing an existing skill, optimizing skill description or triggers, improving SKILL.md structure, auditing skill quality, fixing undertriggering or overtriggering, restructuring skill for progressive disclosure. Do NOT use for: general code review, non-skill markdown editing, MCP server development. Triggers: optimize skill, audit skill, review skill, create skill, improve skill, fix skill triggers, skill best practices, skill quality check.
testing
Discover and remove all Snowflake objects created by skills in this repo. Uses the COMMENT tracking tag (sf_sit-is-fleet) to find objects, generates DROP statements, and optionally executes them. Use when: cleaning up after a demo, removing all skill-created objects, tearing down an environment, uninstalling a specific skill's objects. Do NOT use for: dropping objects not created by these skills, production environment cleanup without review. Triggers: routing-solution-cleanup, cleanup, teardown, remove, uninstall, drop all, clean up demo, remove skill objects, reset environment.
tools
Check and install build prerequisites for the Routing Solution project. Use when: verifying environment setup before building, checking if Docker/Podman/snow CLI are installed, confirming readiness to build. Do NOT use for: building the routing solution itself (use build-routing-solution), deploying demos, or changing ORS configuration. Triggers: check prerequisites, check build prerequisites, am I ready to build, what do I need installed, verify environment setup, Docker installed, Podman installed, snow CLI installed.
tools
Enable or disable ORS routing profiles (driving-car, driving-hgv, cycling, walking, wheelchair). Subskill of routing-customization — must be invoked from the router, not independently. Use when: changing vehicle types as part of customization workflow. Do NOT use for: standalone execution, changing map region, or deploying demo apps. Triggers: change routing profile, change vehicle type, enable profile, disable profile.