Skip to main content
Version: Classic 2.1.0

Discovery (Context Builder)

The Context Builder is an AI agent that researches your codebase and selects relevant files for your task. It's the foundation of every RepoPrompt workflow.

Context Builder 2.0 — Discovery (Context Builder) documentation illustration Context Builder 2.0 AI-powered context selection with CLI Providers

How Context Builder Works​

  1. Task analysis: You describe what you're trying to accomplish
  2. Codebase exploration: The agent uses MCP tools to search and read your code
  3. File selection: Relevant files and codemaps are identified
  4. Token optimization: Selection is refined to fit your token budget
  5. Handoff prompt: A non-opinionated summary is generated

The Handoff Prompt​

The Context Builder produces a "handoff prompt" that contains:

  • Clarified instructions: Your task, refined with specifics
  • Open questions: Ambiguities you may want to address
  • File relationships: How discovered files relate to each other
  • Selected context: Files, slices, and codemaps
tip

Non-Opinionated Discovery: The Context Builder is explicitly instructed to gather facts, not propose solutions. This prevents bias in the handoff prompt and ensures the implementing model gets complete, unbiased context.

Token Budget​

The Context Builder targets a specific token budget to ensure your prompt fits the effective context window of your target model:

TargetBudgetUse Case
ChatGPT Pro60k tokens (default)Pasting into ChatGPT web (Pro plan)
ChatGPT Plus30k tokensPasting into ChatGPT web (Plus plan)
API / Codex CLI128-200k tokensDirect API, Codex CLI, Claude Code
Coding agents24-32k tokensKickstarting agent sessions with context

File Slicing​

One of Context Builder's most powerful tools is file slicing. Instead of including entire files, it can extract only the relevant sections:

  • Massive files become manageable
  • Irrelevant code is excluded
  • Token budget is used efficiently
  • Slices include line numbers for easy reference

CLI Provider Integration​

Context Builder works best when connected to a CLI provider:

ProviderModel UsedSubscription
Claude CodeClaude Sonnet 4.5Claude Pro/Max
Codex CLIGPT-5.5 Low for discovery/explore; GPT-5.5 Medium for engineer/default implementation; GPT-5.5 High for heavier review/planning after discoveryOpenAI Plus/Pro
Gemini CLIGemini 2.5Google AI
Cursor CLIDiscovers models dynamically from your Cursor installationCursor Pro/Business
OpenCodeMultiple providers including some free modelsVarious subscriptions

For Codex users, our current default is GPT-5.5 Low for discovery and Context Builder. It is the practical Codex CLI default for repeated exploration; use GPT-5.5 Medium for engineer/default implementation, and switch to GPT-5.5 High for heavier planning, review, or pair sessions after discovery.

Running Context Builder​

  1. Open your workspace in RepoPrompt
  2. Click Context Builder in the toolbar
  3. Describe your task clearly and specifically
  4. Wait for the agent to explore and select files
  5. Review the selection and handoff prompt
  6. Proceed to your chosen implementation path

Tips for Better Results​

  • Describe what you need, not where to look: The builder explores autonomously. "Add JWT authentication to the API" works better than listing specific files
  • Mention what you know: If you know key areas, modules, or patterns, include them — the builder uses these as starting hints but explores beyond them
  • Don't over-constrain: Being too prescriptive narrows discovery. Let the builder find related code you might not know about
  • Review open questions: The handoff prompt flags ambiguities — address them before handing off to implementation
  • Adjust token budget for your target: Lower for agent handoffs (24-32k), higher for API/CLI usage (128-200k)