Plugin Development
Build Your First Plugin
Section titled “Build Your First Plugin”Ready to extend Stavily? This guide walks you through creating plugins using real examples. We’ll use our Machine Data Extractor plugin as a practical case study.
What You’ll Need
Section titled “What You’ll Need”- Python 3.8+ (or your preferred language)
- Git for version control
- Basic programming knowledge
Real Example: Machine Data Extractor
Section titled “Real Example: Machine Data Extractor”Let’s build a practical plugin that extracts system information. This is a real action plugin that demonstrates the complete development process.
- Create the plugin logic - A Python script that reads from stdin and writes to stdout
- Add configuration - Define what data to extract via plugin.yaml
- Test locally - Verify it works before deploying
- Package for distribution - Make it ready for the marketplace
Step 1: Plugin Code
Section titled “Step 1: Plugin Code”Your plugin reads JSON config from stdin and writes JSON results to stdout:
#!/usr/bin/env python3import jsonimport sysimport platformimport psutil # For system monitoring
def main(): # Read configuration from stdin config = json.load(sys.stdin)
# Extract requested data result = {"status": "success", "data": {}}
if config.get("extract_cpu"): result["data"]["cpu"] = { "count": psutil.cpu_count(), "percent": psutil.cpu_percent(interval=1) }
if config.get("extract_memory"): mem = psutil.virtual_memory() result["data"]["memory"] = { "total": mem.total, "available": mem.available, "percent": mem.percent }
# Write result to stdout print(json.dumps(result))
if __name__ == "__main__": main()Step 2: Plugin Manifest
Section titled “Step 2: Plugin Manifest”The plugin.yaml file tells Stavily how to run your plugin:
id: "machine-data-extractor"name: "Machine Data Extractor"description: "Extracts CPU, memory, and system information"version: "1.0.0"author: "Stavily Team"type: "action"
runtime: type: "python" version: "3.8+" entry_point: "main.py"
configuration: extract_cpu: type: "boolean" description: "Extract CPU information" default: false extract_memory: type: "boolean" description: "Extract memory information" default: false
permissions: [] # No special permissions neededStep 3: Test Your Plugin
Section titled “Step 3: Test Your Plugin”Test locally by piping JSON config to your script:
echo '{"extract_cpu": true, "extract_memory": true}' | python3 main.pyExpected output:
{ "status": "success", "data": { "cpu": {"count": 8, "percent": 15.2}, "memory": {"total": 17179869184, "available": 8589934592, "percent": 50.0} }}Plugin Types & When to Use Them
Section titled “Plugin Types & When to Use Them”Action Plugins (Most Common)
Section titled “Action Plugins (Most Common)”Best for: Tasks that run once and complete Examples: Send notifications, run commands, process data Execution: Short-lived, receives config + trigger data
Trigger Plugins
Section titled “Trigger Plugins”Best for: Continuous monitoring and event detection Examples: Watch files, monitor APIs, schedule tasks Execution: Long-running in orchestrator, emit events
Output Plugins
Section titled “Output Plugins”Best for: Delivering results to external systems Examples: Send to Slack, log to database, update dashboards Execution: Process action results and deliver
Best Practices
Section titled “Best Practices”Security First:
- Validate all inputs to prevent injection attacks
- Request minimal permissions (principle of least privilege)
- Never hardcode secrets - use Stavily’s secret management
Performance:
- Keep plugins lightweight and efficient
- Implement timeouts for external calls
- Handle errors gracefully without crashing
User Experience:
- Clear, descriptive configuration options
- Comprehensive error messages
- Good documentation and examples
Publishing to Marketplace
Section titled “Publishing to Marketplace”Ready to share your plugin? Here’s how to get it listed:
Step 1: Create Git Repository
Section titled “Step 1: Create Git Repository”git init my-awesome-plugincd my-awesome-plugin# Add your plugin filesgit add .git commit -m "Initial plugin release"git remote add origin https://github.com/yourusername/my-awesome-plugin.gitgit push -u origin mainStep 2: Submit to Marketplace
Section titled “Step 2: Submit to Marketplace”- Go to the Stavily marketplace
- Click “Submit Plugin”
- Provide your Git repository URL
- Our team reviews and certifies your plugin
Need Help?
Section titled “Need Help?”- Browse existing plugins for inspiration and code examples
- Join our developer community for support and collaboration
- Check the marketplace for monetization opportunities
Start building - the automation ecosystem needs your creativity!
Step 4: Earn Money
Section titled “Step 4: Earn Money”Ready to monetize? Get paid when users subscribe to your plugins:
- 70% revenue share on premium plugins
- Monthly payouts starting at $100 minimum
- Transparent fees (only standard payment processing)
Step 2: Submit to Marketplace
Section titled “Step 2: Submit to Marketplace”- Push your plugin to a Git repository
- Submit the repo URL to our marketplace
- Our team reviews and certifies your plugin
- Start earning when users install it!
Need More Examples?
Section titled “Need More Examples?”Check out the marketplace for real plugins you can study and modify. The community has built everything from simple notification tools to complex enterprise integrations.
Start small, think big - your first plugin could become the next big automation tool!
This guide gets you building immediately. For advanced topics like multi-language support or complex integrations, explore the architecture guide.