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

# Aliases

> How aliases make dx perfect for AI agents and automated workflows

Aliases are one of dx's most powerful features for AI integration, enabling agents to interact with your development workflow through simple, memorable commands.

Aliases represent a first-principles approach to command efficiency - it's nearly impossible to beat the simplicity and speed of just two letters. When you can type `dx build` instead of navigating complex menus or remembering long command sequences, you're working at the fundamental limit of human-computer interaction efficiency.

## Why Aliases Matter for AI

<CardGroup cols={2}>
  <Card title="Predictable Interface" icon="target">
    AI agents can reliably call `dx build`, `dx test`, `dx deploy` across any project
  </Card>

  <Card title="Context Awareness" icon="brain">
    Aliases provide semantic meaning - `dx deploy` is clearer than `./scripts/deploy.sh`
  </Card>

  <Card title="Standardization" icon="handshake">
    Teams can standardize workflows so AI agents work consistently
  </Card>

  <Card title="Non-Interactive" icon="terminal">
    Perfect for automated environments where TUI interaction isn't possible
  </Card>
</CardGroup>

## AI-Friendly Command Structure

### Direct Execution

AI agents can execute commands without TUI interaction:

```bash theme={null}
# AI agent can call these directly
dx build                 # Build the project
dx test                  # Run tests  
dx deploy                # Deploy to staging
dx check                 # Run linting/checks
```

### List Available Commands

```bash theme={null}
dx aliases              # AI can discover available commands
# Output:
# ALIAS    NAME           TYPE  DETAILS
# build    Build Project  cmd   cargo build --release
# test     Run Tests      cmd   cargo test
# deploy   Deploy App     cmd   ./deploy.sh staging
```

## Setting Up AI-Friendly Aliases

### Essential Development Aliases

<CodeGroup>
  ```yaml dx.yaml theme={null}
  items:
    - name: "Build Project"
      alias: "build"
      description: "Compile and build the project for production"
      cmd: "cargo build --release"
      
    - name: "Run Tests"
      alias: "test"  
      description: "Execute all test suites"
      cmd: "cargo test"
      
    - name: "Lint Code"
      alias: "lint"
      description: "Run code quality checks"
      cmd: "cargo clippy -- -D warnings"
      
    - name: "Format Code"
      alias: "format"
      description: "Auto-format source code"
      cmd: "cargo fmt"
  ```

  ```toml dx.toml theme={null}
  [[items]]
  name = "Build Project"
  alias = "build"
  description = "Compile and build the project for production"
  cmd = "cargo build --release"

  [[items]]
  name = "Run Tests"
  alias = "test"
  description = "Execute all test suites"
  cmd = "cargo test"

  [[items]]
  name = "Lint Code"
  alias = "lint"
  description = "Run code quality checks"
  cmd = "cargo clippy -- -D warnings"

  [[items]]
  name = "Format Code"
  alias = "format"
  description = "Auto-format source code"
  cmd = "cargo fmt"
  ```

  ```json dx.json theme={null}
  {
    "items": [
      {
        "name": "Build Project",
        "alias": "build",
        "description": "Compile and build the project for production",
        "cmd": "cargo build --release"
      },
      {
        "name": "Run Tests",
        "alias": "test",
        "description": "Execute all test suites",
        "cmd": "cargo test"
      },
      {
        "name": "Lint Code",
        "alias": "lint",
        "description": "Run code quality checks",
        "cmd": "cargo clippy -- -D warnings"
      },
      {
        "name": "Format Code",
        "alias": "format",
        "description": "Auto-format source code",
        "cmd": "cargo fmt"
      }
    ]
  }
  ```
</CodeGroup>

### Deployment & Operations

<CodeGroup>
  ```yaml dx.yaml theme={null}
  items:
    - name: "Deploy Staging"
      alias: "deploy"
      description: "Deploy application to staging environment"
      cmd: "kubectl apply -f k8s/staging/"
      
    - name: "Check Status"
      alias: "status"  
      description: "Check application health and status"
      cmd: "kubectl get pods -l app=myapp"
      
    - name: "View Logs"
      alias: "logs"
      description: "Tail application logs"  
      cmd: "kubectl logs -f deployment/myapp"
  ```

  ```toml dx.toml theme={null}
  [[items]]
  name = "Deploy Staging"
  alias = "deploy"
  description = "Deploy application to staging environment"
  cmd = "kubectl apply -f k8s/staging/"

  [[items]]
  name = "Check Status"
  alias = "status"
  description = "Check application health and status"
  cmd = "kubectl get pods -l app=myapp"

  [[items]]
  name = "View Logs"
  alias = "logs"
  description = "Tail application logs"
  cmd = "kubectl logs -f deployment/myapp"
  ```

  ```json dx.json theme={null}
  {
    "items": [
      {
        "name": "Deploy Staging",
        "alias": "deploy",
        "description": "Deploy application to staging environment",
        "cmd": "kubectl apply -f k8s/staging/"
      },
      {
        "name": "Check Status",
        "alias": "status",
        "description": "Check application health and status",
        "cmd": "kubectl get pods -l app=myapp"
      },
      {
        "name": "View Logs",
        "alias": "logs",
        "description": "Tail application logs",
        "cmd": "kubectl logs -f deployment/myapp"
      }
    ]
  }
  ```
