Core concepts
Working with large projects
Manage large codebases in Bob Shell. Understand context window optimization, file handling, and best practices for enterprise-scale projects.
Context limits in large projects
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 include in your chat prompt
- The output of any commands or tools Bob uses
Strategies for managing context
- Be specific: When referring to files or code, use specific file paths and function names. Avoid vague references like "the main file."
- Reference files precisely: Include specific files in your chat prompt using their path (for example,
src/components/MyComponent.tsx), or reference a commit hash to point Bob at a specific Git state. - Break down tasks: Divide large tasks into smaller, more manageable subtasks. This helps keep the context focused.
- 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.
- Prioritize recent history: Bob automatically condenses older messages in the conversation history to stay within the context window. Be mindful of this and reinclude important context if needed.
- Manage MCP tool usage: You can disable and enable specific tools in an MCP service to use only what you need, reducing context consumption from unused tool definitions.
- Use subagents or subtasks for isolated work: For large, self-contained pieces of work, consider using a subagent or subtask. Both run in their own separate context window, keeping the main terminal session lean. See Tools for details on
spawn_subagentandstart_subtask.
Example: Refactoring a large file
If you need to refactor a large TypeScript file (src/components/MyComponent.tsx), here is an effective approach:
- Get an initial overview:
List the functions and classes in src/components/MyComponent.tsx - Target specific functions:
Refactor the `processData` function in src/components/MyComponent.tsx to use async/await instead of Promises. - 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?