Skip to content

Latest commit

 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Claude Code Rundeck Job Generator

Generate production-ready Rundeck job definitions from natural language using Claude Code.

What This Does

Transform plain English into valid Rundeck YAML in minutes:

You: "Generate a job that monitors API health and alerts PagerDuty on failure"

Claude Code: ✅ Generates complete YAML with:

  • Proper plugin configurations
  • Error handlers
  • Log filters for data capture
  • Security best practices (Key Storage, input sanitization)
  • Rich operator documentation
  • ROI metrics

Optional: Upload → Execute → Validate automatically via testing subagent.


Features

  • Natural language → valid Rundeck YAML - No YAML knowledge required
  • Plugin-first approach - Kubernetes, SQL Runner, HTTP, Ansible, and 20+ more
  • Built-in security hardening - Key Storage integration, input sanitization, SSL validation
  • Automatic multi-step design - Pre-check → Action → Verify → Cleanup
  • Correct variable syntax - @option.x@ in scripts, ${option.x} elsewhere (most common error prevented)
  • Rich option descriptions - Operator-focused documentation for every parameter
  • Error handlers and log filters - Automatic failure handling and data capture
  • ROI metrics calculation - Estimates time saved per execution
  • Optional autonomous testing - Upload → Run → Validate with zero manual steps

Time Savings: 30-45 minutes manual → 2-5 minutes with AI (87% faster)


Quick Start

1. Prerequisites

  • Claude Code installed (CLI, Desktop, or VS Code extension)
  • Rundeck instance (self-hosted or SaaS/Process Automation)
  • RD CLI for testing (optional but recommended)

2. Setup (5 minutes)

# Clone this repo into your project directory
git clone https://github.com/YOUR-USERNAME/claude-code-rundeck-job-generator.git
cd claude-code-rundeck-job-generator

# Copy configuration template
cp config.example.sh config.sh

# Edit config.sh with your Rundeck details
nano config.sh  # or your preferred editor

# Source configuration (or add to your shell profile)
source config.sh

# Verify Claude Code sees the skills
claude /help
# Should list: rundeck-job-generator, rd-cli-upload, rd-cli-execute, rd-cli-validate

3. Generate Your First Job

# Start Claude Code
claude

# Use natural language to generate a job
> Generate a job that checks disk usage on /data and alerts if over 80%

# Claude will:
# 1. Parse your request
# 2. Apply safety rules (pre-check → action → verify)
# 3. Generate valid YAML with proper plugin configs
# 4. Save to artifacts/genai-jobs/<job-name>.yaml

# View the generated YAML
> Show me the generated file

# Optional: Test the job automatically (requires RD CLI + test cluster)
> Test this job on my cluster

# Claude will use the rundeck-job-tester agent to:
# 1. Upload job to your test project
# 2. Execute the job
# 3. Validate output matches expectations
# 4. Report results with execution URL

That's it! You now have a production-ready Rundeck job.


Architecture

Three components work together to generate high-quality Rundeck jobs:

┌──────────────────────┐      ┌──────────────────────┐      ┌─────────────────────┐
│   1. SKILL           │ ──>  │  2. CONTEXT FILES    │ ──>  │  3. SUBAGENT        │
│                      │      │                      │      │   (Optional)        │
│  Job Generator       │      │  • patterns.md       │      │                     │
│                      │      │  • plugin-library.md │      │  Autonomous Tester  │
│  Natural language    │      │  • formatting.md     │      │                     │
│  → Valid YAML        │      │                      │      │  Upload → Run       │
│                      │      │  Reference library   │      │  → Validate         │
└──────────────────────┘      └──────────────────────┘      └─────────────────────┘

1. Skill (SKILL.md)

AI instructions for generating Rundeck jobs. Defines:

  • Parsing logic (intent, steps, constraints)
  • Safety rules (when to add pre-checks/verification)
  • Variable syntax handling (the most critical rule)
  • Security hardening requirements
  • Output validation checklist

2. Context Files (references/)

Reference library the skill reads during generation:

  • patterns.md - Common integrations (PagerDuty, Python, conditionals, loops)
  • plugin-library.md - 25+ plugin configurations with exact field names
  • formatting.md - YAML formatting rules and best practices

3. Subagent (Optional, agents/)

