azu dev
The azu dev command provides an enhanced development environment with additional tools and features for productive development. It's an alternative to azu serve with extra development capabilities.
Overview
azu dev [options]Basic Usage
Start Development Environment
# Start development environment
azu dev
# Start with custom port
azu dev --port 4000
# Start with specific environment
azu dev --env developmentDevelopment with Hot Reloading
# Start development server with enhanced features
azu dev
# Output:
# 🚀 Starting Azu development environment...
# 📦 Compiling application...
# ✅ Compilation successful!
# 🌐 Server running at: http://localhost:4000
# 🔥 Hot reloading enabled
# 👀 Watching for file changes...
# 📊 Development dashboard at: http://localhost:4000/dev
# 🧪 Test runner available
# 📝 Code formatter active
#
# Press Ctrl+C to stop the serverCommand Options
--port <port>
Server port
4000
--host <host>
Server host
localhost
--env <environment>
Environment name
development
--debug
Enable debug mode
true
--dashboard
Enable development dashboard
true
--tests
Enable test runner
true
--format
Enable code formatting
true
--lint
Enable linting
true
--coverage
Enable code coverage
false
--workers <number>
Number of worker processes
1
Development Features
Development Dashboard
Access the development dashboard at http://localhost:4000/dev:
# Dashboard features:
# - Application status
# - Database information
# - Route listing
# - Performance metrics
# - Error logs
# - Test results
# - Code coverageEnhanced File Watching
# Watches additional file types
src/
├── *.cr                    # Crystal source files
├── endpoints/              # Endpoint files
├── models/                 # Model files
├── services/               # Service files
├── middleware/             # Middleware files
├── initializers/           # Initializer files
└── pages/                  # Page components
public/
├── assets/                 # Static assets
├── templates/              # Template files
└── *.css, *.js, *.html     # Static files
config/
├── *.yml                   # Configuration files
└── environments/           # Environment configs
spec/
├── *_spec.cr               # Test files
└── factories/              # Test factoriesAutomatic Code Formatting
# Automatically format code on save
# Uses crystal tool format
# Format specific files
crystal tool format src/models/user.cr
# Format entire project
crystal tool format src/Linting and Code Quality
# Run Ameba linter automatically
# Checks for code quality issues
# Manual linting
ameba src/
# Fix auto-fixable issues
ameba --fix src/Test Runner Integration
# Run tests automatically on file changes
# Tests run in background
# Manual test execution
crystal spec
# Run specific test files
crystal spec spec/models/user_spec.cr
# Run with coverage
crystal spec --coverageDevelopment Dashboard
Dashboard Features
Application Status:
- Server uptime 
- Memory usage 
- CPU usage 
- Request count 
- Error rate 
Database Information:
- Connection status 
- Migration status 
- Table count 
- Query performance 
Route Listing:
- All registered routes 
- HTTP methods 
- Endpoint classes 
- Route parameters 
Performance Metrics:
- Response times 
- Throughput 
- Memory allocation 
- Garbage collection 
Error Logs:
- Recent errors 
- Stack traces 
- Error frequency 
- Error categories 
Test Results:
- Test status 
- Coverage reports 
- Failed tests 
- Test performance 
Accessing Dashboard
# Start development server
azu dev
# Access dashboard
# http://localhost:4000/dev
# Dashboard sections:
# /dev/status      - Application status
# /dev/database    - Database information
# /dev/routes      - Route listing
# /dev/performance - Performance metrics
# /dev/errors      - Error logs
# /dev/tests       - Test results
# /dev/coverage    - Code coverageExamples
Basic Development
# Start development environment
azu dev
# Visit application
# http://localhost:4000
# Visit dashboard
# http://localhost:4000/devCustom Configuration
# Development with custom settings
azu dev --port 4000 --host 0.0.0.0 --debug
# Development without dashboard
azu dev --dashboard=false
# Development with coverage
azu dev --coverageTeam Development
# Share development server
azu dev --host 0.0.0.0 --port 4000
# Multiple developers can access:
# http://your-ip:4000
# http://your-ip:4000/devDevelopment Workflow
1. Start Development
# Start development environment
azu dev
# In another terminal, run additional tools
crystal spec --watch
ameba --watch src/2. Make Changes
# Edit files in src/
# Changes are automatically detected
# Server recompiles and restarts
# Tests run automatically
# Code is formatted
# Linting runs3. Monitor Progress
# Check dashboard for:
# - Compilation status
# - Test results
# - Performance metrics
# - Error logs
# Visit: http://localhost:4000/dev4. Debug Issues
# Check error logs in dashboard
# http://localhost:4000/dev/errors
# Check test failures
# http://localhost:4000/dev/tests
# Check performance issues
# http://localhost:4000/dev/performanceAdvanced Features
Code Coverage
# Enable coverage tracking
azu dev --coverage
# View coverage in dashboard
# http://localhost:4000/dev/coverage
# Coverage includes:
# - Line coverage
# - Branch coverage
# - Function coverage
# - File coveragePerformance Profiling
# Enable performance profiling
azu dev --profile
# Profile information available in dashboard
# http://localhost:4000/dev/performance
# Profile data includes:
# - Request timing
# - Database queries
# - Memory usage
# - CPU usageDatabase Monitoring
# Database monitoring in dashboard
# http://localhost:4000/dev/database
# Database information includes:
# - Connection status
# - Migration status
# - Query count
# - Query timing
# - Table sizesError Tracking
# Error tracking in dashboard
# http://localhost:4000/dev/errors
# Error information includes:
# - Error count
# - Error types
# - Stack traces
# - Error frequency
# - Error contextConfiguration
Development Configuration
# config/environments/development.cr
Azu.configure do |config|
  config.debug = true
  config.log_level = :debug
  config.host = "localhost"
  config.port = 4000
  # Development-specific settings
  config.development.dashboard = true
  config.development.auto_format = true
  config.development.auto_lint = true
  config.development.test_runner = true
  config.development.coverage = false
