Working with large projects

You can use Bob with projects of any size, but large projects require extra care to manage context effectively.

Understanding context limits

Bob uses large language models that have a limited context window. This is the maximum amount of text (measured in tokens) that Bob can process at once. If the context is too large, Bob may not be able to understand your request or generate accurate responses.

The context window includes:

  • The system prompt (instructions for Bob)
  • The conversation history
  • The content of any files you mention using @
  • Selected text sent to chat using Cmd + L (Mac) or Ctrl + L (Windows/Linux)
  • The output of any commands or tools Bob uses

Strategies for managing context

  1. Be specific: When referring to files or code, use specific file paths and function names. Avoid vague references like "the main file."

  2. Use context mentions effectively: Use @/path/to/file.ts to include specific files. Use @problems to include current errors and warnings. Use @ followed by a commit hash to reference specific Git commits. You can also highlight text in your editor and use Cmd + L (Mac) or Ctrl + L (Windows/Linux) to send it directly to chat.

  3. Break down tasks: Divide large tasks into smaller, more manageable subtasks. This helps keep the context focused.

  4. Summarize when needed: If you need to refer to a large amount of code, consider summarizing the relevant parts in your prompt instead of including the entire code.

  5. Prioritize recent history: Bob automatically truncates older messages in the conversation history to stay within the context window. Be mindful of this and reinclude important context if needed.

  6. Configure large file handling: Adjust the large file handling setting to control how Bob processes files that exceed a certain size threshold. This helps manage context usage when working with large files.

  7. Manage MCP tool usage: You can disable and enable specific tools in an MCP service to allow you to use only what you need, reducing context consumption from unused tool definitions.

Example: Refactoring a large file

If you need to refactor a large TypeScript file (src/components/MyComponent.tsx), here is an effective approach:

  1. Get an initial overview:

    @/src/components/MyComponent.tsx List the functions and classes in this file.
  2. Target specific functions:

    @/src/components/MyComponent.tsx Refactor the `processData` function to use `async/await` instead of Promises.
  3. Make iterative changes: Make small, incremental changes, reviewing and approving each step.

By breaking down the task and providing specific context, you can work effectively with large files within the context window limits.

How is this topic?