Autonomous testing workflow that:

  1. Calls job-generator skill
  2. Uploads job to test cluster via RD CLI
  3. Executes the job
  4. Validates output against expectations
  5. Reports results with execution URL

See docs/architecture.md for detailed explanation.


Examples

Example 1: Monitor API Endpoint

Prompt:

Generate a job that monitors API endpoint health and captures response time

Generated Output:

  • 4-step job: validate URL → call endpoint → capture metrics → report results
  • HTTP Request plugin with proper error handling
  • Log filter captures response time and status code
  • Error handler reports failure context
  • ROI: 0.5 hours saved per execution

View generated YAML →


Example 2: Install Package with Pre-checks

Prompt:

Create a job to install Claude Code on Linux with pre-checks and validation

Generated Output:

  • 5-step job: check OS → verify prerequisites → install package → validate installation → report
  • Script steps with set -euo pipefail for safety
  • Pre-check prevents execution on unsupported OS
  • Post-validation confirms successful installation
  • Error handlers at each risky step

View generated YAML →


Example 3: PagerDuty Alert Integration

Prompt:

Generate a job that triggers PagerDuty alert on service failure and resolves on success

Generated Output:

  • Service check with PagerDuty Event Notification plugin
  • Trigger alert on failure, resolve on success
  • Integration key from Rundeck Key Storage (secure)
  • Proper payload_severity and dedupe_key configuration
  • Rich context in alert payload

View generated YAML →


Example 4: Conditional Remediation

Prompt:

Create a job that checks disk usage and only cleans up temp files if usage exceeds 80%

Generated Output:

  • Conditional step based on captured disk usage percentage
  • Only executes cleanup when threshold exceeded
  • Log filter captures usage percentage as data
  • Conditional plugin evaluates ${data.usage} > 80
  • Post-cleanup verification confirms space reclaimed

View generated YAML →


More Examples

See docs/examples.md for 15+ more examples with prompts and explanations.

Sample prompt categories:

  • Monitoring (API health, disk space, SSL certificates)
  • Remediation (restart services, clean temp files, kill processes)
  • Deployment (Docker containers, config updates, database migrations)
  • Integration (PagerDuty, Slack, SQL databases, Kubernetes)
  • Conditional logic (if/then, loops, error recovery)

Customization

Add Your Organization's Patterns

Edit .claude/skills/rundeck-job-generator/references/patterns.md:

## Internal Monitoring API

Pattern for calling your monitoring system:

