ContextAgent Module
TheContextAgent class implements advanced Context Engineering principles for AI coding assistants, following the PRD (Product Requirements Document) methodology.
Key Features
- 10x better than prompt engineering
- 100x better than vibe coding
- Comprehensive context generation for first-try implementation success
- Systematic codebase analysis with modern tools
- PRP (Product Requirements Prompt) generation
- Validation loops and quality gates
- Saves every agent response for complete traceability
Import
Quick Example
Constructor
ContextAgent()
Creates a new ContextAgent instance.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
name | str | "Context Engineering Specialist" | Agent name |
role | str | "Expert Context Engineer..." | Agent role |
goal | str | "Perform comprehensive codebase analysis..." | Agent goal |
backstory | str | Auto-generated | Agent backstory |
instructions | str | None | Custom instructions |
llm | str | None | LLM model to use |
tools | list | Auto-configured | Tools for analysis |
project_path | str | None | Path to project to analyze |
auto_analyze | bool | True | Auto-analyze on init |
Phases
The ContextAgent follows a systematic 5-phase approach:Phase 1: Deep Codebase Analysis
Using gitingest, AST analysis, and other tools to understand the codebase structure.Phase 2: Pattern Extraction and Documentation
Identifying coding patterns, conventions, and architectural decisions.Phase 3: Comprehensive PRP Generation
Creating detailed Product Requirements Prompts for implementation.Phase 4: Validation Framework Creation
Building validation criteria and quality gates.Phase 5: Implementation Blueprint Generation
Generating step-by-step implementation guidance.Methods
analyze_and_generate_prp(feature_description)
Performs full context engineering workflow.
Parameters:
feature_description(str): Description of the feature to implement
ContextResult - Contains analysis, PRP, and blueprint
analyze_codebase()
Analyzes the project codebase.
Returns: dict - Analysis results
generate_prp(feature_description)
Generates a Product Requirements Prompt.
Parameters:
feature_description(str): Feature description
str - Generated PRP
generate_implementation_blueprint()
Generates implementation guidance.
Returns: dict - Implementation blueprint
Attributes
| Attribute | Type | Description |
|---|---|---|
project_path | str | Path to the project |
analysis_results | dict | Codebase analysis results |
prp_results | dict | Generated PRPs |
context_documentation | dict | Context documentation |
implementation_blueprint | dict | Implementation guidance |
agent_interactions | list | All agent interactions (for traceability) |
Output Directory
Results are saved to.praison/prp/ in the project directory for complete traceability.
Example: Full Workflow
Related
- Agent Module - Base Agent class
- Task Module - Task definition
- Knowledge Module - Knowledge base

