Glean 拾遗
日刊 /2026-07-08 / 构建 Agent 框架的 14 步路线图:从单代理到自我改进系统

构建 Agent 框架的 14 步路线图:从单代理到自我改进系统

原文 x.com 收录 2026-07-08 06:00 阅读 16 min
AI 解读

本文详细介绍了如何使用 Claude 构建 Agent 运行环境(Harness)的 14 个步骤,从基本的运行时配置到可自我改进的系统。作者强调 Harness 是 Agent 的基础,定义了模型、工具、权限和初始上下文,而循环(Loop)只是在此之上的定时器。文章提供了具体的目录结构(.claude/)、CLAUDE.md 编写规范、settings.json 权限模板、子代理(Subagent)用于隔离脏活、技能(Skills)复用流程、钩子(Hooks)强制执行不可协商的规则、以及记忆(Memory)实现跨会话积累。最终,一个良好的 Harness 能让循环输出有用结果,并在每次运行中不断优化。适合正在使用或计划使用 Claude Code 构建多 Agent 系统的工程师。

原文 16 分钟
原文 x.com ↗
§ 1

Agent harness engineering with Claude: 14-step roadmap from one agent to a self-improving system.

Agent harness engineering with Claude: 14-step roadmap from one agent to a self-improving system.

§ 2

Everyone’s talking about loops. Almost no one is talking about what the loop runs on. 9 out of 10 builders run Claude Code on the default harness - no rules, no subagents, no hooks, no memory.

Then they wonder why their loop produces slop. The truth is simple: a loop is only as good as the harness underneath it. This is the 14-step roadmap to the harness - from one agent to a system that improves itself.

Follow my Substack to get fresh AI alpha: movez.substack.com

Loop engineering - building a system that prompts your agent on a schedule - got all the attention this month. But Addy Osmani, who wrote the long-form piece on loops, was careful to point at what sits below it:

“Loop engineering sits one floor above the harness. The harness is the environment one single agent runs inside. The loop is the harness, but it runs on a timer, spawns helpers, and feeds itself.”

Harness engineering is designing that environment: the model, the tools, the permissions, the context, the memory.

It’s the unglamorous layer - and it’s the one that decides whether everything above it works. A great loop on a bad harness is a fast way to produce garbage at scale.

每个人都在谈论循环(loop)。几乎没人讨论循环运行在什么之上。90% 的开发者使用默认的 developer 工具(Claude Code)——没有规则、没有子代理、没有钩子、没有记忆。

然后他们奇怪为什么循环产出垃圾。真相很简单:循环的好坏取决于它下面的开发工具(harness)。这是构建开发工具的 14 步路线图——从一个代理到一个自我改进的系统。

关注我的 Substack 获取最新 AI 前沿:movez.substack.com

循环工程——构建一个按计划提示代理的系统——这个月获得了所有关注。但撰写循环长篇文章的 Addy Osmani 小心地指出了它下面是什么:

“循环工程位于开发工具之上的一层。开发工具是单个代理运行的环境。循环就是开发工具,但它定时运行,生成辅助工具,并自我喂食。”

开发工具工程是设计那个环境:模型、工具、权限、上下文、记忆。

这是不起眼的层面——但它决定了上面的一切是否有效。一个基于糟糕开发工具的出色循环,是快速大规模生产垃圾的途径。

§ 3

§ 4

14 steps. 3 tiers. The foundation everything else stands on.

14 步,3 层。这是其他一切的基础。

§ 5

Part 1 · what Harness is


第一部分·什么是开发工具

§ 6

01. A harness is the environment one agent runs inside.

Strip away the jargon and a harness is four things: the model doing the thinking, the tools it can reach, the permissions on those tools, and the context it reads at the start of every run.

That’s the whole surface. Everything else - subagents, hooks, memory - is a way of shaping one of those four.

The reason harness matters more than people think: the agent is a while True loop that picks a tool, runs it, looks at the result, and decides the next move.

The harness defines what tools exist, what the agent is allowed to do, and what it knows when it starts. Same model, different harness, completely different agent.

01. 开发工具是代理运行的环境。

