Skip to content

Get started with a coding agent

This tutorial shows you how to use a coding agent and RelationalAI skills to turn raw CSV files into a working semantic model you can query and refine.

You’ll learn how to:

  • Set up your environment and install the RAI agent skills with a coding agent.
  • Build a semantic model from sample CSV files with the rai-build-starter-ontology skill.
  • Use the rai-discovery skill to turn a business question into a prompt.
  • Run the refined prompt to get real answers grounded in your model and data.
  • You have access to a Snowflake account with the RelationalAI (RAI) Native App installed.

    How do I know if the RAI Native App is installed? To check if the RAI Native App is installed in your Snowflake account:

    1. Log in to your Snowflake account.
    2. Run the following SQL command in a worksheet:
      SHOW APPLICATIONS;
    3. Check the output for an application named RELATIONALAI.
      • If you see it listed, the RAI Native App is installed.
      • If not, you need to install it.

    How do I install the RAI Native App? See Install the RAI Native App for Snowflake for instructions.

  • You have a Snowflake user with the RAI_DEVELOPER database role.

    How do I check my roles? To check your roles in Snowflake:

    1. Log in to your Snowflake account.
    2. Run the following SQL command in a worksheet:
      SHOW GRANTS TO USER <your_username>;
    3. Check the output in the name column for the RAI_DEVELOPER role.
      • If you see it listed, you have the required role.
      • If not, contact your Snowflake account administrator to have the role assigned to you. See Set Up User Access for the RAI Native App for more information.

Copy and paste the following prompt into your coding agent to install the RAI agent skills for your preferred coding agent:

