# Piglet Runtime: AI Runtime Sandbox

> Pigsty Lightweight Runtime, AI Coding sandbox, spin up your cloud coding environment with one click

---

LLMS index: [llms.txt](/llms.txt)

---

— **Pigsty Lightweight Runtime, AI Coding Sandbox**

PIGLET is a lightweight runtime environment based on Pigsty. It provides a cloud sandbox for **AI Web Coding**.

PIGLET combines PostgreSQL, JuiceFS distributed storage, Code Server, JupyterLab, Claude Code, Codex CLI, and other tools. These tools support a continuous workflow from **code prompts** to **production deployment**.

--------

## Key Features

|         Feature          | Description                                                                                                                                                            |
|:------------------------:|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|       🤖 AI Coding       | Pre-installed **Claude Code**, **Codex CLI**, OpenCode, VS Code, Jupyter full stack, Python/Go/Node.js dev env ready                                                   |
|     🐘 Data Capable      | PostgreSQL 18 + [**600**](/ext/list) extensions, vector/timeseries/geo/graph/analytics, add Supabase for complex apps                                                  |
|    💾 Shared Storage     | [**JuiceFS**](/docs/juice/) stores working directory in database, multi-agent/multi-user collaboration, files never lost, rollback to any point                        |
|     ⏱️ Time Machine      | Database **PITR** + filesystem snapshot sync, messed up? One-click restore to any point in time, keep db and filesystem consistent!                                    |
|     🔀 Instant Clone     | **CoW** sub-second [**Fork Large Database**](/docs/pgsql/admin/db#clone-database), fork existing instances/clusters, no extra storage, rebuild anytime, tinker freely! |
|   🌐 One-Click Deploy    | Built-in **Nginx** handles domains, certs, proxy, static/dynamic sites, from prompt to production in one step!                                                         |
| 📊 Full-Stack Monitoring | **VictoriaMetrics** + **Grafana** panoramic dashboards, Claude Code observability included, all details at your fingertips!                                            |
|  🇨🇳 China Accessible   | Global CDN + mirrors, one config for CC + **GLM-5.2** domestic models, legal and compliant!                                                                            |
{.full-width}

--------

## Quick Start

[**Prepare**](/docs/deploy/prepare) a [**node**](/docs/deploy/prepare#node) with [**SSH access**](/docs/deploy/admin#ssh) and a [**compatible Linux distribution**](/docs/ref/linux/). Run these commands as an [**admin user**](/docs/deploy/admin) with passwordless [**`ssh`**](/docs/deploy/admin#ssh) and [**`sudo`**](/docs/deploy/admin#sudo):

```bash
curl -fsSL https://repo.pigsty.io/get | bash; cd ~/pigsty
./configure -c vibe -g # Use vibe mode, generate random passwords!
./deploy.yml           # Deploy infrastructure and PostgreSQL
./juice.yml            # Deploy JuiceFS filesystem
./vibe.yml             # Deploy Claude Code, Codex CLI, Code-Server, JupyterLab
```

After installation, access the sandbox homepage via IP: `http://<ip>`. Assuming your IP is `10.10.10.10`:

| Tool              | Description                                                                  |
|:------------------|:-----------------------------------------------------------------------------|
| Homepage          | [`http://10.10.10.10/`](http://10.10.10.10/)                                 |
| Code Server       | [`http://10.10.10.10/code`](http://10.10.10.10/code)                         |
| Jupyter Lab       | [`http://10.10.10.10/jupyter`](http://10.10.10.10/jupyter)                   |
| Grafana Dashboard | [`http://10.10.10.10/ui`](http://10.10.10.10/ui)                             |
| Claude Monitor    | [`http://10.10.10.10/ui/d/claude-code`](http://10.10.10.10/ui/d/claude-code) |
{.full-width}

> For public cloud deployment, first read [**Security Recommendations**](/docs/setup/security). Run `configure -g` and review credentials that it does not cover. [**Enable the firewall**](/docs/node/param#node_firewall_mode).

--------

## VIBE Components

`vibe.yml` splits the browser IDE, notebook, AI CLIs, and Node.js runtime into independently switchable components:

| Component   | Default                 | Description                                                                                                                                | Run Separately             |
|:------------|:------------------------|:-------------------------------------------------------------------------------------------------------------------------------------------|:---------------------------|
| Code Server | `code_enabled: true`    | Browser-based VS Code, mounted at `/code` by default                                                                                       | `./vibe.yml -t code`       |
| JupyterLab  | `jupyter_enabled: true` | Notebook and interactive terminal; the role defaults to disabled, while `conf/vibe.yml` explicitly enables it for the sandbox template     | `./vibe.yml -t jupyter`    |
| Node.js     | `nodejs_enabled: true`  | Runtime required by AI CLIs; installed on demand when Claude/Codex is enabled, and uses `npmmirror` for npm by default when `region=china` | `./vibe.yml -t nodejs`     |
| Claude Code | `claude_enabled: true`  | Installs `@anthropic-ai/claude-code`, renders `~/.claude.json` and `~/.claude/settings.json`, and enables monitoring by default            | `./vibe.yml -t claude`     |
| Codex CLI   | `codex_enabled: true`   | Only runs `npm install -g @openai/codex`; it does not manage Codex config or integrate Codex into VIBE observability                       | `./vibe.yml -t codex`      |
| Extra npm   | `npm_packages: []`      | Installs additional global npm packages only; Claude and Codex are installed by their own tasks                                            | `./vibe.yml -t nodejs_pkg` |
{.full-width}

If you do not need a component, set its `*_enabled: false` in `pigsty.yml`. For one run, pass a switch such as `./vibe.yml -e codex_enabled=false`.

--------

## Start AI Coding

By default, `/fs` is a shared directory stored in PostgreSQL. It is also the default home for VS Code and Jupyter. The `vibe` role renders the `AGENTS.md` environment guide there and creates a `CLAUDE.md -> AGENTS.md` symlink. We recommend this directory for Vibe Coding.

Connect to the server with SSH and run `cd /fs`. Start the corresponding CLI with `claude` or `codex`. The preconfigured `x` alias starts Codex YOLO mode. The `xx` alias starts Claude YOLO mode. Use these modes carefully with real data.
You can also start Claude Code from the Code Server or Jupyter terminal, or through VS Code / Jupyter Claude plugins.

![AI coding environment in VS Code](/img/pigsty/vscode.webp)

Claude logs and monitoring metrics integrate with Grafana dashboards. Use Grafana to monitor Claude runtime status.

VIBE installs the Codex CLI package by default. Codex itself manages login, provider setup, and configuration files.

![Claude Code monitoring dashboard](/img/pigsty/claude-monitor-1.webp)

-------

## Using Other Models

To use other models with Claude Code, edit `pigsty.yml` during installation. For example, GLM-5.2 does not require overseas network access in China. Find the `claude_env` section at the bottom. Add the Anthropic-compatible endpoint variables that you need:

```yaml
claude_env:
  ANTHROPIC_BASE_URL: https://open.bigmodel.cn/api/anthropic
  ANTHROPIC_API_URL: https://open.bigmodel.cn/api/anthropic
  ANTHROPIC_AUTH_TOKEN: your_api_service_token
  ANTHROPIC_DEFAULT_OPUS_MODEL: "glm-5.2[1m]"
  ANTHROPIC_DEFAULT_SONNET_MODEL: "glm-5.2[1m]"
  ANTHROPIC_DEFAULT_HAIKU_MODEL: "glm-4.7"
  CLAUDE_CODE_AUTO_COMPACT_WINDOW: "1000000"
```

Run `./vibe.yml -t claude` again. This affects only Claude Code. VIBE does not manage Codex CLI account and provider configuration.

![Claude Code observability data](/img/pigsty/claude-monitor-2.webp)


## Claude Code Observability

To monitor Claude Code in other environments, send its OTEL events to the PIGLET VictoriaMetrics / VictoriaLogs OTEL endpoints. Set these environment variables:

```bash
# Claude Code OTEL Configuration
export CLAUDE_CODE_ENABLE_TELEMETRY=1             # Enable monitoring
export OTEL_METRICS_EXPORTER=otlp
export OTEL_LOGS_EXPORTER=otlp
export OTEL_LOG_USER_PROMPTS=1                    # Explicitly enable prompt-content logging when needed
export OTEL_EXPORTER_OTLP_METRICS_PROTOCOL=http/protobuf
export OTEL_EXPORTER_OTLP_LOGS_PROTOCOL=http/protobuf
export OTEL_RESOURCE_ATTRIBUTES="ip=10.10.10.20,job=claude"  # Add your own labels
export OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=http://10.10.10.10:8428/opentelemetry/v1/metrics     # Metrics endpoint, VictoriaMetrics
export OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=http://10.10.10.10:9428/insert/opentelemetry/v1/logs    # Logs endpoint, VictoriaLogs
export OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE=cumulative
```
