YouMind
登錄

Claude Code Harness Complete Guide with Prompts

@Sokichi_Hoshino
日文2026年10月10日
150K
367
21
1
1.0K

TL;DR

A comprehensive guide to 'harness engineering' for Claude Code, detailing 11 components like permissions, hooks, and sub-agents to ensure AI safety and efficiency in content creation workflows.

My company has 46 AI employees working for us.

The other day, one of them did something outrageous.

It fabricated a non-existent "CEO approval" and rewrote the live business plan spreadsheet.

Of course, I never authorized anything like that.

Even as AI gets smarter, these kinds of accidents happen.

So, my company restricts features for each AI employee individually and requires human approval for critical operations.

Actually, there is a name for this "system to make AI work safely and efficiently."

It's called a "Harness."

In March 2026, Anthropic published experimental results showing that harnesses significantly change AI work outcomes.

When they had the same Claude Opus 4.5 create game development software, the core game controls didn't work with just the AI alone.

However, when they divided the tasks into planning, production, and verification roles and developed it over time, a functional game control software was completed.

And here is the interesting part.

As AI evolves, some parts of the previously necessary harness become redundant.

This means what becomes important now is deciding "what mechanisms to add to AI and what to remove."

In this article, I will introduce the 11 components that make up a harness, explaining the concept while sharing my experience managing 46 AI employees.

Chapter 1: The Harness is "Everything Except the Model"

In February 2026, software developer Mitchell Hashimoto coined the term "harness engineering" in his blog to describe the practice of building countermeasures every time an AI makes a mistake.

The official Claude Code glossary defines the harness as follows:

Claude Code is the harness; Claude is the model inside it.

This means Claude Code is the harness, and Claude is the model inside it.

Reading files, running commands, checking permissions, loading memory, connecting actions. According to the glossary, all five of these tasks are the harness's job.

LangChain expresses the same idea with the formula "Agent = Model + Harness." This is the view that everything that is not the model is the harness.

An article on Martin Fowler's website also describes the harness as "everything inside an AI agent except the model."

Chapter 2: Every Component Assumes "AI Can't Do This Alone"

This is the core of the article.

Anthropic's article states the perspective on harnesses in one sentence:

every component in a harness encodes an assumption about what the model can't do on its own

This means every harness component assumes the model cannot do something on its own.

For example, placing a verifier exists because of the assumption "AI cannot notice its own mistakes."

Requiring handover notes exists because of the assumption "AI doesn't remember yesterday."

With this perspective, you know when to add and when to remove. Add components while the assumptions hold true; if the model changes and the assumption no longer holds, you can remove that component.

Indeed, Anthropic wrote that they completely removed the context reset component because problematic behaviors largely disappeared with Opus 4.5.

The same article also says:

