agentleFS
ChrisLamDevChrisLamDev/hermes-core-skills/skills/token-efficiency/SKILL.md

token-efficiency

Skill11 starsChanged 5 months agoMITView on GitHub

Use when context is getting large, when working on long sessions, or when you notice token consumption is high. Use before dispatching subagents, before reading large files, and during context compaction.

9 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

12 rules. 0 are common, 11 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 9 edited versions we read keep these.

  • 11

    Distinctive

    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. Distinctive:

    Core principle: Only put in context what's needed for the current task.

    line 33
  2. Distinctive:

    Before dispatching subagents (don't send all context)

    line 39
  3. Distinctive:

    When working on a long-running session (many turns)

    line 40
  4. Distinctive:

    When the user mentions cost concerns

    line 41
  5. Distinctive:

    Before and after context compaction

    line 42
  6. Distinctive:

    Don't read files until you need them:

    line 48
  7. Distinctive:

    Instead of saving raw tool output, summarize:

    line 66
  8. Very specific:

    When dispatching subagents, use the context-inheritance pattern (see references/context-inheritance.md in the subagent-driven-development …

    line 118
  9. Distinctive:

    When running commands, pipe through filters to reduce output:

    line 133
  10. Distinctive:

    Rule of thumb: If it's not directly relevant to the current action, don't put it in context.

    line 155
  11. Distinctive:

    When Hermes triggers context compaction, it's because the window is getting full.

    line 159
  12. Distinctive:

    Keeping: only the current task state and next steps

    line 163

“Common” is measured: kept by at least 6 in 10 of the 9 edited versions of this file we could read. “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

Token Efficiency

Overview

Reduce token consumption by being intentional about what goes into context. Every token costs money and fills the context window. Smart context management can reduce costs by 30-50% without sacrificing quality.

Core principle: Only put in context what's needed for the current task. Everything else is noise.

When to Use

  • Context is approaching the window limit
  • You notice tool outputs are getting large
  • Before dispatching subagents (don't send all context)
  • When working on a long-running session (many turns)
  • When the user mentions cost concerns
  • Before and after context compaction

Techniques

1. Deferred Reading

Don't read files until you need them:

# ❌ Bad: read everything upfront
read_file("src/models/user.py")  # 200 lines
read_file("src/models/product.py")  # 300 lines
read_file("src/models/order.py")  # 250 lines
# → 750 lines in context before you even start

# ✅ Good: read only what you need now
# Start with just the file structure
search_files("*.py", target="files", path="src/models/")
# Read only the file you're about to modify
read_file("src/models/user.py")

2. Summarize Before Saving

Instead of saving raw tool output, summarize:

# ❌ Bad: save raw terminal output
# 200 lines of irrelevant log messages

# ✅ Good: save only the summary
# "Build completed: 45 passed, 0 failed, 3 warnings (all pre-existing)"

3. Use delegate_task for Heavy Lifting

Heavy operations burn token in a separate context, not the main session:

# ❌ Bad: do heavy search in main session
# browser_navigate → browser_snapshot → browser_scroll × 10
# → hundreds of lines of HTML in main context

# ✅ Good: delegate to subagent
delegate_task(goal="Search GitHub trending...", toolsets=['browser'])
# → only the summary enters main context

4. Progressive Disclosure for Skills

Skills should use progressive disclosure (load metadata first, full content only when needed):

# Skill name + 1-line description → Agent decides if relevant
# → Only then load full SKILL.md
# → Only then load reference files

This is already built into Hermes skills system — make sure descriptions are specific enough for accurate matching.

5. Avoid "Just in Case" Context

# ❌ Bad: "let me read this file just in case I need it"
read_file("src/config/settings.py")
read_file("src/config/database.py")
read_file("src/config/cache.py")
# User only asked to fix a button color

# ✅ Good: read the specific UI file first
read_file("src/ui/components/Button.tsx")
# Only read config files if debugging reveals they're relevant

6. Structure Context for Subagents

When dispatching subagents, use the context-inheritance pattern (see references/context-inheritance.md in the subagent-driven-development skill):

Context Package:
- Project: 2-3 lines
- Task: what to do
- Shared State: what's done
- Files: relevant ones only
- Constraints: gotchas to avoid

This reduces subagent context by 60-80% compared to dumping everything.

7. Use Terminal Filters

When running commands, pipe through filters to reduce output:

# ❌ Bad: full output
pytest tests/ -v

# ✅ Good: only failures and summary
pytest tests/ -q --tb=short 2>&1 | tail -20

Cost Estimation

Rough token costs (approximate):

OperationTokensCost (DeepSeek)
Read a 200-line file~2,000~$0.0003
pytest -v full output~5,000~$0.0007
Browser snapshot (full)~8,000~$0.0011
delegate_task (typical)~5,000 input / ~1,000 output~$0.0005
Context compaction~10,000~$0.0014

Rule of thumb: If it's not directly relevant to the current action, don't put it in context.

Context Compaction

When Hermes triggers context compaction, it's because the window is getting full. Help by:

  1. Summarizing what was accomplished so far
  2. Dropping old tool outputs that are no longer relevant
  3. Keeping only the current task state and next steps
  4. Recommending checkpoint save so nothing is lost

Integration

  • context-inheritance-subagent reference — context package for delegate_task
  • subagent-driven-development — uses delegate_task for heavy work
  • writing-plans — plans should be concise, not verbose
  • checkpoints-and-rewind — save before compaction so nothing lost

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.