
Extending AI Capabilities with On-the-Fly Context Using Amazon Q Developer CLI
Discover how Amazon Q Developer CLI transcends traditional AI knowledge boundaries by leveraging on-the-fly context from code repositories and external documents. Master techniques for providing just-in-time information from entire codebases, specific files, or documentation, empowering AI to craft solutions based on patterns outside its training data—delivering expert results even for cutting-edge technologies and specialized implementations.
Kirankumar Chandrashekar
Amazon Employee
Published Apr 10, 2025
AI models have inherent knowledge limitations based on their training data. When you need expertise on recent frameworks or specialized implementations, these models often fall short. But what if you could provide that missing context on the fly—what some call just-in-time context?
AI models are trained on finite datasets with cutoff dates, meaning they can't know about:
- Recently released libraries or frameworks
- Your organization's internal tools and patterns
- The latest versions of rapidly evolving codebases
Amazon Q Developer CLI enables a powerful approach: providing on-the-fly context from code repositories and documentation. Here's how it works:
- Identify a repository containing patterns similar to what you want to build
- Use Amazon Q Developer to analyze these materials in real-time
- Ask Amazon Q Developer to help you build a similar solution based on this context
- Iterate on the implementation with the Q Developer's guidance
What makes this approach powerful is Amazon Q Developer CLI's ability to access repositories directly from your local machine, including internal codebases and proprietary frameworks.
Amazon Q Developer CLI can analyze various materials accessible from your machine:
- Documentation pages and API references
- Architecture diagrams
- Configuration files
- Custom frameworks and libraries
For this example, I used the following prompt:
Below is an excerpt from an actual conversation with Amazon Q Developer CLI, showing exactly how it analyzes an external GitHub repository in real-time and uses that context to build a similar implementation.
This is just the beginning of the conversation. Amazon Q Developer CLI continues by:
- Creating the
models.py
file with Pydantic models for weather data - Implementing
util.py
with formatting functions - Building
server.py
with API endpoints for weather data - Creating
setup.py
,README.md
, and other project files
Throughout the process, Amazon Q Developer CLI:
- Shows you exactly what it's doing (cloning repos, reading files, creating new files)
- Asks for permission before executing commands
- Provides real-time feedback on command execution
- Explains its implementation choices based on the analyzed repository
This authentic dialog demonstrates how Amazon Q Developer CLI leverages on-the-fly context from repositories to build solutions that follow specific patterns, even if those patterns weren't part of its original training data.
Amazon Q Developer CLI created a well-organized project structure following the patterns from the reference repository:
This structure mirrors the architectural patterns of the reference implementation while adapting them specifically for weather data and the Open Weather API's requirements.
While you can point to an entire repository, you can also be more specific about which files to analyze without cloning the entire repository. Here's an alternative prompt that accomplishes this:
This more targeted approach offers several advantages:
- Efficiency: Only the necessary files are analyzed, saving time and resources
- Focus: The AI's attention is directed to the most relevant components
- Specificity: You can explicitly request analysis of particular patterns or features
- Control: You determine exactly which files contribute to the context
By being specific about which files to analyze and what aspects to focus on, you can guide Amazon Q Developer CLI to provide more tailored assistance based on the exact context you need.
When I used this alternative prompt with Amazon Q Developer CLI, here's how the interaction began:
Notice how Amazon Q Developer CLI directly fetches the files from GitHub using
curl
instead of cloning the entire repository. It then proceeds to analyze each file individually and build the implementation based on that analysis.This approach is more efficient and focused, allowing Amazon Q Developer CLI to get exactly the information it needs without downloading unnecessary files or directories.
This approach is particularly valuable when:
- Working with cutting-edge technologies
- Building with organization-specific patterns
- Dealing with complex or specialized systems
- Maintaining consistency across microservices
- Onboarding new team members to existing codebases
- Modernizing legacy systems
- Breaking Knowledge Boundaries: Extend the AI's capabilities beyond its training data
- Learning from Real Implementations: Analyze tested and refined code patterns
- Maintaining Consistency: Ensure new code aligns with established patterns
- Accelerating Development: Build on existing patterns rather than starting from scratch
- Filling Documentation Gaps: Gain insights when documentation is sparse or outdated
- Identify Context Sources: Find repositories with similar functionality and clear structure
- Craft Specific Prompts: Include repository paths and clearly state what you want to build
- Analyze and Generate: Let Amazon Q Developer CLI explore the codebase and generate solutions
- Iterate and Refine: Ask for clarifications and request modifications as needed
- Test Thoroughly: Validate the generated code against your requirements
Amazon Q Developer CLI also offers helpful commands like
/context
for managing contextual information and /profile
for switching between different project profiles, making it even easier to work with different context scenarios.- Respect copyright and licensing terms
- Review generated code for security issues
- Adapt code to your specific requirements
- Understand the code before implementing it
- Be aware of performance impacts with large repositories
Providing on-the-fly context through Amazon Q Developer CLI represents a powerful technique for extending AI capabilities in your development workflow. Rather than being limited by what the AI was trained on months or years ago, you can provide just-in-time context for your specific task.
Next time you're building something and find your AI assistant lacking knowledge about a specific implementation, consider providing that context on the fly. You might be surprised by how effectively it can help you build something similar, even if the original code wasn't part of its original training data.
Any opinions in this post are those of the individual author and may not reflect the opinions of AWS.