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 ./src
Basic Fast Context
praisonai "Explain how the login function works" --fast-context ./src
Expected 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 --planning
How 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 ./src
Bug Investigation
praisonai "Why might the user session expire unexpectedly?" --fast-context ./src/auth
Expected 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 ./src
Feature Planning
praisonai "How would I add OAuth support based on the current auth system?" --fast-context ./src/auth
Documentation Generation
praisonai "Generate API documentation for the user endpoints" --fast-context ./src/api/users
Search 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
Be specific with your search path. Searching a smaller, relevant directory produces better results than searching the entire project.
Large codebases may result in high token usage. Use --metrics to monitor costs.
Specific Paths
Target specific directories for better relevance
Clear Prompts
Use specific technical terms that match your code
Iterative Search
Start broad, then narrow down to specific modules
Monitor Tokens
Use --metrics to track context size and costs
| 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 |