Rethinking Claude Code Best Practices — Lydia Hallie, Anthropic — Transcript
Full transcript
- 0:00I had some technical difficulties during
- 0:03my talk this morning, so I ran back home
- 0:05and I'm just going to record it from my
- 0:07computer instead. So, hi everyone. I'm
- 0:09Lydia. I work on the Cloud Code team at
- 0:11Anthropic. And the models have gotten
- 0:14really good lately. So we have Opus 55,
- 0:16which is my favorite daily driver. And
- 0:19earlier this week, we also launched
- 0:20Fable 52. And these models are extremely
- 0:23good at long-running tasks and
- 0:25understanding your codebase. And
- 0:27especially Fable is also really good at
- 0:29verifying its own output. But as these
- 0:31models get better, the way that we work
- 0:33with them in Cloud Code also changes.
- 0:36So earlier this year, I don't know if
- 0:38you remember, but sessions kind of used
- 0:40to look like this. So we'd use a model
- 0:41like Opus 45, which honestly for its
- 0:44time was really good. I really enjoyed
- 0:45working with Opus 45. But compared to
- 0:48today, it would just stop a lot earlier.
- 0:50So it would just run for shorter amounts
- 0:52of time.
- 0:53And we'd also keep correcting it. We'd
- 0:55keep reminding it to do things, add
- 0:57things like important, exclamation mark,
- 0:59all these things to our Cloud MD file.
- 1:01And also features like auto mode didn't
- 1:03exist yet. So we were either approving
- 1:05everything manually or taking the
- 1:08riskier approach with dangerously skip
- 1:10permission. So we were still very much
- 1:13in the loop as humans.
- 1:15But as these models got better at taking
- 1:17on bigger tasks, our sessions also
- 1:19changed. So nowadays, at least at
- 1:21Anthropic, our sessions look more like
- 1:23this. So we're running dozens of
- 1:24sessions at the same time, running for
- 1:26hours, verifying their own results along
- 1:29the way, and we even have sessions
- 1:31orchestrate other sessions. So whereas
- 1:33we used to be in the loop for almost
- 1:35every step and running one or just a
- 1:37couple sessions at a time, we've now
- 1:39essentially become managers for dozens
- 1:42of sessions.
- 1:43We also got a lot more done though. Now
- 1:45you may have seen our blog post in
- 1:46October about how Anthropic went from
- 1:48about 2,500 changes a day in May to more
- 1:51than 30,000 a day in September. But this
- 1:55also means that we as developers just
- 1:57have to rethink on what we're focused on
- 1:59instead.
- 2:00So, if you think about our best
- 2:01practices from earlier this year, it was
- 2:03mainly about steering sessions,
- 2:05approving commands, saying no to certain
- 2:08things or restricting what Claude could
- 2:09do,
- 2:11the output, and also starting the
- 2:12sessions. So, everywhere that we now
- 2:15step out of that loop, something else
- 2:17has to take over. And this is either the
- 2:19model, the harness, or the environment
- 2:22that it's running in. So, if we are not
- 2:24in the loop to approve every command and
- 2:26we're running so many sessions at the
- 2:27same time, how can we make sure that the
- 2:30code it's writing is still high quality?
- 2:32And most importantly, if these sessions
- 2:34are running for hours without our
- 2:36supervision, how can we make sure that
- 2:38they're running safely? So, let's go
- 2:40through that by taking this old session
- 2:42and seeing what we have to change to get
- 2:44to that end result that I showed
- 2:45earlier.
- 2:46Well, first of all, let's use the actual
- 2:47defaults we start sessions in nowadays.
- 2:49So, that's not really something you
- 2:51should think about. So, let's update the
- 2:52model here from Opus 4 5 to Opus 5 5 and
- 2:55change the manual permission to auto
- 2:57mode. And Opus 5 5 is a lot better at
- 3:00understanding your intent and
- 3:01understanding your code base. So, we
- 3:03really don't have to steer it as much
- 3:04anymore mid session. And you also no
- 3:06longer have to approve every command
- 3:08because we started making auto mode the
- 3:10default permission mode back in August.
- 3:12Now, being better at understanding your
- 3:14intent and your code base also means
- 3:16that we have to rethink the instructions
- 3:18we have in our code base. So,
- 3:20if you followed our best practices from
- 3:21earlier this year, you may still have
- 3:23things like important or never do this,
- 3:25exclamation mark, all these things in
- 3:27your cloud MD file. But with today's
- 3:29models, you really don't need that and
- 3:31it can actually make the model go off
- 3:32track. So, you end up with more tool
- 3:34calls and overall a worse results.
- 3:37So, nowadays your cloud MD file should
- 3:39only include the things the Claude
- 3:40cannot see from your code. So, for
- 3:42example, maybe you have a service that's
- 3:44still using some legacy source
- 3:46somewhere, but it's not directly
- 3:47referenced in the code. That's still
- 3:49good to keep in there. But everything
- 3:51else, like what stack you're on or where
- 3:53to look, you really don't need that
- 3:54anymore. And we actually have a command
- 3:56for this called doctor prompt audit,
- 3:58which makes it really easy to optimize
- 4:00your environment for a specific model.
- 4:02So, if on Opus 55 here and you run this
- 4:05command, it will automatically check
- 4:06your cloud MD and your skills to see
- 4:08what the new model no longer needs.
- 4:11Now, auto mode is a permission mode that
- 4:13runs a separate classifier on pretty
- 4:15much everything that isn't just reading
- 4:17or editing files in your project.
- 4:20So, it automatically allows commands
- 4:22that it knows are safe, like running
- 4:23tests or installing dependencies, but it
- 4:26still blocks commands where it's unsure
- 4:28whether they're safe.
- 4:29And normally that's pretty good. Uh
- 4:31normally that's kind of, you know, what
- 4:32we want. But for example here, if we ask
- 4:35it to ship something to staging, we
- 4:37would have just, you know, approved the
- 4:39push to our deploy repo. But by default,
- 4:42auto mode only trusts this folder and
- 4:44this repo, so it would block that
- 4:45command. So, we're back in the loop.
- 4:48Now, the defaults should be good in most
- 4:50cases, but if you still notice that you
- 4:51have to approve a lot of uh commands
- 4:54even in auto mode, the first thing to
- 4:56look at is settings here because you can
- 4:58configure auto mode in your own settings
- 5:00just in plain English, and this is what
- 5:01gets sent to the classifier, which then
- 5:03decides whether to reject or allow
- 5:05certain commands.
- 5:07So, here we can just write which repos,
- 5:09buckets, domains we trust um and what it
- 5:11should always allow or never do. Okay,
- 5:13so honestly this was pretty easy by just
- 5:15using today's defaults. We've already
- 5:17gotten rid of most of our in-the-loop
- 5:19stuff
- 5:20um because the model took over the
- 5:21steering and auto mode took over all the
- 5:23approving, so getting out of the loop is
- 5:25easy. But the harder question now is how
- 5:28do we make sure it's okay that we're not
- 5:29there anymore? So, first is keeping it
- 5:32safe and then also verification.
- 5:34So, let's start with keeping it safe
- 5:35because everything so far, so upgrading
- 5:37the model and using auto mode is just
- 5:40working with a model.
- 5:42And in most cases it does what you tell
- 5:44it to do, but that's not a guarantee.
- 5:46So, in a study we published back in
- 5:48August, we tested auto mode versus real
- 5:50people in the loop, and only about 14%
- 5:53of people caught a clearly dangerous
- 5:55command. Auto mode blocked 89% of them,
- 5:58so it is a lot better at it than we
- 6:00were.
- 6:01But about one in 10 of those commands
- 6:03still went through. So, if do want the
- 6:05guarantee, you can only enforce that in
- 6:08the harness. And this is where some of
- 6:10our older best practices still matters,
- 6:11and that's permissions. So, for example,
- 6:13if you have a deny rule for a specific
- 6:16tool called in your project, Cloud Code
- 6:18looks at this rule before the automo
- 6:20classifier even looks at it. In fact, if
- 6:22a tool called matches a deny rule, the
- 6:24classifier never even sees it. So,
- 6:26having deny rules is still the best way
- 6:28to make sure Cloud actually never does
- 6:31something.
- 6:32But then how do you know what needs to
- 6:34be a rule in your project versus what
- 6:35the model can just know because they've
- 6:37gotten so good at it? Um I think it kind
- 6:39of just comes down to if Cloud gets this
- 6:41wrong once, can I take it back? So, if
- 6:44it writes the wrong code, you can still
- 6:46revert that. Um so, you can still leave
- 6:48that to the model. But if it throws away
- 6:50our uncommitted changes or it reads a
- 6:52key that's now in your transcript and
- 6:53you don't don't want that, that should
- 6:55still be a rule. So, for example, let's
- 6:58say that we just never want Cloud
- 7:00reading our .env file. Now, by default,
- 7:02automo is fine with this, so it would
- 7:03have just approved it.
- 7:05So so, if you want to make sure that
- 7:07Cloud can never read this file, you
- 7:09should just add a deny rule. And then
- 7:11commands like cat cannot open this file
- 7:12either. But it's not always that
- 7:14straightforward cuz sometimes certain
- 7:16commands can have side effects. So, for
- 7:19example, let's say that npm test here, a
- 7:21very normal command, it's just a test,
- 7:23so automo runs it, that's fine.
- 7:25But when the script is running, it runs
- 7:27code that you didn't write, like your
- 7:29dependencies. Or maybe Cloud runs a
- 7:31script real quick that it wrote just to
- 7:33quickly check something.
- 7:35So, if one of those scripts is
- 7:36compromised, it could just open that
- 7:38same .env file or your SSH keys and send
- 7:41those to a server you've never heard of,
- 7:43right? And even if we were still there
- 7:46as humans approving everything,
- 7:48honestly, we would have just clicked
- 7:49allow cuz there's nothing to say no to.
- 7:50It's just part of the script that in
- 7:53this example case npm test runs. And
- 7:56permissions only decide if a tool call
- 7:59runs, but they cannot limit what it can
- 8:01reach once it's running. So, we want to
- 8:03make sure that these kinds of scripts
- 8:05can still run because this is just part
- 8:07of, you know, how Cloud can check its
- 8:08own work running tests.
- 8:10So we cannot just block npm tests, but
- 8:12we want to limit its side effects. So
- 8:14really, we just want to limit the
- 8:16environment that it's running in.
- 8:18So if you're running it locally or on
- 8:20your own machine, you can run commands
- 8:22like that in a sandbox. So then you have
- 8:24control over which files in a command it
- 8:26can read, which folders it can write to,
- 8:29which hosts it can reach. And the
- 8:31operating system enforces that.
- 8:34Also, this also applies to everything
- 8:35that command then starts, so any child
- 8:37processes.
- 8:39So on its own, that deny rule gets
- 8:41checked by Cloud before the command
- 8:42runs, but all it sees there is npm
- 8:45tests. So it doesn't see which files
- 8:47that script ends up opening. But with
- 8:49the sandbox on, that same rule gets
- 8:51passed on to the operating system. So
- 8:53now when when that dependency tries to
- 8:56open or end file, the operating system
- 8:57just doesn't let it.
- 8:59And by default, it can still read most
- 9:01of your machine, so you'd want to add
- 9:02another rule for your SSH keys if you
- 9:04care about that.
- 9:06And it also cannot reach a host that
- 9:08wasn't approved.
- 9:10But the sandbox only covers the shell
- 9:12commands that Cloud runs and whatever
- 9:14those start. But Cloud's own files, your
- 9:16MCP servers, and all of your hooks still
- 9:18run outside of it. So the rest of your
- 9:21session still runs on your own machine
- 9:22and everything that's on there. So
- 9:24ideally, you want this whole thing to
- 9:26run somewhere where none of that is even
- 9:28there in the first place. And that is a
- 9:31Cloud session because there it gets its
- 9:33own machine with a fresh copy of a repo.
- 9:36And this runs even when we close our
- 9:37laptop, which is definitely something
- 9:39you want for these longer running
- 9:40sessions that run for hours.
- 9:43So in this case, this automatically gets
- 9:45rid of the end file issue because it's
- 9:47not in Git, and neither are my SSH keys
- 9:49or our GitHub token.
- 9:51And if it still needs an API key, you
- 9:54can add that as a network secret where
- 9:55it will it will tell you like, hey, I'm
- 9:57missing an API key mid-session,
- 10:00so it can use it without actually ever
- 10:01sending it to the model. And by default,
- 10:04also in the Cloud session, network
- 10:06access is limited to things like package
- 10:08registries in GitHub. So you have to
- 10:10explicitly add those domains to your
- 10:12environment for Cloud to to reach other
- 10:14hosts.
- 10:16Okay, so with a Cloud session we can run
- 10:18these long-running sessions even with
- 10:20our laptop closed and it keeps us safe
- 10:23because it runs in its own environment.
- 10:26Now it's still good to remember that
- 10:28this machine is disposable, but the
- 10:29things that leave it aren't. So a commit
- 10:32pushed or a message it sent through a
- 10:34connector. So we still run it in auto
- 10:36mode with our deny rules just commit it
- 10:38into the repo so they come along. Uh so
- 10:41it it could still catch things like a
- 10:42forced push or a secret in a commit, all
- 10:44that kind of stuff.
- 10:47And beyond just safety um we also need
- 10:50to make sure that Cloud is actually
- 10:51working on the right thing. So next is
- 10:54verification. And the nice thing about
- 10:56being in a loop uh like we kind of knew
- 10:58the work was good because we'd already
- 11:00kind of seen every change, we'd approved
- 11:02everything.
- 11:03But now if Cloud works for hours in the
- 11:05background, we don't have that anymore.
- 11:07Um and we're not really going to read
- 11:09every file at the end either.
- 11:12So you know, say that we ask you to move
- 11:14our auth to a new API. Well Cloud is
- 11:17very good at understanding what we want,
- 11:19but there are still a lot of small
- 11:20decisions that it has to make along the
- 11:22way. So with the exact same prompt, you
- 11:25know, one run might move it over but
- 11:26leave the old API in there or one might
- 11:29move it but only for new logins and
- 11:31another one might move it but log
- 11:33everyone out. And these all look pretty
- 11:35reasonable, but it really helps to set
- 11:38up these verification points along the
- 11:40way. So Cloud keeps verifying its own
- 11:42results. And those can be anything that
- 11:44comes back as a pass or fail. So tests,
- 11:47a build, a screenshot, whatever you
- 11:48have.
- 11:49So now we just want to make sure that we
- 11:51review these verification points. Uh
- 11:54there are a lot shorter to review than
- 11:55if we just had to you know, review the
- 11:57whole change at the end. So so that's
- 11:58pretty reasonable.
- 12:00So if one of these runs would still log
- 12:01everyone out, it doesn't get past that
- 12:03first check and then it just has to find
- 12:05another way. And there's a couple ways
- 12:07to set this up. Um the easiest one is of
- 12:09course just in your prompt. So you know,
- 12:11you say what done looks like and ask it
- 12:13to split that into tasks so they have
- 12:15their own tests. Um, and I also like to
- 12:17ask it to show the actual output because
- 12:19you weren't there to see it. But again,
- 12:21prompting is not a guarantee that a
- 12:23model will do it. So for the ones that
- 12:25have to run
- 12:27guaranteed run, I would use hooks, um,
- 12:29which are just, you know, scripts that
- 12:31Cloud Code runs at a specific point.
- 12:33And
- 12:34those give you a lot of control because
- 12:36you decide when they run and what they
- 12:38run and what they check.
- 12:39So for example, every time it edits a
- 12:41file, we can run our linter. Every time
- 12:43it wants to mark a task as complete, we
- 12:45can run the tests for what it changed.
- 12:48Um, so you know, if it touched our auth
- 12:49code or something, it has to pass the
- 12:51auth auth tests.
- 12:53And when it wants to finish the whole
- 12:54session, we can just run the entire test
- 12:55suite.
- 12:57And if one of those fails, it goes, oh,
- 12:59that's still broken. It goes back until
- 13:01it passes, so it fixes it. Now, just one
- 13:04thing,
- 13:05um, when a test fails, by default, most
- 13:07tools that exit with a one exit code,
- 13:10um, but with a one, that task by Cloud
- 13:12Code just gets marked as completed
- 13:14anyway. So make sure that your scripts
- 13:17exit with a two exit code because that's
- 13:19what actually sends Cloud back to fix
- 13:21it.
- 13:22So
- 13:24okay, now we have one session that I'm
- 13:25pretty comfortable with leaving alone.
- 13:28So now we can start with a few more of
- 13:30those because they've all got their own
- 13:32machines, so they're, you know, not all
- 13:33working in the same folder and we don't
- 13:35really have to think about work trees
- 13:37too much ourselves anymore.
- 13:39But then we still start every session
- 13:41ourselves and we review every one of
- 13:43them. And honestly, this is already a
- 13:45pretty good place to be. We are still
- 13:47fully in control over what gets started
- 13:50and when we call a task done.
- 13:53But even there, um, you know, we're
- 13:55still the ones kicking off every session
- 13:57and we're still in the loop for all of
- 13:59them. So I think the most important
- 14:01thing to have in place here now is your
- 14:02CI because
- 14:04all of these sessions eventually open a
- 14:06PR and your CI runs the same checks on
- 14:08every one of them, no matter how that
- 14:10session was set up or, you know, what
- 14:11Cloud decided to do along the way. And
- 14:13And you turn on auto fix, we have like
- 14:15CI auto-fix,
- 14:16Claude can also see when one of those
- 14:18checks fails and then go back to fix it.
- 14:20So you're not the one spending your
- 14:22review on things that, you know, a check
- 14:24could have already caught.
- 14:27And for some of them, you can even turn
- 14:28on merge when ready. So then GitHub
- 14:30merges the PR once all of the checks
- 14:32have passed. So you're not in the loop
- 14:34to review. Um but again, that that's not
- 14:37the default and that really depends on
- 14:38how risky the change is. So for example,
- 14:40on our team, every PR gets reviewed by
- 14:43Claude first. So not by the session that
- 14:45wrote it. So it comes with a fresh
- 14:48context and also a separate group of
- 14:50agents to just double check every bug it
- 14:52finds.
- 14:53And then how much we review ourselves
- 14:55just depends on the risk. So smaller
- 14:57changes like docs or copy, they don't
- 14:59need a person. So once the automated
- 15:01checks are green, we're pretty good to
- 15:03go. Um maybe ordinary product changes
- 15:05just need one reviewer and then risky
- 15:07changes might need two.
- 15:10Now ultimately, kind of where we see
- 15:12things going um and we're already kind
- 15:14of doing more of that at Anthropic is
- 15:16that you're not really starting all of
- 15:18those sessions yourself either. Because
- 15:19if you're anything like me, I'm terrible
- 15:21at context switching. So having to
- 15:23manage so many sessions at the at the
- 15:25same time doesn't always go well.
- 15:27So instead, you just have one main
- 15:29session that's your orchestrator and you
- 15:31can already see this in things like
- 15:33Claude Code projects, which is still in
- 15:35beta, but
- 15:37you just tell it what it needs to be
- 15:39done and the orchestrator splits that up
- 15:41and then starts other sessions for each
- 15:43task and it keeps track of what comes
- 15:45back. So it automatically starts and
- 15:47verifies these threads which are just
- 15:49new sessions. So instead of talking to
- 15:52eight sessions, you're just talking to
- 15:53one.
- 15:55And the main session doesn't write the
- 15:56code itself. So there you want a model
- 15:58that's really good at deciding what to
- 16:00do and judging what comes back, a model
- 16:02like Fable. And if something comes back
- 16:05that isn't actually done, it just, you
- 16:06know, sends it back so until it's
- 16:08actually done and passes everything.
- 16:10And the threads need a model that's good
- 16:12at actually doing the work like Opus 55.
- 16:14And you can set those separately. So,
- 16:17you know, one model for the main session
- 16:18and then another one for the threads.
- 16:20And another benefit is that with this
- 16:22setup with CloakCode projects
- 16:24specifically, we don't manage context
- 16:26anymore. That's all done automatically
- 16:28for us.
- 16:29no longer have to think about, you know,
- 16:31when to compact or clear all of that
- 16:33stuff.
- 16:34Okay, so if you look back at those old
- 16:36best practices, they're all still there,
- 16:38but they've just moved.
- 16:40So, the model steers it now, um auto
- 16:42mode approves your deny rules and the
- 16:44environment restricts what's possible,
- 16:46um your tests, your hooks, and your CI
- 16:48checks it. And then ultimately, Cloud
- 16:50can just start them as well. So, almost
- 16:52everything we used to do ourselves is
- 16:54now either the model, the harness, or
- 16:57the environment. And we're really just
- 16:59here to start that first one and to just
- 17:00review what comes out.
- 17:02So, if you want to try this in your own
- 17:04setup, I would say just take one thing
- 17:06that's way bigger than you normally give
- 17:07Cloud. Make sure your CI actually
- 17:10catches the things you care about, and
- 17:12then spend a bit of time just
- 17:13configuring your environment, like its
- 17:14network access, its secret, and its, you
- 17:16know, setup script.
- 17:18And then start in the cloud and see
- 17:20where your sessions get stuck and where
- 17:21you're still in the loop because that's
- 17:23the next thing to hand over to Cloud. I
- 17:26also highly recommend checking out our
- 17:27best practices in the docs as well.
- 17:30Thank you so much.
About this transcript
This page contains the full transcript of Rethinking Claude Code Best Practices — Lydia Hallie, Anthropic by AI Engineer, generated from the public captions YouTube serves with the video. The transcript has 3,618 words across 528 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.
What you can do with it
Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to choose a caption track available on the video.
Free YouTube transcript tool
YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, caption language selection, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.