The Complete Guide to Making Claude Code Work For You (Even While You Sleep)

Claude Code can now run specialized AI workers, automate recurring tasks, and handle your Monday morning busywork before you wake up. Here's everything it can do, how to set it up, and the engineering trick that makes it all affordable.

Written By
Grant Harvey
Grant Harvey
Feb 22, 2026
22 minute read

Think about how many tasks you do every single week that follow the exact same pattern. Check your inbox for urgent emails. Prep for client meetings. Summarize what happened in Slack. Pull the latest industry news. Gather data from three different tools and smoosh it into a report.

Now imagine waking up on Friday morning to an email that already lists every urgent message you haven't replied to, with links to each one. Or opening your laptop before a client call to find a full briefing document — pulled from your email, Slack, Notion, and the web — already compiled and waiting.

That's not hypothetical anymore. Claude Code (Anthropic's AI coding tool that runs in your terminal) has quietly evolved from a helpful coding assistant into something much more powerful: a platform for building specialized AI workers that you can customize, schedule, and put on autopilot.

The catch? Most of these features are buried in documentation that assumes you already know what you're doing. So we dug through all of it — the official docs, the engineering posts, the community tutorials — and put together the complete guide.

This covers everything from "I've never opened a terminal" to "I want to understand the engineering that makes this affordable." Jump to whatever section fits you.

Part 1: The Building Blocks (What Claude Code Can Actually Do Now)

Before we get into automations, you need to understand the four building blocks Anthropic has added to Claude Code. Each one does something different, and they're designed to work together.

Subagents: Your Specialized AI Workers

Here's the big idea. Instead of one Claude that tries to do everything, you can now create specialized Claudes — each one tuned for a specific type of task with its own instructions, its own set of tools it's allowed to use, and (this is key) its own separate memory space.

That last part matters more than you'd think. When regular Claude explores 50 files to answer your question, all 50 files stay in the conversation, eating up space. When a subagent does the same thing, only the final answer comes back to you. The 50 files stay in the subagent's separate workspace and don't clutter your main conversation.

Advertisement

What this looks like in practice: Say you're a developer working on a big feature. You could create:

  • A code-reviewer subagent that automatically reviews your changes for bugs and security issues
  • A researcher subagent that digs through your codebase to find relevant code before you start building
  • A debugger subagent that specializes in tracing errors back to their root cause

Claude automatically hands off work to the right subagent based on what you're asking. Or you can be explicit: "Use the code-reviewer subagent to check my recent changes."

How to set one up:

  1. Open Claude Code and type /agents
  2. Select "Create New Agent"
  3. Choose whether it's project-level (shared with your team via git) or user-level (personal, works everywhere)
  4. Describe the agent's job. You can let Claude generate the initial version, then edit it. Or create the file yourself — it's just a text file with a name, a description of when to use it, a list of tools it can access, and instructions for how it should work

Here's a real example of what that file looks like:

name: researcher

description: Deep research specialist. Use when exploring files or sources before acting.

tools: Read, Grep, Glob, Bash

model: sonnet

---

You are a thorough researcher. When given a topic:

1. Search broadly first, then narrow

2. Cross-reference at least 3 sources

3. Return a structured summary with key findings

4. Flag any contradictions or gaps

That's the whole thing. Save it, and Claude now has a dedicated research assistant it can delegate to whenever you ask a question that requires digging.

