Universal AI Lib
cd ../skills

Context Management

- Long coding sessions spanning multiple features

````instructions
---
name: context-management
description: Strategies for managing AI agent context window, session persistence, and efficient context usage during development sessions.
---

# Context Management

## When to Activate

- Long coding sessions spanning multiple features
- Complex multi-file refactors
- When context window is getting full (agent seems to forget earlier instructions)
- Starting a new session that continues previous work
- Before and after context compaction

## Core Principles

### 1. Context is Finite — Treat It Like Memory

Your context window is a fixed resource. Every file read, every search result, every tool output consumes context. Be surgical about what you load.

### 2. Load Skills, Not Entire Files

Instead of reading entire files, load the relevant skill that summarizes the patterns. Skills are pre-compressed knowledge.

### 3. Progressive Disclosure

Start with high-level understanding, drill into specifics only when needed:

```
CLAUDE.md → Relevant SKILL.md → Specific file sections → Individual lines
```

## Session Persistence

### Save State Before Ending

When ending a session or before context compaction, create a session summary:

```markdown
# Session Summary — [Date]

## What Was Done
- [Completed task 1]
- [Completed task 2]

## What Worked
- [Approach that succeeded]

## What Didn't Work
- [Approach that failed and why]

## What's Left
- [ ] [Remaining task 1]
- [ ] [Remaining task 2]

## Key Files Modified
- `src/data/skill-entries.ts` — Added 3 new skills
- `src/components/resource-card.tsx` — Updated card layout
```

### Resume From State

When starting a new session:
1. Read the previous session summary
2. Check `git log --oneline -10` to see recent changes
3. Run `pnpm build` to verify current state is clean
4. Continue from the remaining tasks

## Efficient Context Usage

### Do
- Read large file sections at once instead of many small reads
- Use `grep` to find specific patterns instead of reading entire files
- Batch related file reads in parallel
- Use skills as compressed knowledge instead of re-reading docs
- Clean up todo lists as tasks complete

### Don't
- Read the same file multiple times
- Load large files you don't need to modify
- Keep failed approaches in context
- Re-search for things already found

## Checklist

- [ ] Loaded only necessary skills for current task
- [ ] Used targeted reads instead of full file reads
- [ ] Session summary saved before ending
- [ ] No redundant context loaded

````

How to use this skill

  1. Click "Copy" to copy the skill content.
  2. Create a folder at .github/skills/context-management/ in your repository.
  3. Paste the content into SKILL.md inside the folder.
  4. Reference the skill name in your AI agent's instructions or copilot config.