Context awareness in coding is an AI coding assistant’s ability to understand and use relevant project information when it suggests or changes code.
AI coding tools promised to accelerate development. In practice, teams often find that the generated code compiles but misses a project-specific pattern, reintroduces a dependency that was deliberately removed, or duplicates logic that already exists somewhere in the repo. When I review a change like that, I want to know which files the assistant read and where we recorded the decision.
Context is the information a model receives when it generates a response. With AI coding tools, that can include your request, the code the agent has read, project instructions, earlier decisions and the results of commands it has run. An inline completion can draw on nearby code and related files. When I ask an agent to change a service, I also want it to find the caller and read the tests that describe the behavior we expect.
I’ve spent quite some time explaining repositories to coding agents, going through the design and telling them what to change. Once I’ve done that, I want my agents to carry those decisions into the implementation, and ideally into the next session too.
Explaining the same requirements and architectural decisions repeatedly became annoying enough that I built a small memory store for my own use. That addressed part of the problem, a lack of continual learning; however, an agent also needs to find current code, understand the rules that apply to it and know how to use the tools we give it. Together, they shape what the model sees when it decides what to do next.
Stay up to date on the most important—and intriguing—industry trends on AI, automation, data and beyond with the Think Newsletter, delivered twice weekly.
Context awareness is a continual and dynamic process. An AI coding assistant combines a model with software that can access tools, relay input instructions and retrieve outputs.
Each time the assistant reads a file or runs a command, the software gathers outputs to include in the next request. So context builds and changes as the task develops; some of it comes from the assistant’s own investigations rather than from anything the developer types into the chat.
Large language models, or LLMs, process that input within a context window. Instructions, tool descriptions, conversation history and command output all take space, with room also needed for the response.
A repository can contain much more information than the model receives in any one request, because the agent can search it and read selected files as needed. Giving it access to a repository therefore also means giving it a way to choose which parts to bring into the conversation.
You can see why that choice affects a coding task. A model may know Java and produce a reasonable implementation while missing a service that already implements half the feature or suggest a dependency the team deliberately removed.
Meanwhile, a long conversation can contain the relevant decision somewhere among earlier plans and command output. The researchers behind Lost in the Middle found that the models they tested often performed worse when required information appeared in the middle of a long input. For our own applications, we can check whether an agent follows an early constraint later in a task, even when the conversation fits within the context limit. Supplying the information and getting the agent to use it are both things we need to pay attention to.
Inline autocomplete works well for what it was designed to do. When the surrounding code makes the next few lines fairly predictable, a completion tool can save real typing time. For isolated tasks in a familiar file, it delivers on its promise.
An inline completion can draw on code in other files, including a header that defines a type I’m using. A feature that touches a service, its caller and a configuration file raises a different question. Which of those files did the assistant use for this suggestion?
The assistant may suggest a dependency the team deliberately removed, miss a utility that already implements half the feature, or produce an implementation that conflicts with a constraint defined three files away. The code compiles. The tests may even pass, if the tests don’t cover that constraint. The problem surfaces later, during review or in production. Then the developer must trace back through the generation to find where the context gap opened up.
If the assistant suggests a dependency we removed, I look for the commit that explains why we removed it. I give the agent that decision and ask it to revise the change. Then I check which dependency it used.
An inline completion suggests code as I type. When I ask an agent to change a feature, it can follow references, inspect the configuration and run the relevant tests if it has access to those tools.
That distinction matters when you are evaluating whether your current tooling is sufficient. If your team’s work mostly involves self-contained changes in well-understood files, a completion tool may cover most of what you need.
If the work regularly spans modules, involves shared conventions that live outside any single file, or requires understanding why a boundary exists, check how the assistant finds those conventions. The choice of model can affect how it follows a reference and applies the rule it finds.
Context engineering means choosing what information a coding agent receives, when it receives it and what it carries into later steps. I start with four questions.
Once you look at everything entering a request, you can start deciding what belongs there and when to load it.
Prompt engineering helps you express the request and instructions, while context engineering also covers the information arriving through files, tools and previous steps. You might write the initial prompt once, but the agent will make further model requests as it investigates the application.
Standing Markdown files give you a place for the guidance you expect it to follow across those tasks. Repository instructions, in files such as AGENTS.md supported by Bob, can describe architectural boundaries, naming conventions and test commands. The build file already tells the agent which dependency versions the project uses; the standing instructions can explain why the team keeps a particular boundary or where to find an example of its preferred design.
Keep those explanations close to the code they describe, so somebody reading the instructions can follow a reference and see how the team applies the rule. Where supported, scope rules to particular files so naming conventions for one module stay with that module.
I’ve put requirements and architectural decisions into standing context, but those files get stale quite fast for me. Well, saving the explanation once doesn’t mean it will describe the application after the next few changes. Treating context as code gives the team a way to maintain it: keep the configuration in version control and include changes to the instructions in the same pull request as the design change. That makes context engineering part of the development workflow, with the application team looking after the decisions it owns. It also keeps old rules from becoming another form of technical debt that agents and developers repeatedly encounter.
Those shared instructions can give the agent a starting point without describing the whole repository. A rule about keeping domain objects independent of the library used to create an API response, for example, explains an architectural decision. To add a feature, the agent then has to find the domain objects and the existing conversion code involved in that feature. Loading all those files permanently would spend the context window on details that many tasks never need. Instead, give the agent enough guidance to recognize the relevant parts and tools that let it retrieve them when the task reaches them.
Whole-codebase indexing makes repository content searchable beyond the open file. Retrieval-augmented generation, often called RAG for code, brings selected material from those searches into the model request. What the agent can find depends on the index. Semantic search can locate code with a related meaning, symbol indexes identify definitions and references, import graphs show module dependencies, and call graphs show which methods may call one another. AI coding tools can combine these approaches with searches and file reads during the task. An initial search might locate a service, after which the agent follows its callers and reads their tests to see how they use it.
I explored that kind of investigation in my Cargo Tracker tutorial with IBM Bob and a Java sample application, by asking for a CSV export for cargo itineraries. Before adding code, Bob needed to find the service that already retrieved an itinerary and see where the application exposed it to a caller. I used a language server through an MCP connection to give Bob specialist code-navigation tools, including symbols and references of the kind I would follow in an editor. Recent commits were available to show how the team had extended the same area before. The standing architectural guidance could explain where a responsibility belonged, and these tools let the agent look for the actual classes that carried it.
The Model Context Protocol, or MCP, provides a standard way to connect AI applications with tools and data sources. In this example, the connection gave Bob access to language-server information; other configured connections can expose issue details, documentation or logs. The application decides what to request and include, within the access granted to those tools. I put an impact map before implementation in the Cargo Tracker tutorial so the agent had to explain its proposed change with references a developer could follow. That lets you question a proposed new service if the application already has one and investigate whether the agent failed to find it or misunderstood its responsibility.
How a tool returns information also affects what the model can make of it. A chunking strategy that keeps a method with its signature and class information can preserve details that a fixed-size fragment cuts apart. As you edit, check whether the index includes uncommitted files, refreshes after changes and respects repository exclusions. In a large monorepo, follow calls across module boundaries too, while recognizing that runtime configuration and dynamically loaded components may need another source to explain their connections. The aim is to give the agent enough surrounding context to follow the operation you want to change, without having you collect and paste every file yourself. That can reduce some of the context switching involved in investigating an unfamiliar part of the application.
Source navigation takes you through the code, but a running application can depend on relationships that cross files and deployment settings. I encountered a small example during my Java servlet upgrade: the frontend requested /resorts/weather, and a deployment descriptor also named /resorts. On my test server, deploying the WAR under a different name let direct servlet requests succeed while the weather panel stayed empty. Using the expected WAR name fixed the panel without changing the source. An assistant investigating that problem needs enough information to follow the request from the browser through the deployment path to the endpoint.
Inline autocomplete can save typing when the nearby code makes the next few lines fairly simple, but the servlet alone wouldn’t explain that empty panel. Completion tools can retrieve related files, and IDE extensions can offer agentic coding across a repository too. Of course, a more capable model may investigate more effectively, provided it can obtain the frontend, configuration and runtime information it needs. For debugging, I usually start with the failing operation and ask the agent to trace the files and runtime information involved, so I can follow its explanation before accepting a fix and repeat the failing request afterward.
As the agent gathers that information, it also needs to keep the task’s scope in view. For my servlet migration, I kept the existing servlet API and frontend. Context pinning lets you keep a file or instruction available as a task develops. To try it on a similar migration, pin the instruction to preserve the servlet API and frontend. After the assistant summarizes the conversation, ask it which parts of the application it plans to change. Then open a fresh session and check which instructions it loads there.
Keeping the active task’s decisions available helps during a session. When I opened another one, though, I found myself explaining the same application again, even after I had taken the time to settle the design. I wanted the agent to retrieve those decisions, and I needed a way to read and correct what it would see, ideally with provenance so I could tell where a record came from. My memory store used a compact index at session start and let the agent read individual records when needed. The next session could then recover a decision from storage without receiving the entire history of the conversation that produced it.
The storage interface also needed an explanation, since an agent couldn’t be expected to know the CLI I had just built. A skill can carry that explanation and the steps for using it. You could, for example, add a Bob skill that tells the agent how to call the CLI, read a record and supply its current version when updating it. In my memory implementation, the storage code checked that version before accepting the update, so accepting a change depended on the storage check as well as the agent following its instructions. Standing Markdown describes the guidance the project shares across tasks; a skill can provide more detailed instructions when the agent needs to perform a particular operation.
I used separate Bob sessions to add, update and delete a preference record. In the update, I added a preference for Podman in container examples, and I could open the saved file to see what a later session would read. The next session retrieved the preference from that file. Context engineering here includes choosing what to save, retaining its source and updating it when the preference changes, just as the team has to update standing instructions when its architecture changes.
I also separated information the user had stated from observations and derived guesses. Otherwise, an agent’s interpretation of something could become a requirement simply because another session found it in a saved record. Retrieved memory needs to keep its role as data, including when it contains instructions. If the agent treats an instruction hidden in a record as permission to change the system, prompt injection can reach it through memory as well. Provenance helps me inspect how a claim entered the store, while the application needs controls over what the agent can do with the information it retrieves.
An IDE plugin adds an AI coding assistant to the editor you already use. A dedicated IDE gives you an editor with the assistant built in. In either one, you might accept a completion as you type or ask an agent to follow a call into another module. If your team depends on a particular debugger or language plugin, open the project and try it in the editor you’d be using every day.
I’d use the CSV export in Cargo Tracker to compare the two editors. Open the class that will return the CSV and ask the assistant where it would get the itinerary. You know there’s a service for that already. Can it take you to the method and show you a caller? If you make a local change to the method, ask again before you commit. That tells you whether the assistant can see the code on your machine. If it needs a language server through MCP to follow the call, include that connection when you try the other editor.
Now give the agent one constraint for the export, such as keeping the existing API response unchanged. If you pin that instruction, check whether a fresh session can recover it and whether a second agent receives it when you hand over the task. On a team, you’ll also want to know who can change that instruction and where you can see which tools the agent called. If the project must stay on an isolated network, try the same export there, with the index, model and MCP server you intend to use.
Supplying context brings the agent closer to the application’s design, and we can check how it uses that context during review. Show it the approved authorization pattern and a nearby test, for example, so it can follow the same pattern during context-aware code generation. Then inspect the proposed change and check it with test automation. Context engineering can guide the proposal, while permissions and controls around the agent determine which actions it can take. I had to look more closely at those controls when I added a hook to check file edits, because the application result didn’t tell me whether the hook had checked anything.
I had attached my check to write_file, and Bob chose apply_diff. Bob edited the source and the test through apply_diff. The test passed. When I read the tool calls, I could see how both edits had bypassed my hook. I expanded the hook to include the editing tools I was testing, with shell commands needing their own controls. I tested the block separately by asking Bob to write a file outside the allowed directories and checking whether it created the file. My memory store follows the same principle: the skill explains the update process, and the storage code checks the version before accepting a change.
Even complete access to the repository cannot explain every business decision. An agent might find a special-case calculation while the architectural record describes an older requirement, or the code might never have done quite what the business intended. Somebody who understands the requirement must help decide what to preserve in those cases. Keep that discussion alongside the code review, because an agent can follow the existing implementation closely and carry its mistakes into the next version. For AI code refactoring, check that the expected outputs survive the structural change and agree on any intended change to those outputs before accepting the patch.
When comparing AI coding tools, follow this process through a task from your own application. Check how the AI coding assistant fits the team’s IDE and command-line use, whether it finds current code across modules and whether you can inspect the rules, skills and sources it loads. Then restart the session or change a rule and repeat the task. That lets you evaluate standing guidance, retrieval and memory together through a change whose expected result you understand.
Context testing should check your context engineering in the environment where you intend to use the tool. Try the actual legacy languages, build systems and generated code your team maintains, and trace where code, indexes and model requests go. If you need self-hosted or air-gapped operation, include external integrations in that check.
Keep everything else consistent when comparing context configurations, repeat the runs and compare how often the agent follows the rule, which tests pass and how much correction you make during review. Access to issue details or logs should follow the permissions you granted, and the tool history should let you inspect which sources and actions contributed to the result.
You don’t have to prepare every repository before trying this. I built my memory store because I wanted to stop explaining the same decisions to an AI coding assistant in every session, and that gave me a specific problem to solve and a result I could check.
An assistant can follow the conventions in my repository and reproduce a mistake along with them. I look for that during review, especially when the proposed change touches a business rule.
A few failure modes recur often enough to be worth naming.
When I see a special-case calculation, I read its tests to see which inputs trigger it and what result callers expect. The code gives me a possible explanation for the exception. I ask the person who owns the requirement whether it should apply to the change I’m making.
Once we agree on the intended behavior, I can put an example in a test and use it to review the patch.
I keep project instructions in version control so I can see when a rule changed. An agent can follow an old rule long after the team has changed the architecture. When I review a change to a module boundary, I check the rule against the current callers.
Stale context engineering artifacts are another form of technical debt, and they carry the additional risk that the agent enforces the old convention at scale before anyone notices the guidance is out of date.
I give the agent our security policy and an example of how the application checks access. The agent can use both when it proposes a change.
Prompt injection can reach an agent through the same retrieval path that brings in legitimate context, including through saved memory records, external documents and issue content.
I enforce the agent’s permissions in the tools it uses. When it changes an endpoint, I review the authorization check and test what happens when a caller lacks permission.
I read the tool trace to see which path an edit took. To check the control itself, I list the tools that can write a file, including the shell if it’s enabled. In a test directory, I try a prohibited edit through each path and check that the file stays unchanged.
Before I accept a patch, I ask the agent to show me a caller that depends on the behavior we changed. I follow that reference and run the test that shows what the caller now receives.
Start with a repository and a change you know well and understand, give the agent the sources behind your decisions, and follow its proposal through to review. As you correct its understanding, keep those corrections with the application and let the agent update the sources. Some of the explanation you write for the agent will also help the next developer, and whoever returns to the code a few months later can read why the team made those choices.
Accelerate software delivery with IBM Bob™, your AI partner for secure, intent-aware development.
Develop, deploy and manage AI applications faster with enterprise-ready tools.
Reimagine legacy systems with intelligent AI modernization.