Skip to main content

Custom Experts

Experts enable HAI Build Code Generator to deliver context-aware code generation tailored to specific technologies, frameworks, or domains. Create custom experts to encode your team’s best practices, coding standards, and institutional knowledge.

Overview

Experts provide:
  • Domain-specific guidelines: Tailored coding standards and best practices
  • Reference documentation: Up to 3 external documentation links
  • Context injection: Automatically loaded when relevant to the task
  • Reusable knowledge: Shared across team members

Built-in Experts

HAI Build includes four ready-to-use experts:
  • .NET: C# and .NET ecosystem best practices
  • Terraform: Infrastructure as Code guidelines
  • Node.js: JavaScript/TypeScript development standards
  • Go: Golang idioms and patterns
These are read-only and provide quick reference for common technologies.

Custom Expert Structure

Custom experts are stored in the .hai-experts folder:

metadata.json

Contains expert configuration:
Fields:
  • name (required): Expert display name
  • createdAt (required): ISO timestamp
  • documentLinks (optional): Array of up to 3 URLs

prompt.md

Contains the expert’s guidelines (required):
components/ ├── Button/ │ ├── Button.tsx │ ├── Button.test.tsx │ ├── Button.styles.ts │ └── index.ts

State Management

  • Use useState for local component state
  • Use useContext for shared state across few components
  • Use Redux Toolkit or Zustand for complex global state
  • Avoid prop drilling - use composition or context

Testing

  • Write tests using React Testing Library
  • Focus on user behavior, not implementation details
  • Aim for > 80% coverage
  • Test accessibility with jest-axe

Accessibility

  • Use semantic HTML elements
  • Include ARIA labels where needed
  • Ensure keyboard navigation works
  • Test with screen readers

Creating a Custom Expert

Via VS Code Extension

  1. Open the HAI Build sidebar
  2. Navigate to the Experts section
  3. Click “Create New Expert”
  4. Fill in the required fields:
    • Name: Expert display name (e.g., “FastAPI Best Practices”)
    • Guidelines: Detailed coding standards and examples
    • Document Links (optional): Up to 3 reference URLs
  5. Click “Create”
HAI Build automatically:
  • Creates the folder structure in .hai-experts
  • Generates metadata.json and prompt.md
  • Processes document links (if provided)
  • Syncs the expert across workspace

Manual Creation

  1. Create expert folder:
  1. Create metadata.json:
  1. Create prompt.md:

Content Guidelines

  1. Be Specific: Provide concrete examples, not abstract advice
  2. Show Code: Include real code snippets demonstrating patterns
  3. Explain Why: Don’t just say what to do, explain the reasoning
  4. Cover Edge Cases: Address common pitfalls and edge cases
  5. Keep Updated: Review and update guidelines as frameworks evolve

Effective Examples

Good Example:

Reference Documentation

Provide up to 3 URLs to external documentation:
  1. Official Documentation: Framework guides and API references
  2. Style Guides: Community-accepted coding standards
  3. Best Practices: Curated resources and patterns

Processing Behavior

When links are provided:
  1. HAI crawls each URL (up to 3 levels deep)
  2. Extracts and converts content to markdown
  3. Stores in docs/ folder
  4. Updates status.json with progress
Processing runs asynchronously and doesn’t block expert creation.

Using Custom Experts

Automatic Context Loading

HAI automatically loads expert context when:
  • Files match the expert’s domain (e.g., .tsx files for React expert)
  • Task description mentions relevant keywords
  • Explicitly requested by the user

Manual Selection

Select an expert explicitly in the HAI interface:
  1. Open HAI Build sidebar
  2. Start a new task
  3. Click “Select Expert”
  4. Choose from available experts

Example Workflow

Managing Experts

Updating Experts

Edit expert files directly:
HAI automatically syncs changes across the workspace.

Deleting Experts

Remove the expert folder:
Or use the HAI interface:
  1. Navigate to Experts section
  2. Click delete icon on the expert
  3. Confirm deletion

Sharing Experts

Commit .hai-experts to version control:
Team members automatically receive experts when they pull the repository.

Advanced Use Cases

Multi-Framework Experts

Create experts for full-stack scenarios:

Team-Specific Standards

Encode institutional knowledge:

Deployment

Follow company CI/CD patterns:
  1. Use .company.yaml for configuration
  2. Run npm run build:prod before deploy
  3. Tag releases with semantic versioning

Security

  • Use company SSO library for authentication
  • Encrypt sensitive data with @company/crypto
  • Log all security events to audit trail
After (React 18):

New Root API

Before:
After:
project/ ├── apps/ │ ├── users/ │ ├── posts/ │ └── common/ ├── config/ │ ├── settings/ │ │ ├── base.py │ │ ├── dev.py │ │ └── prod.py │ └── urls.py └── manage.py

Views

Use class-based views for CRUD operations:
  1. Validate JSON syntax:
  1. Restart HAI Build extension

Document Processing Failed

Check status.json for errors:
Retry processing:
  1. Delete docs/ folder
  2. HAI will re-process on next usage

Next Steps

CLI Usage

Use HAI from the command line

COR-Matrix

Track AI code retention patterns