endDashboard Configuration
# azu.yml
development:
  dashboard:
    enabled: true
    port: 4000
    host: localhost
    auth: false
    metrics:
      enabled: true
      interval: 5s
    tests:
      enabled: true
      auto_run: true
    coverage:
      enabled: false
      threshold: 80Troubleshooting
Dashboard Not Accessible
# Check if dashboard is enabled
azu dev --dashboard=true
# Check dashboard port
# Default: http://localhost:4000/dev
# Check firewall settings
# Ensure port is accessibleTests Not Running
# Check test configuration
azu dev --tests=true
# Run tests manually
crystal spec
# Check test files exist
ls -la spec/Code Formatting Issues
# Check Crystal installation
crystal --version
# Run formatter manually
crystal tool format src/
# Check for syntax errors
crystal build src/main.crPerformance Issues
# Reduce worker processes
azu dev --workers 1
# Disable features
azu dev --coverage=false --profile=false
# Check system resources
top
htopBest Practices
1. Development Workflow
# Use azu dev for development
azu dev
# Use azu serve for simple testing
azu serve
# Use production build for performance testing
crystal build src/main.cr --release2. Dashboard Usage
# Monitor dashboard regularly
# http://localhost:4000/dev
# Check for:
# - Compilation errors
# - Test failures
# - Performance issues
# - Database problems3. Code Quality
# Keep code formatted
# crystal tool format runs automatically
# Fix linting issues
# ameba runs automatically
# Maintain test coverage
# Tests run automatically4. Performance Monitoring
# Monitor performance in dashboard
# http://localhost:4000/dev/performance
# Watch for:
# - Slow requests
# - High memory usage
# - Database bottlenecks
# - Error spikesIntegration with IDEs
VS Code Integration
// .vscode/launch.json
{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Azu Dev",
      "type": "crystal",
      "request": "launch",
      "program": "${workspaceFolder}/src/main.cr",
      "args": ["dev", "--port", "4000"]
    }
  ]
}JetBrains Integration
# Run configuration
# Program: src/main.cr
# Arguments: dev --port 4000
# Working directory: project rootThe azu dev command provides an enhanced development environment with dashboard, testing, formatting, and monitoring capabilities.
Next Steps:
- Development Workflows - Learn development patterns 
- Testing Your Application - Comprehensive testing 
- Database Commands - Manage your database 
Last updated