agentleFS
shivae372shivae372/claude-bootstrap/.claude/skills/context-guard/SKILL.md

context-guard

Skill1 starsChanged 7 months agoApache-2.0View on GitHub

Context window protection. Auto-activates when the conversation is getting long, when the user is about to do a large file read or exploration task, or when the context is approaching its limit. Helps route expensive operations to sub-agents to protect the main session.

5 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

5 rules. 0 are common, 5 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 4 edited versions we read keep these.

  • 5

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Before the expensive operation happens, estimate the token cost:

    line 19
  2. Distinctive:

    If the operation is HIGH risk, do NOT execute it in the main context.

    line 26
  3. Distinctive:

    If a sub-agent result is returned to you, summarize it before adding it to the main conversation:

    line 34
  4. Distinctive:

    Always structured (JSON or bullet list), never raw file dumps

    line 37
  5. Distinctive:

    If the current context is approaching the limit:

    line 40

“Common” is measured: kept by at least 6 in 10 of the 4 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

Purpose

Protect the user's context window from expensive operations that should run in a sub-agent instead. This skill activates automatically when it detects patterns that commonly cause context blowout.

When I Activate

  • User asks to "read", "scan", "explore", or "analyze" a large codebase
  • User asks to run tests and see all output
  • Context window is getting long and a compaction is likely soon
  • User is about to do something that will dump large amounts of text into the main context

What I Do

1. Assess the Risk

Before the expensive operation happens, estimate the token cost:

  • Reading a large file: HIGH risk
  • Exploring a directory: MEDIUM-HIGH risk
  • Running tests with verbose output: HIGH risk
  • A targeted grep: LOW risk

2. Route to Sub-agent If High Risk

If the operation is HIGH risk, do NOT execute it in the main context. Instead:

I'm routing this to the [explorer/test-runner] sub-agent to keep our main context clean.
Use: "[agent-name] — [what you need]"

3. Compress Before Returning

If a sub-agent result is returned to you, summarize it before adding it to the main conversation:

  • Max 20 lines for any exploration result
  • Max 10 lines for a test run summary
  • Always structured (JSON or bullet list), never raw file dumps

4. Warn When Context Is Large

If the current context is approaching the limit:

⚠️ Context Warning: Our session is getting long. I recommend:
1. Using /compact to compress history
2. Starting a new session for the next distinct task
3. Current state will be saved to SESSION_STATE.md first

What I Do NOT Do

  • Block the user from doing anything
  • Make the decision unilaterally — always explain and ask if the rerouting is okay
  • Obsessively activate on every message (only on genuinely expensive operations)

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.