// Search for relevant code snippets, examples, and documentation from billions of GitHub repositories, documentation pages, and Stack Overflow posts. Use this skill when coding tasks require real working code examples, API usage patterns, framework setup instructions, or library implementation details to eliminate hallucinations and provide accurate, token-efficient context.
| name | exa-code-context |
| description | Search for relevant code snippets, examples, and documentation from billions of GitHub repositories, documentation pages, and Stack Overflow posts. Use this skill when coding tasks require real working code examples, API usage patterns, framework setup instructions, or library implementation details to eliminate hallucinations and provide accurate, token-efficient context. |
Exa Code Context is a powerful tool for finding relevant code snippets and examples from the open source community. It searches over billions of GitHub repos, documentation pages, Stack Overflow posts, and more to find perfect, token-efficient context that helps write correct code.
This skill eliminates hallucinations in coding tasks by providing real, working code examples instead of made-up patterns.
Use this skill when:
Example triggers:
The skill provides a Python script that interfaces with the Exa Context API:
from scripts.get_code_context import get_code_context
# Simple usage - automatic token optimization
result = get_code_context("React hooks for state management")
print(result["response"])
# Specify token count for more/less context
result = get_code_context("pandas dataframe filtering", tokens_num=5000)
print(result["response"])
Command-line usage:
python scripts/get_code_context.py "React hooks for state management"
python scripts/get_code_context.py "FastAPI async endpoints" 5000
Find practical examples of how frameworks are used in real projects:
Query: "use Exa search in python and make sure content is always livecrawled"
Returns actual code showing:
Get correct syntax for APIs and SDKs:
Query: "use correct syntax for vercel ai sdk to call gpt-5 nano asking it how are you"
Returns:
Configure development environments correctly:
Query: "how to set up a reproducible Nix Rust development environment"
Returns:
See how libraries are implemented in practice:
Query: "pandas dataframe filtering and groupby operations"
Returns:
Find authentication, security, and architectural patterns:
Query: "authentication patterns in NextJS applications"
Returns:
result = get_code_context("React hooks for state management examples")
# Returns formatted code snippets like:
# - useState examples with event handlers
# - Custom hooks for state management
# - Context API patterns
# - Real component implementations
result = get_code_context("FastAPI async endpoints with dependencies", tokens_num=5000)
# Returns:
# - Async route handlers
# - Dependency injection patterns
# - Database session management
# - Authentication dependencies
result = get_code_context("PostgreSQL connection pooling best practices")
# Returns:
# - Connection pool configurations
# - Context manager patterns
# - Error handling examples
# - Performance optimization tips
The skill supports flexible token management:
When to adjust tokens:
costDollars in responses to track API usageGood queries are specific and actionable:
Avoid vague queries:
To use this skill in your coding workflow:
The skill loads the Exa API key from /backend/.env:
# /backend/.env
EXA_API_KEY=your-api-key-here
Get your API key at: https://dashboard.exa.ai/api-keys
Each query returns:
requestId: Unique identifier for the requestquery: Your original search queryresponse: Formatted code snippets and explanations with source URLsresultsCount: Number of results foundcostDollars: Cost of the API callsearchTime: Time taken in millisecondsoutputTokens: Number of tokens in the responsescripts/get_code_context.py - Python implementation for querying the Exa Context API. Can be imported as a module or run from command line.
references/api_reference.md - Complete API documentation including:
Here are diverse example queries to demonstrate the skill's capabilities:
Web Frameworks:
Frontend Libraries:
Data Processing:
Database Operations:
Authentication:
No API key found:
/backend/.env contains EXA_API_KEY=your-keyPoor results:
Not enough context: