Skip to content
Skills Library
AI & agents · Planning

context-engineering

/context-engineering

Optimize Claude Code context-window usage for accuracy and cost. TRIGGER when: hitting context limits, structuring prompts for an agent, or trimming what gets injected into a task. SKIP: persisting knowledge across sessions (use agent-memory); semantic recall tuning (use semantic-memory-mcp).

Repository
scaffolding ↗
Licence
MIT
Last repository change
27.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 27.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Optimize Claude Code context-window usage for accuracy and cost. TRIGGER when: hitting context limits, structuring prompts for an agent, or trimming what gets injected into a task. SKIP: persisting knowledge across sessions (use agent-memory); semantic recall tuning (use semantic-memory-mcp).

Original author description

Optimize Claude Code context-window usage for accuracy and cost. TRIGGER when: hitting context limits, structuring prompts for an agent, or trimming what gets injected into a task. SKIP: persisting knowledge across sessions (use agent-memory); semantic recall tuning (use semantic-memory-mcp).

How it works

  1. Auto-Invoke Triggers
  2. Context Principles
  3. Context Analysis Process
  4. CLAUDE.md Structure
  5. Always-loaded vs lazy path-scoped rules
  6. Optimization Strategies
  7. Context Health Metrics
  8. Maintenance Schedule
  9. Output: Context Report
Original SKILL.md headings · 195 lines, 755 words
SKILL.md preview
---
name: context-engineering
description: "Optimize Claude Code context-window usage for accuracy and cost. TRIGGER when: hitting context limits, structuring prompts for an agent, or trimming what gets injected into a task. SKIP: persisting knowledge across sessions (use agent-memory); semantic recall tuning (use semantic-memory-mcp)."
---

# Context Engineering Skill

Optimizes Claude Code context for better performance and accuracy.

Tracked files in repo: !`git ls-files 2>/dev/null | wc -l || true`

## Auto-Invoke Triggers

- Every 50 messages in conversation
- After major refactoring
- When context feels stale
- Task switching
- User requests `/context` command

## Context Principles

### Active Curation
- Keep only relevant information
- Remove completed task details
- Archive outdated patterns
- Focus on current work

### Signal-to-Noise Ratio
| High Signal | Low Signal |
|-------------|------------|
| Current APIs | Old experiments |
| Active patterns | Completed tasks |
| Recent decisions | Historical context |
| Project structure | Implementation details |

### Token Budget
| File | Limit | Purpose |
|------|-------|---------|
| CLAUDE.md | < 2000 tokens | Quick reference |
| Agent docs | < 500 per agent | Role definition |
| Skills | < 300 per skill | Methodology |

## Context Analysis Process

### Step 1: Measure Current State
```markdown
## Context Analysis

### Token Counts
- CLAUDE.md: XXX tokens
- Agent docs: XXX tokens total
- Skills: XXX tokens total
- Total: XXXX tokens

### Staleness Check
- [ ] Last updated: [date]
- [ ] References current project state
- [ ] No deprecated APIs/patterns
```

### Step 2: Identify Issues
```markdown
### Issues Found

#### Stale Content
- Section X: Outdated [reason]
- Section Y: No longer relevant

#### Redundant Content
- Duplicated in files A and B
- Can consolidate X and Y

#### Missing Content
- Current API not documented
- New pattern not captured
```

### Step 3: Optimization Actions
```markdown
### Optimization Plan

1. **Archive**: Move section X to knowledge-core.md
2. **Remove**: Delete duplicate Y
3. **Update**: Refresh API documentation
4. **Add**: Document new pattern Z
```

## CLAUDE.md Structure

Optimal structure for quick reference:

```markdown
# Project Name

[One-line description]

## Quick Reference
| Action | Command |
|--------|---------|
| Run | command |
| Test | command |
| Build | command |

## Agent System
[Link to detailed docs]

## Tech Stack
- Frontend: [stack]
- Backend: [stack]

## Project Structure
[Key directories only]

## Key Rules
1. [Critical rule]
2. [Critical rule]
```

## Always-loaded vs lazy path-scoped rules