Claude Code also comes with three built-in subagents you don't need to create:

  • General-purpose subagent — for complex tasks that need both reading and writing. Uses Sonnet (Anthropic's mid-tier model).
  • Plan subagent — activates when you enter plan mode. It researches your codebase before proposing a plan. Read-only, so it can't accidentally change anything.
  • Explore subagent — a fast, lightweight searcher that runs on Haiku (the cheapest model). Strictly read-only. Great for quick lookups where you don't need the heavy artillery.

Skills: Teach Claude Your Playbook

Advertisement

If subagents are separate workers, skills are instruction manuals you give to the current Claude. They inject domain-specific expertise into whatever conversation you're already having.

Say you write a newsletter (hello, that's us). You could create a skill that teaches Claude your exact formatting rules — word count limits, tone, headline style, link formatting. Every time you ask Claude to help with newsletter content, it automatically loads those rules without you having to explain them again.

Skills are just folders with a file called SKILL.md inside. The file has two parts: a short description (so Claude knows when to load it automatically) and the actual instructions.

How to set one up:

  1. Create a folder at .claude/skills/your-skill-name/
  2. Inside that folder, create a file called SKILL.md
  3. Write a description and your instructions

Example:

name: newsletter-format

description: Format content for newsletter publication.

---

When formatting newsletter content:

1. Headlines: 8 words max, active voice, no clickbait

2. Opening line: Lead with the most newsworthy fact

3. Body: 350 words max for main stories

4. Tone: Conversational but authoritative

5. Always end with a "why it matters" sentence

That's it. Claude now auto-loads this skill whenever the context matches. You can also trigger it manually by typing /newsletter-format.

Power move: You can add supporting files in the same folder — templates, reference docs, even executable scripts. Claude reads them only when they're relevant, so they don't waste space in your conversation.

When to use a skill vs. a subagent: Use a skill when you want to change how Claude works in your current conversation (formatting rules, style guides, workflows). Use a subagent when you want to delegate a task to a separate worker with its own memory space (research, code review, debugging).

Advertisement

Hooks: Automated Actions That Fire Every Single Time

Here's the problem with telling Claude "always format the code after you edit it" in a prompt: sometimes it forgets. It's a language model, not a robot. It does its best, but prompts are suggestions.

Hooks are guarantees. They're shell commands (little computer scripts) that automatically execute at specific moments during a Claude Code session. Unlike prompting, hooks fire every time, no exceptions.

The moments you can hook into:

  • After Claude edits a file (PostToolUse) → auto-format the code
  • Before Claude runs a command (PreToolUse) → block dangerous operations
  • When Claude finishes a task (Stop) → send you a desktop notification
  • When a session starts (SessionStart) → inject project context automatically
  • When Claude needs permission (PermissionRequest) → auto-approve safe commands

How to set one up:

  1. Type /hooks in Claude Code
  2. Pick which moment you want to hook into
  3. Add a "matcher" (which specific tools trigger it — or * for everything)
  4. Add the command you want to run
  5. Save to either user settings (applies everywhere) or project settings (just this repo)

Example everyone should set up first: a desktop notification when Claude finishes. This way you can tab away while Claude works and get pinged when it's done, instead of staring at the terminal.

  • Event: Stop
  • Matcher: *
  • Command (Mac): osascript -e 'display notification "Claude is done" with title "Claude Code"'

Cowork Plugins: All of the Above, No Terminal Required

Not a developer? Don't want to touch a terminal? Cowork is Anthropic's answer.

Cowork is a tab inside the Claude Desktop app (Mac and Windows) that gives Claude the same powers as Claude Code — reading your files, running tasks, coordinating multiple work streams — but wrapped in a regular chat interface. No terminal. No code.

Plugins are how you customize Cowork. Each plugin bundles together skills, subagents, and commands into a single installable package. Anthropic ships 11 pre-built plugins covering common business functions:

  • Productivity — tasks, calendars, daily workflows
  • Sales — prospect research, deal prep, CRM integration
  • Marketing — content drafting, campaign planning
  • Finance — financial analysis, forecasting models
  • Legal — contract review, risk flagging
  • Data — querying, visualization, interpretation
  • Plugin Create — a meta-plugin that helps you build custom ones
Advertisement

How to get started:

  1. Open Claude Desktop → click the Cowork tab
  2. Click "Plugins" in the left sidebar
  3. Browse and install any plugin
  4. Click "Customize" and Claude will adapt the plugin to your specific workflow
  5. Use the new /commands each plugin adds (type / to see them)

Part 2: Make It Recurring (The Part Everyone Actually Wants)

Everything above runs when you're actively in a session. But the question everyone asks is: can Claude do stuff automatically, on a schedule, without me being there?

The honest answer: Claude Code doesn't have native scheduled execution yet. Anthropic has an open feature request for it, so it's coming. But in the meantime, people have figured out several ways to make it work — ranging from dead simple to genuinely powerful.

Method 1: Custom Commands + Cron Jobs (The Allie Miller Approach)

AI educator Allie K. Miller recently walked through exactly how she set up automated recurring tasks in Claude Code, and it's one of the most practical tutorials we've seen.

Her headline example: a command called /ue (urgent emails) that runs every Friday at 9 AM, scans her Gmail for messages that need a response, checks whether she's already replied, and emails her a summary with links to each thread. No manual effort. She wakes up and it's done.

Here's the step-by-step:

  • Step 1: Create a custom command. Commands are reusable instructions saved as text files inside Claude Code. You write what you want Claude to do in plain English, give it a name, and it becomes a slash command. Miller's /ue command includes what to search (all emails, read AND unread, from a configurable time window), how to track responses (pull the full thread, check if she replied), and how to format the output (an email with "needs response" items at the top, each linked to the thread).
  • Step 2: Add arguments for flexibility. Miller set up /ue to accept modifiers. Type /ue alone and it defaults to seven days. Type /ue 3 days or /ue 1 month and it adjusts automatically. One command handles every scenario.
  • Step 3: Connect your tools with MCP. MCP (Model Context Protocol) is how Claude Code talks to other apps. Think of it as giving Claude a set of keys to your Gmail, Slack, Google Calendar, or Notion. Miller used Anthropic's official Google Workspace MCP, which she recommends over third-party alternatives for security reasons.
  • This is the most involved step — Miller says it took about an hour her first time, mostly dealing with Google OAuth permissions. But you can paste errors directly back into Claude Code and ask it to help you fix them. As she puts it: talk to it like you've never seen a computer before. It'll walk you through every click.
  • Step 4: Schedule it with a cron job. A cron job is just a task your computer runs on a schedule. Instead of typing /ue every Friday morning, you tell your computer "run this automatically at 9 AM on Fridays." Setting it up is as simple as telling Claude Code: "Set this command up on a cron job that kicks off every Friday at 9 AM."
  • Important caveats: your computer has to be on (if your laptop is closed, the job won't run), authentication tokens can expire (add a fallback that notifies you if something breaks), and you should always test it first (set a job for two minutes from now and verify it works before walking away).
  • Step 5: Stack your commands. This is where it gets genuinely exciting. Miller describes "stacking" — having one command trigger others.
  • Her example: a /daily-brief command that checks Google Calendar, sees three client meetings today, then automatically runs a /client-prep command for each one. Each client-prep pulls the last two weeks of emails, Slack messages, and web news related to that client, then compiles a briefing with key communications, active documents, and even suggested talking points.
Advertisement

She wakes up. Opens her laptop. Three client briefings are sitting in her inbox.

Method 2: runCLAUDErun (The Easy Button)

Don't want to deal with cron jobs and terminal commands? runCLAUDErun is a free Mac app that puts a visual interface on top of Claude Code scheduling. Instead of writing cron syntax, you get a clean app where you create tasks, pick a schedule (daily, weekly, custom), and let it run in the background. Everything runs locally on your machine.

You still need Claude Code installed and a Claude subscription, but this eliminates the terminal-heavy parts.

Method 3: GitHub Actions (Best for Teams)

If you want something that doesn't depend on your laptop being open, GitHub Actions lets you run Claude Code on a schedule in the cloud:

  1. Create a workflow file in your GitHub repo
  2. Set a cron schedule (e.g., "every Monday at 9 AM")
  3. Use Anthropic's official Claude Code Action
  4. Give it a prompt describing what to do

This runs on GitHub's servers, not your computer, so it works even when your laptop is off. It's the most reliable option for teams who want truly hands-off recurring automation.

Method 4: SessionStart Hook (The Simplest Option)

If you don't need full automation and just want a nudge, add a SessionStart hook that prints your recurring tasks every time you open Claude Code:

Set the hook event to SessionStart, the matcher to *, and the command to something like: echo 'TASKS DUE:' && cat ~/.claude/recurring-tasks.md

Then just say "run my recurring tasks" when you're ready. It's semi-automated — Claude reminds you what needs doing and handles the execution when you say go.

What Should You Actually Automate?

Miller suggests giving Claude Code a detailed description of your job, your tools, and your daily workflow, then asking it to brainstorm commands that would save at least one hour per week. When she demoed this for a hypothetical consulting company, Claude suggested:

  • Automated daily industry news summaries
  • Competitor monitoring
  • Tariff/regulatory tracking
  • Client meeting prep from email, Slack, and the web
  • Slack channel digests (key decisions, blockers, wins)
  • Pre-drafted update emails for team members based on Slack activity

The pattern: any task where you're gathering info from multiple sources, summarizing it, and acting on it is ripe for automation.

Part 3: The Engineering That Makes All of This Affordable

Okay. Everything above works. But if you've ever wondered how Anthropic can let Claude Code sessions run for hours without charging you $50 per session — this section is the answer. And understanding it will make you a better builder if you ever touch the API yourself.

Thariq Shihipar, who created Claude Code, just posted a deep breakdown of the single engineering decision that makes the entire product financially viable: prompt caching. Lance Martin, also at Anthropic, followed with details on a new auto-caching feature that simplifies it for developers.

Let's unpack all of this from scratch, assuming you know nothing about how AI models work behind the scenes.

First, some background: AI models are goldfish

Here's something most people don't realize. Every time you send Claude a message — whether in claude.ai, Claude Code, or a custom app — the entire conversation gets sent back to the model from scratch.

Claude doesn't "remember" what you said last turn. The app you're using (Claude Code, claude.ai, whatever) has to repackage everything from the very beginning: the system instructions that tell Claude how to behave, every tool definition (what Claude is allowed to do), the full conversation history, and your new message. It sends all of that as one big bundle every single time.

For a quick chat, this is fine — maybe a few thousand "tokens" (tokens are the chunks of text that AI models process; roughly one token per word, though it varies). But Claude Code sessions can run for hours and accumulate hundreds of thousands of tokens. Without some kind of shortcut, Anthropic would have to process that entire pile of tokens from scratch on every turn. That gets expensive fast.

What prompt caching actually does

When an AI model processes your message, two things happen in sequence.

  • Phase 1: Prefill. The model reads your entire prompt — all the instructions, conversation history, tool definitions, everything — and builds an internal representation of it. Think of this as the model "reading and understanding" everything you sent. For long conversations, this is the expensive part.
  • Phase 2: Decode. The model generates new text, one token at a time. This is the "writing the response" part.

Prompt caching is a shortcut for Phase 1. The idea: if the beginning of your prompt hasn't changed since last time, don't reprocess it. Reuse the work from last time and only process what's new.

In concrete terms: if you send Claude a 100,000-token conversation and only the last message (100 tokens) is new, the system recognizes "I already processed the first 99,900 tokens last turn" and skips straight to the new stuff.

The savings are massive: cached tokens cost 10% of what uncached tokens cost. For a heavy Claude Code session, that's the difference between the product being financially viable and not.

How the system knows what's "the same"

The caching system works by prefix matching — matching from the very beginning of the prompt forward.

Think of it like a book. If you and I have the exact same book, and I've already read chapters 1 through 9, I can skip straight to chapter 10 when we discuss it. But if your version of chapter 3 has even one sentence different from mine, I can't trust that chapters 4 through 9 are the same either. I'd have to re-read from chapter 3 onward.

That's exactly how prompt caching works. The system creates a unique digital fingerprint (technically called a "cryptographic hash" — basically a mathematical signature that's unique to a specific piece of text) of everything from the start of the prompt up to a marked checkpoint. If a future request has the same fingerprint at the same position, it's a "cache hit" — the system reuses the saved work. If anything is different, even by one character, it's a "cache miss" — everything from that point forward has to be reprocessed.

This is why the order of the prompt matters so much. If the stuff that changes frequently is at the beginning, the cache breaks on almost every turn. If the stable stuff is at the beginning, you get cache hits on almost every turn.

How Claude Code is designed around this

Thariq's post revealed that Anthropic organizes Claude Code's prompt in a very specific order, and that order exists entirely to maximize caching:

  1. Layer 1 (most stable): The system prompt and tool definitions. These are the base instructions that tell Claude how to behave, plus the definitions of every tool Claude can use (file editing, running commands, web search, etc.). This is identical for every Claude Code user worldwide, which means every single request from every user shares this cache. It's written once and cached globally.
  2. Layer 2: CLAUDE.md project instructions. This is a file in your project that contains project-specific instructions ("we use TypeScript," "always run tests before committing," etc.). Everyone working on the same project shares this cache. It changes rarely, so it almost always hits.
  3. Layer 3: Session context. Things specific to your current session — what files are open, what you're working on. Stable within a single session, cached per session.
  4. Layer 4 (most volatile): Conversation messages. The actual back-and-forth between you and Claude. This is the only part that changes every turn. It goes last, so everything before it stays cached.

This layered design means the maximum amount of the prompt is shared across the maximum number of requests. But the ordering is surprisingly fragile. Thariq admitted Anthropic has accidentally broken their own cache multiple times:

  • Putting a detailed timestamp in the system prompt (it changed every minute, invalidating the global cache for every user)
  • Shuffling tool definitions in a random order between requests (different ordering = different fingerprint = cache miss)
  • Updating tool parameters between turns

Each of these mistakes meant thousands of users suddenly lost their cache, making every request dramatically more expensive until the fix went out. That's why Anthropic now monitors their cache hit rate the way most companies monitor uptime — and they declare incidents when it drops.

The counterintuitive design rules this creates

Once you understand that everything in Claude Code is built to protect the cache, a bunch of its design decisions suddenly make sense. Here are the specific patterns Thariq shared.

  • Never update the prompt mid-conversation. Use messages instead.
    • Say the date changes during a long session, or the user edits a file that's referenced in the prompt. The obvious fix: update the system prompt with the new information. But that would break the cache — the system prompt is in Layer 1, so changing it invalidates everything after it.
    • Instead, Claude Code sneaks the update into the next regular message using a special tag. From Claude's perspective, it gets the new information ("by the way, it's now Wednesday" or "the user just edited config.js"). From the caching system's perspective, the prompt prefix is unchanged. It's a workaround, but it saves real money.
  • Never switch models mid-conversation.
    • This one trips up even experienced developers. Say you're 100,000 tokens deep in a conversation with Opus (Anthropic's most powerful model) and you want to ask a simple question. Switching to Haiku (the fast, cheap model) seems like it would save money. It doesn't.
    • Why? Each model has its own separate cache. Switching to Haiku means building a brand new cache for 100,000 tokens on a model that's never seen this conversation before. You'd actually pay more than just letting Opus answer the easy question.
    • Claude Code's solution: subagents (the same feature we covered in Part 1). Instead of switching the entire conversation to a different model, Opus prepares a focused summary of what the subagent needs to know and hands it off. The Haiku subagent works with just that small summary — not the full 100,000-token history. Opus keeps its cache completely intact.
    • This, by the way, is a big part of why subagents exist at all. They're not just an organizational convenience. They're a caching architecture decision.
  • Never add or remove tools mid-conversation.
    • Tool definitions (the descriptions of what Claude is allowed to do, like "you can edit files" or "you can search the web") are part of the prompt. They live in Layer 1. Adding a new tool or removing one in the middle of a conversation changes the fingerprint and invalidates the entire cache.
    • This creates a problem: Claude Code can have dozens of tools loaded, especially MCP tools (connections to external services like Slack, GitHub, databases). Including full definitions for all of them in every request is wasteful. But removing any of them breaks the cache.
    • Anthropic's solution is genuinely clever: deferred loading. Instead of including full tool definitions or removing them, they include tiny placeholder stubs — just the tool name and a flag that says "full definition available on request." Claude can discover and load the full details of any tool through a special ToolSearch tool when it actually needs them. The stubs are always present, always in the same order, so the cache stays perfectly stable.
  • Design features around the cache, not the other way around.
    • The best example is Plan Mode. Plan Mode is when you ask Claude Code to research and plan before making changes — a "look but don't touch" mode.
    • The obvious design: when the user enters plan mode, swap out the tool set to only include read-only tools (searching and reading, but not editing or running commands). But swapping tools means changing Layer 1, which breaks the cache.
    • What Anthropic actually did: keep all tools in the prompt at all times and make EnterPlanMode and ExitPlanMode tools themselves. When you toggle plan mode, Claude gets a message (in the conversation, not the system prompt) explaining the new rules: explore the codebase, don't edit files, call ExitPlanMode when your plan is complete. The tool definitions never change. The cache stays intact.
    • This had an unexpected bonus: because EnterPlanMode is a tool Claude can call on its own, it can autonomously switch to planning mode when it encounters a hard problem — without anyone toggling anything and without breaking the cache.
  • Handle context overflow (compaction) carefully.
    • "Compaction" is what happens when a conversation fills up Claude's context window (the maximum amount of text it can work with at once — think of it as Claude's short-term memory limit). When you hit the limit, Claude Code summarizes the conversation so far and continues a new session with that summary.
    • Simple idea, but here's the caching trap. The naive approach: make a separate API call with a different system prompt (something like "please summarize this conversation") and no tools. The problem? That request has a completely different prefix from the main conversation. Different system prompt, no tools, different structure. Zero cache hits. You'd pay full price to re-process every token in the entire conversation just to generate the summary.
    • Anthropic's approach: run the compaction request with the exact same system prompt, tools, and conversation history as the main conversation. Then append the compaction instruction ("now summarize everything above") as a new message at the very end. From the caching system's perspective, this request looks nearly identical to the last regular request — same prefix, same cache hits. The only new cost is the compaction instruction itself.
    • They also reserve a "compaction buffer" — deliberately leaving room in the context window so there's always space for the summary prompt and the model's summary output. Otherwise you'd hit the limit with no room to actually perform the compaction.

