# OpenCode

> Cordium documentation. Canonical page: <https://octelium.com/docs/cordium/latest/examples/opencode>.

[OpenCode](https://opencode.ai) is an open source AI coding agent designed for terminal-native development workflows. It can plan, modify repositories, execute commands, run tests, interact with infrastructure, and automate development tasks directly from within a Workspace. Unlike local development environments or traditional CI runners, Cordium Workspaces allow OpenCode agents to operate inside isolated execution environments with controlled access to infrastructure resources, internal services, databases, Kubernetes clusters, APIs, and deployment systems. All Workspace activity and infrastructure access are emitted via OpenTelemetry-native identity-based application-layer-aware visibility in real-time. Here is an example:

```yaml
spec:
  image:
    dockerfile:
      inline: |
        FROM ubuntu:24.04

        ENV DEBIAN_FRONTEND=noninteractive

        RUN apt-get update && apt-get install -y \
            curl \
            wget \
            git \
            build-essential \
            ca-certificates \
            unzip \
            jq \
            python3 \
            vim \
            npm \
            && rm -rf /var/lib/apt/lists/*

        RUN npm install -g opencode-ai

  repository:
    url: https://github.com/example-org/platform-api

  
  
  vars:
  - name: PROMPT
    value: |
      Connect to the Kubernetes cluster exposed through the `staging.k8s` Octelium Service.
      Inspect all deployments in the `production` namespace, identify unhealthy workloads,
      CrashLoopBackOff containers missing readiness probes, excessive restart counts,
      and resource limit inconsistencies. Generate a remediation report and propose
      corrected Kubernetes manifests.

  runtime:
    envVars:
      - key: OPENCODE_APPROVAL_MODE
        value: auto

    tasks:
      - name: install-dependencies
        type: ON_CREATE
        workingDir: /workspace/repo
        run: |
          npm install

      - name: start-opencode
        type: ON_START
        workingDir: /workspace/repo
        run: |
          opencode --prompt "${{ vars.PROMPT }}"
    autoStop: true
  limits:
    cpu:
      millicores: 4000

    memory:
      megabytes: 8192

    storage:
      megabytes: 30000
```
