Intelligent context selection - load the right files within budget using repo map, symbol map, and priority tiers
Use this skill when starting any task that requires reading project files. AI tools have limited context windows. Loading files randomly wastes tokens. This skill teaches a priority-based strategy that loads the most relevant files first, stays within budget, and tracks what was loaded for efficiency analysis.
.bbg/context/repo-map.json (generated by node .bbg/scripts/build-repo-map.js).bbg/context/symbol-map.json (generated by language-specific extractors).bbg/telemetry.db with context tables (from .bbg/scripts/context-schema.sql)Total budget depends on the model tier:
| Model Tier | Token Budget | Example Models |
|---|---|---|
| Opus | ~120K tokens |
| Claude Opus, GPT-4 |
| Sonnet | ~60K tokens | Claude Sonnet, GPT-4o |
| Light | ~30K tokens | Claude Haiku, GPT-4o-mini |
| Priority | Content | Budget % | Load Order |
|---|---|---|---|
| P0 | Task-direct files (target file + direct dependencies) | 40% | First |
| P1 | Architecture files (AGENTS.md, RULES.md, entry points) | 20% | Second |
| P2 | Related test files | 15% | Third |
| P3 | Recently modified related files | 15% | Fourth |
| P4 | Project repo-map summary | 10% | Last |
Determine the primary files for the task:
Load governance files that provide project context:
AGENTS.md or CLAUDE.md (project instructions)RULES.md (coding standards)isEntry: true)describe/it blocks), not full test bodies.Use the repo map to find high-importance files in the same module.
Load a condensed view of the project structure:
If the SQLite database exists, record the context load in context_loads.
When P0 alone exceeds 40% of budget:
/context-refresh first