Cloud provider detector

From FortiumPartners/ai-mesh · View interactive version

Cloud provider detector is an AI agent skill from the GitHub repository FortiumPartners/ai-mesh. **Auto-detect AWS, GCP, or Azure usage with 95%+ accuracy using multi-signal analysis.**

How to use this skill

Skill file

Cloud Provider Detection Skill

Auto-detect AWS, GCP, or Azure usage with 95%+ accuracy using multi-signal analysis.

Quick Start

const { detectCloudProvider } = require('./detect-cloud-provider.js');

// Auto-detect cloud provider
const result = await detectCloudProvider('/path/to/project');

if (result.detected) {
  console.log(`Detected: ${result.name}`);
  console.log(`Confidence: ${(result.confidence * 100).toFixed(1)}%`);
  console.log(`Signals: ${result.signal_count}`);
}

// Manual override
const awsResult = await detectCloudProvider('/path/to/project', {
  provider: 'aws'
});

Detection Signals

Signal Types (Weighted)

  1. Terraform (weight: 0.5) - Highest priority
  1. Package Manifests (weight: 0.3)
  1. Config Files (weight: 0.3)
  1. CLI Scripts (weight: 0.2)
  1. Docker (weight: 0.2)

Confidence Scoring

Base Score = Σ(detected_signals × signal_weight) / Σ(all_signal_weights)

Multi-Signal Boost:
  if (signal_count >= 3) {
    confidence += 0.2  // Up to maximum of 1.0
  }

Detection Threshold: ≥0.7 (70%)

CLI Usage

# Detect in current directory
node detect-cloud-provider.js

# Detect in specific project
node detect-cloud-provider.js /path/to/project

# Manual override
node detect-cloud-provider.js /path/to/project --provider aws

# Custom confidence threshold
node detect-cloud-provider.js /path/to/project --min-confidence 0.8

# Exit codes:
#   0 = Provider detected
#   1 = No provider detected
#   2 = Error occurred

Response Format

{
  "detected": true,
  "provider": "aws",
  "name": "Amazon Web Services (AWS)",
  "confidence": 0.95,
  "signals": {
    "terraform": true,
    "npm": true,
    "python": false,
    "cli": true,
    "docker": true,
    "config": true
  },
  "signal_count": 5,
  "all_results": [
    {
      "provider": "aws",
      "name": "Amazon Web Services (AWS)",
      "confidence": 0.95,
      "signals": {...},
      "signal_count": 5
    },
    {
      "provider": "gcp",
      "name": "Google Cloud Platform (GCP)",
      "confidence": 0.12,
      "signals": {...},
      "signal_count": 1
    }
  ]
}

Integration Examples

infrastructure-specialist Agent

# In agent YAML behavior section:

**Cloud Provider Detection**:
- **Auto-detect**: Run `node skills/cloud-provider-detector/detect-cloud-provider.js`
  at task start to identify AWS/GCP/Azure usage
- **Load Skills**: If AWS detected (≥70% confidence), load AWS cloud skill
- **Multi-cloud**: If multiple providers detected, load all relevant skills
- **Manual Override**: Accept `--cloud-provider` flag to bypass detection

Example Workflow

// 1. Detect cloud provider
const detection = await detectCloudProvider(projectPath);

// 2. Load appropriate skill
if (detection.detected) {
  if (detection.provider === 'aws') {
    await loadSkill('skills/aws-cloud/SKILL.md');
  } else if (detection.provider === 'gcp') {
    await loadSkill('skills/gcp-cloud/SKILL.md');
  } else if (detection.provider === 'azure') {
    await loadSkill('skills/azure-cloud/SKILL.md');
  }
}

// 3. Execute infrastructure tasks with cloud-specific knowledge

Detection Patterns

AWS Indicators

GCP Indicators

Azure Indicators

Performance

Error Handling

try {
  const result = await detectCloudProvider(projectPath);
} catch (error) {
  if (error.code === 'ENOENT') {
    console.error('Project directory not found');
  } else if (error.message.includes('patterns.json')) {
    console.error('Detection patterns file missing or invalid');
  } else {
    console.error('Detection failed:', error.message);
  }
}

Common Issues

Low Confidence Scores (<0.7):

False Positives:

No Detection:

Customization

Adding New Providers

Edit cloud-provider-patterns.json:

{
  "providers": {
    "digitalocean": {
      "name": "DigitalOcean",
      "confidence_boost": 0.3,
      "detection_signals": {
        "terraform": {
          "weight": 0.5,
          "patterns": ["provider \"digitalocean\"", "digitalocean_droplet"]
        }
      }
    }
  }
}

Adjusting Detection Rules

{
  "detection_rules": {
    "minimum_confidence": 0.6,        // Lower = more permissive
    "multi_signal_boost": 0.3,        // Higher = favor multi-signal
    "minimum_signals_for_boost": 2    // Lower = boost earlier
  }
}

Best Practices

  1. Run Early: Detect cloud provider at task start for optimal skill loading
  2. Check Confidence: Log confidence scores to monitor detection accuracy
  3. Manual Override: Provide --provider flag for edge cases
  4. Multi-Cloud: Handle projects using multiple cloud providers gracefully
  5. Cache Results: Cache detection results per session to avoid re-scanning

Dependencies

Install with:

npm install glob

File Size

Version

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.