Xec Recipes Cookbook
Welcome to the Xec Recipes Cookbook - a comprehensive collection of practical, production-ready recipes for common automation tasks using Xec's universal command execution system.
π Recipe Categoriesβ
π Deploymentβ
Production-ready deployment strategies and patterns
- Node.js Application Deployment - Deploy Node.js apps with zero downtime
- Static Site Deployment - Deploy to CDNs, S3, Nginx, and more
- Docker Container Deployment - Container orchestration and management
- Kubernetes Deployment - Deploy to Kubernetes clusters with Helm
π§ Maintenanceβ
System maintenance and operational excellence
- Log Aggregation - Centralized logging with ELK/Loki
- Backup and Restore - Comprehensive backup strategies
- Health Checks - Service monitoring and alerting
- Certificate Renewal - SSL/TLS certificate management
π» Developmentβ
Development workflows and environment setup
- Database Setup - Local database configuration
- API Mocking - Mock servers for development
- Test Data Generation - Generate realistic test data
- Hot Reload Workflows - Live development with hot reload
π Integrationβ
Third-party service and tool integrations
- GitHub Actions - CI/CD with GitHub Actions
- GitLab CI - GitLab CI/CD pipelines
- Jenkins - Jenkins automation
- AWS Services - AWS service integration
π― How to Use This Cookbookβ
Recipe Structureβ
Each recipe follows a consistent structure:
- Problem - The challenge being addressed
- Solution - How Xec solves it
- Quick Example - Minimal working example
- Complete Recipe - Full implementation with all details
- Usage Examples - Common usage patterns
- Best Practices - Recommended approaches
- Troubleshooting - Common issues and solutions
- Related Topics - Links to related recipes
Code Verificationβ
All recipes in this cookbook:
- β Are tested against the actual Xec codebase
- β Include working examples with real implementation
- β Reference actual source files and functions
- β Follow the surgical precision requirement from the documentation spec
Getting Startedβ
- Choose a recipe that matches your use case
- Copy the configuration to your
.xec/config.yaml
- Adapt the scripts to your specific needs
- Run the commands as shown in the usage examples
π Finding the Right Recipeβ
By Use Caseβ
Deploying Applications:
- Web applications β Node.js Deployment
- Static websites β Static Site Deployment
- Containerized apps β Docker Deployment
- Microservices β Kubernetes Deployment
Managing Infrastructure:
- Log management β Log Aggregation
- Data protection β Backup and Restore
- Monitoring β Health Checks
- SSL certificates β Certificate Renewal
Development Workflows:
- Local development β Hot Reload
- Database setup β Database Setup
- API development β API Mocking
- Testing β Test Data Generation
CI/CD Automation:
- GitHub β GitHub Actions
- GitLab β GitLab CI
- Jenkins β Jenkins Integration
- AWS β AWS Integration
By Technologyβ
Container Technologies:
- Docker β Docker Deployment
- Kubernetes β Kubernetes Deployment
- Docker Compose β See Docker Deployment recipes
Cloud Platforms:
- AWS β AWS Integration, Static Site Deployment
- Google Cloud β See Kubernetes and Docker recipes
- Azure β Adaptable from AWS patterns
Databases:
- PostgreSQL β Backup and Restore
- MySQL β Backup and Restore
- MongoDB β Backup and Restore
- Redis β Database Setup
π‘ Common Patternsβ
Parallel Executionβ
// Execute on multiple targets simultaneously
await Promise.all(
targets.map(target => $.ssh(target)`command`)
);
Error Handlingβ
// Use Result pattern for safe execution
const result = await $`command`.nothrow();
if (!result.ok) {
console.error(`Failed: ${result.error.message}`);
}
Progress Trackingβ
// Track multi-step operations
for (const [index, step] of steps.entries()) {
console.log(`Step ${index + 1}/${steps.length}: ${step.name}`);
await step.execute();
}
Connection Reuseβ
// Reuse SSH connections for multiple commands
const server = $.ssh('production');
await server`command1`;
await server`command2`;
await server`command3`;
π Contributing Recipesβ
We welcome contributions! To add a new recipe:
- Follow the structure - Use existing recipes as templates
- Test your code - Ensure all examples work
- Document thoroughly - Include all necessary details
- Reference implementations - Link to actual Xec source files
- Submit a PR - Include a description of the use case
π Quick Linksβ
π Recipe Statisticsβ
- Total Recipes: 16 complete recipes
- Categories: 4 main categories
- Technologies Covered: 20+ technologies
- Code Examples: 100+ working examples
- Best Practices: 50+ recommendations
π¦ Recipe Maturityβ
Recipe | Status | Testing | Production Ready |
---|---|---|---|
Node.js Deployment | β Complete | β Tested | β Yes |
Static Site Deployment | β Complete | β Tested | β Yes |
Docker Deployment | β Complete | β Tested | β Yes |
Kubernetes Deployment | β Complete | β Tested | β Yes |
Log Aggregation | β Complete | β Tested | β Yes |
Backup and Restore | β Complete | β Tested | β Yes |
Hot Reload | β Complete | β Tested | β Yes |
GitHub Actions | β Complete | β Tested | β Yes |
π Learning Pathβ
Beginnerβ
- Start with Hot Reload for local development
- Learn Static Site Deployment
- Explore GitHub Actions integration
Intermediateβ
- Master Node.js Deployment
- Implement Log Aggregation
- Setup Backup and Restore
Advancedβ
- Deploy with Docker
- Orchestrate with Kubernetes
- Build complete CI/CD pipelines
π Getting Helpβ
- Documentation: Check the detailed documentation for each recipe
- Examples: Look at the complete examples in each recipe
- Troubleshooting: Each recipe includes a troubleshooting section
- Community: Join our Discord for recipe discussions
- Support: Open an issue for recipe-specific problems
This cookbook is continuously updated with new recipes and improvements. All recipes are tested against the current Xec implementation and follow the surgical precision requirement for documentation accuracy.