back to index

Building headless automation with Claude Code | Code w/ Claude


Whisper Transcript | Transcript Only Page

00:00:00.000 | SIRBIT ASARIA: Good afternoon, everybody.
00:00:08.060 | My name is SIRBIT ASARIA.
00:00:10.220 | I am an engineer on the Cloud Code team.
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:20.480 | was just announced today.
00:00:21.360 | Cool.
00:00:24.660 | So a little bit about the agenda.
00:00:26.100 | We do a little quick start for the SDK,
00:00:28.680 | just to give some examples of how to get started
00:00:30.440 | and how to use the SDK.
00:00:32.580 | We will then dive into a live demo of the GitHub Action,
00:00:37.200 | which should be fun.
00:00:38.520 | The GitHub Action was built on top of the SDK,
00:00:40.920 | so it's meant to be a source of inspiration
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:00.720 | and build on top of it.
00:01:01.580 | Cool.
00:01:04.880 | Actually, before we get started, can I get a show of hands here?
00:01:07.240 | How many people have used Cloud Code?
00:01:12.120 | That's a lot of people.
00:01:13.080 | And of the people who have used Cloud Code, how many
00:01:16.500 | have used Cloud dash P or know what that is?
00:01:19.720 | Cloud.
00:01:21.680 | Far fewer people.
00:01:23.460 | It's good to know.
00:01:25.020 | If you guys don't have Cloud Code installed in your laptop,
00:01:27.780 | that's how you get it.
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:37.920 | It's all good.
00:01:38.440 | Cool.
00:01:41.800 | So what is the Cloud Code SDK?
00:01:43.500 | It is a way to programmatically access the power of the Cloud Code agent
00:01:48.640 | in headless mode.
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:01:57.600 | that just weren't possible before.
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:16.720 | So you can use it in your Unix pipelines.
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:26.300 | You can then build CI automation on it.
00:02:28.660 | So you can have Cloud review your code.
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:36.340 | that you can't define programmatically.
00:02:38.180 | You can get Cloud Code to do it.
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:45.460 | that's certainly possible.
00:02:47.240 | If you want Cloud Code to write you code in a new environment
00:02:51.400 | or a separate remote environment,
00:02:53.520 | you can build those kinds of applications as well.
00:02:57.280 | And finally, these are a few features.
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:04.760 | for the Cloud Code SDK coming up soon.
00:03:06.980 | So that should make it much easier for you guys to consume it
00:03:09.520 | and build on top of it.
00:03:11.680 | So let's jump into some basic examples.
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:23.120 | So in this example, I'm telling Cloud
00:03:25.440 | to write me a Fibonacci sequence generator.
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:37.040 | so it can write files to my file system.
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:52.280 | I don't like looking at logs manually.
00:03:54.040 | So this is something I do quite often.
00:03:56.400 | And as you can see, it does a pretty decent job of summarizing
00:03:58.740 | what the log failures were.
00:04:01.860 | Similarly, if you're anything like me,
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:10.900 | And Cloud does it for me over here.
00:04:14.460 | And finally, this is kind of what makes the SDK tick.
00:04:18.400 | We have an output format.
00:04:20.000 | If you do a dash dash output format JSON,
00:04:22.820 | Cloud code will actually output things or its response in JSON
00:04:26.860 | as opposed to plain text.
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:35.300 | what else you can do with this JSON,
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:45.100 | which is the Cloud GitHub Action.
00:04:48.520 | So Cloud GitHub Action was built on top of the SDK.
00:04:52.300 | And it can be used to review code.
00:04:55.080 | It can be used to create new features.
00:04:57.120 | It can be used to triage bugs and so on.
00:05:01.640 | And this is also open source.
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:08.340 | for how to use it.
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:19.020 | for the purposes of this demo.
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:28.140 | on top of it for us.
00:05:30.020 | So I just did an NPM start, which opened up my shiny new quiz
00:05:35.080 | It's actually pretty nifty.
00:05:36.060 | It allows you to choose a bunch of categories,
00:05:39.300 | how many questions you want, difficulty,
00:05:41.240 | definitely easy for me.
00:05:42.300 | I suck at trivia type of questions.
00:05:45.780 | And then there's a countdown timer.
00:05:47.680 | So we're not going to actually answer these,
00:05:50.160 | unless someone feels very strongly.
00:05:51.520 | Please shout out the answer.
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:01.680 | There we go.
00:06:04.380 | Not surprising.
00:06:05.140 | You got a great F, but that's OK.
00:06:08.680 | So this was the little demo quiz app that's open sourced.
00:06:12.940 | And if you look at the issues for this repo,
00:06:18.680 | we see a couple very interesting ones.
00:06:21.660 | There's one issue that says, we should
00:06:24.640 | add power-ups for 50/50 elimination of options
00:06:28.740 | and skip questions for free.
00:06:31.400 | Because I suck at trivia, I really like that feature,
00:06:34.480 | and I want to build it.
00:06:36.340 | And before this presentation, I already
00:06:38.580 | installed the Cloud GitHub action in my repo.
00:06:41.180 | So it's already available.
00:06:42.840 | But we'll go over how to set that up later, too.
00:06:48.060 | OK, so here's the issue.
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:02.380 | elimination.
00:07:03.720 | For the skip question, it should award user points,
00:07:06.020 | even though the question was skipped.
00:07:09.180 | And users should be able to configure this
00:07:10.860 | from the config page.
00:07:12.200 | So there's a lot of creative room for Cloud
00:07:14.160 | to do whatever it wants to do in this case.
00:07:16.940 | And I'm excited to see what it actually ends up building.
00:07:19.080 | So what I'm going to do is say, add Cloud.
00:07:21.840 | Please implement this feature.
00:07:25.320 | And comment on it.
00:07:27.860 | So it usually does take four or five seconds for it to respond.
00:07:32.580 | And while it's doing that, for good measure,
00:07:34.460 | we'll just also take this other GitHub issue.
00:07:37.240 | This is talking about a per-question timer.
00:07:40.340 | So we saw there was a global timer on the quiz app,
00:07:42.520 | but there was no per-question timer.
00:07:44.680 | So that's what this one's talking about.
00:07:46.760 | So let's go and say, Cloud, please build this.
00:07:53.280 | And now we have two things building.
00:07:56.160 | Cool.
00:07:56.660 | So now when I get back to this tab,
00:07:58.680 | you see that Cloud responded with a comment
00:08:01.980 | on this GitHub issue saying that it's working.
00:08:05.520 | It also has a link to the job run, which
00:08:08.940 | is the GitHub action run.
00:08:10.640 | If I click into it, and if I actually click on the logs,
00:08:14.620 | I'll see that it's doing a bunch of stuff.
00:08:16.400 | You can see all this JSON being output.
00:08:18.720 | This is from the SDK.
00:08:20.840 | So we won't look at the JSON too much,
00:08:22.660 | because it's not much fun to parse it manually.
00:08:24.740 | But over here, we can see that it also
00:08:26.880 | created a to-do list for us.
00:08:28.560 | So Cloud is now going to actually go through this to-do list
00:08:30.940 | and try to implement the power-up feature.
00:08:35.540 | And similarly, for the question timer,
00:08:37.960 | it's going to do something similar.
00:08:41.680 | One more thing that we should do here
00:08:43.980 | is there are already a couple of pull requests that
00:08:47.600 | have been opened for this repo.
00:08:50.760 | And let's get Cloud to review it or change some
00:08:53.220 | of these pull requests just for fun.
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:08.460 | Please change this to green.
00:09:13.320 | This one is fairly easy.
00:09:14.220 | And I'm pretty sure Cloud's going to do this.
00:09:16.180 | But I just wanted to show you guys that I
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:33.600 | OK, cool.
00:09:34.440 | So let's do a little bit of a deep dive
00:09:36.580 | on the features of the SDK.
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:09:55.140 | which allows you to pre-configure Cloud
00:09:58.260 | with any permissions that you think
00:10:00.480 | it might need in the future for your given task.
00:10:04.140 | So in this case, in the first example,
00:10:05.940 | you see that I've given it permissions--
00:10:08.060 | bash permissions to npm run build, npm test,
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:31.940 | you can allow list those MCP tools as well.
00:10:34.600 | So it's a very similar process.
00:10:39.280 | Then structured output--
00:10:40.840 | we already saw an example of structured output,
00:10:43.300 | both from the GitHub Actions logs and also
00:10:46.860 | the little screenshot I showed you earlier.
00:10:49.140 | But there's two modes here.
00:10:50.540 | There's stream JSON and JSON.
00:10:53.040 | It does exactly what it sounds like.
00:10:55.020 | If you select stream JSON, it'll actually stream messages
00:10:58.740 | to you as and when they're available,
00:11:00.700 | versus JSON will just give you one giant blob of JSON
00:11:03.600 | at the end.
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:11.040 | and create features for your users.
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:23.380 | of your day, which is actually quite fun.
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:49.260 | it's going to return a session ID.
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:26.340 | It's -- it's -- permission prompt tool.
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:21.180 | All right. So this is the power-up issue.
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:49.820 | So you see some set power-up stuff.
00:13:53.820 | Seems all right.
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:29.260 | and restart our process.
00:14:35.900 | OK. Awesome.
00:14:38.420 | It looks like we have a power-up section now at the bottom of our config page.
00:14:44.100 | And it's a little checkbox.
00:14:45.500 | I like that touch.
00:14:47.340 | We'll keep both of them on.
00:14:48.700 | And let's select general knowledge and start playing this game.
00:14:54.700 | Let's see what it did.
00:14:56.940 | Oh, sweet.
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:08.860 | Does anybody know what that is?
00:15:10.140 | Cadbury D.
00:15:11.620 | D? OK, there we go.
00:15:12.660 | That makes sense. Cadbury, yeah.
00:15:17.860 | I'm going to skip this one.
00:15:19.620 | And then let's just breeze through the other ones for the sake of time.
00:15:25.980 | Cadbury D. All right.
00:15:26.620 | I still got an F, but we got one correct answer, which is better than zero correct answers.
00:15:37.340 | And, yeah, I guess --
00:15:42.620 | Yeah, it tricked us.
00:15:44.620 | That was a good one.
00:15:45.740 | But, yeah, I mean, it seems like it worked.
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:56.140 | Let's go back to the presentation now.
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:13.340 | It's able to create commits for you.
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:29.420 | And you can get it to answer questions.
00:17:31.420 | And it can, of course, review your code.
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:47.340 | Okay, so how were the actions built, right?
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:04.620 | And then we have two other actions on top.
00:18:07.020 | We have the Cloud Code base action.
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:50.300 | Yeah.
00:18:52.860 | Yeah.
00:18:54.860 | Yeah.
00:18:56.780 | And then, finally, we also--
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:25.740 | as well as merging it.
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:54.700 | So please have a look at the docs.
00:19:57.260 | The docs are pretty comprehensive in helping you set up the GitHub action for both Bedrock and Vertex.
00:20:07.820 | Cool.
00:20:08.140 | Finally, resources.
00:20:09.980 | These are resources for things that we've talked about today.
00:20:12.620 | If you want to snap a picture, go ahead.
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:40.780 | Cool.
00:20:42.780 | That's all I have for today.
00:20:44.300 | Thanks for joining me.
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:49.820 | Thank you.
00:20:49.900 | Thank you.
00:20:50.460 | Thank you.
00:20:50.540 | Thank you.
00:20:50.540 | And I hope you guys have a good rest of the day.
00:20:52.860 | Thank you.
00:20:54.300 | Transcription by CastingWords