Anthropic Just Dropped a Masterclass on Building Agent Harnesses — Deep Dive

Cole Medin · ~28 min · Deep Dive Document
⏱ ~28 min 🎤 Cole Medin 🏷 Anthropic 🏷 Agent Harnesses 🏷 Claude Code 🏷 AI Layer 🏷 Large Codebases
Video thumbnail — Anthropic Masterclass on Building Agent Harnesses

Overview

Cole Medin breaks down Anthropic's blog post on using Claude Code in large codebases. The key thesis: the harness (AI layer) matters as much as the model. He covers 7 strategies for building an effective AI layer, demonstrates each with a concrete demo codebase, and shares a Claude plugin that bundles the most useful strategies for immediate use.

1 The Problem — Large Codebases

▶ 0:00 ▶ 0:47 ▶ 2:01

Coding agent tutorials rarely address large codebases (tens to hundreds of thousands of lines). Strategies that work for simple projects fail as complexity grows. Anthropic published an article covering how Claude Code is used in enterprise environments: multi-million line monorepos, legacy systems, distributed architectures spanning dozens of repos.

Key insight: Claude Code uses agentic search — no RAG, no indexing, no semantic search. It navigates codebases like an engineer would, using CLI tools (grep, directory structure). Trade-off: works best when it has enough starting context to know where to look.

2 The Core Thesis — Harness > Model

▶ 2:58 ▶ 3:31

The harness matters as much as the model. The "AI layer" is a third component of every codebase alongside code and tests. It includes: global rules, skills, MCP servers, sub-agents, hooks, LSP, and plugins. Each of the 7 components maps to a strategy.

Diagram concept: Code + Tests + AI Layer = Modern Codebase

3 Strategy 1 — Lean & Layered Global Rules

▶ 4:17 ▶ 5:54 ▶ 7:03

Global rules (CLAUDE.md) are the foundation — they dictate behavior the entire session.

  • Keep rules lean — studies prove thousands of lines hurts performance
  • Include only: what the codebase is about, tech stack overview, general conventions/gotchas, commands for testing/dev server
  • Layer rules with subdirectory CLAUDE.md files — progressive disclosure
  • Each subdirectory loads its own rules when Claude starts editing there
  • Claude walks UP the directory tree, loading every CLAUDE.md it finds
Pro tip: Initialize Claude Code in a subdirectory when you know exactly where to work (from a Jira ticket/GitHub issue). This scopes the working directory and loads only relevant rules.

4 Strategy 2 — Codebase Maps

▶ 8:08

When the directory structure doesn't tell the whole story, build a codebase map in your global rules: outline subdirectories with brief descriptions. This helps Claude discover which slice of the codebase to focus on based on the current task.

5 Strategy 3 — Self-Improving Hooks

▶ 10:30 ▶ 11:57 ▶ 12:54

Hooks are usually used defensively (blocking edits to certain directories). But their more valuable use is continuous improvement.

Two Hook Types Demonstrated

  • Stop hook: Runs when Claude finishes a turn. Launches a separate headless Claude session to compare changes against CLAUDE.md rules, proposes updates in a markdown review document. Ensures rules evolve with the codebase.
  • Start hook: Loads dynamic context at session start — git status, unstaged changes, recent commits. Can be extended to pull from Confluence, Jira, etc.
"It's really bad when your CLAUDE.md goes stale." The stop hook creates a self-reflection process that constantly proposes updates.

6 Strategy 4 — Path-Scoped Skills

▶ 15:23 ▶ 16:30

Skills = reusable workflows loaded on demand (progressive disclosure). In large codebases, you may have dozens or hundreds of task types.

Critical feature most people miss: skills can be scoped to specific paths using the path parameter. Example: an "add API routes" skill only activates when editing files in the API services directory.

Distinction: Global rules (CLAUDE.md) = conventions and rules. Skills = workflows and processes.

7 Strategy 5 — LSP via MCP Server

▶ 17:17 ▶ 19:44

For massive codebases (100K+ lines), grep alone is slow and token-inefficient. Solution: expose a Language Server Protocol through a local MCP server.

This gives Claude the same navigation developers have in their IDE:

  • Symbol-level search (not just string matching)
  • Find definitions and references
  • Type-aware navigation
Demo ▶ 19:44: "Find every place monthlyTotalSense is referenced" — using where_is and find_references tools instead of grep. Result: 1 definition, 2 references with precise locations.

8 Strategy 6 — Sub-Agents for Exploration

▶ 21:59

Use sub-agents to split exploration from editing. Exploration tasks (web research, codebase discovery) can consume hundreds of thousands of tokens. If the primary session does this, the context window is bloated before editing even begins.

  • Pattern: dispatch exploration to sub-agents → they return summaries → primary session reasons and acts on the summaries.
  • Example prompt: "Spin up three sub-agents: one for the database, one for the backend, one for the frontend. Help me figure out how to add authentication."

9 Strategy 7 — The Claude Plugin

▶ 24:15

Cole built a Claude plugin bundling the key strategies for immediate use in any codebase:

  • Self-improving stop hook
  • Explorer sub-agent
  • Codebase search MCP server (with LSP)
  • Path-scoped skill example

Installation: /plugin marketplace add <repo-path>/tooling then /plugin install helpline-ai-layer@helpline-tooling

Alternative: clone the demo repo, point Claude Code at it, and say "help me understand these strategies and incorporate them for my codebase."

10 Enterprise Adoption Advice

▶ 26:23 ▶ 27:52

Anthropic's advice for organizations:

  • Assign ownership — have a small team champion the AI layer build-out
  • Start with a "quiet investment period" — build rules, skills, LSP, MCP servers
  • Roll out to the organization over time
  • Avoid: individual developers being disappointed without an AI layer, everyone building separate incompatible AI layers
  • Goal: create a standard for consistent results across the organization

🎯 Key Takeaways

  1. The harness (AI layer) matters as much as the model itself
  2. Keep global rules lean — studies prove bloated rules hurt performance
  3. Layer rules with subdirectory CLAUDE.md files for progressive disclosure
  4. Use stop hooks for self-improving CLAUDE.md maintenance
  5. Scope skills to specific paths — don't overwhelm with irrelevant context
  6. LSP via MCP gives Claude IDE-level navigation for large codebases
  7. Sub-agents should handle exploration; keep the primary session for editing
  8. A dedicated team should champion AI layer adoption for organizations
  9. "A focused agent is a performant agent" — context engineering is about just the right things
  10. The AI layer is now the third component of every modern codebase

⏱ Timestamp Index

0:00Introduction: the large codebase problem
0:47Anthropic's blog post overview
2:01Agentic search: how Claude navigates
2:58Core thesis: harness > model
3:31The AI layer diagram: 7 components
4:17Strategy 1: Lean & layered global rules
5:54Subdirectory CLAUDE.md files
7:03Initializing in subdirectories
8:08Strategy 2: Codebase maps
10:30Strategy 3: Hooks for self-improvement
11:57Start hook demo: Git context loading
12:54Stop hook demo: CLAUDE.md updates
15:23Strategy 4: Path-scoped skills
16:30Rules vs workflows distinction
17:17Strategy 5: LSP via MCP server
19:44MCP server demo: symbol search
21:59Strategy 6: Sub-agents for exploration
24:15Strategy 7: The Claude plugin
26:23Enterprise adoption advice
27:52Conclusion