抛开术语,开发工具包含四样东西:进行思考的模型、它可以接触的工具、这些工具上的权限、以及每次运行开始时读取的上下文。

就这么简单。其他一切——子代理、钩子、记忆——都是对这四个要素的塑造。

开发工具比人们想象的更重要的原因:代理是一个 while True 循环,它选择工具、运行它、查看结果、决定下一步。

开发工具定义了存在哪些工具、允许代理做什么、以及它开始时的知道什么。相同的模型,不同的开发工具,完全不同的代理。

§ 7

§ 8

02. The whole harness lives in one folder. .claude/

Everything that shapes your agent sits in a single directory at your project root. Learn this layout and you can read anyone’s harness at a glance:

.claude/
├─ CLAUDE.md          # standing facts — read every session
├─ settings.json      # permissions, model, hooks
├─ .mcp.json          # external tool connections
├─ rules/             # path-scoped behaviors
│  ├─ tests.md
│  └─ python-types.md
├─ agents/            # subagent definitions (~30 lines each)
│  ├─ reviewer.md
│  └─ eval-runner.md
├─ skills/            # reusable workflows
│  └─ pr-checklist/
│     └─ SKILL.md
└─ agent-memory/      # what survives between runs
   └─ STATE.md

One rule that separates a clean harness from a mess: keep it small enough that you can explain why every file exists. If you can’t say what a rule, hook, or subagent is for, delete it.

02. 整个开发工具都在一个文件夹里。.claude/

所有塑造代理的东西都放在项目根目录下的一个目录中。了解这个布局后,你可以一眼读懂任何人的开发工具:

.claude/
├─ CLAUDE.md          # 固定事实——每次会话读取
├─ settings.json      # 权限、模型、钩子
├─ .mcp.json          # 外部工具连接
├─ rules/             # 路径作用域的行为
│  ├─ tests.md
│  └─ python-types.md
├─ agents/            # 子代理定义(每文件约30行)
│  ├─ reviewer.md
│  └─ eval-runner.md
├─ skills/            # 可重用工作流
│  └─ pr-checklist/
│     └─ SKILL.md
└─ agent-memory/      # 运行间存活的内容
   └─ STATE.md

区分干净开发工具与混乱的一条规则:保持足够小,以至于你能解释每个文件为什么存在。如果你说不出某个规则、钩子或子代理的用途,就删除它。

§ 9

03. Harness vs loop vs system. Three floors, don’t mix them.

Most “my agent setup is a mess” problems come from confusing the three floors. Keep them straight:

  • The harness is the runtime one agent lives in. Static configuration: model, tools, permissions, context. This issue.
  • The loop prompts the agent on a timer, spawns helpers, feeds itself. It runs on top of the harness.
  • The self-improving system is a loop plus memory that compounds - every run leaves the next run sharper. The practical version: put standing facts in context, enforcement in hooks, procedures in skills, and isolation in subagents.

Mixing these up - enforcement in CLAUDE.md, procedures bloating context - is the root cause of inconsistent, expensive agents.

03. 开发工具 vs 循环 vs 系统。三层,不要混淆。

大多数“我的代理设置一团糟”的问题源于混淆这三层。把它们分清:

  • 开发工具是单个代理所在的运行时。静态配置:模型、工具、权限、上下文。本期内容。
  • 循环按定时器提示代理,生成辅助工具,自我喂食。它运行在开发工具之上。
  • 自我改进系统是一个循环加上不断积累的记忆——每次运行都能让下次运行更聪明。 实际版本:将固定事实放在上下文中,强制执行放在钩子中,流程放在技能中,隔离放在子代理中。

混淆这些——把强制执行放在 CLAUDE.md 中,流程膨胀上下文——是产生不一致、昂贵代理的根本原因。

§ 10

04. The default harness. What you get out of the box.

Install Claude Code, open a folder, and you already have a harness - just an empty one. The default gives you a capable model, the built-in tools (read, write, bash, search), and approval prompts on everything risky. No project context, no custom subagents, no memory.

For a one-off task, the default is fine. For anything you do more than once, the default leaves the agent re-deriving your project from scratch every session, asking permission for safe operations, and forgetting everything when you close the terminal.

