Skip to main content

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

πŸ”§ Maintenance​

System maintenance and operational excellence

πŸ’» Development​

Development workflows and environment setup

πŸ”Œ Integration​

Third-party service and tool integrations

🎯 How to Use This Cookbook​

Recipe Structure​

Each recipe follows a consistent structure:

  1. Problem - The challenge being addressed
  2. Solution - How Xec solves it
  3. Quick Example - Minimal working example
  4. Complete Recipe - Full implementation with all details
  5. Usage Examples - Common usage patterns
  6. Best Practices - Recommended approaches
  7. Troubleshooting - Common issues and solutions
  8. 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​

  1. Choose a recipe that matches your use case
  2. Copy the configuration to your .xec/config.yaml
  3. Adapt the scripts to your specific needs
  4. Run the commands as shown in the usage examples

πŸ” Finding the Right Recipe​

By Use Case​

Deploying Applications:

Managing Infrastructure:

Development Workflows:

CI/CD Automation:

By Technology​

Container Technologies:

Cloud Platforms:

Databases:

πŸ’‘ 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:

  1. Follow the structure - Use existing recipes as templates
  2. Test your code - Ensure all examples work
  3. Document thoroughly - Include all necessary details
  4. Reference implementations - Link to actual Xec source files
  5. Submit a PR - Include a description of the use case

πŸ“Š 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​

RecipeStatusTestingProduction 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​

  1. Start with Hot Reload for local development
  2. Learn Static Site Deployment
  3. Explore GitHub Actions integration

Intermediate​

  1. Master Node.js Deployment
  2. Implement Log Aggregation
  3. Setup Backup and Restore

Advanced​

  1. Deploy with Docker
  2. Orchestrate with Kubernetes
  3. 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.