The new auto-caching feature (for developers)

Lance Martin's post covers a practical improvement to the API that makes all of this easier for people building their own apps.

Previously, developers had to manually place "breakpoints" in their prompts — markers that tell the caching system "cache everything up to here." As conversations grew, you had to keep moving these markers forward, and getting it wrong meant cache misses.

With the new auto-caching feature, you set a single parameter on your API request, and the breakpoint automatically moves to the last block in your prompt. As your conversation grows, caching keeps up without you managing it. You can still set manual breakpoints for fine-grained control, but the default behavior now just works.

Part 4: For Builders — How to Actually Get Started With the Agent SDK

Everything above is about using Claude Code as an end user. But if you want to build your own AI-powered tools — your own agents that can read files, run commands, search the web, and work autonomously — Anthropic offers the Claude Agent SDK (previously called the Claude Code SDK).

Think of it this way: Claude Code is a finished product you use. The Agent SDK is the engine under the hood, available for you to build your own products with.

What the Agent SDK gives you

The SDK is available in both Python and TypeScript. It gives your code access to the same tools that power Claude Code:

  • File operations — read, write, edit, and search files
  • Bash commands — run anything you'd run in a terminal
  • Subagents — spawn specialized workers for subtasks
  • MCP connections — connect to external services
  • Compaction — automatic context management for long-running agents
  • Hooks — lifecycle triggers just like in Claude Code