The next ten steps are about closing that gap.

04. 默认开发工具。开箱即得的东西。

安装 Claude Code,打开一个文件夹,你就有了一个开发工具——只是一个空的。默认提供的是高性能模型、内置工具(读、写、bash、搜索),以及对所有风险操作的批准提示。没有项目上下文,没有定制子代理,没有记忆。

对于一次性任务,默认工具没问题。对于任何你需要重复做的事情,默认工具会让代理每次会话都从头重新推导你的项目,要求批准安全操作,并在关闭终端时忘记一切。

接下来的十步是关于缩小这个差距。

§ 11

§ 12

05. CLAUDE.md: standing facts, kept short.

CLAUDE.md is read at the start of every session. It’s the agent’s standing knowledge of your project - conventions, architecture, the “we don’t do it this way because of that incident.”

The single most common mistake: letting it grow into a giant procedures document that bloats every session.

The rule from practitioners running this daily: keep the main memory file under ~500 tokens. Standing facts go here.

Multi-step procedures go in skills (step 8). Path-specific behaviors go in rules/ files scoped to where they apply. If a section of CLAUDE.md has become a procedure rather than a fact, it belongs somewhere else.

Read your CLAUDE.md out loud. Every line should be a fact the agent needs in every session (“we use pnpm, not npm”). If a line is a procedure (“to add a feature, first…”), move it to a skill.

If it’s a rule for one folder, move it to rules/.

05. CLAUDE.md:固定事实,保持简短。

CLAUDE.md 在每次会话开始时被读取。这是代理对你项目的固定知识——约定、架构、“我们不这样做是因为那次事故”。

最常见的错误:让它膨胀成一个巨大的流程文档,拖累每次会话。

日常运行它的实践者的规则:将主记忆文件保持在约 500 tokens 以下。固定事实放在这里。

多步骤流程放在技能(第 8 步)。特定路径的行为放在 rules/ 文件中,作用域限定于它们应用的地方。如果 CLAUDE.md 的某个部分变成了流程而不是事实,它属于别处。

大声读出你的 CLAUDE.md。每一行都应该是代理在每次会话中需要的事实(“我们使用 pnpm,而不是 npm”)。如果一行是一个流程(“要添加功能,首先……”),把它移到技能中。

如果它是一个文件夹的规则,移到 rules/。

§ 13

§ 14

06. settings.json: permissions and model, set once.

The default harness asks before every risky action. That’s right when you’re watching and wrong when you’re not. settings.json is where you pre-approve the safe stuff, deny the dangerous stuff, and pick which model runs.

{
  "model": "claude-sonnet-4-6",
  "permissions": {
    "autoApprove": [
      "Read(*)", "Grep(*)",
      "Bash(npm test)", "Bash(git status)"
    ],
    "deny": [
      "Bash(rm -rf*)", "Bash(git push*)",
      "Edit(.env*)", "Edit(secrets/*)"
    ]
  }
}

The test for what to auto-approve: if this goes wrong, how hard is it to undo? Cheap to undo → auto-approve.

Expensive to undo (force-push, deleting files, touching secrets) → always deny or prompt. The middle ground is fine to auto-approve if you log it.

06. settings.json:权限和模型,一次设置。

默认开发工具会在每个风险操作前询问。当你监视时这没问题,但当你不在时就有问题。settings.json 是你预先批准安全操作、拒绝危险操作、并选择哪个模型运行的地方。

{
  "model": "claude-sonnet-4-6",
  "permissions": {
    "autoApprove": [
      "Read(*)", "Grep(*)",
      "Bash(npm test)", "Bash(git status)"
    ],
    "deny": [
      "Bash(rm -rf*)", "Bash(git push*)",
      "Edit(.env*)", "Edit(secrets/*)"
    ]
  }
}

自动批准的标准:如果这出错了,撤销有多难?容易撤销 → 自动批准。

难以撤销(强制推送、删除文件、触及密钥)→ 总是拒绝或提示。中间情况,如果你记录它,可以自动批准。

§ 15

07. Subagents: isolated context for the dirty work.