CLAUDE.md content splits into two tiers by *when* it must be available:

| Tier | Lives in | Loads | Examples |
|------|----------|-------|----------|
| **Always-loaded** | project-root `CLAUDE.md` | every message, before any file is touched | routing Protocol + Decision Tree + Agents table |
| **Lazy / path-scoped** | nested `CLAUDE.md` in a subdir | only while editing under that directory tree | per-area code conventions, stack notes, types location |

**Hard rule:** the routing sections NEVER move into a nested `CLAUDE.md` — routing
must fire on the first message, but a nested file only loads on Edit/Write under
its tree (too late to route). Only path-specific *code conventions* are
candidates to relocate, and only via the opt-in `/init-rules` scaffolder. This
trims always-loaded tokens (modest for the plugin CLAUDE.md, larger for heavy
project repos) without weakening routing. `/doctor` asserts the routing section
is still present in the root CLAUDE.md.

## Optimization Strategies

### Token Reduction
- Use tables instead of prose
- Link to details instead of inline
- Remove examples from main docs
- Keep explanations brief

### Information Hierarchy
1. **Immediate**: In CLAUDE.md
2. **Reference**: In linked docs
3. **Archive**: In knowledge-core.md
4. **Delete**: Truly obsolete

### Import Chain Management
- Max 5 levels of imports
- No circular references
- Clear dependency direction

## Context Health Metrics

| Metric | Healthy | Warning | Critical |
|--------|---------|---------|----------|
| CLAUDE.md tokens | < 1500 | 1500-2500 | > 2500 |
| Stale sections | 0 | 1-2 | 3+ |
| Redundancy | 0% | < 10% | > 10% |
| Missing critical | 0 | 1 | 2+ |

## Maintenance Schedule

| Trigger | Action |
|---------|--------|
| Every 50 messages | Quick analysis |
| After major change | Update relevant sections |
| Weekly | Full review |
| Task switch | Clear task-specific context |

## Output: Context Report

```markdown
## Context Report

**Date**: [date]
**Health**: Healthy | Warning | Critical

### Metrics
- Total tokens: XXXX
- Stale sections: X
- Redundancy: X%

### Findings
1. [Finding]
2. [Finding]

### Recommendations
1. [Action to take]
2. [Action to take]

### Potential Savings
- Current: XXXX tokens
- After optimization: XXXX tokens
- Savings: XX%
```

Versions

RepositoryScoreLicence
This page · komluk/scaffolding100MIT
mvschwarz/openrig100Apache-2.0
TerminalSkills/skills100Apache-2.0
FrancoStino/opencode-skills-collection100MIT
drvoss/everything-copilot-cli100MIT
kdlbs/kandev100AGPL-3.0
proxify-dev/agentic-kit100MIT
krzysztofsurdy/code-virtuoso100MIT
sickn33/agentic-awesome-skills100MIT

Database snapshot: 13.11.2026 · package version c97fe7e17458 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 90vc:context-engineering
    Check context limits, optimize token usage, and debug context failures. Use when asking about rate limits, usage warnings, memory systems, or context-aware agent design.
  • 90vc:context-engineering
    Check context limits, optimize token usage, and debug context failures. Use when asking about rate limits, usage warnings, memory systems, or context-aware agent design.
  • 100agent-memory
    Use when an agent needs state that survives a session or a context compaction. Covers what to persist, file-based memory, structuring notes for retrieval, and preventing memory from becoming stale. Trigger on "agent forgets everything between sessions", "agent keeps retrying the…
  • 100check-context
    Accurately check current context window and token usage. Use when the user asks about context usage, token consumption, or when monitoring context levels.
  • 90dev10x:context-audit
    Audit context window utilization — CLAUDE.md files, rules, agent specs, references, and memories. Reports budget compliance, flags oversized files, and suggests pruning actions. TRIGGER when: user wants to optimize context usage, after adding many rules or memories, or when…
  • 100evaluate-context-engineering
    Context-engineering audit (C1-C6) of skills and always-loaded rules. Use when trimming context bloat, auditing a plugin, or after a new Claude model ships.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.