Your first agent (Python)

Here's the simplest possible agent — one that lists files in a directory:

import asyncio

from claude_agent_sdk import query, ClaudeAgentOptions


async def main():

    options = ClaudeAgentOptions(

        system_prompt="You are a helpful file assistant.",

        permission_mode="acceptEdits",

        allowed_tools=["Read", "Bash", "Glob"],

    )


    async for message in query(

        prompt="List all Python files in the current directory",

        options=options

    ):

        print(message)


asyncio.run(main())

That's a working agent. It can read files and run commands. From here, you add complexity: custom tools, subagents, MCP connections, hooks.

Where prompt caching comes into play

If you're building with the SDK, prompt caching applies automatically when you use the Anthropic API. But how much you benefit from it depends on how you structure your requests — and this is where all the lessons from Thariq's post become directly actionable.

  • When you're making a single API call (not building a multi-turn agent), caching doesn't do much. There's nothing to reuse.
  • When you're building a multi-turn agent — one that loops through gather context → take action → verify → repeat — caching becomes critical. Each turn repackages the full conversation and sends it to the API. Without caching, you pay full price for the entire conversation on every turn. With caching, you only pay full price for the new tokens.

How to implement it: Add the auto-caching parameter to your API requests:

response = client.messages.create(

    model="claude-sonnet-4-5-20250929",

    max_tokens=1000,

    cache_control={"type": "ephemeral"},

    messages=conversation_history

)