</CodeGroup>

## AI Agent Integration Patterns

### GitHub Actions Integration

```yaml theme={null}
# .github/workflows/ai-workflow.yml
name: AI-Powered Workflow
on: [push]
jobs:
  ai-tasks:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Install dx
        run: curl -fsSL https://usedx.sh | sh -s -- -y
        
      - name: AI Build
        run: dx build
        
      - name: AI Test  
        run: dx test
        
      - name: AI Quality Check
        run: dx lint
```

### Local AI Development

```bash theme={null}
# AI agent working on codebase
dx build                 # ✅ Build succeeds
dx test                  # ❌ Tests fail
dx format                # 🔧 Auto-fix formatting
dx test                  # ✅ Tests now pass
dx deploy                # 🚀 Deploy to staging
```

## Advanced AI Features

### Performance Benchmark

dx aliases have literally zero overhead - here's the proof:

<CodeGroup>
  ```bash Real Timing theme={null}
  $ time dx build
  real    0m0.047s
  user    0m0.021s  
  sys     0m0.015s

  $ time dx test
  real    0m0.031s
  user    0m0.018s
  sys     0m0.008s

  $ time dx deploy  
  real    0m0.042s
  user    0m0.019s
  sys     0m0.012s
  ```

  ```bash The Math theme={null}
  # LLM prompt generation: ~3 seconds
  # dx execution: ~0.04 seconds

  # You can run dx commands:
  3000ms ÷ 40ms = 75 times

  # While AI generates ONE response,
  # dx can execute 75 commands
  # That's not overhead - that's instant
  ```

  ```bash Hooks Integration theme={null}
  # Cloud Code hooks can trigger dx aliases
  pre-commit: dx lint && dx test
  post-merge: dx build && dx deploy
  on-save: dx format
  ```
</CodeGroup>

While your LLM is thinking, dx has already built, tested, and deployed your project.

### Command Discovery

AI agents can introspect available commands:

```bash theme={null}
# Agent discovers available operations
dx aliases | grep -E "(build|test|deploy)"

# Agent can read command details
dx aliases | grep "test" | cut -f4
# Output: cargo test --all-features
```

### Agent Friendly Design

```bash theme={null}
# Built-in timeouts prevent hanging
dx build                # Auto-timeout after 5min
dx test --timeout 30s   # Custom timeout  
dx deploy --no-input    # Never prompts for input

# Safe for unattended execution
dx build && dx test && dx deploy  # Chain with confidence
```

AI agents often fail when tasks hang indefinitely or require user input. dx prevents this by defaulting to reasonable timeouts and non-interactive execution, ensuring your automation never gets stuck waiting.

### Recording for Analysis

```bash theme={null}
# AI can record sessions for later analysis
dx build --record        # Creates timestamped recording
dx test --record         # AI can replay/analyze later
```

## Best Practices for AI Integration

### 1. Use Semantic Aliases

```toml theme={null}
# ✅ Good - Clear semantic meaning
alias = "build"          # AI knows this builds the project
alias = "test"           # AI knows this runs tests
alias = "deploy"         # AI knows this deploys

# ❌ Avoid - Unclear meaning  
alias = "cmd1"           # AI doesn't know what this does
alias = "run-script"     # Too generic
```

### 2. Provide Descriptions

```toml theme={null}
[[items]]
name = "Build Production"
alias = "build"
description = "Compile project for production with optimizations"
cmd = "cargo build --release"
```

### 3. Standardize Across Projects

```bash theme={null}
# Same aliases work across all projects
dx build                 # Always builds the project
dx test                  # Always runs tests  
dx deploy                # Always deploys (to appropriate env)
dx status                # Always checks health
```

### 4. Handle Different Environments

```toml theme={null}
[[items]]
name = "Deploy to Staging"
alias = "deploy"
description = "Deploy to staging environment"
cmd = "deploy.sh staging"

[[items]] 
name = "Deploy to Production"
alias = "deploy-prod"
description = "Deploy to production (requires confirmation)"
cmd = "deploy.sh production"
```

## Integration with AI Coding Assistants

### Cursor Integration

dx aliases work seamlessly with Cursor's terminal:

```javascript theme={null}
// Cursor can suggest and run dx commands
const buildProject = () => {
    // User: "build the project"
    // Cursor: suggests "dx build"
    terminal.run('dx build');
}
```

### Claude/ChatGPT Integration

```markdown theme={null}
**System Prompt for AI:**
This project uses dx for workflow automation. Key commands:
- `dx build` - Build the project
- `dx test` - Run tests
- `dx deploy` - Deploy to staging  
- `dx aliases` - List all available commands

Always use these standardized commands instead of direct tool invocation.
```

<Tip>
  Create a `DEVELOPMENT.md` file documenting your dx aliases so AI agents can understand your project's workflow.
</Tip>

<Note>
  Aliases make dx workflows discoverable and standardizable, perfect for AI agents that need predictable interfaces.
</Note>
