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.
| 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.Core Methods
analyze_codebase_with_gitingest(project_path)
Analyzes a codebase using gitingest for comprehensive understanding.
generate_comprehensive_prp(feature_request, context_analysis)
Generates a comprehensive Product Requirements Prompt.
build_implementation_blueprint(feature_request, context_analysis)
Creates a step-by-step implementation blueprint.
create_validation_framework(project_path)
Creates validation criteria and quality gates.
Protocol
ContextAgent implementsContextEngineerProtocol:
Async Methods
All core methods have async versions for non-blocking execution:Configurable Output
Control output using theoutput= parameter (inherited from Agent):
Output Directory
Results are saved to.praison/prp/ for complete traceability:
Example: Full Workflow
Related
- Agent Module - Base Agent class
- Context Management - Context window management
- Knowledge Module - Knowledge base