A subagent is an independent Claude session launched from the main one - its own context window, its own tool list. The point isn’t parallelism for its own sake. It’s keeping noise out of the main context.

A research task that reads 40 files, a review pass that needs a fresh perspective, an eval run that produces a wall of logs - those belong in a subagent so they don’t pollute the main thread.

The most valuable subagent in any harness is the one that checks work the main agent did. A model reviewing its own output is too easy on itself;

A separate reviewer with a fresh context window catches what the writer talked itself into. This is the writer-vs-checker split that makes every loop above the harness trustworthy.

07. 子代理:隔离上下文做脏活。

子代理是从主代理启动的独立 Claude 会话——它有自己的上下文窗口、自己的工具列表。重点不是为并行而并行,而是不让噪音进入主上下文。

一个需要读取 40 个文件的研究任务、一个需要全新视角的审查流程、一个产生大量日志的评估运行——这些都应由子代理处理,这样它们就不会污染主线程。

任何开发工具中最有价值的子代理是检查主代理工作的那个。模型审查自己的输出对自己太宽松了;

一个拥有全新上下文窗口的独立审查者能抓住作者自我说服的错误。这就是作者-审查者分离,它让开发工具之上的每个循环变得可信。

§ 16

08. Skills: procedures the agent reuses.

A Skill is a SKILL.md file the agent runs - either when you call it with /skill-name or automatically when the task matches its description.

Unlike a subagent, it runs in the same context window. It’s just reusable instructions that become part of the session.

The trigger to create one: you notice yourself pasting the same instructions into every new conversation. That’s a skill waiting to happen. A PR checklist, an eval procedure, a release process - written once, invoked forever.

And because skills are the reusable unit, they’re what makes the harness improve over time: each time the procedure fails in a new way, you add the lesson to the skill, and the next run inherits it.

08. 技能:代理可重用的流程。

技能是一个 SKILL.md 文件,代理运行它——要么你通过 /skill-name 调用,要么当任务匹配其描述时自动运行。

与子代理不同,它在同一个上下文窗口中运行。它只是可重用的指令,成为会话的一部分。

创建的触发点:你注意到自己在每个新对话中粘贴相同的指令。那就是一个技能等待诞生。PR 检查清单、评估流程、发布流程——写一次,永远调用。

由于技能是可重用单元,它们使开发工具随时间改进:每次流程以新方式失败,你就将教训添加到技能中,下次运行继承它。

§ 17

§ 18

09. Hooks: deterministic rules the model can’t hallucinate.

Everything so far depends on the model understanding your instructions. Hooks don’t.

A hook is a shell command that fires at a fixed point in the agent lifecycle - before a tool runs, after a file changes, when the session ends- and its exit code can block the action. Hooks are enforcement, CLAUDE.md is suggestion.

Two hooks earn their place in almost every harness:

  • A PreToolUse gate that blocks dangerous commands deterministically — rm -rf, reading .env, pushing to main. Exit code 2 stops the call before it happens. The model can’t talk its way past it.
  • A PostToolUse formatter that runs your linter or formatter after every edit. The agent never ships unformatted code because the harness formats it automatically.
"hooks": {
  "PreToolUse": [{
    "matcher": "Bash",
    "command": "./.claude/hooks/block-dangerous.sh"
    // exit 2 = block the call before it runs
  }],
  "PostToolUse": [{
    "matcher": "Edit|Write",
    "command": "prettier --write \"$CLAUDE_FILE_PATH\""
  }]
}

Use hooks for anything that must happen or must never happen - safety, formatting, audit logging.

Don’t use them for judgment calls; that’s what the model is for. A good harness has one or two sharp hooks, not twenty.

09. 钩子:模型无法幻觉的确定性规则。

到目前为止,一切都依赖于模型理解你的指令。钩子并非如此。

钩子是一个 shell 命令,在代理生命周期的固定点触发——在工具运行前、文件更改后、会话结束时——其退出码可以阻止操作。钩子是强制执行,CLAUDE.md 是建议。

