Harness Engineering with Claude Code: A Five-Layer Design Pattern
Main Thesis
Good prompts alone are not enough to use Claude Code well. The author argues for harness engineering: designing the environment around the model, using Claude Code's configuration mechanisms (CLAUDE.md, Rules, Skills, Agents, Settings, Hooks) to steer its behavior deliberately. The article presents a five-layer implementation from a personal information-collection and knowledge-management repository. Hooks are not used yet.
Background
- Origin: Mitchell Hashimoto introduced the term in February 2026. When an agent makes a mistake, you fix the environment permanently so it doesn't repeat it.
- Why it's needed: LLMs are stateless. Conversation history and project context are re-injected on every request, and anything not injected effectively doesn't exist for the model.
- Three disciplines:
- Prompt engineering optimizes what you ask.
- Context engineering optimizes what the model sees.
- Harness engineering is broader: tools, permissions, and guardrails, with context engineering as a part of it.
The Five Layers
1. CLAUDE.md (the "constitution")
- Covers project purpose, structure, technical rules, and security rules.
- Explicitly lists what the assistant should not do. This defines behavioral scope rather than suppressing reasoning, and reduces drift.
- In team repos, personal preferences go in a gitignored file imported with
@. Missing import targets are ignored, so the import is safe to commit.
2. Rules (domain-specific rulebooks)
- Markdown files in
.claude/rules/, split by domain to keep CLAUDE.md small. - A
globsfrontmatter field enables lazy loading and saves context. The author reports parsing bugs with the documentedpathsfield, soglobsis safer for now.
3. Skills (reusable workflows)
- Invoked as
/commandand defined in SKILL.md. The author runs 13. - Principle: separate what the LLM does from what a script does. Moving RSS fetching and parsing into Python, and leaving only translation and classification to the LLM, cut token use to about one-sixth and processing time to about one-third.
- Running scripts with
uv runand pinned versions needs no environment setup and lowers supply-chain risk. - A good
descriptionfield lets Claude Code suggest relevant skills on its own.
4. Agents (specialized subagents)
- Invoked as
@nameand run in a separate context. - Main benefit is context isolation: searching hundreds of notes doesn't fill the main context, and only a summary returns.
5. Settings (permissions and security)
-
settings.jsonallow and deny lists act as the safety mechanism. - Allow routine commands broadly, explicitly deny destructive operations (such as repo deletion), and keep machine-specific permissions in
settings.local.json. - Piped commands are evaluated per subcommand and are hard to match with allow patterns. Running commands without pipes and letting the LLM parse the output is more reliable.
Lessons Learned
- Defining "what not to do" is the most cost-effective choice. It prevents unrequested "improvements."
- Separate deterministic work from LLM judgment. API calls, parsing, and file I/O go in scripts; judgment and generation go to the LLM.
- Keep CLAUDE.md lean. Treat it as a constitution, not an encyclopedia. Domain detail goes to Rules, workflows to Skills.
- Tune permissions iteratively. Run the workflow, note the prompts that appear, and add patterns over time.
- Defer Hooks. CLAUDE.md and Rules are advisory; Hooks are deterministic. Static
denypatterns cover most needs, and LLM-based Hooks add token cost on every tool call. Start minimal and add Hooks after observing real failures.
Conclusion
Layering CLAUDE.md, Rules, Skills, Agents, and Settings turns Claude Code from a "smart chatbot" into a personalized development environment that carries context across sessions and works within defined rules, which the author calls a "personal team."
