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.cause}`);
}

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.