几乎每个开发工具中都有两个钩子占有一席之地:

  • 一个 PreToolUse 门,确定性地阻止危险命令——rm -rf、读取 .env、推送到 main。退出码 2 在调用发生前阻止它。模型无法绕过它。
  • 一个 PostToolUse 格式化器,在每次编辑后运行你的 linter 或格式化工具。代理永远不会提交未格式化的代码,因为开发工具自动格式化。
"hooks": {
  "PreToolUse": [{
    "matcher": "Bash",
    "command": "./.claude/hooks/block-dangerous.sh"
    // exit 2 = block the call before it runs
  }],
  "PostToolUse": [{
    "matcher": "Edit|Write",
    "command": "prettier --write \"$CLAUDE_FILE_PATH\""
  }]
}

钩子用于必须发生或绝不能发生的事情——安全、格式化、审计日志。

不要用它们做判断性决定;那是模型的工作。一个好的开发工具有一两个锐利的钩子,而不是二十个。

§ 19

§ 20

Part 3 · make It Compound


第三部分·让它积累

§ 21

10. Add a loop. Now the harness runs on a timer.

A configured harness still waits for you to type. A loop makes it run on its own. The simplest version is /loop in Claude Code - a recurring prompt on a cadence.

Pair it with /goal and the loop keeps going until an objective condition is true, checked by an independent grader rather than the agent grading itself.

> /loop 30m /goal All tests pass and lint is clean.
  Triage new failures, draft fixes in claude/ branches.

▲ Claude uses the harness you built:
  - rules/ for conventions
  - reviewer subagent to check each fix
  - PreToolUse hook blocks pushes to main
✓ Looping. Independent grader decides "done."

Notice what just happened: the loop didn’t add intelligence. It re-used everything in the harness - the rules, the reviewer subagent, the safety hook. A good harness makes a loop trivial. That’s the whole point of building the foundation first.

10. 添加循环。现在开发工具定时运行。

配置好的开发工具仍然等待你输入。循环让它自主运行。最简单的版本是 Claude Code 中的 /loop——按节奏重复提示。

与 /goal 搭配使用,循环会持续运行直到客观条件满足,由独立评分者而非代理自己评估。

> /loop 30m /goal All tests pass and lint is clean.
  Triage new failures, draft fixes in claude/ branches.

▲ Claude uses the harness you built:
  - rules/ for conventions
  - reviewer subagent to check each fix
  - PreToolUse hook blocks pushes to main
✓ Looping. Independent grader decides "done."

请注意发生了什么:循环没有增加智能。它重用了开发工具中的所有东西——规则、审查子代理、安全钩子。一个好的开发工具使循环变得微不足道。这正是先打好基础的全部意义。

§ 22

§ 23

11. Add dynamic workflows. The harness writes its own orchestration.

For tasks too complex for a single loop - massively parallel, highly structured, adversaria- Claude can write its own JavaScript harness on the fly.

That’s a dynamic workflow: agent() to spawn, parallel() to fan out, pipeline() to stream. It composes the subagents your harness defines into patterns like fan-out-and-synthesize or adversarial verification.

The connection to harness engineering: a dynamic workflow is only as good as the subagents and skills it can call.

If your harness has a sharp reviewer subagent and a well-written eval skill, the workflow has good pieces to orchestrate. If the harness is empty, the workflow has nothing to work with.

The workflow is the conductor, your harness is the orchestra.

11. 添加动态工作流。开发工具自写编排。

对于单个循环来说过于复杂的任务——大规模并行、高度结构化、对抗性——Claude 可以动态编写自己的 JavaScript 开发工具。

这就是动态工作流:agent() 生成,parallel() 扇出,pipeline() 流式处理。它将开发工具定义的子代理组合成扇出并合成或对抗性验证等模式。

与开发工具工程的联系:动态工作流的好坏取决于它能调用的子代理和技能。

如果你的开发工具有一个锐利的审查子代理和一个编写良好的评估技能,那么工作流就有好的部分来编排。如果开发工具是空的,工作流就没有东西可用。

工作流是指挥,你的开发工具是乐团。

§ 24

§ 25

12. Add memory. What the agent forgets, the harness remembers.

This is the step that turns a configured harness into a system that actually improves. The agent forgets everything between runs. The harness doesn’t have to.

