Context is a budget, not a warehouse for the entire repository

Context is a limited resource shared by conversation history, files, logs, project rules, and completion criteria. Passing the entire repository often adds noise, expands scope, and prompts unnecessary edits.

The optimal approach is the minimum sufficient context, with the option to expand it selectively when the investigation reveals a specific lack of data.

SignalRole in the task
GoalWhat should change
Affected areaWhere to look for related implementation
EvidenceWhy the problem is considered real
ConstraintsWhat must not be changed
Style sampleWhat an accepted similar implementation looks like

Context selection order

  1. State the goal and expected result.
  2. Identify the affected area: module, files, classes, or tests.
  3. Collect evidence: a log, stack trace, reproduction steps, failing test, or screenshot.
  4. Record constraints and immutable APIs or dependencies.
  5. Add one to three relevant files or one small module.
  6. Add a similar implementation when the style needs to be followed.
  7. Expand the context only after a concrete signal that data is missing.

Context depends on the task type

TaskMinimum useful set
BugfixReproduction steps, stack trace, failing test, and related code
DocumentationActual API, usage example, and current rules
FeatureGoal, affected flow, constraints, and acceptance criteria
InvestigationSymptoms, evidence, hypotheses, and questions to verify

How to ask for candidate files

Read-only request to expand context
Find files, classes, and tests related to the symptom.
Do not edit code.
Name each candidate file and explain which fact
needs to be verified before making changes.
Do not add the entire repository without a specific reason.

What not to provide

  • the entire repository without a need;
  • hours of logs instead of a short relevant fragment;
  • unverified old assumptions;
  • unrelated tasks and outdated documentation;
  • .env, keys, tokens, and other sensitive data.

Canonical lesson source · JavaRush

Open JavaRush material