02-generated-repo-core/context-intelligence/SKILL.md
Manages context window budgets, loading strategies, and compaction techniques for AI-assisted coding sessions. Trigger on 'context window', 'what to load', 'context management', 'context overflow', 'token budget'. DO NOT USE for loading specific project docs into agent context (use project-context) or prompt wording and optimization (use prompt-crafting).
npx skillsauth add chelch5/skilllibrary context-intelligenceInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Manages context window usage intelligently: what to load into context, what to summarize, what to defer. Prevents context rot—where too much information degrades model performance—by curating what's in context rather than just cramming everything in. Implements strategies from Anthropic's context engineering guidance.
Use when:
Do NOT use when:
Claude models have context windows up to 200K-1M tokens, but:
Budget allocation: | Content Type | Typical Allocation | |--------------|-------------------| | System prompt | 1-5K tokens | | Core instructions | 2-5K tokens | | Active file(s) | 5-20K tokens | | Supporting context | 10-50K tokens | | Conversation history | Remainder |
For implementation tasks:
# Load only what's directly needed
cat src/auth/login.ts # File being modified
cat src/auth/types.ts # Types it uses
cat src/auth/login.test.ts # Its tests
cat tickets/TKT-042.md # The ticket
# Total: ~4 files, focused context
Start minimal, expand as needed:
1. Load task description
2. Load primary file
3. If blocked, load dependencies
4. If still blocked, load examples
5. If still stuck, load full module
For large files/sections:
## Summary of src/database/
- models/: User, Post, Comment entities
- queries/: CRUD operations for each model
- migrations/: 12 migrations, latest adds 'preferences' table
[Full files available on request]
Following Anthropic's guidance—put long documents at TOP:
[LONG DOCUMENTS AND DATA - TOP]
---
[Your query and instructions - BOTTOM]
This can improve response quality by up to 30% for complex tasks.
Monitor usage during sessions:
## Context Budget
Window: 200K tokens
Used: ~45K tokens (22%)
- System prompt: 3K
- Project context: 12K
- Current files: 15K
- Conversation: 15K
Remaining: ~155K tokens
Status: GREEN (under 50%)
Thresholds:
Remove old turns that aren't relevant:
Keep: Last 5 turns, any turns with key decisions
Remove: Investigation turns that led nowhere, verbose tool outputs
Replace large files with summaries:
## Summary: src/database/queries.ts (was 2000 lines)
- exports 45 functions
- key patterns: findById, findMany, create, update, delete
- uses Prisma client
- relevant functions for current task: getUserById, updateUser
Keep only turns with:
For long document tasks, extract relevant quotes first:
Before answering, find relevant sections:
From src/auth/README.md:
> "JWT tokens expire after 24 hours and must be refreshed..."
From docs/API.md:
> "The /refresh endpoint requires the expired token in the Authorization header..."
Now, based on these quotes: [answer]
This reduces hallucination and improves accuracy.
When approaching limits, prepare for context transition:
## Context Transition Checkpoint
### Persisted artifacts:
- tickets/TKT-042.md updated with progress
- src/auth/login.ts committed
- START-HERE.md created with handoff
### Next window should load:
1. START-HERE.md (fastest reorientation)
2. tickets/TKT-042.md (remaining work)
3. src/auth/login.ts (current file)
Report context status when relevant:
## Context Status
Usage: 45K / 200K (22%)
Strategy: Focused loading
Loaded: 4 files (auth module)
Deferred: test fixtures, migration history
development
Implements authentication, session, token, and authorization patterns for the current stack. Trigger on 'add auth', 'JWT', 'OAuth', 'login endpoint', 'session management', 'API key auth'. DO NOT USE for OWASP hardening checklists (use security-hardening), threat modeling (use security-threat-model), or secret rotation/storage (use security-best-practices).
tools
Defines request/response shapes, versioning, validation, and compatibility rules for API-first work. Trigger on 'design API', 'OpenAPI spec', 'REST schema', 'API versioning', 'generate client SDK'. DO NOT USE for GraphQL schemas, gRPC/protobuf definitions (use stack-standards), auth endpoint logic (use auth-patterns), or external API client wrappers (use external-api-client).
development
Create a repo-local ticket system with an index, machine-readable manifest, board, and individual ticket files. Use when a repo needs task decomposition that autonomous agents can follow without re-planning the whole project each session. Do not use for executing tickets (use ticket-execution) or quick fixes that don't warrant formal tickets.
development
Detect a project's language, framework, runtime, testing setup, and deployment target from repository contents and produce a structured STACK-PROFILE.md. Use when scaffolding a new project and need to determine stack from code evidence, onboarding to an existing repo with unknown stack, or generating stack-specific skills. Do not use when stack is already documented in STACK-PROFILE.md or for repos with no code (infer from specs instead).