A state file - a markdown file in agent-memory/, or a Linear board - records what was tried, what worked, what failed, what rules survived.

The pattern that makes memory compound, drawn from how the strongest agents use it:

  • Write before walking away. Every run ends by updating the state file - lessons learned, verified facts, what’s next.
  • Read at the start. Every run begins by reading the state file and relevant skills, so it resumes instead of restarting.
  • Distill into skills. When a lesson is general (“Windows runners need bash, not PowerShell”), it graduates from the state file into a skill, where it applies to every future project.
# Project memory

## Verified facts # stop guessing about these
- prc is in dollars, not cents (checked via SELECT MIN/MAX)
- auth middleware order: rate_limit -> jwt -> rbac

## Lessons learned # distill the general ones into skills
- Windows CI runners fail TLS 1.2 in PowerShell — use bash
- Migrations on tables >1M rows must batch in 10k chunks

## Last session # resume, don’t restart
2026-06-11 · 3 fixes merged, 2 escalated. Next: verify rate-limit fix.

12. 添加记忆。代理忘记的,开发工具记住。

这一步将配置好的开发工具变成一个实际上改进的系统。代理在运行之间忘记一切。开发工具不必如此。

一个状态文件——agent-memory/ 中的 markdown 文件,或一个 Linear 看板——记录尝试了什么、什么有效、什么失败、哪些规则存活下来。

使记忆积累的模式,借鉴于最强代理的使用方式:

  • 离开前写入。每次运行结束通过更新状态文件——经验教训、验证过的事实、下一步。
  • 开始时读取。每次运行开始通过读取状态文件和相关技能,以便恢复而不是重启。
  • 提炼为技能。当一条经验是通用的时(“Windows runner 需要 bash,而不是 PowerShell”),它从状态文件毕业进入技能,在那里应用于每个未来项目。
# Project memory

## Verified facts # stop guessing about these
- prc is in dollars, not cents (checked via SELECT MIN/MAX)
- auth middleware order: rate_limit -> jwt -> rbac

## Lessons learned # distill the general ones into skills
- Windows CI runners fail TLS 1.2 in PowerShell — use bash
- Migrations on tables >1M rows must batch in 10k chunks

## Last session # resume, don’t restart
2026-06-11 · 3 fixes merged, 2 escalated. Next: verify rate-limit fix.
§ 26

§ 27

13. Close the loop. Output → lesson → skill → better output.


Here’s where the three floors lock together into something that improves itself. Each run produces output. The reviewer subagent (step 7) checks it.

The result - what passed, what failed, what was learned - gets written to memory (step 12). The general lessons get distilled into skills (step 8).

The next run inherits sharper skills and richer memory.

That’s the whole self-improving loop, and notice it’s built entirely from harness parts:

  • Subagent grades the work - objective check, fresh context.
  • Memory records the verdict - survives between runs.
  • Skills a runs it again - now with everything the last run learned.
  • The loop runs it again - now with everything the last run learned. The model never changed. The harness around it got sharper. That’s what “self-improving” honestly means - not a model that learns, but a harness that accumulates.

13. 闭合循环。输出→教训→技能→更好输出。


这就是三层锁定成一个自我改进系统的地方。每次运行产生输出。审查子代理(第7步)检查它。

结果——通过什么、失败什么、学到什么——被写入记忆(第12步)。通用教训被提炼为技能(第8步)。

下一次运行继承更锐利的技能和更丰富的记忆。

这就是整个自我改进循环,注意它完全由开发工具部件构建:

  • 子代理评价工作——客观检查,全新上下文。
  • 记忆记录裁决——在运行间存活。
  • 技能再次运行它——现在拥有上次运行学到的一切。
  • 循环再次运行它——现在拥有上次运行学到的一切。 模型从未改变。它周围的开发工具变得更锐利。这就是“自我改进”的真正含义——不是模型学习,而是开发工具积累。
§ 28

14. Ship the harness. Package it. Share it. Reuse it.

A harness that works on one project is an asset.

Bundle the skills, subagents, and rules into a plugin and your whole team installs the same setup in one step - same conventions, same safety hooks, same reviewer.

