ipcalc-for-cloud
Calculates IP ranges, CIDR blocks, and subnet allocations for cloud networks (Azure, AWS, GCP, Oracle, AliCloud). Supports single VNet/VPC or hub-spoke topologies with automatic AZ distribution. Outpu
Files29
View on GitHubSKILL.mdskills/ipcalc-for-cloud/SKILL.md
GitHub<objective>
Calculate IP ranges, CIDR blocks, and subnet allocations for cloud network planning. This skill:
- Performs CIDR subnet calculations and splitting for cloud providers
- Creates single VNet/VPC with multiple subnets OR hub-spoke topologies
- Validates IP ranges and detects overlaps
- Automatically assigns optimal CIDR blocks or uses custom subnet prefixes
- Distributes subnets across availability zones (AWS, GCP, AliCloud)
- Calculates provider-specific reserved IPs and usable ranges
- Outputs results as formatted tables, JSON, or IaC templates
Supported Cloud Providers: Azure, AWS, GCP, Oracle Cloud, AliCloud, On-Premises
Uses Python for deterministic IP calculations matching the TypeScript CLI implementation. </objective>
<quick_start> Users ask for IP calculations and subnet planning in natural language. Examples of how users will phrase requests:Show network information:
"Calculate 4 subnets for Azure, base CIDR 10.0.0.0/16"
Generate Terraform for AWS:
"Give me Terraform for an AWS VPC at 10.0.0.0/16 with 3 subnets"
Custom subnet prefix (to avoid filling entire network):
"Plan 4 subnets for Azure 172.16.1.0/24 using /26 prefix"
Hub-spoke topology for Azure:
<workflow> ## Step 1: Parse Input Specifications"Create an Azure hub-spoke with hub 10.0.0.0/16 (2 subnets), spokes at 10.1.0.0/16 and 10.2.0.0/16 (2 subnets each), output Terraform" </quick_start>
Accept user input specifying:
- Cloud provider: azure, aws, gcp, oracle, alicloud, onpremises
- Base CIDR: Network CIDR block (e.g., "10.0.0.0/16")
- Number of subnets: How many subnets to create (1-256)
- Output format: depends on provider (see mapping below);
infoandjsonwork for all providers- Azure:
terraform,bicep,arm,powershell,cli - AWS:
terraform,cloudformation,cli - GCP:
terraform,gcloud - Oracle:
terraform,oci - AliCloud:
terraform,aliyun - On-Premises: (info and json only)
- Azure:
- Optional - Custom subnet prefix (
--subnet-prefix): Desired subnet prefix (e.g., /26) to override auto-calculation - Optional - Resource name prefix (
--prefix): Prefix for resource names in generated IaC (default:ipcalc) - Optional - Hub-spoke: Spoke network CIDRs and subnet counts for hub-spoke topology
Hub-spoke is only supported for Azure and GCP. If the user requests hub-spoke for AWS, Oracle, AliCloud, or On-Premises, explain the limitation and suggest using a single VNet/VPC instead.
If the user requests a format not supported by their chosen provider, inform them and suggest the closest available alternative (e.g., use terraform or info instead).
Step 2: Run IP Calculations
Path assumption: The script path
~/.claude/skills/ipcalc-for-cloud/scripts/ipcalc.pyassumes this skill is installed or symlinked at~/.claude/skills/ipcalc-for-cloud/. If the script is not found, inform the user and ask them to confirm the installation path.
Execute the IP calculation script with cloud provider configuration:
python ~/.claude/skills/ipcalc-for-cloud/scripts/ipcalc.py \
--provider azure \
--cidr "10.0.0.0/16" \
--subnets 4 \
--output terraform
With custom subnet prefix:
python ~/.claude/skills/ipcalc-for-cloud/scripts/ipcalc.py \
--provider azure \
--cidr "172.16.1.0/24" \
--subnets 4 \
--subnet-prefix 26 \
--output info
With hub-spoke topology:
python ~/.claude/skills/ipcalc-for-cloud/scripts/ipcalc.py \
--provider azure \
--cidr "10.0.0.0/16" \
--subnets 2 \
--spoke-cidrs "10.1.0.0/16,10.2.0.0/16,10.3.0.0/16" \
--spoke-subnets "2,2,2" \
--output terraform
The script validates CIDR, calculates optimal subnets, distributes across AZs, applies provider-specific reserved IP counts (Azure: 5, AWS: 5, GCP: 4, Oracle: 3, AliCloud: 4), detects overlaps, and renders the requested output format.
Step 3: Output Results
Info format (default): Human-readable table with network details, subnet CIDRs, AZ assignments, reserved and usable IP counts.
JSON format: Structured JSON with complete network and subnet data; machine-readable for integration.
Terraform format: HCL with provider config, variables, network/subnet resources, outputs, hub-spoke peering (if applicable), and IP allocation comments.
Other IaC formats (all fully implemented):
- Bicep (Azure only): Azure Bicep template with inline subnets
- ARM (Azure only): Azure Resource Manager JSON template
- PowerShell (Azure only): Azure PowerShell script with cmdlets
- CloudFormation (AWS only): AWS YAML template with intrinsic functions
- CLI (Azure, AWS): Bash scripts with az/aws commands
- gcloud (GCP only): gcloud CLI commands
- OCI (Oracle only): OCI CLI commands
- Aliyun (AliCloud only): Aliyun CLI commands
Step 4: Validate Output
- IP range validation: no overlaps, proper nesting, valid CIDR notation
- Provider constraint validation (prefix limits)
- Capacity validation: requested subnets fit in network
- For Terraform: syntax validation if terraform CLI available (
terraform init && terraform validate) - For hub-spoke: peering configuration correctness</workflow>
IaC output checklist:
- Provider configuration present with correct version
- Variables defined for customization (region, prefix, CIDRs)
- Output variables defined for resource IDs
- Hub-spoke peering complete and bidirectional (if applicable)
- IP allocation table in comments</validation>
For script and template internals, read references/internals.md.
</success_criteria>