drewid74/ai_skills/harness-engineering
Claude Code and agent skill by drewid74/ai_skills
- community
- ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
Checking that the SKILL.md file is still in the repository.
Use this when: design an agent harness, what goes in AGENTS.md, my agent keeps doing the wrong things, workspace isolation for agents, agent ignores my rules, structure agent instructions, prevent agent drift, agent keeps breaking things, CI for agent PRs, my agent breaks production, multi-agent coordination, AGENTS.md structure, agent hooks, PreToolUse hook, PostToolUse hook, agent entropy, blast radius control, agent loop termination, agent state persistence, checkpoint resume, generator evaluator pattern, eval harness CI gate, authority tier model, Symphony harness, WORKFLOW.md design, harness vs agent loop, minimum viable harness, production harness, agent guardrails, agent permission model, tool registry, execution context, harness engineering checklist, context window engineering, mechanical enforcement linters hooks, agent observability tracing, cost controls circuit breaker, human in the loop escalation
Install
npx vskill@latest install drewid74/ai_skills/harness-engineeringSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
The same SKILL.md was published earlier as drewid74/ai_skills/harness-engineering.
Harness Engineering
Core Insight
An agent harness is everything that surrounds the model. The model generates text. The harness decides:
- What the model sees (context management)
- What it can do (tool registry + permission model)
- When it must stop (termination controls)
- What is enforced regardless of what the model decides (hooks, linters)
- What happens when things go wrong (state recovery, escalation, kill switch)
The critical distinction: AGENTS.md rules are advice the model can reason away. Hooks are constraints that always fire. A PreToolUse hook blocking .env edits cannot be overridden by the model's reasoning. A CLAUDE.md rule saying "don't edit .env" can be.
Four-Layer Architecture
Source: WOWCharlotte/harness-skills community spec, validated across 10 production sources.
Layer 1: Harness Core
Agent Loop — the loop itself (while (!done) { LLM → tools → loop }) is not the harness. The harness controls the loop:
max_turnshard limit (not optional)- Timeout enforcement (wall-clock, not just turns)
- Loop detection: same action repeated without progress → terminate
- Forced termination paths with state preservation
Session Manager
- Sessions serialize to disk and are resumable
- Each session has isolated working directory, env vars, and tool cache
- Message history: ToolResult appended after each tool execution
Config & Permissions
- Three tiers:
ReadOnly/WorkspaceWrite/DangerFullAccess - Least-privilege default: start minimal, elevate only with confirmation gate
- All config version-controlled alongside code
Layer 1 Engineering Checklist
- [ ] Agent loop has explicit termination conditions, cannot loop infinitely
- [ ] Session message history is serializable and resumable
- [ ] Permission model covers all tools with no gaps
- [ ] LLM call failures have retry with exponential backoff
- [ ] Tool execution timeouts can be forcibly terminated
Layer 2: Tool System
Tool Registry
- Declarative registration: tools declare metadata, discovered at runtime
- Schema-driven validation: LLM sees
input_schema, never implementation code - Three categories: built-in (filesystem/bash/network), MCP (external services), user-defined
Tool Executor
- Executor is pluggable: same ToolSpec can have different backends (local vs. container)
- Dangerous tools execute in subprocess/container for isolation
- Tool results are cacheable by input for idempotency
Execution Context — per-invocation context containing:
- Working directory (workspace-scoped)
- Env vars (explicit allowlist only — never parent
os.environ) - Tool call audit log
- Session-level permission grants
Layer 2 Engineering Checklist
- [ ] Tool description gives LLM enough context to choose correctly
- [ ]
input_schemaincludes required field validation — invalid input → structured error, not crash - [ ] Bash tool has timeout limit — broken commands cannot freeze the system
- [ ] Dangerous tools execute in subprocess/container
- [ ] Registered-only tools — no dynamic tool discovery in production
Layer 3: Plugins & Hooks
The enforcement layer. Intercepts every tool call at two points regardless of what the model decided.
PreToolUse Hook (blocking)
Minimum production requirements:
- Block writes to secrets files (
.env,*.pem,*.key,id_*) - Block destructive patterns (
rm -rf /,DROP TABLE, production DB writes) - Validate parameter schemas — schema mismatch → structured error
- Detect prompt injection in tool inputs
- Rate limiting per tool per session
PostToolUse Hook
Responsibilities:
- Validate output schema
- Detect silent failures (3-15% of tool calls fail without raising)
- Inject additional context into model's next message
- Write structured audit log entry
Additional lifecycle hooks:
SessionStart— inject context, initialize telemetry, load progress filesSessionEnd— persist state, clean up workspace, write summaryAfterCompaction— re-inject critical rules that summarization may have lostOnEscalation— human handoff with state preservation
Plugin Lifecycle:
Layer 3 Engineering Checklist
- [ ] PreToolUse hook covers all destructive operations
- [ ] Secrets files are on a blocklist — not just documented in AGENTS.md
- [ ] Every tool call produces a structured audit log entry
- [ ] Silent failure detection in PostToolUse (output validation)
- [ ] SessionEnd hook persists state — crash-safe recovery
Layer 4: Multi-Agent System
Topology patterns:
Planner / Executor / Evaluator (most common)
Critical: Evaluator must be a separate agent from the one that generated the output. Self-evaluation produces systematically optimistic results.
Coordinator / Worker
Coordinator maintains the plan; workers own atomic units of work.
Authority Tier Model (Stackbilt pattern)
Authority tier is determined deterministically from task metadata (labels, issue fields) — never from LLM classification of its own work.
State Handoff Contract Spawning agent MUST pass to sub-agent:
- Current working directory and branch
- Progress file path (or inline progress summary)
- List of files already modified
- Test run results
- Explicit scope (files/modules this sub-agent may touch)
- Files/modules out of scope (MUST NOT)
Layer 4 Engineering Checklist
- [ ] Evaluator is distinct from generator — same agent cannot grade its own output
- [ ] Authority tier determined from task metadata, not LLM self-assessment
- [ ] State handoff contract explicitly lists in-scope and out-of-scope files
- [ ] Orphaned workspaces are garbage-collected on session end
- [ ] Sub-agent spawn includes explicit max_turns budget
Minimum Viable Harness
All six required. Missing any one = not production-safe.
AGENTS.md / Knowledge Base Structure
Source: OpenAI harness engineering blog — field-tested on 1M-line codebase.
Do not write a monolith. A single large AGENTS.md fails in three ways:
- Context is scarce — it crowds out task, code, and relevant docs
- When everything is "important," nothing is — agents pattern-match locally instead of navigating
- It rots instantly — agents can't distinguish stale rules; humans stop maintaining it
Correct structure:
Progressive disclosure: agents start with the small entry point (AGENTS.md) and navigate to deeper docs as needed. The harness teaches agents where to look, not everything they need to know upfront.
Mechanical enforcement: CI jobs validate that docs/ is up-to-date, cross-linked, and structured correctly. A recurring "doc-gardening" agent scans for stale docs that don't reflect real code behavior and opens fix-up PRs.
Entropy Management (Garbage Collection)
Source: OpenAI harness engineering, field result: eliminated "AI slop Friday" (20% of eng week).
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingharness-engineering/SKILL.md
Popularity
- Repository stars
- 8
- Repository forks
- 1
- 7-day trend score
- 11
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 28 May 2026, 6 months ago.
Extension points
hookPre/post lifecycle hooks
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/drewid74/ai_skills/harness-engineering)