The harness stops being your personal setup and becomes shared infrastructure.

The order to build, one last time, because order is the lesson: get one manual run reliable on a clean harness.

Add the context and permissions. Add a reviewer subagent. Add memory. Then and only then wrap it in a loop. A loop on a good harness compounds. A loop on a bad harness just bleeds faster.

14. 打包开发工具。封装它。分享它。复用它。

一个在一个项目上有效的开发工具就是一项资产。

将技能、子代理和规则打包成一个插件,你的整个团队可以一步安装相同的设置——相同的约定、相同的安全钩子、相同的审查者。

开发工具不再是你的个人设置,而成为共享基础设施。

最后一次强调构建顺序,因为顺序就是教训:先让一次手动运行在干净的开发工具上可靠。

添加上下文和权限。添加审查子代理。添加记忆。然后,只有然后,才把它包装成循环。良好开发工具上的循环会积累。糟糕开发工具上的循环只会更快流血。

§ 29

§ 30

§ The harness mistakes that make every loop worse

  • Running on the default. No context, no rules, no memory - the agent re-derives your project every session.
  • A bloated CLAUDE.md. Procedures stuffed into standing context, bloating every run. Move them to skills.
  • Enforcement in CLAUDE.md instead of hooks. The model can ignore a suggestion. It can’t ignore a hook that exits 2.
  • One agent writing and grading its own work. Add a reviewer subagent with a fresh context window.
  • No memory. Every run restarts from zero. The state file is what makes tomorrow resume.
  • Wrapping a loop around a bad harness. The loop just produces slop faster. Build the foundation first.
  • Twenty hooks. One or two sharp ones beat a pile nobody understands.
  • Shipping a harness without scanning it. Leaked secrets and over-broad permissions spread to everyone who installs it.

§ 让每个循环变糟的开发工具错误

  • 运行默认配置。没有上下文、没有规则、没有记忆——代理每次会话重新推导你的项目。
  • CLAUDE.md 过于臃肿。流程被塞进固定上下文,拖累每次运行。将它们移到技能中。
  • CLAUDE.md 中做强制执行而非钩子。模型可以忽略建议。它不能忽略退出码为 2 的钩子。
  • 单个代理编写并评价自己的工作。添加一个拥有全新上下文窗口的审查子代理。
  • 没有记忆。每次运行从零开始。状态文件让明天恢复。
  • 将循环包装在糟糕的开发工具上。循环只会更快地产生垃圾。先打好基础。
  • 二十个钩子。一两个锐利的钩子胜过一堆没人理解的。
  • 未扫描就发布开发工具。泄露的密钥和过宽的权限会传播给所有安装它的人。
§ 31

Conclusion:

The loop gets the glory. The harness does the work.

Loop engineering is the exciting part - the agent prompting itself, running while you sleep. But a loop is just a harness on a timer.

Everything that decides whether the output is good or garbage lives one floor down, in the model you picked, the tools you allowed, the context you wrote, the reviewer you added, the memory you kept.

Build that floor well and everything above it compounds: the loop re-uses your subagents, the workflow orchestrates your skills, the memory makes each run sharper than the last.

Self-improvement was never a property of the model. It’s a property of the harness you build around it.

Pick one thing you’re not doing - probably a reviewer subagent, a safety hook, or a state file — and add it today. Keep the harness small enough to explain. Then put a loop on top, and watch the foundation do the work.

结论:

循环获得荣耀。开发工具做实际工作。

循环工程是激动人心的部分——代理自我提示,你在睡觉时它运行。但循环只是定时运行的开发工具。

决定输出是优质还是垃圾的一切都位于下一层:你选择的模型、你允许的工具、你编写的上下文、你添加的审查者、你保留的记忆。

把那层建好,上面的一切都会积累:循环复用你的子代理,工作流编排你的技能,记忆让每次运行比上次更锐利。

自我改进从来不是模型的属性。它是你围绕模型构建的开发工具的属性。

选择一件你还没做的事——很可能是审查子代理、安全钩子或状态文件——今天添加它。保持开发工具足够小到能解释清楚。然后在上面放一个循环,看着基础发挥作用。

打开原文 ↗