Overview
The Intent.AI.AutoImplementation module uses AI to automatically implement theHandler method of a Command or Query, based on the full context provided by generated code and model metadata from Intent Architect.
This module leverages Large Language Models (LLMs) to generate production-ready business logic by analyzing your domain entities, repository interfaces, DTOs, and service contracts.
To use this feature, ensure that the required User Settings have been completed — including a valid API key for your selected AI provider.
What Gets Generated
Handler Implementations
The AI analyzes your application context and generates:- Complete handler method implementation with all business logic
- Repository interactions for data access
- Entity mapping between DTOs and domain models
- Validation logic when appropriate
- Error handling for common scenarios
- Proper async/await patterns
Application/Customers/CreateCustomer/CreateCustomerCommandHandler.cs
Installation
Prerequisites
- An Intent Architect application with Commands or Queries
- An AI provider account (OpenAI, Azure OpenAI, or Anthropic)
- Valid API key configured in User Settings
Installation Steps
Install the module
In Intent Architect, right-click on your application and select Manage Modules. Search for
Intent.AI.AutoImplementation and install it.Configure AI provider
Go to Tools → User Settings → AI Configuration and enter your API key for your chosen provider (OpenAI, Azure OpenAI, or Anthropic).
Usage
Basic Workflow
Model your Command or Query
In the Services Designer, create a Command or Query with the appropriate mapping to your domain entities.
Run the Software Factory
Execute the Software Factory to generate the handler class with an empty
Handle method.Right-click and Implement with AI
In the Services Designer, right-click on your Command or Query and select Implement with AI.

Influencing Factors
The quality and relevance of the generated implementation depend on several factors.Intent Modeling
Before running Implement with AI, ensure the following:- Generated Code is up-to-date: Run the Software Factory to apply all outstanding code changes
- Command/Query is mapped: Ensure the
CommandorQueryis associated with the appropriateEntityusing aCreate Entity,Update Entity, orQuery Entityaction (a dotted line should appear between the elements) - Repository interfaces exist: Make sure repository templates have been generated
- DTOs are properly mapped: For queries, ensure return types map correctly to entities
Adjusting the Prompt
While Intent Architect supplies a default prompt and relevant file context to the AI provider, you can optionally provide additional context to refine the result. Add custom instructions:
Example prompts:
AI responses are not deterministic — each execution may produce different results. Use the additional context prompt to guide the AI toward your desired implementation.
Examples
Create Command Implementation
Modeled Command:- Command:
CreateOrderCommand - Mapping:
Create Entity→Order - Properties:
CustomerId,OrderItems[]
Application/Orders/CreateOrder/CreateOrderCommandHandler.cs
Update Command Implementation
Modeled Command:- Command:
UpdateCustomerCommand - Mapping:
Update Entity→Customer - Properties:
Id,Name,Email,PhoneNumber
Application/Customers/UpdateCustomer/UpdateCustomerCommandHandler.cs
Query Implementation
Modeled Query:- Query:
GetCustomerByIdQuery - Mapping:
Query Entity→Customer - Return Type:
CustomerDto
Application/Customers/GetCustomerById/GetCustomerByIdQueryHandler.cs
Complex Business Logic
Custom Prompt:Application/Orders/ApproveOrder/ApproveOrderCommandHandler.cs
Code Changes Review
Once the AI Agent completes the task, suggested code changes will be displayed for review:
You can:
- Review the diff to see exactly what will change
- Accept or reject the implementation
- Rerun with additional context if the result isn’t satisfactory
Execution Output
Full logs of the execution, including the AI prompt and any errors, are available in the Execution tab:
This helps you understand:
- What context was sent to the AI
- How the AI reasoned about the implementation
- Any errors or warnings during generation
Best Practices
Model First
Create complete domain models with proper entity relationships before using AI implementation.
Keep Commands Simple
Focus each command on a single responsibility. Complex operations can be split into multiple commands.
Review Generated Code
Always review AI-generated implementations for correctness, security, and alignment with your coding standards.
Iterate with Prompts
Use custom prompts to guide the AI toward specific patterns, validations, or business rules.
Integration with Other Modules
AI Unit Tests
After implementing handlers, use AI to generate comprehensive unit tests.
FluentValidation
Combine with validation modules for input validation before handler execution.
MediatR
Works seamlessly with MediatR-based CQRS implementations.
Entity Framework
Generates proper EF Core repository usage patterns.
Related Resources
Next Steps
AI Unit Tests
Generate tests for your implementations
AI Blazor
Build UI components with AI
Domain Modeling
Learn best practices for domain modeling
