agent-harness-optimizer

agent-harness-optimizer is a skill for Claude Code from oyi77/1ai-skills. It costs 38 tokens per session (2,500 once invoked), scanned A, original, MIT.

A guide to improving the environment around an AI coding agent, including its prompts, memory, model choices, and session handling. The goal is to manage how the agent works across tasks and conversations.

In plain words
What is it for?
Use it to tune agent prompts and hooks, preserve useful memory, manage sessions, reduce token costs, and compare behavior across agent tools.
Why use it?
It helps address high token use, slow responses, lost context, and inconsistent results. It applies across coding-agent tools and runtimes.

Skill for Claude Code

Written for Claude Code: SessionStart hook event. Also seen: reads .claude/ paths; mentions CLAUDE.md; mentions subagents.

Part of the 1ai-skills plugin — 209 skills, 4 commands shipped together

Good fit Use it to tune agent prompts and hooks, preserve useful memory, manage sessions, reduce token costs, and compare behavior across agent tools.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/oyi77/1ai-skills/agent-harness-optimizer
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add oyi77/1ai-skills --skill agent-harness-optimizer
Clone the repo
git clone --depth 1 https://github.com/oyi77/1ai-skills

Made for: Claude Code.

Or install 1ai-skills, the plugin that ships this one along with the rest of its 209 skills, 4 commands.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for agent-harness-optimizer

README.md
[![agentmods](https://agentmods.dev/badge/skills/oyi77/1ai-skills/agent-harness-optimizer/github.svg)](https://agentmods.dev/skills/oyi77/1ai-skills/agent-harness-optimizer)
Your own site
<a href="https://agentmods.dev/skills/oyi77/1ai-skills/agent-harness-optimizer"><img src="https://agentmods.dev/badge/skills/oyi77/1ai-skills/agent-harness-optimizer/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for agent-harness-optimizer

Your own site · 80×15
<a href="https://agentmods.dev/skills/oyi77/1ai-skills/agent-harness-optimizer"><img src="https://agentmods.dev/badge/skills/oyi77/1ai-skills/agent-harness-optimizer.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 38 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,500 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00038 $0.02500
Opus 5 $0.00019 $0.01250
Sonnet 5 $0.00008 $0.00500
Haiku 4.5 $0.00004 $0.00250

Measured 8d ago against content hash f69c707a1231, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

agent-harness-optimizer scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 8d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

core/agent-harness-optimizer/SKILL.md · 265 lines

How it starts

The opening of the file, as written. The whole thing — 265 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Overview

Agent harness optimization is the practice of tuning the runtime environment that surrounds an AI agent -- model selection, prompt structure, hook configuration, memory persistence, and session management -- to maximize output quality while minimizing token cost and latency. Derived from real-world patterns across 10+ months of daily agentic work, these techniques apply to any harness: Claude Code, Cursor, OpenCode, Codex, Gemini, and beyond.

Anti-Rationalization Table

Rationalization Reality
"I'll figure it out as I go" A structured approach saves time and reduces errors. Follow the workflow in this skill rather than improvising.
"I already know this topic" Familiarity breeds shortcuts. Use the checklist to verify you haven't missed critical steps.
"This doesn't apply to my situation" The patterns here generalize across contexts. Adapt, don't skip — the underlying principles hold.
"One more tool will fix it" Adding complexity rarely solves process gaps. Master the core workflow first.

When to Use

Trigger phrases:

  • "agent harness optimizer"

  • "Token costs are rising faster than output quality"

  • "Agents lose context between sessions or after compaction"

  • "Hook scripts are slow, brittle, or produce noisy output"

  • Token costs are rising faster than output quality

  • Agents lose context between sessions or after compaction

  • Hook scripts are slow, brittle, or produce noisy output

  • You need the same agent behavior across multiple AI coding harnesses

  • Session history grows unwieldy and needs structured management

  • Background processes are eating into the main context window

  • You want to set up continuous learning from session patterns

When NOT to Use

  • Task is outside your authorization scope
  • You need to implement controls (use implementing-* skills)
  • Task is about analysis, not action (use analyzing-* skills)
  • You don't have access to target systems
  • Task requires compliance expertise (consult professionals)
  • Task is about defense, not offense (use defensive skills)

Read the full file on GitHub · 265 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 8d ago First seen · 265 lines · 38 tokens per session scan A f69c707a1231

Subscribe to this mod's changes

agent-harness-optimizer is a skill published in the GitHub repository oyi77/1ai-skills (12 stars, last pushed today), licensed MIT. It adds 38 tokens to every session and 2,500 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.