Overview
HAI Build provides intelligent code generation capabilities that go beyond simple autocomplete. The AI assistant understands your codebase, follows your patterns, and generates context-aware code that integrates seamlessly with your existing architecture.Code Generation Workflows
HAI Build supports multiple approaches to code generation:Conversational Generation
Describe what you need in the chat, and HAI generates appropriate code
Context-Based Generation
Select existing code and request modifications or extensions
File-Level Generation
Request new files, components, or modules
Inline Improvements
Improve, refactor, or optimize existing code
Starting a Code Generation Task
Describe Your Requirements
Be specific about what you want to create. Include:
- Purpose: What the code should do
- Context: Where it fits in your application
- Requirements: Specific features or constraints
- Patterns: Any coding standards or patterns to follow
Review the Plan
HAI analyzes your codebase and presents a plan showing:
- Files that will be created or modified
- Approach to implementation
- Reasoning behind decisions
Accept or Refine
- Accept: Approve the plan to proceed with code generation
- Refine: Provide feedback to adjust the approach
Example Code Generation Requests
Creating New Components
Modifying Existing Code
Advanced Code Generation
Using Experts for Domain-Specific Code
Activate experts to generate code following specific frameworks or patterns:- .NET Expert
- Node.js Expert
- Terraform Expert
- Go Expert
Generates C# code following .NET best practices:
- Async/await patterns
- Dependency injection
- Entity Framework conventions
- ASP.NET Core patterns
Learn more about configuring and creating custom experts in our Custom Experts guide.
Multi-File Generation
Generate complete features spanning multiple files:Example: Full Feature Request
- Analyze your existing code structure
- Plan which files to create/modify
- Generate all necessary code
- Ensure consistency across files
- Present changes for your review
Test Generation
Generate comprehensive tests for your code:Code Generation Best Practices
Provide Clear Context
Provide Clear Context
Include:
- File paths where code should go
- Related files or components
- Coding standards or patterns to follow
- Dependencies or libraries to use
Reference Existing Patterns
Reference Existing Patterns
Help HAI understand your codebase conventions:HAI will analyze the referenced file and match its style.
Specify Requirements Explicitly
Specify Requirements Explicitly
Be explicit about:
- Language and framework versions
- Type safety requirements (TypeScript, etc.)
- Testing expectations
- Performance considerations
- Security requirements
Iterate and Refine
Iterate and Refine
Don’t expect perfection on the first try:
- Review generated code
- Provide specific feedback
- Request adjustments
- Test the implementation
- Refine as needed
Review Before Accepting
Review Before Accepting
Always review generated code for:
- Correctness: Does it do what you asked?
- Style: Does it match your codebase conventions?
- Performance: Are there obvious inefficiencies?
- Security: Are there potential vulnerabilities?
- Maintainability: Is it readable and well-documented?
Common Code Generation Scenarios
Scaffolding New Features
Request
Refactoring Legacy Code
Request
Adding Integrations
Request
Documentation Generation
Request
Working with Generated Code
Accepting Changes
Review Diffs
HAI presents changes in a diff view showing:
- Lines added (green)
- Lines removed (red)
- Lines modified (yellow)
Accept or Reject
- Accept: Apply changes to your files
- Reject: Discard and provide different instructions
- Modify: Request specific adjustments
Using Checkpoints
HAI Build creates automatic checkpoints:- Before major changes: Revert if needed
- After task completion: Jump back to working states
- On request: Create manual checkpoints
Code Quality and Standards
Ensure generated code meets your standards:Type Safety
Request for TypeScript
Testing
Request with Tests
Documentation
Request with Docs
Troubleshooting Code Generation
- Code Doesn't Match Patterns
- Missing Context
- Incorrect Implementation
Issue: Generated code doesn’t follow your conventionsSolutions:
- Reference specific files that exemplify your patterns
- Provide style guide or coding standards
- Create a custom expert with your conventions
- Iterate with specific feedback
Next Steps
Git Integration
Generate commit messages for your code changes
Custom Experts
Create experts for your specific frameworks
Inline Editing
Quick AI-assisted code modifications
MCP Integration
Extend code generation with external tools
Pro Tip: The more you use HAI Build, the better it understands your codebase patterns. Over time, generated code will increasingly match your style.