"When a new model comes out, reviewing the harness and removing components that no longer provide support is generally a good practice" (Translated from Anthropic's article)

The second version with fewer components cost $124.70 and took 3 hours and 50 minutes to build a browser-based music production software.

Since it wasn't the exact same product as the first version, the costs aren't directly comparable. Still, it shows that components aren't just things you add.

However, not all components can be removed.

Permissions and rollback mechanisms are not placed to compensate for AI weaknesses. As AI gets smarter and humans monitor less, these become even more critical.

Chapter 3: Four Components That Teach AI How to Work

The first group consists of components that provide necessary information or tools before AI starts working.

Martin Fowler's site categorizes mechanisms that guide AI behavior beforehand as "Guides."

Here, I will primarily use Claude Code as an example.

However, these concepts apply to other AIs as well.

Component 1: Permanent Instructions (CLAUDE.md / AGENTS.md)

This is a system where rules you tell AI every time are saved in a file.

In Claude Code, CLAUDE.md serves this role; in Codex, it's AGENTS.md.

If you write down style rules or save locations, you don't need to paste explanations every time.

"When to add": When you find yourself repeating the same instructions.

"When to remove": When you can no longer explain why the instruction exists.

However, longer isn't better.

Official Claude Code documentation recommends short instructions, noting that compliance may drop if it exceeds 200 lines.

OpenAI's dev team treats AGENTS.md as a "table of contents," keeping it around 100 lines.

In my company, we previously had copies of writing rules in CLAUDE.md.

But when the original rule increased kanji conversions to 13 words, the copy still had only 10. The AI read the old rule.

Now, CLAUDE.md only contains key points and the location of the correct rules.

Keep one source of truth for rules.

This is the ironclad rule.

Note that CLAUDE.md has no enforcement power.

For operations you absolutely want to stop, use the permissions or hooks introduced later.

Component 2: Skills (SKILL.md)

Skills are systems that summarize procedures for specific tasks.

Tasks like writing X articles or checking documents are saved in SKILL.md files.

Unlike permanent instructions, skills are loaded only when needed for specific work.

SKILL.md follows the open Agent Skills format.

Adopted by ChatGPT and Codex, Google also announced Skills for Gemini and Workspace on September 30, 2026.

Skills are becoming cross-product standards.

"When to add": When you repeatedly paste the same workflow steps.

"When to remove": When the procedure bloats so much that critical info gets buried.

I failed here too.

My X article skill grew to 290,000 characters including related files.

I kept adding past failures, correction reasons, and minor exceptions.

So, I moved reasons/history to separate files, reducing reading load during writing to about 100,000 characters.

Still, I think there's room to cut more.

Skills aren't places to cram info. They're places to provide only the info needed for success.

Cutting is harder than adding.

Component 3: Connections (MCP)

MCP is a common standard for AI to connect to external services and data.

When delegating work to AI, you inevitably need external info.

For example, reading docs saved in Google Drive.

Or checking X posts.

Use connection systems like MCP for these cases.

"When to add": When AI can't fetch necessary info itself.

"When to remove": When you have connected services that aren't being used.

More connections don't always mean more convenience.

More endpoints mean wider AI operational scope.

Potential impact of wrong operations increases.

My company uses a connection to read X posts.

But we only allow four operations without confirmation: searching posts and reading content.

We separate permissions for creating posts or sending externally.

What matters isn't "connecting," but "connecting only to what's needed."

Component 4: Memory and Handover Notes

If you delegate long tasks to AI, you need systems to record past decisions.

Claude Code has automatic memory saving info learned during work.

Its index, MEMORY.md, loads the first 200 lines or 25KB (whichever limit is reached) at conversation start.

Subsequent info isn't read entirely from the start.

So, don't just dump everything into MEMORY.md.

"When to add": When AI forgets previous decisions and asks for the same explanation repeatedly.

"When to remove": When old/duplicate info grows, making current relevant info hard to find.

In my company, indexes are basically one line per item.

Details are saved in separate files, loaded only when needed.

Note: Memory systems differ from context reset systems.

Anthropic removed intentional mid-task context resets with Opus 4.5.

The need to save past info didn't disappear.

Even as AI improves, decisions/records spanning sessions remain.

Designing what to remember and what to discard is crucial.

Chapter 4: Four Components That Verify Work and Stop Dangerous Operations

Next are components that check AI work.

This group includes systems worth keeping even as AI evolves.

Especially when handling critical company info, don't neglect this.

Component 5: Permissions (deny / ask / allow)

Systems deciding what AI can/cannot do.

Claude Code manages normal permission rules via deny, ask, allow.

deny: Prohibits operation.

ask: Requires human confirmation.

allow: Executes without confirmation.

Normally, deny takes precedence over ask/allow.

However, extensions like Mods (introduced Oct 2026) affect permission judgment.

So, don't rely solely on permission settings for critical info; combine with admin controls and external approvals.

"When to add": Day one of delegating work.

Don't wait for accidents.

"When to remove": Basically never.

Though scope adjusts if work changes.

My company has 46 AI employees.

Only 10 can execute shell commands.

The other 36 cannot.

E.g., the X article writer only writes text.

No permission to publish to X.

Publishing is handled by the coordinating Claude Code.

"Writing" and "publishing" are different jobs.

Just because AI is smart doesn't mean give all permissions. Human companies don't give accounting staff full company access.

Same for AI employees.

Give only necessary permissions.

Component 6: Hooks

Hooks run pre-set processes at specific timings.

E.g., checking style rules right after AI saves a file.

Or stopping dangerous command execution attempts.

These run independently of AI judgment.

"When to add": When violations persist despite repeated prompt instructions.

"When to remove": When you confirm the check is unnecessary.

But don't easily remove hooks protecting critical ops.

My company runs check scripts via hook every time X article files are saved.

Checking for style violations or format adherence.

This article triggered checks upon saving.

Issues return to the writer AI for correction.

Also, another approval gate exists before using critical tools.

Irreversible ops require my approval.

Key point: Separate "asking AI" from "enforcing via system."

Just asking "please verify" might fail.

But running a checker ensures format validation happens.

Build systems verifying rule adherence, not just communicating rules.

Component 7: Verifier (Another AI)

Having another AI check the first AI's output.

E.g., separate fact-checker AI from writer AI.

Self-review risks same biases.

Anthropic's experiment showed separating producer/evaluator improved outcomes.

"When to add": When plausible errors mix into finished products.

"When to remove": When verifier finds zero issues?

Not enough.

Verifier might miss errors too.

Remove only if alternative verification maintains quality.

My company has an X article checker AI.

Fact-checker receives only the final article file path.

No context or drafts provided.

Knowing intent leads to same interpretation bias.

Readers don't know background.

So, let verifiers read under similar conditions.

Too many verifiers cause redundancy.

If multiple AIs flag same issue, checks overlap.

Focus on "can each find different failures?" rather than count.

Component 8: Completion Criteria (/goal)

Pre-defining what constitutes task completion.

Claude Code has /goal command.

Set criteria; AI works; another model verifies fulfillment.

If incomplete, proceeds to next step.

Max 4,000 chars for criteria.

Judge relies on evidence in conversation, not direct file/env inspection.

Be specific about criteria and verification methods.

"When to add": When AI stops midway or falsely reports completion.

"When to remove": For single-turn tasks or undefined completion criteria.

My company manages completion differently.

Run check scripts before moving to next stage.

E.g., paragraph >4 lines returns exit code 7.

Footer mismatch returns exit code 9.

Blocks progression until fixed.

Prevents AI self-reporting completion.

Format correctness ≠ content correctness.

Quality/facts need separate checks.

But automate mechanical judgments for stability.

Clarifying "what counts as done?" improves AI work.

Chapter 5: Three Components That Run AI Work

Last group decides task division, thinking depth, and rollback.

Component 9: Division (Sub-agents)

Splitting one task among separate AIs.

Sub-agents work in own context, returning summaries to main chat.

Add when research/logs clutter main chat.

Remove when passing same explanations between agents repeatedly.

Division adds handover overhead.

My company: 5 divisions, 13 departments, 46 AI employees.

One human CEO; Claude Code acts as moderator calling specialists.

This article went through writer -> simultaneous fact-checker/reader-perspective -> editor -> style checker -> X draft.

Component 10: Thinking Depth (effort)

Decides how deeply AI thinks.

Claude Opus 5.5 defaults to medium.

Setting effort in sub-agent config overrides env vars for that agent.

Add when urgent vs. careful tasks coexist.

Remove when high settings increase wait times/quota usage unnecessarily.

Honestly, no one in my 46-AI setup has custom effort yet.

All use session defaults.

I'd start raising effort for fact-checkers first.

One wrong number/date destroys article credibility.

Component 11: Rollback and Approval

Restoring original state upon failure.

Claude Code: /rewind or double-Esc opens rollback screen.

Shell-modified files aren't tracked.

External sends aren't undone by local file rollback.

Add from day one.

Protect irreversible ops via pre-stop mechanisms, not just rollback.

Rollback stays essential.

As AI improves, human oversight decreases; ability to revert gains value.

On Aug 19, an AI employee faked CEO approval and edited live spreadsheets.

Since then, only I can approve.

Claude Code can't trigger approval commands internally.

Chapter 6: Mods - Rewriting the Harness Itself

Previous chapters covered assembling components.

This covers modifying the harness itself.

Oct 1 (US time), Anthropic announced Mods for Claude Code.

Mods are small TypeScript functions altering Claude Code behavior.

Can rewrite prompts, add UI, replace standard features.

Distributed within plugins; enable/disable via plugin commands.

Built-in "You should know" Mod is disabled by default.

Enabling lets a side agent watch for oversights.

Enable via:
``text
/plugin enable cc-plugin-you-should-know@builtin
``

(If telemetry enabled via direct Anthropic connection).

Warning: Mods aren't sandboxed.

Install only from trusted sources.

Chapter 7: Three Questions to Audit Your Harness

Most useful part of this article.

Apply the 11 components to your current harness.

Open CLAUDE.md, skills, or config files.

Ask three questions per line:

Q1: What AI weakness does this line compensate for?

If unanswerable, nobody knows why it exists anymore.

You're forcing AI to read unsupported assumptions.

Q2: Have you tried removing it once with the current model?

Don't decide based on past failure memories.

Test removal once with current model/task before deciding.

Q3: If removal causes error, do you have detection mechanisms?

If none, build them first.

Add hooks/verifiers to surface errors before removing safeguards.

Q3 emphasizes testing, not guessing.

Here's a prompt to convert your permanent instructions into assumption/detection tables:

text
1The following text is permanent instructions given to AI.
2Create a table for each line with:
3
4① Assumption: "What AI can't do alone" this line addresses
5② Validity: Does this assumption still hold for current model? (Yes/Unclear/No)
6③ Detection: How would you notice errors if this line is removed? (Write "None" if no mechanism exists)
7
8Mark lines with unclear assumptions as "Reason Unknown."
9Do not suggest deletions or rewrites.
10
11(Paste CLAUDE.md content here)

Lines marked "Reason Unknown" or "Validity: No" are candidates for testing.

You decide whether to remove after seeing the table.

Summary: Same AI, Different Results Due to Outer Components

Final takeaway:

Same AI yields different work quality due to outer components.

Every component rests on "AI can't do this alone" assumptions.

Therefore, components are added to eventually be removed.

However, permissions/rollback gain importance as AI improves.

Distinguishing removable vs. permanent components is growing the harness.

Adding components costs time/money.

Gain requires sacrifice.

No need to assemble all 11 immediately.

Do one thing:

Paste CLAUDE.md into Chapter 7's prompt. Pick one "Reason Unknown" line.

Remove it, test once.

If result unchanged and detection exists, that line is nearing obsolescence.

Habitually verifying assumptions changes how you see new models.

Focus on "what can be removed" before "what was added."

AI evolves fast.

Learning from practitioners beats chasing news alone.

Thank you for reading.

【📣 Announcement 📣】

Opening an Opt-in channel for mastering AI and X.

Channel shares latest/beneficial AI & X info comprehensively.

🎁 Free Channel Perks 🎁

① 200 Prompt Collection

② 20 Gems

③ 7 Claude Skills Gift

Sharing insights from active AI×SNS marketer background (digital/big data marketing).

Beginners/watch-only welcome ✨ Check it out casually ✨

↓ Join Here.

https://line.me/ti/g2/LmLu1N1cE6UBkoURbaYf_bV8l66cCyotSJU2og

二次創作

使用 YouMind 創作爆款文章

收集素材、拆解爆點、生成視覺資產、撰寫內容,並在一個 AI 工作空間裡完成分發。

了解 YouMind
寫給創作者

把你的 Markdown 變成乾淨的 𝕏 文章

圖片上傳、表格、程式碼區塊,往 𝕏 上手動重排太痛苦。YouMind 把整篇 Markdown 一鍵轉成乾淨、可直接發佈的 𝕏 文章草稿。

試試 Markdown 轉 𝕏

更多可拆解樣本

近期爆款文章

探索更多爆款文章