That single cache_control parameter enables auto-caching. The breakpoint automatically moves to the end of your conversation on each turn. As long as you follow the design rules from earlier — don't change your system prompt, don't shuffle tools, don't switch models — you'll get cache hits on the vast majority of your tokens.

For maximum caching, structure your requests in this order:

  1. System prompt (stable across all requests)
  2. Tool definitions (stable across all requests)
  3. Project-specific context (stable within a project)
  4. Conversation history (grows each turn, but the prefix is always the same)
  5. New user message (the only truly new content each turn)

This is the same layered ordering Claude Code uses, and it maximizes how much of each request can be served from cache.

The core agent loop

Anthropic's engineering team describes the pattern that most successful agents follow:

  • Gather context → Give your agent tools to find information. File search, web search, database queries, MCP connections to external services. The Agent SDK includes built-in tools for this, and you can add custom ones.
  • Take action → Define tools for the actions your agent should take. Send an email, edit a file, create a ticket, post to Slack. Tools are how you make your agent do things, not just say things.
  • Verify the work → This is what separates good agents from bad ones. Give Claude ways to check its own output — run tests, lint code, take a screenshot of the result and evaluate it visually, or have a separate subagent review the work.
  • Repeat → The agent loops until the task is done or it decides to stop.

The Agent SDK handles the loop, context management, and compaction for you. Your job is deciding what tools to give it, what instructions to provide, and how it should verify its work.

The Bottom Line

Claude Code has evolved from "AI that helps you write code" to "a platform for building and running specialized AI workers." The building blocks — subagents, skills, hooks, plugins, MCP connections — are all live and documented. Recurring scheduling isn't native yet, but cron jobs, GitHub Actions, and tools like runCLAUDErun fill the gap.

And none of it would be affordable without prompt caching — the invisible engineering decision that Anthropic monitors like uptime and designs every feature around.

Whether you're a non-technical knowledge worker setting up your first Cowork plugin, or a developer building a custom agent with the SDK, the through-line is the same: the people getting the most out of AI right now aren't the ones writing better prompts. They're the ones building infrastructure around it.

A subagent that reviews your code after every change. A skill that enforces your brand voice. A hook that formats every file the second Claude touches it. A cron job that compiles your inbox summary before you wake up. These take minutes to set up and pay off every session after that.

Get started:

Grant Harvey

Grant Harvey is the Lead Writer of The Neuron, where he continues to lead the publication's daily coverage of AI news, tools, and trends.

The Neuron Logo

Don't fall behind on AI. Get the AI trends & tools you need to know. Join 700,000+ professionals from top companies like Microsoft, Apple, Salesforce and more.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.