agentleFS
th3r-devth3r-dev/th3-skills/skills/agent-kit/cost/SKILL.md

agent-kit-cost

Skill2 starsChanged 2 days agoMITView on GitHub

Spend fewer tokens on agent work by routing each task to the cheapest model tier that can finish it, giving every agent a checkable finish line, and not spawning agents the task doesn't need. Use WHENEVER you are about to spawn a subagent, fork, parallel agents or a Workflow, choose a model for an agent, plan a multi-agent job, switch models mid-session, or the user says "cost", "cheaper agents", "token budget", "which model", "too many agents", "ลดค่า token". Ships a PreToolUse hook that nudges every Agent call that sets no model.

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Effort is the user's knob: Don't raise an agent's effort unless the user or the project's instructions ask.

    line 39

≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Agent cost

Most agent spend is waste of three kinds: a frontier model doing a search, an agent with no finish line looping, and an agent spawned for work that was five tool calls. Each rule below cuts one of them. Prompt-cache rules (byte-stable prefixes, forks, SendMessage, TTL) live in ../prompt-cache/SKILL.md; follow both.

Rules

  1. Do it inline first. A lookup whose target you know, or a handful of tool calls, costs less in this session than any agent: an agent re-reads context, and its summary drops detail you then redo. Spawn only for independent work that can run in parallel, or a side task that would flood this context with file dumps.
  2. Route by tier, start cheap. Set model on every Agent call:

    Workmodel
    search, file inventory, reading logs, collecting factshaiku
    a bounded code change with a test, a review of one diffsonnet
    planning, multi-file architecture, a task a cheaper tier already failedomit (inherit) or opus

    Escalate one tier when an agent fails its finish line, not before. The orchestrator plans; workers on cheaper tiers execute.

  3. Every brief has a finish line. Goal, scope (files, what not to touch), what to return, and how done is checked (a command and its expected output, a test name, a count). "Improve this" with no check is how an agent loops.
  4. Split big jobs into checkpoints. Several small agents with testable outputs beat one long agent you can only judge at the end. Small jobs stay single-session: multi-agent overhead (briefs, handoffs, re-reading) outweighs the parallelism.
  5. Don't switch the session's model mid-task. The prompt cache is per model; a switch makes the new model read the whole history at full price. Run /compact or start a fresh session first. A subagent on another tier doesn't touch the parent's cache, but starts its own prefix cold, so give siblings the same brief prefix.
  6. Effort is the user's knob. Don't raise an agent's effort unless the user or the project's instructions ask. Top effort tiers buy little accuracy for many more tokens.
  7. Pre-allow what is reversible. An agent stalled on a permission prompt burns wall-clock and context. Allowlist reads, tests and builds in settings.json (/fewer-permission-prompts); keep deletes, pushes and anything outward-facing behind a confirmation.
  8. The final report stands alone. Written for someone who didn't watch: what changed, the proof (test or command output), what's left. Relay what matters; the user never sees an agent's report.

The hook

scripts/agent_guard.py is a PreToolUse hook on Agent. When a call sets no model (forks excepted: they always inherit), it adds the tier table to the context. It never blocks. Register it in the project's or user's settings.json:

{"hooks": {"PreToolUse": [{"matcher": "Agent", "hooks": [{"type": "command",
  "command": "uv run --script /path/to/agent-kit/cost/scripts/agent_guard.py"}]}]}}

uv run --script scripts/agent_guard.py --selftest checks it.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.