Optimizing Claude Code and Codex Usage Limits
AI LABSgo watch the original →
the gist
Extend Claude usage limits by reducing context window bloat through modular skills, CLI-over-MCP tool integration, and aggressive pruning of default agent behaviors.
Context Management and Workflow Habits
To maximize the five-hour usage window, developers must treat the context window as a finite resource. Every message, system instruction, and connected tool definition consumes tokens, and the cost per message increases as the conversation history grows.
- Clear frequently: Run the
/clearcommand when switching tasks to purge unrelated context from the session. - Avoid unnecessary compaction: Compaction consumes tokens to summarize history, often losing critical details. Only compact before taking a break, and explicitly instruct the agent on what information to retain.
- Consolidate prompts: Send one comprehensive prompt for a set of tasks rather than multiple small messages. This reduces the overhead of re-sending the entire conversation history for every minor instruction.
- Use rewind: Instead of sending correction prompts, which keep both the error and the fix in the context, use the
/rewindcommand or double-tapEscapeto remove the erroneous message entirely.
Tooling and Configuration Strategies
Changing how tools are integrated and how the agent is configured can significantly reduce token consumption.
- Prefer CLI over MCP: When a tool offers both, choose the CLI. MCP servers load all tool definitions into the context window permanently, whereas CLI tools only execute when called, keeping the context clean.
- Modularize instructions: Keep
claude.mdfiles under 200 lines. Move project-specific rules into folder-levelclaude.mdfiles or specialized skills that only load when relevant to the current task. - Optimize model and effort: Use smaller models (Sonnet or GPT-4o mini) for routine tasks and reserve Opus or high-reasoning models for complex logic. Set the effort level to
mediumby default, only increasing it via theultrainkkeyword or configuration for specific, difficult problems. - Filter terminal output: Implement a hook to filter out passing test results, ensuring only failing tests are injected into the context window. Alternatively, reduce the
bashMaxOutputLengthinsettings.jsonfrom the default 30,000 characters to 10,000.
Pruning Default Behaviors
Many agents ship with default features that silently drain usage limits by loading unnecessary data into the context window.
- Disable memory: Turn off the memory feature via the
/memorycommand to stop the agent from loading historical patterns into every session. - Disable bundled skills: Set
disableBundledSkillstotruein your configuration to remove unused pre-installed skills from the context. - Manage workflows: Disable automated workflows if they are not required, as these often trigger multiple sub-agents that consume tokens rapidly.