Claude Code + Snowflake: The Productivity Game-Changer
By Kyle Chalmers | Data + AI
Summary
Topics Covered
- AI-Data Warehouse Integration 10x's Productivity
- CLI Exports Data Efficiently, Uses Fewer Tokens
- Claude Auto-Generates Data Catalogs and Analysis
- Bypass Permissions Frees Time for Parallel Tasks
- MCP Enables Seamless Claude Desktop Integration
Full Transcript
Hello. Today I'm going to show you the key integration that really was a light bulb moment for me when unlocking
productivity with AI. Connecting AI and your data warehouse will 10x your productivity as I know it has for me.
I've seen other people on my team utilize tools like Claude Code and Claude integrated with their SQL data
warehouses in order to ask questions to claude, have it build data pipelines, look at data architecture, look at everything within your database and give
it the context that it needs to understand that and have immense success with seeing more efficient, more effective SQL queries that otherwise
would have taken us humans a very very long time to write. This is the first step that I had and hopefully the first step for those of you who are learning
this for the first time to unlock AI in your day-to-day work and it immensely expands what is possible and how
productive you can be and it is the jumping off point I found for everything else that you can integrate AI with in your data analytics workflow as it
exists today By the end of this video, you will have learned how to connect Snowflake to Claude and Claude Code and what you can do with Claude after
connecting it to Snowflake and how that can unlock your productivity gains. So
before hopping in, let's talk about tools real quick. For this video, I'm going to be using Claude and Claude Code. And those generally will be my
Code. And those generally will be my preferred tools moving forward for future demos and future videos I do. For
anyone who's not familiar with cloud code, it is essentially cloud that you can access in your terminal and it can access files and folders and all the different structures that you have
stored in your local computer. You do
need a pro account, which I believe costs, as of the recording of this video, about $20 a month, but you should be able to follow along this demo with
other LLMs that you use like chat GBT or uh Gemini or Cursor as well.
Additionally, I have Snowflake as my data warehouse. uh you can follow
data warehouse. uh you can follow similar approaches with MySQL, Postgress, SQL, Redshift or other SQLbased databases. Um for Snowflake
SQLbased databases. Um for Snowflake specifically, if you want to follow along my workflow, you can open an account for free and you end up just paying for the storage and compute costs
associated with each query that you issue. I am using a Mac, but again, you
issue. I am using a Mac, but again, you should be able to follow this workflow via Windows. And while I'm not demoing
via Windows. And while I'm not demoing other data warehouses or other LLMs, uh this framework generally applies to all those other tools as I previous
mentioned. But if there are specific
mentioned. But if there are specific other LLMs or other data warehouses that you'd like me to walk you guys through, then please let me know in the comments.
But other than that, let's actually dive into the content of this video.
All right. So, I will be sharing all of the links for all the resources and materials that I reference throughout this video in the description below, as
well as this repository, which has the instructions guides, as well as a bunch of other helpful documents and documentation for how I ran through my
testing later in the video. I really
have done a lot of research to make this super seamless for you guys to actually integrate these systems and get the power that you can out of this Snowflake
and Claude partnership. That said, we're going to be integrating Snowflake with Claude in two different ways today. We
have the Snowflake command line interface, the Snowflake CLI and the Snowflake MCP or model context protocol.
So what is the difference between these two different methods for seemingly accomplishing the same things? Well, the
CLI I'll say is the one I utilize more frequently and generally prefer. It's
better for exporting data out of your Snowflake and onto your desktop and it takes a lot less tokens, but it doesn't
have some of the access configurations and native integrations that the Snowflake MCP has where you can actually
put the MCP inside of claw desktop as well. So that's why I think it's very
well. So that's why I think it's very valuable to talk through both the CLI and the MCP.
And what we'll be doing is referencing the setup guides that I have for the CLI
as well as the MCP as a basis for the remainder of this video. To install
Snowflake CLI, what you'll need first need to do is have open a terminal window and then you can just really follow the instructions that Snowflake gives you here. Again, if you have a
Windows or Linux machine or you want to do it following some other method, uh there are the other instructions on the same web page that I will link below.
But I already have Homebrew installed, which you can install it here if necessary and you want to follow along that specific way.
And really what I've done is just copy and pasted these commands that are below here. And I will click run. Okay. So it
here. And I will click run. Okay. So it
looks like the install finished. And so
for me to test it, I'll just do snowel.
And there we go. It's working here. And now
the key step in this process is going to actually be setting up a connection. To
set up that connection, I've opened up a new terminal tab to get a clean screen so we can go through all the connection details required there as well as the
documentation from Snake on configuring the Snowflake CLI.
So if I type in snow connection, we'll see the few commands here which will be add list set default test
and adding allows me to add a new connection. List allows me to see what I
connection. List allows me to see what I have. Set default makes that particular
have. Set default makes that particular connection my default. And then test allows me to test authentication.
And so if I say snow connection list here, uh I will see that I already have my particular connection set up and
that it is my default. So these are my details through which I connect to my snowflake account. Uh which shows you
snowflake account. Uh which shows you what you'll need handy here. uh where
you'll have the Snowflake account details. Uh in particular, your account
details. Uh in particular, your account are actually these uh uh first few characters that are head of Snowflake computing. You need your username,
computing. You need your username, password, uh the host, um which is everything including snowflakeing.com,
the port, um and what authentication method you want to utilize. Uh for this snow CLI, I have the JSON web token here, but the more common ones other
than this one for my particular setup uh which uses a private key file is username password MFA which you can
authenticate utilizing Duo or external browser which is an SSO authentication via web browser if you have SSO authentication set up for your
Snowflake. I'll add a uh connection here
Snowflake. I'll add a uh connection here that sets it up via username password MFA and we can test that uh to go
through that together. So I am going to say snow connection add um we will call
this one uh MFA on and then uh my account name is this.
And at this point in the video I'm going to pause fill this out and then we'll come back once I've filled this out. All
right. So, I've added my new connection here. We're on a new tab again uh
here. We're on a new tab again uh because I messed up a couple times while doing it. But this is the final uh
doing it. But this is the final uh corrected connection. You can see that I have uh
connection. You can see that I have uh the Snowflake account name. I've named
it uh multiffactor authentication connection. Uh I have this specific
connection. Uh I have this specific role. Now you may want to change the
role. Now you may want to change the role depending on the type of permissions you want cla to have. Uh I
like giving it permissions to even insert create drop different things and actually handle that structure within
the instructions I give Claude itself explicitly asking me the user for permission whenever I'm chatting with it before it runs any of those operations.
But that's up to you for how you want to permission it. If you have certain users
permission it. If you have certain users or generally just want to be a little bit more conservative with your approach to claude, uh then giving it a role
where it can't write or drop anything might be best for your use case. But
I'll leave that up to uh the person byperson use case for how they want to permission this particular uh connection with claude that snowflake has. I give
it a warehouse. Again, this is optional as well too. As you can see in the different uh bracketed criteria here
within the Snowflake connection, uh I give it the host, the port, and then the authentication method, which this is where I designate uh that I want to do it with multiffactor authentication. And
here's where the files ultimately save to, which you can actually go in and edit if you need to do it. So, let's
test it. And let me do snow connection test and then connection
then MFA con.
So, here we go. We're testing it. I got
my phone open here and I am waiting for the dual authentication. Ah, we can see it popped
authentication. Ah, we can see it popped up here. I'm going to approve it. And
up here. I'm going to approve it. And
yay. Uh, it's successfully connecting to my Snowflake. Now, now if I want to, uh,
my Snowflake. Now, now if I want to, uh, set this as my default. Again, we have
the command that is set default here.
So, I'm going to copy that. and snow
connection set default.
All right. So you can see now that my default connection is set to MFA con.
And so if I go to snow connection list and here we see it MFA con set to true
the account details and then the RSA con here um is no longer the default connection. So, we successfully set up
connection. So, we successfully set up Snowflake CLI and now let's actually do some of the fun stuff of running some
queries with it through Claude. So, I've
opened up cursor here to open claude and uh just one quick note here. I've
integrated into my repository here some permissions and some specific rules for cloud to operate by. So I always want it
to issue select queries meaning that it can read data as it desires to and then I need it to ask me permission before it
runs any destructive queries or creation queries. meaning you know this line here
queries. meaning you know this line here that's highlighted with update, alter, delete, drop, insert, create or replace, etc. too. And so these are some of the
etc. too. And so these are some of the guidelines that Claude has uh to help you instruct it for specific context
that it needs to operate. Um, and the command I like to do is I actually run claw dangerously skip permissions. Uh
what this does is it allows Claude to run and not ask for my permissions every single time that it does a specific
query or edits a specific file. So,
that's something that um you might just want to instead run claude when we're first starting this out because it gives you a little bit more control. But you
will have to be pressing a button essentially approving all the different actions that Claude takes. But for this use case, I will use the bypass
permissions. I'll kill this terminal
permissions. I'll kill this terminal here. Um, and this is within cursor, my
here. Um, and this is within cursor, my integrated development environment. It's
recommended that you run cloud code within a GitHub or GitLab repository because it can store all its work within
a repository very easily and you can review its output. And additionally, you can feed it context like I have in these
cla MD files or claude markdown files where you can specify cla code. Here are
some instructions. Here are some operating rules. Uh here are different
operating rules. Uh here are different things I want you to um you know govern yourself by. With that, I'm going to
yourself by. With that, I'm going to enter my test prompt here.
And one quick note, uh, make sure that the snow CLI you downloaded, uh, is the latest version, meaning 3.0 or above,
because that's going to be critical for us to exporting results as a CSV. If you
had Snow CLI previously and maybe it's from 2.8 or before, then you might want to upgrade that. Otherwise, if you just downloaded Snow CLI with me during this
tutorial, you should be fine. I am going to issue this query saying hey uh go to
this snowflake sample data information schema schema columns do a simple select uh put the query into SQL file output
into CSV format into this folder and let's see how it does that and one other neat trick with cloud code as you work with it with SQL
is I actually like to do plan mode first, especially if you're bypassing permissions. So, I will have it on plan
permissions. So, I will have it on plan mode and then it will output a plan to me that I can review for the actions going to take and then I can say yes,
this looks good or no, let me give you some feedback. This plan is very simple.
some feedback. This plan is very simple.
So, I'm going to say yes, this looks good and bypass permissions. So, here we go. Let me click one. Perfect. And if
go. Let me click one. Perfect. And if
you set up with MFA, make sure you have your phone handy so you can approve it um as it's accessing Snowflake. So, I'm
going to pause here, let it run, and then we'll come back here in a second.
All right, 20 seconds later or less, I am back and uh it has written a query and done the results CSV. So, there's
the query. There's the results. Um, and
again, super simple, easy example uh, for this. So, I thought I'd write up some prompts to take this to the next level and then also show you all how I
really get some pretty significant productivity gains out of this. So, what
I'll do is I'm going to split my terminal here. And this is a great thing
terminal here. And this is a great thing about Claude. Um, and you can do this
about Claude. Um, and you can do this with other uh, you know, CLI integrations like Gemini or Codeex for
OpenAI is I can have multiple them of them going at once. So, I'm going to copy and paste this prompt here, put it
in this one, and then I'm going to copy and paste this prompt here and put it in this one. So,
this one. So, um, in this prompt over here, I'm telling it to analyze my schema and
understand the joins between the tables, uh, give me a data catalog and then check if there's any duplicate primary keys while you're at it. So, I'm having
it build out documentation on my data architecture, which would be great for new hires, great for claude or your LLM to reference in the future as it's
querying your data. And then in this one, I'm asking it an analysis question.
I have a specific analysis ticket that came in to me and I need to know how many customers are from Canada and how many of them have bought something in the past month and what was their
average transaction side and the total amount was. And so what I'm going to do
amount was. And so what I'm going to do again start in plan mode and then plan mode.
And one of the reasons why I do bypass permissions too is it just makes it a lot quicker I find where I don't have to sit by my computer. And that's really
when I see the productivity gains from cloud is when I'm able to enable it and not approve all of the interactions it's having like I see in this window too
because if I didn't have it in bypass permissions mode then I would keep having to approve all those interactions too. Sometimes it asks you some
too. Sometimes it asks you some questions in plan mode. Let me approve this. And so let me answer these
this. And so let me answer these questions real quick. And I'm going to pause and then once I have both of plans, we'll come back here together.
All right. So the right side of my screen finished pretty quickly. We can
see I've dragged it over a little bit. I
answered some of the questions here for, you know, what the time period was, transaction tables, and then how to calculate transaction price. So, it's
asking really smart analysis questions that any good data analytics professional, data analyst might ask themselves as they go through this analysis. And then presents me this plan
analysis. And then presents me this plan where it's going to do some data exploration, develop a query analysis, go through some quality control and deliverables. And again, I have this set
deliverables. And again, I have this set to do some specific settings with this cloud file here. But you'll have access to that cloud file and can implement the same settings uh I've done here. So, I
feel good about this plan. So, let me go ahead and bypass permissions. And again,
that took 2 minutes. We'll let this run and I'll come back once this plan is done here. Okay. So Claude uh has some
done here. Okay. So Claude uh has some queries that are still running on some large fact tables, but it has a plan here. And really that's what I needed to
here. And really that's what I needed to do is I needed to explore and figure out what this data is. So I'm fine with those queries still running. And this
looks good for it to create all of the different dimension and fact table references and structures. I am going to
click yes. Go ahead. bypass it. And you
click yes. Go ahead. bypass it. And you
know, this is a task too where I I'll say I'm still iterating with AI where it might have been better instead of just going into plan mode, just having it go in and start querying. There's some
things and experimentation that you'll figure out as you continue to work with AI and data that maybe work better than others. If you all have uh any ways that
others. If you all have uh any ways that you work with claude that are really effective, I'd love to hear about them and I'd love to highlight those uh on
this channel as well. So my clouds are now running and this is what I'm talking about right when it mean when I'm saying that you can really you know 10x your
productivity because while these are running think I could be doing other tasks and you know or starting another session with claude if I really wanted
to get ambitious which I have done that before. It frees up a lot of my time and
before. It frees up a lot of my time and does this analysis a lot quicker than I ever would have just me sitting down and
writing SQL and analyzing all the tables in our database to understand the right uh structure for a data catalog here.
And as I'm talking, we can see, all right, all the outputs have been saved in uh a Canadian customer analysis
folder here. And I have it fi final
folder here. And I have it fi final deliverables in my QC queries here. And
all of them are labeled with numbers to make it very easy for me to understand.
So let me drag this down a little bit.
Look at my main analysis query. We see
it has some common table expressions, some CTE for identifying the Canadian customers. Looking at the uh dates,
customers. Looking at the uh dates, [snorts] uh December 2002. Uh I'm
curious why it does that. I assume it just took a sample date. Um or it's the most recent calendar month that's available in the sample data. Okay, that
makes sense. Um so it made that inference there and then goes through all sales um unioning the uh store
sales, web sales, catalog sales uh looking at the order totals from all those sales union uh and then gets me some metrics for the
Canadian customers. So I'm able to
Canadian customers. So I'm able to quality check the SQL it produces and then here's the main results that it has
for me. Uh and then the sales channel
for me. Uh and then the sales channel breakdown catalog store web. Uh we can have all this analysis here. And then
it's also done these uh QC queries here.
1 2 3 4 and then has an overall readme that it's outputed for this analysis.
And again, all this is very easy for me uh as the person who is reviewing it to make sure that this is correct. And so
if there's anything wrong, I I found say I actually meant to do this analysis
for the United States. Can you change Oh, realize we lost the visual into
that. Can you change the
that. Can you change the filter to the US and reproduce the output
overwriting the previous output?
So if I had something like that that I needed to do, I could give it that and then it's off to the races again, right,
for any adjustments that I need to make.
And here we can see that all right, this has created a data catalog now. Um so
let's check out that data catalog again.
Looks at fact tables, dimension tables, meaning dimension tables um which is great uh to understand
this um primary keys attributes. Wow,
this is great. And so every time that Claude would query this data again or you know I need to provide documentation about our database
to somebody uh I can give them this version and granted this might take a couple edits to get it exactly how I want it but it's done a lot of work in
terms of identifying the primary keys uh and the measures and the specific links uh to other tables. or joining criteria.
This is a great overview of Snowflake CLI. So hopefully you're really starting
CLI. So hopefully you're really starting to see the power of this. All right,
we've now set up the Snowflake CLI.
Now you can get started working with Claude and your CLI and our next step is to actually set up the Snowflake MCP.
What are the benefits that this MCP offers you that the CLI doesn't? Again,
it allows you to actually interact with Snowflake through Cloud Desktop and you can also utilize it to explore data
through cloud code as well. Although the
CLI is much better for exporting data and doing large data pools and for programming in general, you can utilize both. That's why I'm giving you both
both. That's why I'm giving you both options so you can understand which is better for you. And just to show you what Snowflake MCP does, if I type this
into Claude here saying, "Hey, can you issue a sample query to show me that the Snowflake MCP works?" It might think for a second and then it will actually run
the query.
All right, it's running the query, doing it against some sample data that I have.
Um, but it's utilizing the MCP server.
So, let's actually jump in and I am going to get this repo pulled up, the Snowflake
Labs MCP repo on my desktop and we can install this together.
All right, we have the Windows open that we need. Occupying the majority of my
we need. Occupying the majority of my screen is the Snowflake MCP repository which is the basis for everything that
we'll be doing for this section and it contains all the tools that Claude will utilize to access Snowflake. And then on this side is the Snowflake MCP setup
guide that I created for you all that is inside my data AI tickets template repo link that I will be providing for everyone in the YouTube video
description. And let me give everyone a
description. And let me give everyone a little hack here and this applies to setting up the Snowflake CLI as well is
you can actually use cloud code to help you with configuration. For me, I've never been somebody who's been super strong about configuring my
environments. It's not been my greatest
environments. It's not been my greatest area of knowledge. And Cloud Code has really actually helped me improve that where instead of me having to figure all
of this out, I can just say, "Hey, Claude Code, can you set up Snowflake CLI? Can you write me an instruction
CLI? Can you write me an instruction document for how to do that?" And that's what I did with this MCP server as well to help me troubleshoot my installation
and figure out exactly what I wanted.
It's, hey, help me install the Snowflake MCP server and I want it to work whenever I open any session with Claude.
It'll go forward from there. I'm just
going to say no and be able to show you guys here that I have my MCP successfully connected following my
steps. While I use cloud code for
steps. While I use cloud code for setting up a lot of my configuration, I do want to show you all exactly how to do this so you get the sense of
understanding how the MCP works and where to go for troubleshooting and you get a better sense of the configuration that you want and the specific details
of the configuration that you can set up. Therefore, I am going to start here.
up. Therefore, I am going to start here.
with these two commands. So, pip install UV and which UVX these are both important details. I've
already installed UV and which UVX returns this file location where UVX is or folder location which is really
critical to running MCPS. There's not
much more you need to know other than that. The next thing I want to show is
that. The next thing I want to show is actually the MCP instructions from the readme from Snowflake themselves where
they talk about service configuration.
And this is the file where I talked about where you get a more granular level of control of what actually your Snowflake MCP can and cannot do and what
you decide to allow it to do. And
there's a bunch of different services here with agent services, search services analyst uh, Cortex if you have this all enabled.
For my Snowflake, I don't have that enabled. And really, the main things I
enabled. And really, the main things I care about are going to be the SQL statement permissions where I can type in true or false depending on what I
want to allow and what I don't want to allow. Therefore, if I said, "Hey, I
allow. Therefore, if I said, "Hey, I don't want my Snowflake MCP to allow dropping, so Claude can't drop anything
uh even by mistake." Then I could go into this config file that I set up for my Snowflake MCP and I can type in
false, but I'm going to leave it as true for now. And you want to set up this
for now. And you want to set up this snowflake_config.yaml
snowflake_config.yaml YAML file in your home directory under this MCP folder and it's going to be a
key argument for the MCP to utilize when it's starting up to understand these permissions. And so this is one file
permissions. And so this is one file that you'll get directly from these instructions built by Snowflake that you want to have built out.
Now, this next step I'm hoping will be easy for you all as I've gone through a couple rounds of troubleshooting and making sure I understand exactly how
this works to provide you with the correct instructions on what you can do to set up this MCP successfully so you don't have to go through those rounds of
troubleshooting. We will go to this
troubleshooting. We will go to this fourth step here in the quick start guide. There are other authentication
guide. There are other authentication methods listed in here depending upon how you want to authenticate into Snowflake. But given that I
Snowflake. But given that I authenticated using my username and password as well as multiffactor authentication for Snowflake CLI earlier
in this video, I will do the same thing here. Let me zoom in to make sure the
here. Let me zoom in to make sure the text I'm about to paste is visible. And
then I will paste in this command which the key things to note about this command are one claude mcp add. This is
a command to add a model context protocol for claude. Two the scope is set to user. This is really important
because you want the MCP to be set up for your user and not for your project or repository. This means that whenever
or repository. This means that whenever you open up another repository, say you're working on a DBT repository, you're working on a tickets repository,
you're going to have access to MCP via your user settings and can query Snowflake via the MCP in all those projects. Otherwise, if you had another
projects. Otherwise, if you had another argument specified, then it would just be for this individual project and you want it to work for your entire time
you're using Cloud Code, no matter where you're using it. Snowflake password is going to be the name of the MCP because
I have another Snowflake MCP already set up using my JSON web token. And then I have this UVX followed by the Snowflake
Labs MCP uh which is telling it what to how to run the MCP. The service config file which is what we just went over with the true false and how you want to
decide to permission your Claude with the MCP tools it has at its disposal.
And then some account information where you have your account user, password, role. And again, I'm going to change
role. And again, I'm going to change this to public since we shouldn't be putting this as account admin. And I
will change my password here to my actual password. So I'll pause and come
actual password. So I'll pause and come back after I successfully run this.
Okay, we have successfully run it. I
cleared out my terminal here just to hide my password. But when you run it, you should see a successful command
saying, "Hey, this added the MCP server." And then if you go into
server." And then if you go into thiscloud.json
thiscloud.json JSON under your home directory.
You can see at the end of the file there's this MCP servers section and you will see your MCP servers listed there.
And I have my Snowflake password listed here. I'll stay up because I don't want
here. I'll stay up because I don't want to expose my password. But here's the previous one I did utilizing the JSON
web token. And now I am going to
web token. And now I am going to actually test the MCP server. To test
the MCP server, we can run this claude MCP list command. I am going to click enter in my terminal. And if you did
username and password, have your phone handy with your authentication for Duo.
And let's see. I received it. I'm clicking
let's see. I received it. I'm clicking
approved and there we go. We are
connected and we can actually begin running via claude code. If I type in
claude here and utilize the MCP
and we can see we have the two MCP servers that are now connected and available for use. Just in the same way that we could issue queries with the
Snowflake CLI, we can now utilize the Snowflake MCP to issue queries. say
issue a sample query with the snowflake MCP and it should
go through the process to issue a query.
And here we go. It's using snowflake list objects which is a specific command from the MCP. We can see it's
working. We'll stop it there. And
working. We'll stop it there. And
awesome. Let's go to Claude Desktop to show you how to set it up there. Now,
moving to Cloud Desktop to show you how to set up the MCP with Cloud Desktop.
First, you'll go to your user inside of Cloud Desktop settings, developer, and you'll see local MCP servers. And
you can see here I have Snowflake MCP already up and running. But to go to the right place, you can click edit config and then it will open up the finder or
folder window where you can find the cloud desktop config JSON which will
take you to this file here. And here you can copy and paste essentially the same JSON that you had in that MCP server
section for cloud code and that will work just fine here. Again, I'm going to change this to public
editing on the fly here. And this should set you up with Claude Desktop and Cloud Code. One thing to note, the first time
Code. One thing to note, the first time you're implementing this, you're going to need to quit Claude Desktop. You're
going to need to quit Claude Code and then restart it. And then once you restart, then it should take effect.
And I believe that is it for setting you up with Snowflake.
Thank you so much for watching all the way through the video. I hope that so many of you who watch this had that same light bulb moment that I did for when you actually integrate Claude or
whatever AI platform you're using with your data and particularly Snowflake. It
opens up the possibilities immensely for how many things you can get done, how quickly you can do it. It is truly a gamecher for productivity. And to
briefly recap what we went over, we talked about the differences between a CLI and the MCP for Snowflake connections with Claude. And then we ran
through how to integrate with both of those tools with Claude. I hope you enjoyed this video and I will talk to you guys next time with some more
helpful tips about how you can integrate AI with your day-to-day being a data professional. Thanks so much and please
professional. Thanks so much and please like and subscribe.
Loading video analysis...