Searchable transcript of Context-Aware Coding: Give AI Agents the Right Context — IBM Technology (06:34). Search for a phrase, then click its timestamp to jump straight to that moment in the video.
Captions sourced from the original video on YouTube, published by IBM Technology. The video, its captions and all related intellectual property remain the property of their respective owners; AINotes claims no ownership. Provided for research, accessibility and search — see the Transcript Notice and Copyright Policy.
00:00 Agentic coding is opening software building to people from all sorts of backgrounds. So today we'll look at how you, the builder, can keep the power by making sure that you're giving your agent here really great context. For example, say you ask your agent to add a login endpoint. Now, will that agent follow your error format and folder layout? Will it use your auth library?
00:32 All of that is going to come down to the context that this agent here has. So, if our prompt here is a single sentence requesting a login endpoint, and our codebase is thousands of files, maybe even years of decisions, then that prompt alone can't explain all of that. And so our coding decisions need to depend upon what's already there. Which framework, which database layer, is there a validation pattern that everyone follows.
00:58 So that the exact same request should produce different code in different repositories. In repository A here, maybe we have a fast API route with the pyantic model. And then maybe in repo B here, we're using a Go handler with a completely different shape. So what is the ideal context that your agent can actually use to understand these repos? Let's talk a bit about agent inputs.
01:31 First, we need to think about files and existing code. The best agents can search, Rep, open files themselves so that they can understand the things that you can't necessarily add to the prompt. And your job becomes pointing the agent in the right direction. Maybe you add follow the pattern in the readme into your prompt so the agent knows where to start.
01:53 And that brings us into our next point, repository structure. Where to test live? What's the module layout? It's a good idea to make sure that you have some sort of tool that builds a compact repo map for your agent. This can be a list of files and symbols so that the model can see the shape of the project without having to read through every line. Okay.
02:14 Third, dependencies. And this one's sneaky because it's not necessarily enough to know that you use a library. The agent needs the version. And your lock file, which is a machine generated file that records the exact resolved versions of every dependency in a project, including transitive ones, says which APIs actually exist, because a lot of hallucinated functions are maybe really version mismatches.
02:43 Now, the fourth input for an agent that can really help your agent out is a test that your agent knows how to pass. That way it can have a feedback loop where it writes and then runs and then tries to fix and resolve this failing test. And agentic coding can really shine there when it knows what good looks like. Fifth, let's think about documentation.
03:08 Valuable docs to your agent include conventions, build commands, and instructions like don't touch this directory. And you can put those in a checkedin instructions file called an agents.md. This is an emerging open convention. Many tools have their own version. And sixth, developer intent is important. What does done look like to you? What are the constraints?
03:30 What should it not do? And this is one piece of context that the agent can never discover by reading your repo. Only you have this. Now, maybe you're thinking that's all great if you already know what an Auth library is or a lock file is, but a lot of newer builders don't know what questions to ask yet. So, we can make the agent surface the context that it needs for us.
03:54 Three moves to do so. First great trick. Before you write any code or ask it to write you any code, say interview me and ask me questions until you understand what you need. Next, you can instruct the agent to explore this repo and explain how it's put together in plain language. And now both of you have an understanding of a map of this repo. And then three, you can make a plan and a list of what you're assuming.
04:32 It's great to know what the agents assumptions are before you go into this process so that a question that maybe you didn't know to ask, you now can. And when you're done, have it write what it learned back in to this agent's markdown file so that next time when we go through this process, it's already there. So ideally, your agent is going to do the digging, but you will make sure you're still the one making the decisions here.
04:57 Now, the natural instinct is context is good. So, give your agent everything. Dump the whole repo in, but don't because models don't pay equal attention to everything in a long input. Research has shown that they tend to do best with the information that's at the beginning and the end, and worse with with what's buried in the middle. Every irrelevant file is going to compete with a file that does matter.
05:24 So your context needs to be relevant to the task and that should be the filter that you're thinking about. So if we go back to our example where we're changing the login flow, our agent there needs auth module, its test, our conventions, but it doesn't need our billing service or 3 week old build logs. So practically that means start a fresh session with every new task so that you can point to these specific files and clear out noise when a session is starting to get long.
05:54 So to recap, a prompt alone isn't enough because good code depends on the code base around it. So give your agents the right inputs, code, structure, test, docs, dependencies, and all of your intent. If you don't know what to ask, let the agent ask you and curate it. The goal isn't more context, it's the right context and keeping you in charge of it. Thanks so much for watching. Drop your favorite context trick in the comments.