# How I Fix 90% of Errors In Claude Code

Source: https://www.youtube.com/watch?v=NuKrtiJqW3Y
Recap page: https://rapidrecap.app/video/NuKrtiJqW3Y
Generated: 2025-12-26T13:33:30.425+00:00

---
## Quick Overview

The video demonstrates how the developer fixes errors encountered while using Claude Code with its Chrome extension, primarily by implementing better context management, creating dedicated testing workflows, and developing custom tools like a cookie banner dismisser to streamline automated testing and reduce context token waste.

**Key Points:**
- The developer implemented custom instructions in a CLAUDE.md file to enforce context checking (autocompaction) before starting long tests, preventing context window overflow (188:47).
- A major issue involved excessive token usage due to browser interactions; this was mitigated by creating an `auto_dismiss_banners.js` script to handle pop-ups automatically via an MCP tool call (3:09).
- The developer created a comprehensive testing structure in a dedicated 'tests/' folder, including detailed Markdown files for each test case's steps, preconditions, and expected results (5:56).
- The Claude in Chrome integration uses custom MCP tools (like `puppeteer_screenshot`) for visual testing, which consumes more tokens than standard chat interactions (10:06, 2:44).
- A key bug was identified where audio elements in the Ambient Player component were not added to the DOM, confirmed by reading console logs for 'audio|error' patterns (6:33).
- The integration with Chrome is native but has limitations, such as not supporting other Chromium-based browsers or mobile devices, and long operations can cause the extension to disconnect (5:03, 5:39).

![Screenshot at 0:00: The initial setup screen shows instructions for setting up the Widget Extension target, highlighting the complexity of manual configuration before the agent attempts to automatically 'discombobulate' the process.](https://ss.rapidrecap.app/screens/NuKrtiJqW3Y/00-00-00.jpg)

**Context:** This video details the iterative process of improving a developer workflow using Claude Code, specifically focusing on testing a 'Focus Application' that integrates ambient sounds and session tracking within a web interface. The developer encounters several issues related to the agent's context window limits, handling website interruptions like cookie banners, and the fragility of browser automation tools (like Puppeteer/Selenium) when sessions are interrupted, leading to the creation of custom scripts and strict testing protocols.

## Detailed Analysis

The video outlines several critical issues encountered while using Claude Code to test a web application and the custom solutions implemented to resolve them, focusing heavily on context management and robust testing procedures. The first major problem was context window exhaustion (hitting 95% usage) during complex tasks, which was addressed by creating instructions in CLAUDE.md to force an autocompaction (`/compact`) before any operation if context space is low (188:47). A second issue involved tedious manual dismissal of cookie banners on various websites (like H&M and a hCaptcha demo); this was solved by creating a custom JavaScript snippet (`auto_dismiss_banners.js`) executable via an MCP tool, which successfully removed two banners on the H&M site (3:09). Furthermore, testing procedures were formalized by creating a comprehensive 'tests/' directory structure containing detailed Markdown files for each test case, specifying priority, steps, and expected results (5:56). The developer also resolved a bug where audio elements in the application's Ambient Player were not correctly added to the DOM, which was diagnosed by reading console output for audio errors (6:33). Finally, the limitations of the Claude in Chrome integration were noted: it requires native Chrome support and long-running tasks can cause the browser extension to disconnect unexpectedly, halting automated testing unless the user manually prompts a restart (5:03, 5:39).

### Context Management & Token Efficiency

- Implementing /compact command
- Forcing autocompaction before tests
- Context usage monitoring shows 95% usage during complex operations (12:11)

### Handling Website Interruptions

- Creation of 'auto_dismiss_banners.js' script
- Executing script via mcp__claude_in_chrome__javascript_tool
- Successfully removed 2 cookie banners on H&M site (3:33)

### Formalized End-to-End Testing

- Creation of a 'tests/' directory structure
- Test files detail preconditions, steps, and expected results (e.g., TC-PERF-001 for CPU usage) (5:56)

### Debugging Browser Interactions

- Diagnosing Ambient Player issue by reading console output for 'audio
- error' patterns
- Confirming switching behavior works perfectly despite errors (7:17)

### Integration Limitations

- Claude in Chrome is limited to Chrome and breaks if sessions are too long (over 5 minutes) or if the extension disconnects, requiring manual restart prompts (5:03, 5:39)

![Screenshot at 0:00: The initial terminal view showing the 'Discombobulating...' process, indicating the agent is attempting to set up the environment or resolve initial configuration.](https://ss.rapidrecap.app/screens/NuKrtiJqW3Y/00-00-00.jpg)
![Screenshot at 0:04: The advertisement for the Claude Chrome extension, which allows Claude to navigate, click buttons, and fill forms in the browser, highlighting its beta status for paid subscribers.](https://ss.rapidrecap.app/screens/NuKrtiJqW3Y/00-00-04.jpg)
![Screenshot at 0:08: A view of the 'Puppeteer' MCP server configuration page, showing it is connected and detailing configuration scopes.](https://ss.rapidrecap.app/screens/NuKrtiJqW3Y/00-00-08.jpg)
![Screenshot at 0:11: The context usage monitor displaying that the agent is near its token limit \(190k/200k tokens, 95%\) due to extensive system tools and messages being included.](https://ss.rapidrecap.app/screens/NuKrtiJqW3Y/00-00-11.jpg)
![Screenshot at 0:45: A slide titled 'Major Issues' signaling the transition to discussing problems encountered during development and testing.](https://ss.rapidrecap.app/screens/NuKrtiJqW3Y/00-00-45.jpg)
