Contents

OpenCode AI Skills

OpenCode AI Skills

opencode-ai-skills is a collection of custom skill modules for OpenCode, the AI-powered terminal coding assistant. Skills extend OpenCode’s behavior with custom automation workflows and domain-specific capabilities.

What are OpenCode Skills?

OpenCode skills are Python modules (or scripts) that the AI agent can invoke as tools. They allow you to package domain knowledge, automate repetitive workflows, and integrate with external systems — all callable by the agent through natural language.

Project Structure

opencode-ai-skills/
├── skills/
│   ├── network/
│   │   ├── containerlab_deploy.py
│   │   └── topology_validate.py
│   ├── infra/
│   │   ├── k8s_apply.py
│   │   └── ansible_run.py
│   └── utils/
│       └── git_summary.py
├── config.yaml
└── README.md

Example Skill: ContainerLab Deploy

"""
Skill: Deploy a containerlab topology and return node access info.
"""
import subprocess
import json
import sys

def run(topology_file: str, sudo: bool = True) -> dict:
    cmd = ["sudo"] if sudo else []
    cmd += ["containerlab", "deploy", "-t", topology_file, "--format", "json"]

    result = subprocess.run(cmd, capture_output=True, text=True)
    if result.returncode != 0:
        return {"error": result.stderr}

    data = json.loads(result.stdout)
    nodes = {
        node["name"]: {
            "mgmt_ip": node.get("mgmt_ipv4_address"),
            "kind":    node.get("kind"),
        }
        for node in data.get("nodes", [])
    }
    return {"status": "deployed", "nodes": nodes}

if __name__ == "__main__":
    topology = sys.argv[1] if len(sys.argv) > 1 else "topology.clab.yaml"
    print(json.dumps(run(topology), indent=2))

Example Skill: Kubernetes Status

"""
Skill: Get pod status across all namespaces, filtered by label.
"""
import subprocess
import json

def run(label_selector: str = "", namespace: str = "--all-namespaces") -> dict:
    cmd = ["kubectl", "get", "pods"]
    if namespace == "--all-namespaces":
        cmd.append("--all-namespaces")
    else:
        cmd += ["-n", namespace]

    if label_selector:
        cmd += ["-l", label_selector]

    cmd += ["-o", "json"]
    result = subprocess.run(cmd, capture_output=True, text=True)
    if result.returncode != 0:
        return {"error": result.stderr}

    pods = json.loads(result.stdout)["items"]
    summary = []
    for pod in pods:
        meta   = pod["metadata"]
        status = pod["status"]
        summary.append({
            "name":      meta["name"],
            "namespace": meta.get("namespace", ""),
            "phase":     status.get("phase"),
            "ready":     all(
                c["ready"] for c in status.get("containerStatuses", [])
            ),
        })
    return {"pods": summary, "count": len(summary)}

Skill Configuration

# config.yaml
skills:
  - name: containerlab_deploy
    path: skills/network/containerlab_deploy.py
    description: "Deploy a containerlab topology file"
    parameters:
      topology_file:
        type: string
        description: "Path to .clab.yaml topology file"

  - name: k8s_status
    path: skills/infra/k8s_apply.py
    description: "Get Kubernetes pod status"
    parameters:
      label_selector:
        type: string
        description: "kubectl label selector (optional)"
      namespace:
        type: string
        description: "Namespace or --all-namespaces"

Use Cases

These skills were built for a networking/DevOps workflow — deploying lab topologies, checking cluster state, and running Ansible plays through natural language prompts to OpenCode.

Source: GitHub