back to indexBuilding headless automation with Claude Code | Code w/ Claude

00:00:13.240 |
And today, we're going to be talking a little bit 00:00:14.960 |
about the Cloud Code SDK and the Cloud GitHub Action that 00:00:28.680 |
just to give some examples of how to get started 00:00:32.580 |
We will then dive into a live demo of the GitHub Action, 00:00:38.520 |
The GitHub Action was built on top of the SDK, 00:00:43.860 |
for the kind of things that you can do using the Cloud Code SDK. 00:00:47.500 |
We'll then dive into some more advanced features of the SDK. 00:00:52.660 |
And then we'll end with having all of you set up the Cloud GitHub 00:00:57.360 |
GitHub Action on your repos, so you guys can start using it 00:01:04.880 |
Actually, before we get started, can I get a show of hands here? 00:01:13.080 |
And of the people who have used Cloud Code, how many 00:01:25.020 |
If you guys don't have Cloud Code installed in your laptop, 00:01:28.900 |
I'd encourage you to install it in your laptops and follow along. 00:01:32.420 |
There will be parts of this talk that will be beneficial to follow along. 00:01:36.080 |
And then if you don't want to, you don't have to. 00:01:43.500 |
It is a way to programmatically access the power of the Cloud Code agent 00:01:50.200 |
This is powerful because it's a new kind of primitive 00:01:53.800 |
and a new kind of building block that allows you to build applications 00:02:00.840 |
Things that you can do with the SDK are super simple things to get started. 00:02:05.860 |
For example, you can use it like a Unix tool. 00:02:09.080 |
The Unix-ish tool philosophy is what really makes Cloud Code powerful 00:02:12.580 |
because you can plug it in anywhere where you can run bash or a terminal. 00:02:20.020 |
You can pipe stuff into it, pipe stuff out of it, 00:02:22.860 |
make complex chains out of it and stuff like that. 00:02:30.960 |
Some people actually get Cloud to write new linters for them too. 00:02:33.980 |
So Cloud can lint your code if there are specific things 00:02:40.000 |
And then we get into fancier applications as well. 00:02:42.000 |
So if you want to build your own chatbot that's powered by Cloud Code, 00:02:47.240 |
If you want Cloud Code to write you code in a new environment 00:02:53.520 |
you can build those kinds of applications as well. 00:02:59.180 |
We'll talk more about the features in the coming slides. 00:03:01.560 |
And we have Python and TypeScript SDKs or like bindings 00:03:06.980 |
So that should make it much easier for you guys to consume it 00:03:15.720 |
Calling the Cloud Code SDK is as simple as doing cloud-p 00:03:20.140 |
and following it up with the string that you want to ask Cloud. 00:03:28.500 |
And if you notice, I also give it a dash dash allow tools write, 00:03:32.260 |
which is a way for me to proactively give it access to the right tool 00:03:39.160 |
And then this is something I like doing too, piping logs to Cloud. 00:03:45.700 |
So you can do cat app dot log and then pipe that into cloud dash p. 00:03:56.400 |
And as you can see, it does a pretty decent job of summarizing 00:04:04.540 |
I just can't get myself to understand the output of if config. 00:04:08.520 |
I still don't know what it means, but Cloud does. 00:04:14.460 |
And finally, this is kind of what makes the SDK tick. 00:04:22.820 |
Cloud code will actually output things or its response in JSON 00:04:28.360 |
And you can parse this JSON and build on top of it. 00:04:32.340 |
So we'll talk more about details for how this is-- 00:04:37.340 |
but I wanted to throw that example out there. 00:04:41.520 |
Let's get into a significantly more complex example now, 00:04:48.520 |
So Cloud GitHub Action was built on top of the SDK. 00:05:03.480 |
So I'll include a link at the very end of the talk, 00:05:05.680 |
so you guys can go have a look at the source for inspiration 00:05:09.680 |
But for now, let's jump into a live demo on my laptop. 00:05:13.440 |
So I have cloned a popular small open source quiz app 00:05:21.200 |
And we are going to fire it up just to see how that works. 00:05:24.740 |
And then we will tell Cloud to build something 00:05:30.020 |
So I just did an NPM start, which opened up my shiny new quiz 00:05:36.060 |
It allows you to choose a bunch of categories, 00:05:52.680 |
But I'm just going to just fly through these just 00:05:56.680 |
to show you guys how this little quiz app works. 00:06:08.680 |
So this was the little demo quiz app that's open sourced. 00:06:24.640 |
add power-ups for 50/50 elimination of options 00:06:31.400 |
Because I suck at trivia, I really like that feature, 00:06:38.580 |
installed the Cloud GitHub action in my repo. 00:06:42.840 |
But we'll go over how to set that up later, too. 00:06:50.320 |
It has pretty sparse details on how to implement this. 00:06:54.800 |
It's just literally a wish list, really, like a wish feature. 00:06:58.260 |
It's saying, add a power-up option in the config, 50/50 00:07:03.720 |
For the skip question, it should award user points, 00:07:16.940 |
And I'm excited to see what it actually ends up building. 00:07:27.860 |
So it usually does take four or five seconds for it to respond. 00:07:34.460 |
we'll just also take this other GitHub issue. 00:07:40.340 |
So we saw there was a global timer on the quiz app, 00:07:46.760 |
So let's go and say, Cloud, please build this. 00:08:01.980 |
on this GitHub issue saying that it's working. 00:08:10.640 |
If I click into it, and if I actually click on the logs, 00:08:22.660 |
because it's not much fun to parse it manually. 00:08:28.560 |
So Cloud is now going to actually go through this to-do list 00:08:43.980 |
is there are already a couple of pull requests that 00:08:50.760 |
And let's get Cloud to review it or change some 00:08:57.840 |
There's this one, which is change background color to blue. 00:09:02.680 |
All right, I actually think I like green better. 00:09:04.820 |
So I'm just going to be like, all right, Cloud. 00:09:14.220 |
And I'm pretty sure Cloud's going to do this. 00:09:17.720 |
can also add commits for a pull request that's already open. 00:09:22.960 |
OK, so this is going to take a few minutes to run. 00:09:25.020 |
And while this runs, let's go back to the presentation. 00:09:28.460 |
And then we'll check up on how this is doing towards the end. 00:09:39.640 |
When you call Cloud-P, by default, it has no edit or destructive 00:09:45.780 |
permission access, which is great for safety. 00:09:48.880 |
But it's not great for actually getting things done, which 00:09:52.080 |
is why there is a dash dash allowed tools option, 00:10:00.480 |
it might need in the future for your given task. 00:10:12.580 |
and the write tool, which is a good set of permissions, 00:10:17.020 |
because this allows Cloud to self-verify what it's writing 00:10:22.180 |
and build your project and test and then continue writing. 00:10:27.780 |
Similarly, for MCP, if you have MCP servers configured, 00:10:40.840 |
we already saw an example of structured output, 00:10:55.020 |
If you select stream JSON, it'll actually stream messages 00:11:00.700 |
versus JSON will just give you one giant blob of JSON 00:11:04.980 |
And parsing this JSON and building on top of it 00:11:07.860 |
is really how you can make use of the Cloud Code SDK 00:11:14.400 |
And then you can also configure the system prompt. 00:11:16.700 |
So you can do -- system prompt, talk like a pirate, 00:11:20.980 |
and you can get Cloud Code to talk like a pirate for the rest 00:11:24.860 |
If you haven't done it, I'd encourage you to try it out. 00:11:30.980 |
So we also have a few user interaction features built into the SDK. 00:11:37.660 |
And what that means is that the first one is resuming session state. 00:11:42.860 |
So when you call Cloud-P in structured output or JSON mode, 00:11:51.660 |
And this session ID is useful because you can then reference the session ID 00:11:55.940 |
to go back to the same context state that Cloud had when it finished that process. 00:12:00.940 |
So by preserving these session IDs and keeping track of them, you can enable or build user interactive features, 00:12:07.060 |
where the user says something, you pass that on to Cloud, Cloud returns a response, 00:12:12.220 |
and now you want the user to give feedback on that response. 00:12:15.220 |
And that's how this kind of enables you to build those types of interactions in your apps. 00:12:21.460 |
And then the last one -- and this one's actually pretty interesting, and it's fairly recent, too. 00:12:30.300 |
We talked a little bit about how to give Cloud permissions using the allowed tools flag. 00:12:34.500 |
And that requires you to pre-configure them in advance. 00:12:38.940 |
But what if you didn't want to do them because you don't know what tools Cloud would want to use in the future? 00:12:46.460 |
In that case, you can use the -- permission prompt tool and offload the permission management to an MCP server. 00:12:53.460 |
So you can ask users in real time for whether they want to accept a tool or reject a tool. 00:12:58.780 |
And you can have an MCP server kind of handle that for you, as opposed to trying to predict which tools are OK and which tools are not. 00:13:05.700 |
So this is -- this is fairly recent, and we'd love to get feedback on this if you guys end up trying it out. 00:13:10.460 |
OK, let's -- let's go back to our demo and see what Cloud's done. 00:13:24.500 |
We can see that Cloud has actually gone through his to-do list. 00:13:29.620 |
OK, I'm going to open a -- there's a link over here to create a PR. 00:13:37.500 |
And I'm going to click that and see what that gives us. 00:13:41.500 |
I'll actually create the pull request, too, so it's easier for us to review. 00:13:44.500 |
I don't really know how this code base works, but we'll still eyeball it just to see if, you know, it's doing the right thing. 00:13:57.820 |
OK, there's, like, some configuration in the main component. 00:14:03.460 |
All right. I think what we should do and what will make this fun is that we should just get this branch locally and see what Cloud did. 00:14:12.140 |
Because there's no way that we can actually figure out what it did in the short amount of time that we have. 00:14:16.260 |
So I'm going to go back to my terminal, do a good fetch, check out the branch that Cloud just created, 00:14:38.420 |
It looks like we have a power-up section now at the bottom of our config page. 00:14:48.700 |
And let's select general knowledge and start playing this game. 00:14:57.500 |
So you see it has, like, this little 50/50 button on the bottom left and a skip questions button on the right. 00:15:05.260 |
I'm just going with 50/50 because I have no idea what the answer to this is. 00:15:19.620 |
And then let's just breeze through the other ones for the sake of time. 00:15:26.620 |
I still got an F, but we got one correct answer, which is better than zero correct answers. 00:15:47.740 |
I think there's definitely more we could do here. 00:15:49.580 |
We could, like, show how the power -- like, which questions we use the power upon over here. 00:15:55.500 |
And there's, like, definitely more we can do. 00:15:57.100 |
But at the most basic level, I think Claude was able to do the task that we assigned it to do, which is exciting. 00:16:05.740 |
Like, this is kind of the power of the GitHub Action because you didn't really have to run this on your own infra. 00:16:10.460 |
You can just literally comment on a thread saying, please build this for me. 00:16:14.220 |
It uses your GitHub Action Runners and just, like, does the thing. 00:16:19.820 |
We -- let's also look at the PR that we told it changed from blue to green. 00:16:27.100 |
It's all hex codes, so let's just see what it did in the commits. 00:16:29.660 |
So we see there's two commits, and Claude has added this last one to switch it from blue to green. 00:16:36.460 |
And it did it for all three of the places where we -- where the color was defined, which is awesome. 00:16:42.780 |
Okay, I'm not going to go over the last one, the question timer, because we might run out of time. 00:16:48.860 |
But this hopefully gives you insight into what the Claude GitHub Action can do for you. 00:16:57.980 |
Okay, so just as a recap, the Claude GitHub Action, 00:17:05.340 |
as it's implemented today, is able to read your code. 00:17:09.340 |
It's able to create PRs for you from GitHub issues, like we just saw. 00:17:14.860 |
So if you already have a PR and you commit or you comment on it, 00:17:17.980 |
it can add a commit to an existing branch or an existing PR. 00:17:21.340 |
It can answer questions. It doesn't have to do something. 00:17:24.620 |
It can just literally answer questions for you. 00:17:26.300 |
If you don't understand something, you can be like, "Hey, Claude, how does this work?" 00:17:32.940 |
The best part of all of this is that you don't have to take care of the infra. 00:17:37.180 |
It runs on existing GitHub runners, which almost everyone has configured if you're using GitHub Actions. 00:17:43.020 |
So that's kind of the really nice thing about this is you don't have to worry about any of the infra. 00:17:55.900 |
I think I may have mentioned that these actions were built on top of the SDK. 00:18:00.700 |
So the SDK does form the foundation of how these actions were built. 00:18:09.500 |
This is a thin layer that just implements the piece which talks to Cloud Code and returns the response from Cloud Code. 00:18:19.500 |
And then we have another action on top of this, which is called the PR action. 00:18:24.300 |
And this action is responsible for all the fancy things that you saw on the PR. 00:18:28.540 |
So it's responsible for making comments, for the to-do list, for rendering it the right way, 00:18:32.300 |
for adding the PR links, and things like that. 00:18:35.580 |
So it's kind of three layers in which it's built. 00:18:39.980 |
Both the base action and the PR action are open sourced. 00:18:43.500 |
So I would encourage you guys to go have a look, 00:18:46.140 |
take inspiration from how that works, and maybe that inspires more ideas. 00:18:59.820 |
you guys can install the Cloud GitHub actions today. 00:19:03.820 |
The easiest way to do this is to open up Cloud Code in a terminal in the repo that you want to install it in. 00:19:12.540 |
And once you open up Cloud Code, just do /install GitHub action. 00:19:18.780 |
And that is going to present you with a nice flow which guides you through configuring your GitHub action 00:19:26.860 |
So the end result of this would be a PR, which would be a YAML file for your GitHub action. 00:19:33.340 |
And once you merge that in and you configure your API keys and things like that, you're off to the races. 00:19:38.700 |
And you can go ahead and start tagging Cloud and using Cloud like we just did right now. 00:19:46.300 |
So, small caveat, if you're a Bedrock or a Vertex user, the instructions are a little bit different and a tiny bit more manual. 00:19:57.260 |
The docs are pretty comprehensive in helping you set up the GitHub action for both Bedrock and Vertex. 00:20:09.980 |
These are resources for things that we've talked about today. 00:20:14.940 |
The open source repos for both the base action and the Cloud Code action are here. 00:20:22.620 |
And we absolutely love your feedback as well. 00:20:26.220 |
So if you guys have any feedback on the SDK, on the GitHub action, or on Cloud Code, 00:20:31.900 |
please go to our public Cloud Code GitHub repo and file an issue there. 00:20:38.300 |
And someone will have a look and get back to you. 00:20:46.140 |
And I hope you guys have a good rest of the day. 00:20:48.860 |
And I hope you guys have a good rest of the day. 00:20:50.540 |
And I hope you guys have a good rest of the day.