Install the RelationalAI Agent Skills (https://github.com/RelationalAI/rai-agent-skills) for this environment. Provide me with instructions on how to keep up-to-date and leverage them across projects. Once installed, print the skill inventory given in the README.
  1. Gather your Snowflake connection details.

    You will need:

    DetailWhere to find it
    AccountLog in to the Snowflake account that has the RAI Native App installed. Execute the following SQL command in a worksheet to find your account name:
    SELECT CURRENT_ORGANIZATION_NAME() || '-' || CURRENT_ACCOUNT_NAME() AS account_identifier;
    UserThe Snowflake username you will use to connect. This user must have the RAI_DEVELOPER role.
    PasswordThe password you use to log in to Snowflake.
    WarehouseThe name of the Snowflake warehouse you want to use to execute SQL queries. Can be any existing X-SMALL or larger warehouse.
  2. Install RAI and set up your project environment.

    Both the agent prompt and manual steps below make use of the uv package manager because it manages project environments and package installation with one tool. This makes it easier to keep your agent’s Python setup isolated from the rest of your machine.

    Copy and paste the following prompt into your coding agent to install RAI and set up your project environment using the rai-setup skill:

    /rai-setup Use uv (install if missing) to create a new project called my-first-rai-project using version of Python supported by RelationalAI. Then use uv to install the relationalai package in this new project environment. Try to connect to Snowflake using the external browser method. Ask me one item at a time for the required connection details. If external browser authentication fails because my Snowflake account doesn't support it, update the configuration to use username/password authentication instead. In that case, use a placeholder for the password and instruct me to edit the configuration file with the real password when you are done.
    • Uses uv to install relationalai and create the project environment if needed.
    • Creates or updates raiconfig.yaml with your Snowflake connection settings.
    • Tries to connect to Snowflake using external browser authentication, which opens a browser window for you to log in with your Snowflake credentials.
    • If external browser authentication is not set up for your account, this falls back to username/password authentication and prompts you to edit the config file with your password.
  3. Verify your connection with rai connect.

    In your terminal, run:

    Terminal window
    uv run rai connect

    You should see a success message confirming that you are connected to Snowflake.

This tutorial uses sample CSV files from the Energy Grid Planning template. The template models an ERCOT-style grid planning scenario for evaluating AI data center interconnection requests against existing capacity and possible infrastructure upgrades.

The sample data includes six CSV files covering:

  • Substations
  • Generators
  • Transmission lines
  • Demand forecasts
  • Pending data center requests
  • Candidate substation upgrades

Follow these steps to download the sample data and add it to your project.

Copy and paste the following prompt into your coding agent to download the sample data and place it in your project:

Download the Energy Grid Planning sample data from https://docs.relational.ai/templates/zips/v1/energy_grid_planning.zip into my current project.
Extract the zip, copy the `data/` directory from the extracted `energy_grid_planning` folder into my project root as `./data`, and then clean up the downloaded zip file and extracted folder.

Now that you have some data, let’s use RelationalAI’s agent skills to build a semantic model and help you answer a complex business question.

RelationalAI semantic models are built using PyRel, a Python DSL for declaratively defining concepts, properties, relationships, and connecting them to your data.

Use the rai-build-starter-ontology skill to build a PyRel semantic model based on the sample data.

  1. Invoke the rai-build-starter-ontology skill.

    Copy and paste the following prompt into your coding agent:

    /rai-build-starter-ontology Build an ontology for grid infrastructure planning from the CSVs in data/ covering substations, generators, transmission lines, demand forecasts, data center requests, and substation upgrades. Write the code to a file named energy_grid.py in the project root and execute it to run the validation queries.
  2. Choose one-shot mode.

    The agent will prompt you to choose between one-shot and guided mode. For this tutorial, select one-shot mode so the agent generates the entire model in a single response.

  • Analyzes the CSV files in /data to infer the domain model.
  • Identifies the concepts, properties, and relationships to include in the PyRel semantic model.
  • Writes a PyRel model with validation queries.
  • A complete energy_grid.py model with concepts, relationships, and validation queries.
  • If the agent skips validation, run uv run energy_grid.py yourself.
  • Iterate with your agent until all validation queries pass.

To help you understand the structure of the model you just built, use the rai-querying skill to visualize the ontology as a concept-relationship diagram and report row counts per concept.

Copy and paste the following prompt into your coding agent to invoke the skill:

/rai-querying Show the ontology as a concept-relationship diagram and report row counts per concept.
  • Generates a concept-relationship diagram of your model so you can inspect its structure.
  • A diagram with concepts as boxes and relationships as labeled arrows.
  • Some agents render it directly. Others return Mermaid code that you can render using a tool like Mermaid Live Editor.

Use the rai-discovery skill to refine your questions and choose the right skills and prompts. In this grid planning scenario, the goal is to decide which requests to approve and upgrades to fund.

Copy and paste the following prompt into your coding agent to invoke the skill:

/rai-discovery I need to determine which datacenter requests to approve and which upgrades to fund at what budget level. What combination of skills/prompts can I use to answer these questions? The prompt should give me an end-end-answer and explain the results for a non-technical business user. Give me copy-pastable options as:
OPTION N: <NAME>
<Describe the option in a few sentences.>
```
[/skill1 [+ /skill2 ...]] <PROMPT>
```
**Benefits:**
- Benefit 1
- Benefit 2
- ...
**Trade-offs:**
- Trade-off 1
- Trade-off 2
- ...
  • Checks whether your question is feasible with your model and data.
  • Recommends which skills to use and how to combine them.
  • Returns copy-paste prompts with the benefits and trade-offs of each option.
  • Expect several skill combinations for different solution paths.
  • Common choices include:
    • rai-rules-authoring for rule-based reasoning
    • rai-prescriptive-problem-formulation for optimization
    • rai-graph-analysis for network analysis

Pick one of the options from the previous step. Then paste its prompt into your coding agent to run the required skills.

For example, Option 2 in the previous step’s sample output shows how graph and prescriptive can be used together to answer the question in a more nuanced way:

[/rai-graph-analysis + /rai-prescriptive-problem-formulation + /rai-prescriptive-results-interpretation] First analyze the transmission network in the energy_grid ontology to identify structurally critical substations and constrained corridors. Then use those graph outputs in a prescriptive optimization that decides which DataCenterRequest records to approve and which SubstationUpgrade records to fund across multiple budget levels. Optimize for business value while penalizing plans that overload or over-concentrate demand on structurally critical substations. Give me an end-to-end answer for a non-technical business audience: explain the approval and upgrade recommendation by budget level, describe the grid-risk trade-offs in plain English, identify which substations are strategic bottlenecks, and recommend the budget level that gives the best balance of growth, resilience, and upgrade spend.
  • Adds a criticality score to each Substation in energy_grid.py using RAI’s graph reasoning capabilities.
  • Uses those scores in a prescriptive optimization problem.
  • Runs the optimization using a prescriptive reasoner in the RAI Native App.
  • Summarizes which data centers to approve, which upgrades to fund, and why.
  • A second Python script in addition to energy_grid.py with a name like dc_approval_optimizer.py or energy_grid_investment_plan.py.
  • A results summary in your chat showing explaining the recommended approvals and upgrades.

You now know how to use RelationalAI’s agent skills to build a semantic model, inspect its structure, and apply it to a real business question.

By completing this tutorial, you saw that:

  • RelationalAI can model your business domain semantically.
  • Reasoners support graph analysis, rules, and optimization without complex data pipelines or moving data into separate systems.
  • Agent skills can build and refine a semantic model from prompts.
  • You can use skills to answer real business questions with answers grounded in your data and semantic model.