# Principle guard the context window

> Principle guard the context window is an open-source agent skill for developer tools. Keeps an agent's context window from overflowing during large or long-running tasks. It is available on Claude Code.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code
- **Website:** https://github.com/michael-denyer/pstack-claude/tree/main/plugins/pstack/skills/principle-guard-the-context-window
- **Repository:** https://github.com/michael-denyer/pstack-claude
- **GitHub stars:** 5,057
- **License:** MIT
- **Skill name:** principle-guard-the-context-window
- **Collection:** https://github.com/michael-denyer/pstack-claude
- **Categories:** [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-12-01

## About

This skill is a guiding principle for managing context budget. It tells the agent to notice when its working context is filling up, such as after large command outputs, long files, repeated reads, or when planning work that fans out across many steps. The core guidance is to route bulk work to subagents and keep only condensed summaries in the main conversation rather than raw payloads.

The workflow it sets out is to size phases of work in advance and cap their scope, for example by limiting how many files a phase touches, setting turn budgets, and accounting for the cost of each mechanism used. The rationale given is that a crowded context degrades reasoning quality, introduces compression artifacts, and can stall progress.

The skill is a short markdown instruction file with no scripts or bundled reference files. It is written for Claude Code and is packaged as part of a Claude Code plugin in the pstack-claude marketplace. It is not meant to be invoked directly by users.

## When your agent uses it

> Apply when context is filling up: large outputs, long files, repeated reads, fan-out planning. Route bulk to subagents; keep summaries in the main thread, not raw payloads.

## What it can access

From a static check of the files on GitHub; nothing was run.

- [Instructions only, no scripts](https://github.com/michael-denyer/pstack-claude/tree/HEAD/plugins/pstack/skills/principle-guard-the-context-window)
- [License: MIT](https://github.com/michael-denyer/pstack-claude/tree/HEAD/plugins/pstack/skills/principle-guard-the-context-window)

## Features

- **Context overflow detection:** Prompts the agent to recognise when its working context is filling up during a task.
- **Subagent delegation:** Recommends routing bulk reading and large outputs to subagents so the main thread stays lean.
- **Summary-first results:** Keeps condensed findings in the main conversation instead of raw payloads.
- **Phase sizing and scope caps:** Guides limiting files per phase and setting turn budgets before starting work.
- **Fan-out planning:** Covers accounting for the cost of each mechanism when planning parallel work.

## Good for

- Break up a large codebase audit so results come back as summaries
- Plan a multi-file refactor in phases with limited files per step
- Process long log output without pasting the full payload into the conversation
- Coordinate several parallel research tasks and collect only their conclusions

## Install

### Claude Code

This skill ships in the `pstack` plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):

```sh
/plugin marketplace add michael-denyer/pstack-claude
/plugin install pstack@pstack-claude
```

Or copy only this skill to `~/.claude/skills/principle-guard-the-context-window`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/michael-denyer/pstack-claude.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/principle-guard-the-context-window &&
cp -R "$tmp/plugins/pstack/skills/principle-guard-the-context-window" ~/.claude/skills/principle-guard-the-context-window &&
rm -rf "$tmp"
```

For one project only, put the folder in `.claude/skills/principle-guard-the-context-window` inside it instead.

### Codex

Copy the skill folder to `~/.agents/skills/principle-guard-the-context-window` to use it in every repository:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/michael-denyer/pstack-claude.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/principle-guard-the-context-window &&
cp -R "$tmp/plugins/pstack/skills/principle-guard-the-context-window" ~/.agents/skills/principle-guard-the-context-window &&
rm -rf "$tmp"
```

For one repository only, put the folder in `.agents/skills/principle-guard-the-context-window` inside it instead.

### Cursor

Copy the skill folder to `~/.cursor/skills/principle-guard-the-context-window` to use it in every project:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/michael-denyer/pstack-claude.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/principle-guard-the-context-window &&
cp -R "$tmp/plugins/pstack/skills/principle-guard-the-context-window" ~/.cursor/skills/principle-guard-the-context-window &&
rm -rf "$tmp"
```

For one project only, put the folder in `.cursor/skills/principle-guard-the-context-window` inside it instead.

### Gemini CLI

Run in a terminal (add `--scope workspace` to install it for the current workspace only):

```sh
gemini skills install https://github.com/michael-denyer/pstack-claude.git --path plugins/pstack/skills/principle-guard-the-context-window
```

Or copy the folder to `~/.gemini/skills/principle-guard-the-context-window` yourself.

### VS Code

For GitHub Copilot in VS Code, copy the skill folder to `~/.copilot/skills/principle-guard-the-context-window`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/michael-denyer/pstack-claude.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/principle-guard-the-context-window &&
cp -R "$tmp/plugins/pstack/skills/principle-guard-the-context-window" ~/.copilot/skills/principle-guard-the-context-window &&
rm -rf "$tmp"
```

For one project only, put the folder in `.github/skills/principle-guard-the-context-window` inside it instead.

### Other agents

Get the folder:

```sh
git clone --depth 1 https://github.com/michael-denyer/pstack-claude.git
```

Then copy `pstack-claude/plugins/pstack/skills/principle-guard-the-context-window` into your agent's skills folder as `principle-guard-the-context-window`. Agents that support SKILL.md read one folder per skill.

## FAQ

### When does Principle guard the context window apply?

It is meant to apply when context is filling up, such as with large outputs, long files, repeated reads, or fan-out planning.

### Does Principle guard the context window need any scripts or extra tools?

No. It has no scripts, and its frontmatter does not restrict allowed tools. It consists of a SKILL.md instruction file and one other file.

### Can users invoke Principle guard the context window directly?

No. The skill is marked as not user-invocable, so it is loaded by the agent when the task matches.

### How do I install Principle guard the context window in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/principle-guard-the-context-window to use it in all your projects, or to .claude/skills/principle-guard-the-context-window in one project. Or install the pstack plugin, which includes it: /plugin marketplace add michael-denyer/pstack-claude, then /plugin install pstack@pstack-claude.

### Does Principle guard the context window run scripts?

No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

### Which AI agents can use Principle guard the context window?

Claude Code. It reads skills in the SKILL.md format; the install steps on this page show where to put the folder.

### What are the best alternatives to Principle guard the context window?

The closest alternatives to Principle guard the context window are Principle never block on the human, Context strategy, Context budget, Principle foundational thinking and Principle laziness protocol.

## Where this comes from

- Description: from the skill's own SKILL.md.

## Alternatives

- [Principle never block on the human](https://ai-powered.com/skills/principle-never-block-on-the-human): Principle never block on the human is an open-source agent skill for developer tools.
- [Context strategy](https://ai-powered.com/skills/context-strategy): Context strategy is an open-source agent skill for developer tools.
- [Context budget](https://ai-powered.com/skills/context-budget): Context budget is an open-source agent skill for developer tools.
- [Principle foundational thinking](https://ai-powered.com/skills/principle-foundational-thinking): Principle foundational thinking is an open-source agent skill for developer tools.
- [Principle laziness protocol](https://ai-powered.com/skills/principle-laziness-protocol): Principle laziness protocol is an open-source agent skill for developer tools.
- [Principle subtract before you add](https://ai-powered.com/skills/principle-subtract-before-you-add): Principle subtract before you add is an open-source agent skill for developer tools.
- [Principle build the lever](https://ai-powered.com/skills/principle-build-the-lever): Principle build the lever is an open-source agent skill for developer tools.
- [Agentic os](https://ai-powered.com/skills/agentic-os-smartworldarafath): Agentic os is an open-source agent skill for developer tools.

---
Source: https://ai-powered.com/skills/principle-guard-the-context-window
