Fast Context
Search codebase for relevant context to enhance agent responses
The --fast-context flag searches your codebase for relevant code and adds it as context to the agent’s prompt.
Quick Start
praisonai "Find authentication code" --fast-context ./srcUsage
Basic Fast Context
praisonai "Explain how the login function works" --fast-context ./srcExpected Output:
⚡ Fast Context enabled - searching ./src
📂 Found relevant files:
• src/auth/login.py (95% relevance)
• src/auth/utils.py (78% relevance)
• src/models/user.py (65% relevance)
╭─ Agent Info ─────────────────────────────────────────────────────────────────╮
│ 👤 Agent: DirectAgent │
│ Role: Assistant │
│ 📄 Context: 3 files, 245 lines │
╰──────────────────────────────────────────────────────────────────────────────╯
╭────────────────────────────────── Response ──────────────────────────────────╮
│ Based on the codebase, the login function in `src/auth/login.py` works as │
│ follows: │
│ │
│ 1. **Input Validation**: The function first validates the email format │
│ using the `validate_email()` helper from `utils.py` │
│ │
│ 2. **User Lookup**: It queries the database using the User model to find │
│ the user by email │
│ │
│ 3. **Password Verification**: Uses bcrypt to compare the hashed password │
│ │
│ 4. **Token Generation**: On success, generates a JWT token with user claims │
╰──────────────────────────────────────────────────────────────────────────────╯Specify Search Path
# Search specific directory
praisonai "How does the API handle errors?" --fast-context ./src/api
# Search from project root
praisonai "Explain the database schema" --fast-context /path/to/project
# Search current directory
praisonai "Find all test files" --fast-context .Combine with Other Features
# Fast context with metrics
praisonai "Optimize this function" --fast-context ./src --metrics
# Fast context with guardrail
praisonai "Refactor the code" --fast-context ./src --guardrail "Maintain backward compatibility"
# Fast context with planning
praisonai "Add new feature" --fast-context ./src --planningHow It Works
- Query Analysis: Analyzes your prompt to understand what code is relevant
- Codebase Search: Searches the specified directory for matching files
- Relevance Ranking: Ranks files by relevance to your query
- Context Injection: Adds relevant code snippets to the agent’s context
- Enhanced Response: Agent responds with full codebase awareness
Use Cases
Code Explanation
praisonai "Explain how the payment processing works" --fast-context ./srcBug Investigation
praisonai "Why might the user session expire unexpectedly?" --fast-context ./src/authExpected Output:
⚡ Fast Context enabled
📂 Found relevant files:
• src/auth/session.py
• src/auth/middleware.py
• src/config/settings.py
╭────────────────────────────────── Response ──────────────────────────────────╮
│ Based on the code analysis, there are several potential causes for │
│ unexpected session expiration: │
│ │
│ 1. **Short Timeout**: In `settings.py`, `SESSION_TIMEOUT` is set to 300 │
│ seconds (5 minutes), which may be too short for some use cases │
│ │
│ 2. **Missing Refresh**: The `session.py` doesn't implement token refresh │
│ on activity, so sessions expire even during active use │
│ │
│ 3. **Race Condition**: In `middleware.py` line 45, there's a potential │
│ race condition when checking session validity │
╰──────────────────────────────────────────────────────────────────────────────╯Code Review
praisonai "Review the error handling in this codebase" --fast-context ./srcFeature Planning
praisonai "How would I add OAuth support based on the current auth system?" --fast-context ./src/authDocumentation Generation
praisonai "Generate API documentation for the user endpoints" --fast-context ./src/api/usersSearch Configuration
File Types Searched
By default, Fast Context searches common code files:
| Language | Extensions |
|---|---|
| Python | .py |
| JavaScript | .js, .jsx, .ts, .tsx |
| Go | .go |
| Rust | .rs |
| Java | .java |
| C/C++ | .c, .cpp, .h, .hpp |
| Ruby | .rb |
| PHP | .php |
Ignored Paths
These directories are automatically excluded:
node_modules/venv/,.venv/__pycache__/.git/dist/,build/
Best Practices
Specific Paths
Target specific directories for better relevance
Clear PromptsUse specific technical terms that match your code
Iterative SearchStart broad, then narrow down to specific modules
Monitor TokensUse --metrics to track context size and costs
Performance Tips
| Scenario | Recommendation |
|---|---|
| Large codebase | Search specific subdirectories |
| Many files found | Refine your prompt to be more specific |
| Slow search | Exclude unnecessary directories |
| High token usage | Limit search depth or file count |