\`\`\`yaml
- description: Call internal monitoring API
  configuration:
    url: https://monitoring.internal.yourcompany.com/api/v1/metrics
    method: POST
    headers: |
      Authorization: Bearer ${option.api-token}
      Content-Type: application/json
    authentication: None
    sslVerify: 'true'
  nodeStep: true
  type: httpRequest
\`\`\`

Enforce Company Policies

Edit .claude/skills/rundeck-job-generator/SKILL.md:

### Security Hardening

- **NEVER hardcode credentials** - Use Rundeck Key Storage
- **Company requirement**: All production jobs must include approval gate
- **Naming convention**: Jobs must follow `<team>-<action>-<target>` format
- **Required tags**: All jobs must include tags: `team:<team-name>`, `env:<environment>`

Remove Unsupported Plugins

Edit .claude/skills/rundeck-job-generator/references/plugin-library.md:

# Remove or comment out plugins not available in your Rundeck instance
# Example: If you don't have the SQL Runner plugin installed, remove that section

Testing

Manual Testing (Basic)

  1. Generate job YAML using natural language prompt
  2. Review the generated YAML
  3. Upload to Rundeck via UI or rd jobs load command
  4. Execute and verify behavior

Autonomous Testing (Recommended)

Setup:

  1. Create dedicated test project in Rundeck (e.g., ai-automated-tests)
  2. Install and configure RD CLI
  3. Set environment variables in config.sh:
    export RD_URL="https://your-rundeck-instance.com"
    export RD_TOKEN="your-api-token"
    export RD_PROJECT="ai-automated-tests"
    export RD_TEST_NODE="your-runner-node"

Usage:

# After generating a job
> Test this job on my cluster

# Claude will:
# 1. Upload job using rd-cli-upload skill
# 2. Execute job using rd-cli-execute skill
# 3. Validate output using rd-cli-validate skill
# 4. Report: ✅ Job works OR ❌ Issues found with details

Benefits:

  • ✅ Catches issues before production
  • ✅ Validates generated YAML is syntactically correct
  • ✅ Confirms job executes without errors
  • ✅ Verifies output matches expectations
  • ✅ Learning loop: failures improve future generations

See docs/architecture.md#testing-workflow for detailed setup.


Troubleshooting

Issue: Variable syntax errors in generated YAML

Symptom: Job fails with "variable not found" or variables show literal text like @option.name@

Fix: The skill has strict rules about variable syntax:

  • Inside script blocks: Use @option.name@, @data.key@
  • Everywhere else: Use ${option.name}, ${data.key}

This is covered in .claude/skills/rundeck-job-generator/SKILL.md section 6.


Issue: Plugin not found on upload

Symptom: rd jobs load fails with "Plugin 'xyz' not found"

Fix:

  1. Verify the plugin is installed: Rundeck UI → System → Plugins
  2. If not available, install the plugin or update plugin-library.md to remove it
  3. Tell Claude: "Don't use the XYZ plugin, use a script step instead"

Issue: Upload fails with "mapping values are not allowed"

Symptom: YAML syntax error on rd jobs load

Fix: This is usually caused by error handlers using exec: instead of script: |-

Check for lines like:

errorhandler:
  exec: echo "error"  # ❌ WRONG

Should be:

errorhandler:
  script: |-           # ✅ CORRECT
    echo "error"

The skill should generate correct syntax, but if you manually edited the YAML, this is a common mistake.


Issue: Job generated but doesn't match my needs

Fix: Provide more specific prompts:

❌ Too vague:

Generate a monitoring job

✅ Specific:

Generate a job that monitors the /health endpoint of my API at https://api.example.com 
every 5 minutes. Capture the response time and alert to PagerDuty if response time 
exceeds 2 seconds or the endpoint returns non-200 status.

More Troubleshooting

See docs/troubleshooting.md for:

  • RD CLI authentication issues
  • Node filter mismatches
  • Execution timeout problems
  • Data capture not working
  • Notification failures

Success Metrics

Based on testing with 1000+ generated jobs:

Metric Before AI After AI Improvement
Time to create job 30-45 min 2-5 min 87% faster
First-try success rate ~60% ~95% +35 points
Jobs per engineer/day 3-5 20-30 5-7x more
Documentation quality Inconsistent Rich descriptions always 100% coverage
Security compliance Manual review needed Built-in best practices Zero hardcoded secrets

License

MIT License - see LICENSE file for details.

Feel free to use this in your organization, modify it, and share improvements back to the community.


FAQ

Q: Do I need to know YAML to use this? A: No! That's the whole point. You describe what you want in plain English, and Claude generates valid YAML.

Q: Will this work with my Rundeck plugins? A: Yes, but you may need to add your plugin configurations to plugin-library.md. The starter kit includes 25+ common plugins.

Q: Can I use this for Rundeck Enterprise or just Community? A: Both! Works with Rundeck Community, Enterprise, and PagerDuty Runbook Automation (SaaS). However, note that certain plugins from plugin-library.md might only be available in the Enterprise Version.

Q: What if my organization has specific security requirements? A: Customize the skill! Edit SKILL.md to enforce your policies (approval gates, naming conventions, required tags, etc.)

Q: How accurate is the generated YAML? A: With good prompts, ~95% first-try success rate. The skill includes validation rules to catch common errors.

Q: Can I generate jobs for Windows? A: Yes! The skill supports PowerShell scripts with proper .ps1 file extension configuration.

Q: Does this replace learning Rundeck? A: No, it accelerates job creation for those who know Rundeck, and helps newcomers learn faster by seeing well-structured examples.

Q: How do I get support? A: Open an issue on GitHub, ask in PagerDuty Community, or check the troubleshooting guide.


What's Next?

  1. Star this repo if you find it useful
  2. 🔧 Customize the skill with your organization's patterns
  3. 🚀 Generate your first 10 jobs and see the time savings
  4. 📊 Track your metrics (time saved, jobs created, quality improvements)
  5. 🤝 Share your learnings back to the community
  6. 💬 Join the discussion in GitHub Issues or Rundeck Slack

Happy automating! 🎉

About

Generate production-ready Rundeck jobs from natural language using Claude Code

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages