# Manage LLM Context Windows Reliably

Long conversations can exceed token limits and lose important details. This skill provides budgeting, summarization, prioritization, and routing strategies for reliable context assembly.

## Install

```bash
npx skillstore add sickn33/context-window-management
```

## Metadata

- Status: approved
- Slug: sickn33-context-window-management
- Skillstore revision: r2
- Version status: missing
- Tree hash: eb8faeea0da4a960011a3b354e4f4e86257d080c6b0d564183d083a6b4fa106b
- Author: sickn33
- GitHub username: sickn33
- License: MIT
- Repository: https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/context-window-management
- Ref: f9e2c34b4f19c7f3e6b0a1e93227b5f77cc12526
- Supported tools: Claude, Codex, Claude Code
- Audit status: complete
- Agent install advisory: confirmation\_required
- Manual install advisory: allowed
- Artifact signature: available
- Audit attestation: unavailable
- Human verification: not\_verified
- Risk factors: external\_commands
- Quality score: 38
- Quality tier: warning
- Public page: https://skillstore.pages.dev/skills/sickn33-context-window-management
- Manifest: https://skillstore.pages.dev/api/skills/sickn33-context-window-management/manifest

## Capabilities

- Selects full-context, summarization, or retrieval strategies according to token counts.
- Structures prompts to place critical context at positions with strong attention.
- Prioritizes messages using importance, critical information, and later references.
- Allocates token budgets across system instructions, critical context, history, queries, and responses.
- Identifies missing token counting, naive truncation, hardcoded limits, and absent management strategies.
- Suggests related skills for retrieval, persistent memory, and prompt caching.

## Use Cases

- Design Multi-Turn Assistants: Choose a context strategy that preserves recent messages, decisions, preferences, and enough capacity for each response.
- Standardize Token Budgets: Define predictable allocations for system instructions, critical context, history, current queries, and generated responses.
- Diagnose Context Overflow: Review a prompt pipeline for missing token counts, naive truncation, hardcoded limits, and weak prioritization.

## Prompt Templates

### Choose a Basic Strategy

```
Recommend a context strategy for this assistant. Model limit: [tokens]. Typical history: [size]. Preserve: [critical information].
```

### Allocate a Token Budget

```
Allocate [total tokens] across system instructions, critical context, history, current query, and response. Explain each allocation.
```

### Design Summarization Rules

```
Design summarization rules for [conversation type]. Preserve [facts and decisions], keep [recent messages], and identify validation checks.
```

### Audit an Advanced Context Pipeline

```
Audit this context pipeline: [description]. Evaluate token counting, routing, prioritization, summarization safety, retrieval triggers, and response capacity. Propose a staged improvement plan.
```

## Limitations

- Provides TypeScript-style examples and design guidance, not a complete production library.
- Does not implement retrieval, embedding models, persistent memory, or model fine-tuning.
- Requires model-specific limits, tokenizer integration, and testing within the target environment.
- Summarization can omit details or preserve injected instructions unless implementations validate generated summaries.

## Best Practices

- Reserve response capacity before adding optional history or retrieved context.
- Preserve explicit decisions, preferences, constraints, and unresolved tasks during summarization.
- Count the assembled context with the tokenizer used by the target model.

## Anti Patterns

- Do not remove the oldest messages without checking their importance.
- Do not use one hardcoded token limit for every model.
- Do not promote unvalidated summaries of untrusted messages into system instructions.

## Security Audit

- Audited at: 2026-07-23T21:21:40.81\+00:00
- Summary: All 11 external-command findings are false positives: the flagged backticks are JavaScript template literals or Markdown delimiters, not shell execution. The summarization example directly embeds message content into an LLM prompt and promotes its output to a system message, creating a prompt-injection risk.

## Stats

- Views: 91
- Downloads: 13
- Favorites: 0
- Popularity score: 0
