00:00:00With the advancement of AI and the increasing power of each new model being released,
00:00:04the way we produce code has been completely transformed.
00:00:07There are now many tools specialized for coding, like ClodCode, Cursor, Antigravity, and others,
00:00:12each with its own unique capabilities.
00:00:14But good models alone don't determine the quality of the code you produce.
00:00:18How you use the tool and manage context matters just as much.
00:00:22All of these tools have some inherent mechanism for context engineering,
00:00:25but Cursor just made a major push for a new approach, building it natively into the app itself.
00:00:29As I went through their article, I realized these principles are genuinely strong.
00:00:33We have a lot to talk about today because these ideas can be applied broadly to any platform you use to build applications.
00:00:40Context management has always been critical when working with AI agents
00:00:44because good context management determines the output quality.
00:00:47We have previously talked in our videos about how important context management is and talked about workflows for it.
00:00:53Cursor implemented context management features directly into their product and released an article about it.
00:00:58These principles are based on their observation that, to get good results from models,
00:01:02it's better to provide as few details as possible in the context window.
00:01:06The less information the model receives at once, the less data it has to process at once,
00:01:10meaning lesser confusion and more focus on the task it needs to do at the moment,
00:01:14because only relevant information is included.
00:01:17This approach is what they call dynamic context discovery.
00:01:20The idea is structured note-taking.
00:01:22That is, the information not needed right now should not be in the context window,
00:01:26excluding potentially confusing or contradictory details,
00:01:29improves the quality of the agent's responses significantly.
00:01:32Cursor's current release adds five dynamic context management methods rolling out to users soon.
00:01:37Even though Cursor is implementing this as a product update,
00:01:40these principles are widely transferable to all AI agents.
00:01:44The first update Cursor mentioned is that long tool responses should go into files.
00:01:48MCPs often return large responses that stay in the context window.
00:01:52Not all of the information from the responses is always needed.
00:01:55Cursor mentioned that the common approach of the most coding tools is to truncate long MCP responses,
00:02:01which leads to data loss or important information that might be necessary for the context being removed.
00:02:07Claude's Chrome extension is a very tool-heavy extension,
00:02:10and just a few prompts can fill up the context because of loading a huge chunk into the context window.
00:02:15So I added an instruction in the Claude.md file that any MCP tool response greater than 50 lines
00:02:21must be saved to an MCP folder within the .context folder by running an echo command in the terminal.
00:02:27When I ran the Chrome extension to analyze the UI of a landing page,
00:02:30whenever Claude came across a tool like ReadPage that significantly bloats the context window,
00:02:35it saved the MCP response into a file for further reading,
00:02:39using which it analyzed the whole page and gave me a report.
00:02:42This workaround improved the accuracy of the tool response analysis
00:02:45by letting Claude analyze the responses from files as many times as needed
00:02:49and eliminated the need for repetitive tool calls.
00:02:52When data from previous MCP calls is needed, Claude can read it directly from the .context folder
00:02:57instead of making tool calls, saving significant time.
00:03:00Before we move on to the next change, let's hear it from our sponsor, Zen Rose.
00:03:04If you're building AI products, automations, or data-driven systems, you already know one thing,
00:03:09everything starts with reliable web data. But getting clean, structured data at scale
00:03:14is harder than it sounds. That's where Zen Rose fits perfectly into the stack.
00:03:18Zen Rose handles data extraction from complex websites while automatically
00:03:22managing anti-bot bypass so you can focus on what actually matters using the data.
00:03:27Instead of dealing with messy outputs, Zen Rose delivers structured results like JSON or Markdown
00:03:32ready to plug directly into your pipelines. It's integration-ready and business-focused,
00:03:37which makes it ideal for AI startups, data teams,
00:03:40and automation builders who don't want to babysit infrastructure.
00:03:43Whether you're enriching leads, powering AI agents, or automating research,
00:03:47Zen Rose just works. If your work depends on web data, Zen Rose belongs in your stack.
00:03:52Click the link in the pinned comment and start building today.
00:03:55We know that the summarization step when the context window is filled is messy and leads to
00:03:59losing a lot of information. Most tools, including cursor and Claude code, trigger a summarization
00:04:04step and start the session with a fresh context window with the summary as a starting point.
00:04:09When you hit compact again and again, the summary starts to forget details that
00:04:13might be important to you but that the model's summary may miss.
00:04:16There is only so much control you have over auto-compaction, and repeated compression
00:04:21leads to the loss of crucial information if you have to do it repeatedly.
00:04:24Cursor's solution is to save all previous chat history as a file for the agent to reference later.
00:04:30When we provide a very specific prompt and the model cannot find the information in the summary,
00:04:34the previous transcript serves as its knowledge base.
00:04:37The model uses that transcript to generate the solution,
00:04:40allowing it to recover anything that was lost from the summary.
00:04:43Until cursor's implementation rolls out and becomes available for everyone,
00:04:47I tried implementing this feature with Claude code.
00:04:50I added the instruction inside the Claude.md file to update the chat history after each turn,
00:04:55documenting all the key decisions and steps taken.
00:04:58It used a history folder inside the .context folder with each file's name reflecting the session.
00:05:03So whenever I ask it to perform any task, at the end of its task execution session,
00:05:07it documents the chat history into the corresponding history file, adding everything to that file.
00:05:12This way, the .context folder contains detailed records of all sessions and everything that was done.
00:05:18Agents were given skills to help manage the context problem MCPs were causing.
00:05:23The whole purpose of skills is to make agents provide better ability to use its own capabilities
00:05:28by guiding through scripts and instruction files, reducing context bloat by progressive disclosure.
00:05:33Anthropic was the first to come up with the idea, which is basically giving the agents a set of
00:05:37instructions, scripts, and resources that the agent can discover and use to perform better at specific
00:05:43tasks. Anthropic basically open-sourced these agents' skills, setting a standard that others
00:05:48could implement. Following this, Codex, Gemini, and others started implementing agents' skills,
00:05:53after which it was finally cursor's turn to do the same. cursor's skills are basically the same
00:05:58executables and scripts bundled together into a single skill that the agent can use for its
00:06:02respective tasks. Only the skills' name and description are in the static context.
00:06:06Once they are inside the static context, the agents can pull their skills on their own,
00:06:11using grep and cursor's semantic search. This is what makes it different, because cursor's
00:06:15semantic search uses its own embedding model and indexing pipelines in the background, instead of
00:06:20plain pattern matching, like regex-based searches in grep commands. Claude's skills only expose the
00:06:26name and description in the context, no matter how many files the script uses, preventing context
00:06:31bloat. In my project, I had configured 5 skills, each consuming very few tokens, only about 0.2%
00:06:37of the total, leaving more room for working. What's different is that Claude's skills can also be
00:06:42accessed via /commands, letting you manually trigger them whenever needed, addressing people's complaints
00:06:47about skills not being loaded on demand properly. MCPs contain a lot of tools all exposed in the
00:06:52context window, bloating the context window unnecessarily. Cursor took it upon themselves
00:06:57and emphasized that it is the responsibility of the coding agents, not the MCP servers,
00:07:02to fix the context bloat. The solution for this was dynamic context discovery by syncing tool
00:07:06descriptions in a folder. Cursor's idea is to have all of the MCPs with their names in separate
00:07:11folders, named after each connected MCP, and within each folder, all the tools must be listed. With
00:07:17this, the agent only receives the names of tools, and whenever it needs any tool, it looks it up
00:07:22through the folders. In the testing they did, they discovered that dynamic discovery of MCP tools
00:07:27reduced usage by 46.9%, which makes a huge difference if you are working on a long-running
00:07:32system. This implementation also helps in cases where MCP servers accidentally get disconnected
00:07:38or require re-authentication. Normally, the system would just forget about those tools,
00:07:42but now the agent can actually notify the user that re-authentication is required. Claude also has an
00:07:47advanced search tool that is specifically designed to address this problem, using a certain set of
00:07:52flags to let Claude know whether to load it or not. It implements Cursor's exact idea of dynamic
00:07:57context discovery, but this is limited to the developer platform, and only for those building
00:08:01with APIs. We cannot modify how MCPs are used in Claude code, because they are built into it
00:08:07by Anthropic. Just as I was looking for ways to implement this in Claude code, I came across a
00:08:11hidden flag. Without setting this flag, all the MCP tools I had connected were exposed in the context
00:08:17of Claude code. When I set the enable experimental MCP CLI flag, all the tools were removed from the
00:08:23context window, freeing up space that was previously occupied by the MCP tools. But that does not mean
00:08:28the MCPs get disconnected when this CLI is enabled. The only difference is that they are not exposed
00:08:34up front in the context window. Instead of putting all the schemas into the context, Claude now uses
00:08:38a middle bash layer called MCP CLI, which handles all MCP-related tasks. Claude uses this middle
00:08:44layer to search, get information, and invoke the tools. Whenever you ask Claude to perform any task
00:08:49that requires an MCP tool call, instead of using the usual method, it uses the MCPs via MCP CLI and
00:08:56performs the task it is required to do. By using this tool, Claude executes all the tasks as usual,
00:09:01just through this middle layer. Reporting terminal errors is hard in Cursor because of its limited
00:09:06access. If the terminal showed any error, you needed to add it to the chat and then have it
00:09:10fixed. Cursor's solution for this is also moving the terminal sessions to files. So whenever you
00:09:15ask it any questions, it references those history files and uses grep to extract the relevant output.
00:09:20Since server logs are usually long running and contain lots of noise for the agent,
00:09:24using the grep task is more efficient because it lets the agent pattern match. They got this idea
00:09:29from CLI-based coding agents, which run the commands, but then the output is injected into
00:09:34the context exactly the way Claude code and others do by default. Even though Claude intelligently
00:09:39handles this on its own, we can manage it even further by using instructions in Claude.md
00:09:44to instruct it to add all terminal logs into a file in the terminal folder inside the .context
00:09:49folder. Basically, if Claude runs any npm command, it runs a special command that logs both the output
00:09:55stream and the input stream into the document files. Here, 2 represents the standard error stream
00:10:00and 1 represents the standard output stream. It writes these logs to the terminal folder,
00:10:05marking them with a timestamp. Then, whenever it needs to search through them, it simply uses a
00:10:09grep command with a specified pattern and loads the last 20 lines to extract only what matters.
00:10:15So whenever I tested my development server, it used these commands and kept writing the
00:10:19terminal runs to files in accordance with the Claude.md file. After running the server,
00:10:24it referred to the log files and figured out what was causing the issue and fixed the problem for me.
00:10:29Now even though this add-on to Claude code might seem insignificant because it doesn't appear to
00:10:33have much impact on immediate work, it can be very useful when you want to refer back to your app's
00:10:38functioning. Just like when I needed to identify which service was causing my app to crash, I simply
00:10:43told Claude to refer to the test logs instead of running the tests again, saving me from rerunning
00:10:48a 2-minute test suite just to reproduce an error I had already seen. That brings us to the end of
00:10:52this video. If you'd like to support the channel and help us keep making videos like this, you can
00:10:57do so by using the super thanks button below. As always, thank you for watching and I'll see you
00:11:02See you in the next one.