This document provides practical examples of using the CodePrism skill with AI agents.
Scenario: You want to understand a complex payment processing function.
Prompt:
Use codeprism to understand the process_payment function in payments/processor.py. Explain what it does, who calls it, what it calls, and any security considerations.
Expected Agent Response:
- Calls
search_symbolto locate the function - Calls
get_context(payments/processor.py, process_payment, depth=2) - Provides:
- Function signature and purpose
- List of direct callers (which parts of the app use it)
- List of direct callees (what dependencies it has)
- Types and parameters
- Any security-related calls
Tokens used: ~250 tokens (vs ~2,000 tokens for reading the file)
Scenario: You want to rename a core utility function.
Prompt:
I want to rename the format_date function in utils/helpers.py. Use codeprism to check the impact before I start. Tell me what will break.
Expected Agent Response:
- Calls
get_impact(utils/helpers.py, format_date) - Reports:
- Severity (HIGH/MEDIUM/LOW)
- Number of direct dependents
- List of affected files
- Affected test files
- Transitive dependents (files that depend on dependents)
Tokens used: ~300 tokens (vs ~5,000 tokens for manual analysis)
Scenario: You wrote a new authentication function and want to check for security issues.
Prompt:
I just wrote a new authentication function in auth/login.py. Use codeprism to scan it for security issues before I commit.
Expected Agent Response:
- Calls
scan_file(auth/login.py)orscan_diffwith changes - Reports:
- Status (PASS/WARN/BLOCK)
- Any secrets detected
- Any injection vulnerabilities
- Any weak cryptography
- Any unsafe dependencies
If BLOCK:
- Agent refuses to commit
- Explains the specific issues
- Suggests fixes
If PASS:
- Agent approves commit
- Reports any warnings
Scenario: You need to audit all authentication-related code.
Prompt:
Find all functions in this codebase that handle authentication. Use codeprism to search for them.
Expected Agent Response:
- Calls
search_symbol("auth", kind="function") - Presents:
- List of matching functions
- Their locations
- Brief descriptions
- Ranking by relevance
Tokens used: ~200 tokens (vs grepping through all files)
Scenario: You want to know what a module depends on.
Prompt:
Use codeprism to analyze the dependencies of the auth module. What does it import and what depends on it?
Expected Agent Response:
- Calls
get_dependencies(auth/login.py)for imports - Calls
get_dependents(auth/login.py)for dependents - Reports:
- Internal dependencies (other project files)
- External dependencies (libraries)
- Files that depend on this module
- Dependency graph overview
Scenario: You want to trace where user input flows.
Prompt:
Trace where data from the handle_request function flows. Use codeprism to find all the sinks.
Expected Agent Response:
- Calls
get_data_flow(api/handlers.py, handle_request) - Reports:
- Data sources
- Intermediate processing steps
- Final sinks (database, API calls, file writes)
- Security-critical paths
Scenario: You're exploring a new codebase and want to understand a module quickly.
Prompt:
Use codeprism to give me a high-level overview of the core module. What does it do and what are its main components?
Expected Agent Response:
- Calls
get_module_summary(codeprism/core/__init__.py) - Reports:
- Module purpose (narrative summary)
- Public API (main functions/classes)
- Key classes
- Dependencies
- Complexity score
Tokens used: ~150 tokens (vs ~1,000 tokens for reading the file)
Scenario: Your team is planning a large refactoring and needs to coordinate.
Prompt:
We're planning to refactor the user model. Use codeprism to check the impact and tell me which teams and files will be affected.
Expected Agent Response:
- Calls
get_impact(models/user.py, User) - Reports:
- Severity assessment
- List of affected files grouped by module
- Test files that need updates
- Suggested coordination points
Scenario: You want to find all validation functions.
Prompt:
Find all functions that validate input. Use codeprism to search for validation-related functions.
Expected Agent Response:
- Calls
search_symbol("validate", kind="function") - Presents:
- All validation functions
- Their locations
- Brief descriptions
- Can group by validation type
Scenario: A long multi-step task where the agent should remember what it has read.
Prompt:
I need to refactor the payment system. Use codeprism throughout:
1. First, check the impact of changing process_payment
2. Then understand who calls it
3. Then understand what it calls
4. Then make the changes
5. Finally, scan for security issues before writing
Use session tracking to avoid re-reading the same context.
Expected Agent Response:
- Calls
get_contextandrecord_readfor each query - Uses
get_session_contextto check what's already been read - Avoids re-fetching the same information
- Calls
scan_diffbefore writes - Calls
record_writeto track changes
Benefits:
- Token-efficient (no repeated reads)
- Faster (no re-querying)
- Consistent state tracking
Scenario: Your project has Python and TypeScript code.
Prompt:
Find all functions that call the Python API from the TypeScript frontend. Use codeprism to trace the cross-language calls.
Expected Agent Response:
- Searches for API functions in Python
- Searches for callers in TypeScript
- Reports:
- Cross-language call graph
- Entry points
- Integration points
Scenario: A function is slow and you want to understand why.
Prompt:
The export_data function is slow. Use codeprism to analyze what it calls and identify potential bottlenecks.
Expected Agent Response:
- Calls
get_context(export_data, depth=2) - Analyzes callees for:
- Database operations
- File I/O
- Network calls
- Complex computations
- Reports:
- Likely bottlenecks
- Suggested optimization points
Good:
Use codeprism to find who calls the process_payment function in the payments module.
Bad:
Use codeprism to tell me about process_payment.
Good:
Use codeprism to analyze the impact of changing this function and tell me what tests I need to update.
Bad:
Use codeprism to get the impact of this function.
Good for:
- Understanding relationships (callers, callees)
- Impact analysis
- Dependency analysis
- Security scanning
- Symbol search
Not for:
- Exact implementation details (read the file after getting context)
- Line-by-line code review
- Business logic verification
Good:
Use codeprism to get the context for this function, then read the file if you need implementation details.
Use codeprism to give me a quick overview of [module/file].
Use codeprism to get context for [function] with depth=2, then read the file for implementation details.
Use codeprism to check the impact of changing [symbol] before I start refactoring.
Use codeprism to scan [file] for security issues before I commit.
Use codeprism to find all functions that [condition] in this codebase.
| Task | Without CodePrism | With CodePrism | Savings |
|---|---|---|---|
| Understand function | ~2,000 tokens | ~250 tokens | 87.5% |
| Find callers | ~3,000 tokens | ~300 tokens | 90% |
| Impact analysis | ~5,000 tokens | ~350 tokens | 93% |
| Security scan | ~1,000 tokens | ~150 tokens | 85% |
| Module summary | ~1,000 tokens | ~150 tokens | 85% |
Average: 88% token reduction
- Try these examples in your own codebase
- See User Guide for detailed instructions
- Read Full Documentation for CodePrism features