ProDG Mainframe — Option D: VS Code Server + Claude Extension
Deep Implementation Plan with Risk Mitigations
Version: 1.0.0
Date: 2026-04-27
Classification: Internal — CEO/CIO Eyes Only
Author: Hermes Agent
Scope: Deploy browser-based VS Code Server (code-server) on the ProDG Mainframe with Claude Code CLI and Claude for VS Code extension, enabling infrastructure-as-code development, dashboard authoring, and Hermes API tool integration via Tailscale-secured access.
Executive Summary
Option D deploys a browser-accessible VS Code Server (code-server) on the ProDG Mainframe, running within Docker alongside the existing stack. The installation will include:
- VS Code Server (
code-server) — Browser-based IDE accessible athttps://code.mainframe.prodg.studio - Claude Code CLI (
claude) — Anthropic's agentic coding tool for infrastructure operations - Claude for VS Code Extension — AI pair-programming inside the browser IDE
- Hermes Tool Integration — Custom VS Code tasks/terminals for interacting with the Hermes API
This transforms the Mainframe from a passive infrastructure host into an active development environment where you (or delegated agents) can build dashboards, modify Docker Compose configurations, author Grafana dashboards-as-code, and orchestrate multi-agent workloads — all from an iPad or any browser.
1. Architecture Overview
1.1 Deployment Topology
┌──────────────────────────────────────────────────────────────────────────┐
│ ProDG Mainframe VPS │
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Caddy ├──────▶│ code-server │──────▶│ /opt/prodg │ │
│ │ :8443 │ │ :8443 │ │ workspace │ │
│ │ (internal) │ │ │ │ │ │
│ └──────────────┘ ├──────────────┘ └──────────────┘ │
│ │ │ │ │
│ │ ├───────────▶ Docker Socket (ro) │ │
│ │ │ │ │
│ │ ├───────────▶ prodg-internal Network │ │
│ │ │ │
│ ┌──────────────┐ ┌──────────────┐ │ │
│ │ Prometheus │ │ Grafana │ │ │
│ │ :9090 │ │ :3000 │ │ │
│ └──────────────┘ └──────────────┘ │ │
└──────────────────────────────────────────────────────────────────────────┘
│
│ HTTPS (Tailnet-only binding or public)
│
┌───────┐
│ User │
│Browser│
└───────┘
Access URL: https://code.mainframe.prodg.studio
1.2 Data Flow
- User opens browser and navigates to
https://code.mainframe.prodg.studio - Caddy terminates TLS and reverse-proxies to code-server container (port 8443)
- code-server authenticates user via password (and optionally Tailscale identity)
- Inside code-server:
- VS Code IDE loads with
/opt/prodgas workspace - Claude extension activates (if API key configured)
- Terminal allows running
claudeCLI,docker compose,psql, etc.
- VS Code IDE loads with
- User edits files in
/opt/prodg, commits via built-in git, runs Hermes API commands
1.3 Component Breakdown
| Component | Image | Purpose | Network |
|---|---|---|---|
| code-server | codercom/code-server:latest | Browser IDE | prodg-internal + host |
| claude-cli | Installed inside container | Agentic coding | Via container shell |
| Claude Extension | MSIX from OpenVSX | AI pair programming | Calls Anthropic API |
| Hermes tasks | VS Code tasks.json | Quick API interactions | Internal API calls |
2. Implementation Plan
Phase D1: Container Deployment
Step 1.1: Create code-server Dockerfile
Build a custom image that includes:
- Base:
codercom/code-server:latest(Ubuntu-based) - Installed:
claudeCLI,dockerCLI,psql,curl,jq,python3,node,git - Pre-installed VS Code extensions: Claude, Docker, YAML, Python, JSON, Markdown
- Pre-configured: settings.json, keybindings, terminal defaults
# /opt/prodg/code-server/Dockerfile
FROM codercom/code-server:latest
USER root
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
docker.io \
postgresql-client \
curl \
jq \
python3 \
python3-pip \
nodejs \
npm \
git \
htop \
tmux \
&& rm -rf /var/lib/apt/lists/*
# Install Claude Code CLI
RUN curl -fsSL https://claude.ai/install.sh | sh
# Switch back to coder user
USER coder
# Install VS Code extensions
RUN code-server --install-extension anthropic.claude-code \
&& code-server --install-extension ms-azuretools.vscode-docker \
&& code-server --install-extension redhat.vscode-yaml \
&& code-server --install-extension ms-python.python \
&& code-server --install-extension esbenp.prettier-vscode
# Default workspace
WORKDIR /workspace
# Expose port
EXPOSE 8443
Step 1.2: Docker Compose Integration
Add to /opt/prodg/compose/docker-compose.yml:
code-server:
build:
context: /opt/prodg/code-server
dockerfile: Dockerfile
container_name: code-server
restart: unless-stopped
user: "1000:1000" # Run as prodg user (UID 1000)
environment:
# code-server auth
PASSWORD: ${CODE_SERVER_PASSWORD}
SUDO_PASSWORD: ${CODE_SERVER_SUDO_PASSWORD}
# Claude Code environment
HERMES_API_TOKEN: ${HERMES_API_TOKEN}
HERMES_API_URL: http://hermes-api:8000
ANTHROPIC_API_KEY: ${ANTHROPIC_API_KEY}
# Terminal defaults
TERM: xterm-256color
SHELL: /bin/bash
volumes:
# Workspace: full ProDG directory
- /opt/prodg:/workspace:rw
# Docker socket (read-only for container management)
- /var/run/docker.sock:/var/run/docker.sock:ro
# SSH keys for git / remote access
- /home/prodg/.ssh:/home/coder/.ssh:ro
# code-server config persistence
- /opt/prodg/data/code-server:/home/coder/.local/share/code-server:rw
# Bash history persistence
- /opt/prodg/data/code-server/bash_history:/home/coder/.bash_history:rw
networks:
- prodg-internal
# Resource limits to prevent starving other services
deploy:
resources:
limits:
cpus: '2.0'
memory: 2G
reservations:
cpus: '0.5'
memory: 512M
# Do NOT expose port externally — Caddy handles access
# Security: container has no external ports bound
Step 1.3: Caddy Route
Add to /opt/prodg/compose/Caddyfile:
code.mainframe.prodg.studio {
reverse_proxy code-server:8443
# Security headers
header {
Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
X-Content-Type-Options "nosniff"
X-Frame-Options "SAMEORIGIN"
X-XSS-Protection "1; mode=block"
Referrer-Policy "strict-origin-when-cross-origin"
Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline';"
}
# Rate limiting (prevent brute force on login)
rate_limit {
zone code_server {
key {remote_host}
events 10
window 1m
}
}
}
Note: If Caddy's
rate_limitmodule isn't installed, omit that block. It is not part of the standard distribution.
Step 1.4: Environment Variables
Add to /opt/prodg/compose/.env:
# code-server Authentication CODE_SERVER_PASSWORD=$(openssl rand -base64 24 | tr -dc 'a-zA-Z0-9' | head -c 24) CODE_SERVER_SUDO_PASSWORD=$(openssl rand -base64 24 | tr -dc 'a-zA-Z0-9' | head -c 24) # Claude Code / Extension ANTHROPIC_API_KEY= # From https://console.anthropic.com/
Phase D2: Workspace Configuration
Step 2.1: Pre-configure VS Code Settings
Create /opt/prodg/data/code-server/User/settings.json:
{
"workbench.colorTheme": "Default Dark+",
"editor.fontSize": 14,
"editor.fontFamily": "JetBrains Mono, Fira Code, monospace",
"editor.formatOnSave": true,
"terminal.integrated.defaultProfile.linux": "bash",
"terminal.integrated.profiles.linux": {
"bash": {
"path": "/bin/bash",
"args": ["-l"]
}
},
"terminal.integrated.env.linux": {
"HERMES_API_TOKEN": "${env:HERMES_API_TOKEN}",
"HERMES_API_URL": "http://hermes-api:8000"
},
"files.exclude": {
"**/.git": true,
"**/node_modules": true,
"**/__pycache__": true
},
"search.exclude": {
"**/node_modules": true,
"**/data": true
},
"claude.apiKey": "${env:ANTHROPIC_API_KEY}",
"docker.showStartPage": false
}
Step 2.2: Hermes API Tasks
Create /opt/prodg/.vscode/tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"label": "Hermes: Check Health",
"type": "shell",
"command": "curl -s http://hermes-api:8000/health | jq .",
"group": "build",
"presentation": { "echo": true, "reveal": "always" }
},
{
"label": "Hermes: List Agents",
"type": "shell",
"command": "curl -s -H \"X-API-Token: ${HERMES_API_TOKEN}\" http://hermes-api:8000/v1/agents | jq .",
"group": "build"
},
{
"label": "Hermes: List Tasks",
"type": "shell",
"command": "curl -s -H \"X-API-Token: ${HERMES_API_TOKEN}\" http://hermes-api:8000/v1/tasks | jq .",
"group": "build"
},
{
"label": "Docker: Stack Status",
"type": "shell",
"command": "docker compose ps",
"group": "build",
"options": { "cwd": "/workspace/compose" }
},
{
"label": "Docker: Restart Hermes API",
"type": "shell",
"command": "docker compose restart hermes-api",
"group": "build",
"options": { "cwd": "/workspace/compose" }
},
{
"label": "Backup: Trigger Now",
"type": "shell",
"command": "/workspace/backups/scripts/backup-all.sh",
"group": "build"
},
{
"label": "Grafana: Open Dashboard",
"type": "shell",
"command": "echo 'Open: https://metrics.mainframe.prodg.studio'",
"group": "build"
}
]
}
Step 2.3: Bash Profile Convenience
Create /opt/prodg/data/code-server/.bashrc_addons:
# ProDG Mainframe Conveniences export PS1="\[\e[36m\]\u@mainframe\[\e[0m\]:\[\e[33m\]\w\[\e[0m\]$ " # Hermes CLI helpers alias h-health='curl -s http://hermes-api:8000/health | jq .' alias h-agents='curl -s -H "X-API-Token: $HERMES_API_TOKEN" http://hermes-api:8000/v1/agents | jq .' alias h-tasks='curl -s -H "X-API-Token: $HERMES_API_TOKEN" http://hermes-api:8000/v1/tasks | jq .' alias h-dispatch='curl -s -X POST -H "X-API-Token: $HERMES_API_TOKEN" http://hermes-api:8000/v1/dispatch/docker' # Docker helpers alias d-ps='docker compose -f /workspace/compose/docker-compose.yml ps' alias d-logs='docker compose -f /workspace/compose/docker-compose.yml logs --tail 50' alias d-restart='docker compose -f /workspace/compose/docker-compose.yml restart' # Git helpers alias gs='git status' alias gd='git diff' alias gcm='git commit -m' # Quick navigation cd /workspace
Phase D3: Deployment & Testing
Step 3.1: Build and Start
cd /opt/prodg/compose docker compose up -d code-server
Step 3.2: Verify Internally
docker exec code-server curl -s http://localhost:8443/healthz docker logs --tail 20 code-server
Step 3.3: Verify Externally
curl -s -o /dev/null -w "%{http_code}" https://code.mainframe.prodg.studio/login
# Expected: 200
Step 3.4: Claude Code Handoff Test
# Inside code-server terminal cd /workspace/hermes-api claude # Inside Claude Code: # /handoff "Review the FastAPI agent orchestrator and suggest improvements"
Phase D4: Dashboard-as-Code Workflow
One of the primary use cases is building Grafana dashboards programmatically. Here's the intended workflow:
1. User opens code-server in browser (on iPad or laptop) 2. Creates new file: /workspace/compose/grafana/provisioning/dashboards/infrastructure.json 3. Uses Claude extension: "Generate a Grafana dashboard for Docker container CPU/memory" 4. Claude produces valid dashboard JSON 5. User runs task: "Docker: Restart Grafana" 6. Dashboard appears at https://metrics.mainframe.prodg.studio 7. User commits JSON to git for version control
3. Risk Assessment Matrix
| Risk | Likelihood | Impact | Severity | Category |
|---|---|---|---|---|
| Exposed IDE accessible to attackers | Medium | Critical | CRITICAL | Network |
| .env secrets visible in workspace | High | Critical | CRITICAL | Data |
| Docker socket abuse (container escape) | Medium | Critical | CRITICAL | Container |
| Resource exhaustion (CPU/memory) | Medium | High | HIGH | Availability |
| Session hijacking / credential theft | Medium | High | HIGH | Authentication |
| Supply chain compromise (base image) | Low | High | MEDIUM | Supply Chain |
| Data exfiltration via browser | Low | Medium | MEDIUM | Data |
| Privilege escalation inside container | Low | High | MEDIUM | Container |
| Long-lived sessions without timeout | High | Low | LOW | Operational |
4. Risk Mitigations
Mitigation 1: Tailnet-First Access (CRITICAL)
Risk: Public internet exposure of a full IDE.
Mitigation: Configure code-server to be reachable ONLY via the Tailnet, not the public internet.
Implementation Options:
Option A: Caddy bind to Tailscale interface (Recommended)
code.mainframe.prodg.studio {
bind tailscale0 # Caddy binds only to Tailscale interface
reverse_proxy code-server:8443
}
Option B: No Caddy route — direct Tailnet access
# code-server docker-compose ports: - "100.64.0.1:8443:8443" # Bind to Tailscale IP only
Access via: http://100.64.0.1:8443 from any tailnet device.
Option C: Caddy + Tailscale Serve/Funnel Use Tailscale's own serve/funnel commands instead of Caddy public exposure.
Recommendation: Use Option B for maximum security. No public DNS resolution needed. Mitch accesses via http://100.64.0.1:8443 when on the tailnet. If public access is ever needed, add Caddy later.
Trade-off: Cannot access from devices not on the tailnet (e.g., public WiFi without Tailscale). Acceptable for ProDG's security model.
Mitigation 2: Secret Isolation (CRITICAL)
Risk: /opt/prodg/compose/.env is mounted as workspace; any code execution or VS Code extension can read all secrets.
Mitigation: Mount secrets via Docker environment variables, not files. Use read-only mounts where possible.
Implementation:
# docker-compose.yml — modified volume mounts volumes: # Mount workspace BUT exclude .env - /opt/prodg:/workspace:rw # Do NOT mount .env directly — inject via env vars only
Additionally, add a .gitignore and .dockerignore in the workspace:
# /workspace/.gitignore .env *.env */.env secrets/
Advanced: Move secrets to Infisical before deploying code-server. Then:
.envfile is deleted or encrypted- code-server uses Infisical CLI to inject secrets on-demand
- No plaintext secrets on disk
Status: This is Phase 9 work. For now, Mitigation 2A is: code-server runs as prodg user (not root), and .env is chmod 600 owned by root. The container user cannot read .env unless explicitly granted.
Wait — if the workspace is /opt/prodg and we mount it as prodg:prodg, then prodg user CAN read .env if .env is world-readable. Currently .env is chmod 600 root:root, so the prodg user inside the container (running as UID 1000) cannot read it.
This is actually already safe. The container runs as UID 1000 (prodg), and .env is owned by root with 600 permissions. The container cannot read secrets from the file. Secrets are injected via Docker environment variables ONLY for the specific keys declared in environment:.
Verification:
docker exec code-server cat /workspace/compose/.env # Expected: Permission denied
Mitigation 3: Docker Socket Sandboxing (CRITICAL)
Risk: Docker socket mounted as read-only still allows:
- Listing all containers
- Reading container logs
- Inspecting container configs (which may contain env vars with secrets)
- Creating new containers (wait — read-only socket shouldn't allow this)
Actually, Docker socket permissions are ALL-OR-NOTHING. Even "read-only" mount allows write operations. The :ro flag only prevents modifications to the socket device node, not to the Docker API. ANY access to the Docker socket is root-equivalent on the host.
Revised Risk: Container with Docker socket access = full host compromise if breached.
Mitigation Options:
Option A: Remove Docker socket mount entirely
- User cannot run
docker composefrom within code-server - Must SSH to host or use Hermes API for container ops
- Safest option
Option B: Docker Socket Proxy (Recommended if Docker access needed) Deploy a filtering proxy:
docker-socket-proxy:
image: tecnativa/docker-socket-proxy:latest
environment:
CONTAINERS: 1
SERVICES: 1
NETWORKS: 1
# Explicitly deny dangerous endpoints
POST: 0 # No container creation
DELETE: 0 # No container deletion
IMAGES: 0 # No image operations
VOLUMES: 0 # No volume operations
BUILD: 0 # No builds
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
networks:
- prodg-internal
Then code-server mounts the PROXY socket, not the real one.
Option C: Hermes API as abstraction layer
- code-server has NO Docker socket
- All container ops go through Hermes API:
/v1/dispatch/docker - API enforces tier-based access control
- Most aligned with ProDG architecture
Recommendation: Start with Option A (no Docker socket). For day-to-day editing, you don't need Docker inside the IDE. For container operations, use the Hermes API or SSH to host. If Docker access becomes essential, upgrade to Option B (proxy).
Mitigation 4: Resource Limits
deploy:
resources:
limits:
cpus: '2.0'
memory: 2G
reservations:
cpus: '0.5'
memory: 512M
Rationale: code-server + Electron renderer + Claude extension + terminals can consume significant RAM. Limit to 2GB to prevent OOM kills of Postgres or Redis.
Monitoring: Alert if container_memory_usage_bytes{container_name="code-server"} / container_spec_memory_limit_bytes > 0.9.
Mitigation 5: Authentication Hardening
Layer 1: code-server password
- 24-character random password stored in
.env - Changed on first login (configurable)
Layer 2: Caddy basicauth (if publicly exposed)
code.mainframe.prodg.studio {
basicauth {
mitch $2a$14$...bcrypt_hash...
}
reverse_proxy code-server:8443
}
Layer 3: Tailnet binding (strongest)
- code-server not reachable from public internet at all
- Only accessible from tailnet IPs (100.64.0.x)
- Equivalent to VPN-based access control
Layer 4: Session timeouts
// settings.json "workbench.tree.indent": 20, "terminal.integrated.enablePersistentSessions": false
Recommendation: Implement Layers 1 + 3. Layer 2 only if public exposure is required. Layer 4 via code-server configuration.
Mitigation 6: Audit Logging
All file changes inside /opt/prodg are already captured by:
- Promtail → Loki: Docker container logs
- filesystem audit (optional):
auditdrules on/opt/prodg
Additional: Enable code-server's built-in audit logging:
# code-server startup flags --log debug --disable-telemetry # Don't send to external services
Mitigation 7: Network Isolation
# code-server docker-compose networks: - prodg-internal # NO host network mode # NO external port bindings
code-server can reach:
- Other containers via Docker DNS (e.g.,
http://hermes-api:8000) - The internet (for Anthropic API, package downloads)
- The host filesystem (only via explicit volume mounts)
code-server CANNOT reach:
- Host services not on
prodg-internalnetwork - Other Docker networks
- Host's localhost services (unless explicitly bridged)
Mitigation 8: Supply Chain Security
# Pin to specific SHA instead of 'latest' FROM codercom/code-server:4.99.2@sha256:abcdef123456...
Update policy:
- Subscribe to coder/code-server GitHub releases
- Test updates in isolated environment before mainframe deployment
- Automated vulnerability scanning with Trivy:
docker run --rm aquasec/trivy image code-server:latest
Mitigation 9: Backup & Recovery
code-server user data (extensions, settings, history) is stored in:
/opt/prodg/data/code-server(Docker volume)- This directory is included in the nightly B2 backup (
backup-configs.sh)
Rollback procedure:
cd /opt/prodg/compose docker compose stop code-server docker compose rm code-server # Restore data from B2 if needed # Rebuild image if Dockerfile changed docker compose up -d code-server
Mitigation 10: Claude Code /handoff Isolation
Claude Code's /handoff command allows transferring a task context to another Claude Code instance. On the Mainframe:
Scenario: You start a task on your laptop (claude CLI), then /handoff to continue on the server's code-server instance.
Risk: Handoff data may contain sensitive file contents or environment variables.
Mitigation:
/handoffonly transfers the conversation context, not files- File contents must be re-read by the receiving instance
- Ensure the receiving instance has the same file access permissions
- Do NOT hand off from a local session that has accessed
.envto a server session that shouldn't
5. Operational Procedures
Starting code-server
cd /opt/prodg/compose docker compose up -d code-server
Stopping code-server
cd /opt/prodg/compose docker compose stop code-server
Accessing code-server
From Tailnet (recommended):
http://100.64.0.1:8443
From Public (if configured):
https://code.mainframe.prodg.studio
Updating the Image
cd /opt/prodg/code-server docker build -t prodg/code-server:latest . cd /opt/prodg/compose docker compose up -d code-server
Installing Additional VS Code Extensions
docker exec code-server code-server --install-extension <publisher.extension-name>
Viewing Logs
docker logs --tail 100 -f code-server tail -f /var/log/prodg-backup.log
6. Monitoring & Alerting
Grafana Dashboard for code-server
Metrics to expose (via cadvisor + node-exporter):
- Container CPU usage
- Container memory usage
- Container network I/O
- Disk I/O on
/opt/prodg/data/code-server
Alert Rules
# Add to Grafana provisioning
- alert: code-server High CPU
expr: rate(container_cpu_usage_seconds_total{container_name="code-server"}[5m]) > 1.5
for: 10m
labels:
severity: warning
annotations:
summary: "code-server consuming excessive CPU"
- alert: code-server High Memory
expr: container_memory_usage_bytes{container_name="code-server"} / container_spec_memory_limit_bytes > 0.9
for: 5m
labels:
severity: critical
annotations:
summary: "code-server approaching memory limit"
7. Rollback Plan
If code-server causes issues:
# Immediate stop cd /opt/prodg/compose && docker compose stop code-server # Remove container docker compose rm code-server # Verify other services unaffected docker compose ps curl -s https://api.mainframe.prodg.studio/health curl -s https://metrics.mainframe.prodg.studio/api/health # If needed, remove Caddy route sed -i '/code\.mainframe\.prodg\.studio/,/}/d' /opt/prodg/compose/Caddyfile docker exec caddy caddy reload --config /etc/caddy/Caddyfile
Zero-downtime rollback: Stopping code-server does not affect any other service. It's completely isolated.
8. Decision Log
| Decision | Choice | Rationale |
|---|---|---|
| Tailnet vs Public | Tailnet | Eliminates entire attack surface of public IDE exposure |
| Docker socket | None (initially) | Hermes API provides safer abstraction |
| Base image | codercom/code-server | Official, well-maintained, Ubuntu-based |
| User in container | coder (UID 1000) | Matches host prodg UID for file ownership |
| Resource limit | 2 CPU / 2 GB RAM | Prevents starvation of core infrastructure |
| Claude CLI inside | Yes | Enables /handoff from local to server |
| Claude Extension | Yes | AI pair-programming in browser |
| Workspace | /opt/prodg | Full infrastructure visibility |
9. Appendix: Comparative Trade-off Summary
| Dimension | Option D (This Plan) | Option A (SSH + tmux) | Option E (Local Laptop) |
|---|---|---|---|
| Accessibility | Any browser, including iPad | SSH client only | Local machine only |
| Always-on | Yes (container runs 24/7) | Yes (tmux persists) | No |
| Security surface | Medium (Tailnet mitigates) | Low (SSH only) | Low (local) |
| File editing | GUI with IntelliSense | Vim/nano only | Full VS Code |
| Claude /handoff | Native support | Native support | Native support |
| Docker control | Via Hermes API (safe) | Direct (risky as root) | SSH to host |
| iPad usability | Excellent | Poor | N/A |
| Resource use | ~2GB RAM | Negligible | N/A |
| Setup complexity | Medium | Low | Already done |
Document Version: 1.0.0 — Generated by Hermes Agent for ProDG Studio