# context-engineering

Guides LLM agent context design, token compaction, and memory isolation to prevent attention degradation during long runs.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 495 installs · ★ 2228
- Author: mrgoonie
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/mrgoonie/claudekit-skills/tree/HEAD/.claude/skills/context-engineering/SKILL.md
- Updated: 2026-04-03
- HTML: https://affpapa.org/en/nevibecode/skills/mrgoonie-context-engineering

## What it does

This skill structures context handling for autonomous agents. Model attention is finite. Because critical information gets lost in middle positions, the skill applies a four-bucket approach: write externally, select relevant tokens, compress state, and isolate workloads. It includes reference documents covering memory architectures, tool design frameworks, and LLM-as-Judge evaluation, alongside Python utilities `context_analyzer.py` and `compression_evaluator.py`.

Multi-agent setups consume roughly 15 times more tokens than a single agent baseline. Without strict boundaries, token growth spirals quickly. Compaction should trigger at 70% to 80% utilization, targeting a 50% to 70% size reduction with less than 5% loss in task quality.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add mrgoonie/claudekit-skills --skill context-engineering -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/context-engineering/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/context-engineering/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add mrgoonie/claudekit-skills --skill context-engineering -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/context-engineering/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add mrgoonie/claudekit-skills --skill context-engineering -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/context-engineering/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install mrgoonie/claudekit-skills context-engineering
```

2. **Manually: put the files in place**
- File: `.github/skills/context-engineering/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add mrgoonie/claudekit-skills --skill context-engineering -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/mrgoonie/claudekit-skills --path .claude/skills/context-engineering
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/context-engineering/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add mrgoonie/claudekit-skills --skill context-engineering -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/mrgoonie/claudekit-skills/tree/HEAD/.claude/skills/context-engineering/SKILL.md

## When to use it
- trigger token compaction before hitting context capacity limits
- isolate context across sub-agents to limit multi-agent token growth
- debug lost-in-middle attention failures in extended agent sessions
- evaluate compression quality using `compression_evaluator.py`

## Example prompts
- Analyze our agent's token usage and set up a context compaction strategy
- Help me partition context boundaries across our sub-agents
- Audit our tool definitions using the four-question framework

## Similar
- [context-engineering-collection](https://affpapa.org/en/nevibecode/skills/context-engineering-collection.md) — skill · 4200 installs
- [context-compression](https://affpapa.org/en/nevibecode/skills/muratcankoylan-context-compression.md) — skill · 459 installs
- [multi-agent-patterns](https://affpapa.org/en/nevibecode/skills/multi-agent-patterns.md) — skill · 1300 installs
- [ai-agents-architect](https://affpapa.org/en/nevibecode/skills/sickn33-ai-agents-architect.md) — skill · 1500 installs
- [prompt-engineering](https://affpapa.org/en/nevibecode/skills/neolabhq-prompt-engineering.md) — skill · 1400 installs
- [context-window-management](https://affpapa.org/en/nevibecode/skills/sickn33-context-window-management.md) — skill · 1600 installs

## Other versions with the same name
- [context-engineering · addyosmani](https://affpapa.org/en/nevibecode/skills/context-engineering.md) — 61600 installs
- [context-engineering · mvschwarz](https://affpapa.org/en/nevibecode/skills/mvschwarz-context-engineering.md) — ★ 8172

From the same set: [mrgoonie/claudekit-skills](https://affpapa.org/en/nevibecode/by/mrgoonie/claudekit-skills.md) — 21 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
