principle-guard-the-context-window

principle-guard-the-context-window is a skill for Claude Code, Cursor from backnotprop/pstack. It costs 46 tokens per session (112 once invoked), scanned A, a copy of principle-guard-the-context-window, MIT.

A workflow for managing an AI agent's limited context window, the amount of information it can work with in one session. It routes large material to separate workers and keeps concise summaries in the main conversation.

In plain words
What is it for?
Use it when a task involves many files, large outputs, repeated reads, or parallel work, so only relevant summaries and bounded amounts of information stay in the main context.
Why use it?
It reduces overload from long files, large command outputs, screenshots, and repeated reading, which can make reasoning less reliable.

Skill for Claude CodeCursor

Written for Claude Code and Cursor: disable-model-invocation in frontmatter, but also shipped in a Cursor plugin. Also seen: mentions subagents.

Part of the pstack plugin — 61 skills, 2 agents shipped together

Good fit Use it when a task involves many files, large outputs, repeated reads, or parallel work, so only relevant summaries and bounded amounts of information stay in the main context.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/backnotprop/pstack/principle-guard-the-context-window
About the project

pstack is a collection of plain Agent Skills and engineering principles that guide AI-assisted software development across coding agents such as Claude Code, Codex, Pi, Cursor, and OpenCode. It is for developers who want reusable practices for tasks including testing, technical writing, debugging, review, and coordinating agent work. The catalogue entries are the project's skills, agents, and plugin.

backnotprop/pstack · 2,800 stars · on GitHub

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 backnotprop/pstack --skill principle-guard-the-context-window
Clone the repo
git clone --depth 1 https://github.com/backnotprop/pstack

Made for: Claude Code, Cursor.

Or install pstack, the plugin that ships this one along with the rest of its 61 skills, 2 agents.

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 principle-guard-the-context-window

README.md
[![agentmods](https://agentmods.dev/badge/skills/backnotprop/pstack/principle-guard-the-context-window/github.svg)](https://agentmods.dev/skills/backnotprop/pstack/principle-guard-the-context-window)
Your own site
<a href="https://agentmods.dev/skills/backnotprop/pstack/principle-guard-the-context-window"><img src="https://agentmods.dev/badge/skills/backnotprop/pstack/principle-guard-the-context-window/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 principle-guard-the-context-window

Your own site · 80×15
<a href="https://agentmods.dev/skills/backnotprop/pstack/principle-guard-the-context-window"><img src="https://agentmods.dev/badge/skills/backnotprop/pstack/principle-guard-the-context-window.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 46 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 112 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
  • Socket pass 13 Oct 2026
  • Snyk pass 13 Oct 2026
How audits are shown
Origin 95% copy Near-identical to another mod 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.00046 $0.00112
Opus 5.5 $0.00018 $0.00045
Sonnet 5.5 $0.00009 $0.00022
Haiku 4.5 $0.00005 $0.00011

Measured 13d ago against content hash af0b9dd70b43, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

principle-guard-the-context-window 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 13d 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.

Origin

This is a copy

95% identical to principle-guard-the-context-window — 2 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

skills/principle-guard-the-context-window/SKILL.md · 13 lines

What it actually says

Guard the Context Window

Why: Context overflow degrades reasoning quality, creates compression artifacts, and halts progress.

Pattern:

  • Size phases and cap scope. Limit files per phase, set turn budgets, account for mechanism costs.
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. 13d ago Changed · -4 lines af0b9dd70b43
  2. 21d ago Changed · -1 lines d2cef1478625
  3. 1mo ago Changed 9f60e2c79b35
  4. 1mo ago First seen · 18 lines · 46 tokens per session scan A 291d0125125e

Subscribe to this mod's changes

principle-guard-the-context-window is a skill published in the GitHub repository backnotprop/pstack (2,800 stars, last pushed today), licensed MIT. It adds 46 tokens to every session and 112 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. It is 95% identical to principle-guard-the-context-window, differing in 2 lines, and is treated as a copy.

Related

Other skills, from other repositories

coordinate-reasoning

AI internal coordination using stigmergic signals — managing information freshness in context and memory, decay rates for assumption staleness, and emergent coherent behavior from simple local protocols. Use during complex tasks where multiple sub-tasks must coordinate, when context has grown long and information…

pjt222/agent-almanac · 90 tokens

bootstrap-agent-identity

Consistent agent behavior after restart — progressive identity loading, working context reconstruction from persistent artifacts, fresh-vs-continuation detection, calibration through centering and attunement, and identity verification for coherence. Addresses the cold-start problem where an agent must reconstruct who…

pjt222/agent-almanac · 105 tokens

log-session

Append a structured entry to the project's session log (docs/LOGS.md): what was done this session, files touched, decisions taken, and the next step — so the next session (or another person) can pick up the thread without re-reading git history. Run it before /clear, before closing your agent session, or at any…

gtrabanco/agentic-workflow · 133 tokens

decision-logger

Two-layer memory architecture for board meeting decisions. Manages raw transcripts (Layer 1) and approved decisions (Layer 2). Use when logging decisions after a board meeting, reviewing past decisions with /cs:decisions, or checking overdue action items with /cs:review. Invoked automatically by the board-meeting…

bestagentkits/agency-skills · 76 tokens

context-engine

Loads and manages company context for all C-suite advisor skills. Reads /.claude/company-context.md, detects stale context (>90 days), enriches context during conversations, and enforces privacy/anonymization rules before external API calls. Use when starting any C-suite advisor session, when context looks stale or…

bestagentkits/agency-skills · 75 tokens

decide

/cs:decide — Log a decision to two-layer memory via decision-logger. Approved memo becomes durable; raw transcripts kept for reference. Use when the founder has approved a boardroom memo and the decision must become durable company memory — e.g. right after /cs:boardroom concludes.

bestagentkits/agency-skills · 66 tokens