Note: This portfolio site was launched on 30th March 2025. More stories, resources, and portfolio updates will be added progressively as I move forward and subject to available personal time.
Agent Intelligence: Context Before Code
AI can generate code quickly. The engineering challenge is making sure that code fits the solution. Context Before Code explores how architecture, patterns, documentation, requirements, and human judgment can provide AI with the information needed for more informed implementation.
TECHNICAL
Kiran Kumar Edupuganti
8/9/20266 min read


Agent Intelligence: Context Before Code
Designing Context-Aware AI-Enabled Development
1. Introduction — Why Context Matters Before Code
AI-assisted development has made it easier to generate code, modify existing implementation, explain errors, and explore possible solutions.
But generating code is only one part of development.
When AI is asked to implement something without sufficient understanding of the surrounding solution, the generated result may be technically reasonable but still unsuitable for the intended architecture, coding pattern, configuration, or business behaviour.
This creates an important consideration for AI-enabled development:
What does AI need to understand before implementation begins?
The answer is context.
Context can come from requirements, existing code, architecture, implementation patterns, configuration, documentation, examples, or execution information. The objective is not to provide everything to AI, but to provide the relevant information required for the task.
This changes the way we approach AI-assisted development.
Instead of immediately asking:
“Generate the code.”
we can first establish:
“Understand the context, identify the existing pattern, and then implement.”
This is the thinking behind Context Before Code.
2. Why Code Generation Alone Is Not Enough
Code generation is useful, particularly for repetitive implementation, boilerplate, refactoring, and exploring possible approaches.
However, generated code does not automatically mean integrated code.
For example, an AI assistant may generate an API test correctly from an endpoint definition. But the implementation may not follow the existing framework's:
Reusable Client Pattern
Configuration Approach
Validation Pattern
Naming Convention
Logging Standard
Reporting Structure
The code may work independently while still being inconsistent with the overall solution.
This is where context becomes important.
The challenge is therefore not simply:
Can AI generate the code?
It is:
Can AI generate implementation that fits the intended solution?
That distinction is important in larger repositories where existing architecture and implementation patterns matter.
AI can assist with implementation, but engineers still need to determine whether the generated result is appropriate, correct, maintainable, and aligned with the solution.
3. What Do We Mean by Context?
Context should not be interpreted as giving AI the entire repository or a very large prompt.
It means providing the relevant information needed to understand the task.
Depending on the development activity, useful context may include:
Business Context
User Story
Acceptance Criteria
Business Rules
Expected Behaviour
Technical Context
Architecture
Technology Stack
Existing Components
Design Patterns
Coding Conventions
Implementation Context
Similar Existing Implementation
Reusable Utilities
Configuration
Data Models
API Definitions
Existing Test Patterns
Operational Context
Execution Logs
Error Messages
Configuration Values
Runtime Behaviour
The required context will vary by task.
A developer creating a new API validation does not necessarily need the entire repository. They may need the endpoint definition, an existing similar test, the validation pattern, relevant configuration, and the expected behaviour.
Relevant context is more useful than excessive context.
4. Context Before Code — A Practical Development Pattern
A simple pattern can be used for AI-assisted implementation:
Intent → Context → Pattern → AI Assistance → Implementation → Validation
Intent
Clearly define what needs to be achieved.
Context
Identify the information AI needs to understand the requirement.
Pattern
Determine how similar functionality is already implemented.
AI Assistance
Use AI to analyse, generate, modify, or suggest implementation.
Implementation
Integrate the result into the solution.
Validation
Review the implementation against functional, technical, and architectural expectations.
This does not mean every task requires a lengthy process.
For a small change, the context may be minimal.
For a framework-level change, more context may be necessary.
The important change is in the sequence of thinking.
Instead of treating AI as a code-generation endpoint, we treat it as an assistant that needs enough relevant information to work within the solution.
5. From Individual Prompts to Structured Development
A simple prompt can be useful:
“Create an API test for this endpoint.”
But a more contextual instruction could identify:
The endpoint
The expected response
The existing API test pattern
The validation approach
The configuration to use
The reusable component to follow
This gives AI more information about where the implementation belongs and how it should behave.
The progression is therefore not necessarily about making prompts longer.
It is about making them more relevant.
From:
Instruction
↓
To:
Instruction + Relevant Context
↓
To:
Context + Existing Pattern + Expected Outcome
This approach can reduce unnecessary back-and-forth and make AI assistance more useful during implementation.
However, it does not eliminate review. Generated implementation still needs to be examined and validated.
6. Applying Context Across Automation Development
The concept is applicable across different automation activities.
API Automation
Relevant context may include:
OpenAPI / Swagger Definition
Endpoint Behaviour
Existing API Client
Validation Patterns
BDD Scenarios
Configuration
Similar Existing Tests
AI can then assist with creating or extending implementation while following the established patterns.
UI Automation
Context may include:
User Story
Expected User Flow
Existing Page Components
Locator Strategy
Existing Scenarios
Framework Conventions
This can help AI understand how a new scenario should fit into the existing automation solution.
Mobile Automation
Context may include:
Application Flow
Existing Screen Components
Device Configuration
Automation Patterns
Expected Behaviour
The same principle applies: provide the information relevant to the implementation rather than treating every task as a blank development exercise.
Framework Development
Here, context becomes even more important because changes can affect multiple components.
Architecture, reusable components, configuration, logging, reporting, and coding patterns can all influence how a new capability should be implemented.
7. Human-in-the-Loop — The Engineer Still Owns the Decision
Context does not remove the need for engineering judgment.
AI can analyse the information provided and suggest or generate an implementation, but the engineer remains responsible for deciding:
What Context Is Relevant
Which Pattern Should Be Followed
Whether The Approach Is Appropriate
Whether The Generated Implementation Is Correct
What Trade-Offs Should Be Accepted
Whether The Final Solution Meets The Requirement
This is where Human-in-the-Loop Engineering becomes important.
The engineer's role is not simply to accept or reject generated code.
The engineer provides direction, establishes constraints, evaluates alternatives, and validates the final result.
AI can accelerate implementation, but responsibility for the solution remains with the engineer.
8. Implementation Perspective — Context Applied to AI-Assisted Development
A practical AI-enabled development setup can make relevant solution information available during implementation.
For example, when extending an existing automation capability, the development context can include the relevant architecture, similar implementation, reusable components, configuration, and expected behaviour.
AI can then be used to:
Analyse Existing Implementation
Identify Reusable Patterns
Suggest Implementation
Generate Supporting Code
Explain Existing Logic
Assist With Refactoring
Analyse Execution Information
The important point is that AI is not being asked to design everything from an empty starting point.
It is working within an existing engineering context.
This approach has been applied in AI-assisted automation development where existing framework structures and implementation patterns are used as part of the development context.
The outcome is not that AI always produces the final implementation correctly. Rather, it provides a more informed starting point, while engineering review and validation remain part of the process.
9. How Structured Context Supports Consistent Development
Structured context can help reduce some common issues in AI-assisted development.
Without sufficient context, engineers may need to repeatedly explain:
How The Framework Is Structured
Which Component Should Be Reused
What Coding Pattern Is Expected
Where Configuration Is Maintained
How Validation Is Implemented
Providing this information appropriately can reduce unnecessary clarification and rework.
It can also help maintain consistency when multiple development activities follow the same patterns.
However, consistency should not be assumed simply because context was provided.
The quality of the context, the capability of the AI system, the complexity of the task, and the engineer's validation all influence the result.
Therefore, the practical objective is not:
“Give AI context and everything will be correct.”
It is:
“Give AI relevant context so that implementation starts from a better understanding of the solution.”
That is a much more realistic expectation.
10. Context as an Engineering Asset
Source code has always been an important engineering asset.
So are architecture documents, reusable components, configuration, test scenarios, and implementation guidelines.
In AI-enabled development, these sources can also become inputs for AI-assisted engineering.
This gives structured engineering information another purpose.
Documentation can help AI understand a solution.
Existing implementation can provide patterns.
Architecture can establish boundaries.
Examples can demonstrate expected behaviour.
Execution information can provide additional evidence.
The more consistently these assets are maintained, the easier it becomes for engineers — and AI assistants — to understand how a solution is expected to work.
This does not mean every organization needs to create extensive documentation specifically for AI.
It means that well-structured engineering information has increasing value in an AI-assisted development environment.
11. Final Insights — Context Before Code
AI has changed how quickly developers can explore and produce implementation.But speed of code generation does not automatically translate into quality of the overall solution.
The surrounding context still matters.
Requirements provide intent.
Architecture provides structure.
Existing implementation provides patterns.
Documentation provides guidance.
Execution information provides evidence.
Human judgment connects these elements and determines whether the resulting implementation is appropriate.
This leads to a simple principle:
Before asking AI to write the code, give it enough relevant context to understand where that code belongs.
Context Before Code is therefore not about making prompts longer or giving AI everything available.
It is about making AI-assisted development more deliberate:
Understand → Contextualize → Assist → Implement → Validate
That is where I see an important shift in AI-enabled engineering — from simply generating code to developing within context.


Stay tuned for the next article from rewireAdaptive portfolio
This is @reWireByAutomation, (Kiran Edupuganti) Signing Off!
With this, @reWireByAutomation has published a "Agent Intelligence: Context Before Code"