> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ultrabalancer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# AI Agent Integration

> How to tell AI coding agents to implement and configure UltraBalancer

## Overview

This guide shows you how to instruct AI coding agents (Claude, ChatGPT, Cursor, etc.) to implement UltraBalancer in your infrastructure.

## Installation Prompt

Use this prompt to have an AI agent install UltraBalancer:

```text theme={null}
Install UltraBalancer load balancer on Ubuntu 22.04 server:

1. Install Rust toolchain and dependencies
2. Clone https://github.com/bas3line/ultrabalancer.git  
3. Build with cargo build --release
4. Install to /usr/local/bin/ultrabalancer
5. Verify with ultrabalancer --version

Please execute these commands and show me the output.
```

## Configuration Prompt

Use this to generate a configuration file:

```text theme={null}
Create a UltraBalancer configuration file at /etc/ultrabalancer/config.yaml:

- Listen on port 80
- Backend servers: 192.168.1.10:8080, 192.168.1.11:8080, 192.168.1.12:8080
- Use round-robin algorithm
- Enable health checks every 5 seconds
- Maximum 3 failures before marking server down

Generate the complete YAML configuration file.
```

## Systemd Service Prompt

```text theme={null}
Create a systemd service for UltraBalancer:

1. Create service file at /etc/systemd/system/ultrabalancer.service
2. Run as user 'ultrabalancer'
3. Use config file /etc/ultrabalancer/config.yaml
4. Auto-restart on failure
5. Enable on boot
6. Start the service and show status

Execute all steps.
```

## Docker Deployment Prompt

```text theme={null}
Create a Docker Compose setup for UltraBalancer:

1. Use image: ghcr.io/bas3line/ultrabalancer:latest
2. Map port 80 to container port 8080
3. Mount config.yaml file
4. Include 3 nginx backend containers
5. Create custom network
6. Start with docker-compose up -d

Generate the docker-compose.yml file and start the services.
```

## Kubernetes Deployment Prompt

```text theme={null}
Create Kubernetes manifests for UltraBalancer:

1. ConfigMap with configuration
2. Deployment with 2 replicas  
3. Service (LoadBalancer type)
4. Health check probes
5. Apply all manifests

Generate all YAML files and apply to cluster.
```

## Testing Prompts

### Basic Health Check

```text theme={null}
Test UltraBalancer is working:

1. Check health endpoint: curl localhost/health
2. Check metrics: curl localhost/metrics  
3. Send 10 test requests
4. Verify requests are distributed across backends

Show all outputs.
```

### Failover Testing

```text theme={null}
Test UltraBalancer failover:

1. Check current health status
2. Kill one backend server
3. Wait 10 seconds
4. Check health status again (should show degraded)
5. Send 10 requests (should only go to healthy backends)
6. Restart the backend
7. Verify it recovers

Show all outputs and verify failover works.
```

### Load Testing

```text theme={null}
Performance test UltraBalancer:

1. Install Apache Bench (ab)
2. Run: ab -n 10000 -c 100 http://localhost/
3. Check metrics endpoint
4. Report: requests/sec, response time, failures

Show results and analysis.
```

## Common Scenarios

<AccordionGroup>
  <Accordion title="Add New Backend">
    ```text theme={null}
    Add a new backend server to UltraBalancer:

    1. Edit /etc/ultrabalancer/config.yaml
    2. Add new backend: 192.168.1.20:8080 with weight 100
    3. Reload service: sudo systemctl reload ultrabalancer
    4. Verify backend is healthy
    5. Test traffic distribution

    Show updated config and verification.
    ```
  </Accordion>

  <Accordion title="Switch Algorithm">
    ```text theme={null}
    Change load balancing algorithm to least-connections:

    1. Edit config file
    2. Change algorithm field  
    3. Restart service
    4. Send test requests
    5. Verify new distribution

    Show before/after metrics.
    ```
  </Accordion>

  <Accordion title="Setup Monitoring">
    ```text theme={null}
    Setup Prometheus monitoring for UltraBalancer:

    1. Install Prometheus
    2. Configure scrape endpoint
    3. Restart Prometheus  
    4. Verify metrics collection
    5. Create basic dashboard

    Show Prometheus config and verify data collection.
    ```
  </Accordion>

  <Accordion title="Production Hardening">
    ```text theme={null}
    Harden UltraBalancer for production:

    1. Create dedicated user
    2. Set file permissions
    3. Configure resource limits
    4. Setup log rotation
    5. Configure firewall rules
    6. Enable systemd hardening

    Apply all hardening steps and verify.
    ```
  </Accordion>
</AccordionGroup>

## Complete Deployment Example

Use this comprehensive prompt for full deployment:

```text theme={null}
Deploy UltraBalancer on Ubuntu 22.04 production server:

Repository: https://github.com/bas3line/ultrabalancer

Requirements:
- Build from source using Rust/Cargo
- Install to /usr/local/bin
- Config: /etc/ultrabalancer/config.yaml
- Listen on port 80
- Backends: 10.0.1.10:8080 (weight 200), 10.0.1.11:8080 (weight 100)
- Use least-connections algorithm
- Health checks every 5 seconds
- Run as systemd service
- Start on boot
- Run as unprivileged user

Steps:
1. Install dependencies
2. Build and install
3. Create user and directories
4. Create configuration
5. Create systemd service
6. Configure firewall
7. Start and verify

Show output of: ultrabalancer --version, curl localhost/health, curl localhost/metrics
```

## Tips for AI Agents

<Tip>
  Be specific about paths, ports, and configuration values in your prompts.
</Tip>

<Tip>
  Always ask AI to verify installation with version check and health endpoints.
</Tip>

<Tip>
  Request AI to show full error messages if something fails.
</Tip>

<Tip>
  Include the repository URL in prompts: [https://github.com/bas3line/ultrabalancer](https://github.com/bas3line/ultrabalancer)
</Tip>

## Next Steps

<CardGroup cols={2}>
  <Card title="Configuration" icon="gear" href="/configuration/overview">
    All configuration options
  </Card>

  <Card title="Deployment Guides" icon="server" href="/deployment/linux-server">
    Detailed deployment tutorials
  </Card>

  <Card title="Monitoring" icon="chart-line" href="/integration/monitoring">
    Set up monitoring and alerts
  </Card>

  <Card title="Troubleshooting" icon="wrench" href="/advanced/troubleshooting">
    Common issues and solutions
  </Card>
</CardGroup>
