Claude
Skills
Sign in
Back

sandbox:language-environment-config

Included with Lifetime
$97 forever

This skill should be used when detecting programming languages in projects, determining language versions from config files, installing development environments (Rust, Python, Node.js), setting up LSP servers, installing CLI development tools, or configuring shell environments (oh-my-zsh, starship). Provides knowledge for language detection and environment setup in sandboxes.

Backend & APIsscripts

What this skill does


# language-environment-config

Detect programming languages, parse version requirements, and install complete development environments for Rust, Python, and Node.js in Docker-based sandboxes.

## Purpose

This skill provides knowledge for setting up language-specific development environments inside sandbox containers. Focus on the three primary languages (Rust, Python, Node.js) and their associated tooling, LSP servers, and development utilities.

## Language Detection

### Detection Strategy

Identify languages by scanning for configuration and dependency files:

**Rust indicators:**
- `Cargo.toml` - Rust project manifest
- `Cargo.lock` - Dependency lock file
- `rust-toolchain.toml` - Rust version specification
- `.rs` files in `src/` directory

**Python indicators:**
- `pyproject.toml` - Modern Python project config
- `requirements.txt` - Dependency list
- `setup.py` - Package setup script
- `Pipfile` - Pipenv config
- `.python-version` - Python version file
- `.py` files

**Node.js indicators:**
- `package.json` - npm project manifest
- `package-lock.json` - npm lock file
- `pnpm-lock.yaml` - pnpm lock file
- `.nvmrc` - Node version specification
- `.node-version` - Alternative version file
- `.js`, `.ts`, `.jsx`, `.tsx` files

### Detection Script

Use the `scripts/detect_languages.py` script to analyze a project:

```python
# Returns detected languages and their config files
python3 scripts/detect_languages.py /path/to/project
```

Output format:
```json
{
  "rust": {
    "detected": true,
    "indicators": ["Cargo.toml", "src/main.rs"]
  },
  "python": {
    "detected": true,
    "indicators": ["pyproject.toml", "requirements.txt"]
  },
  "nodejs": {
    "detected": true,
    "indicators": ["package.json", ".nvmrc"]
  }
}
```

## Version Detection

### Version Files and Parsing

Each language has standard files for version specification:

#### Rust Version Detection

**Primary: `rust-toolchain.toml`**
```toml
[toolchain]
channel = "1.93.0"
# or
channel = "stable"
# or
channel = "nightly"
```

Parse with:
```python
import toml
config = toml.load("rust-toolchain.toml")
version = config["toolchain"]["channel"]
```

**Legacy: `rust-toolchain` (plain text)**
```
1.93.0
```

#### Python Version Detection

**Primary: `pyproject.toml`**
```toml
[project]
requires-python = ">=3.14.2"
```

Parse with:
```python
import toml
config = toml.load("pyproject.toml")
version_spec = config["project"]["requires-python"]
# Extract version: ">=3.14.2" → "3.14.2"
```

**Alternative: `.python-version`**
```
3.14.2
```

**requirements.txt (less precise)**
```
python>=3.14
```

#### Node.js Version Detection

**Primary: `.nvmrc`**
```
18.20.0
```

Or semantic versions:
```
lts/*
node
v18
```

**Alternative: `.node-version`**
```
18.20.0
```

**package.json engines field**
```json
{
  "engines": {
    "node": ">=18.0.0"
  }
}
```

### Version Parsing Script

Use `scripts/parse_versions.py`:

```python
# Extract version requirements from project files
python3 scripts/parse_versions.py /path/to/project
```

Output:
```json
{
  "rust": "1.93.0",
  "python": "3.14.2",
  "nodejs": "18.20.0"
}
```

## Language Installation

### Rust Installation

**Install via rustup** (preferred for version flexibility):

```dockerfile
# Install specific version
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \
    sh -s -- -y --default-toolchain 1.93.0

# Install stable (current)
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \
    sh -s -- -y --default-toolchain stable

# Install nightly
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \
    sh -s -- -y --default-toolchain nightly
```

**Critical: Version keywords vs numbers**

✅ **GOOD - Always current:**
```dockerfile
RUN rustup install stable
RUN rustup install nightly
RUN rustup default stable
```

❌ **BAD - Becomes outdated:**
```dockerfile
RUN rustup install 1.93.0  # Fixed version, will be old
```

**When to use specific versions:**
- Project requires exact version (from rust-toolchain.toml)
- User explicitly requests specific version

**Components to install:**
```dockerfile
RUN rustup component add clippy rustfmt rust-analyzer
```

**Standard tools:**
```dockerfile
# After Rust is installed
RUN cargo install cargo-dist cargo-deny cargo-release cocogitto
```

### Python Installation

**Install via apt** (system Python):

```dockerfile
RUN apt-get update && apt-get install -y \
    python3 \
    python3-pip \
    python3-venv \
    && rm -rf /var/lib/apt/lists/*
```

**Install via uv** (for specific versions):

```dockerfile
# Install uv first
RUN pip3 install --no-cache-dir uv

# Install specific Python version
RUN uv python install 3.14.2

# Install current stable
RUN uv python install

# Python doesn't have official LTS - use current stable
# When user asks for LTS, install current stable instead
```

**Critical: Version keywords**

✅ **GOOD - Always current:**
```dockerfile
RUN uv python install  # Latest stable
RUN pip3 install --upgrade pip  # Latest pip
```

❌ **BAD - Becomes outdated:**
```dockerfile
RUN uv python install 3.14  # Major version, but not latest patch
RUN uv python install 3.14.2  # Specific version, will be old
```

**Standard tools:**
```dockerfile
RUN pip3 install --no-cache-dir uv ruff mypy black pytest
```

### Node.js Installation

**Install via nvm** (preferred for version flexibility):

```dockerfile
ENV NVM_DIR="/root/.nvm"

# Install nvm
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash

# Install current stable
RUN . "$NVM_DIR/nvm.sh" && nvm install node && nvm alias default node

# Install LTS
RUN . "$NVM_DIR/nvm.sh" && nvm install --lts && nvm alias default lts/*

# Install nightly (latest, including pre-release)
RUN . "$NVM_DIR/nvm.sh" && nvm install node --latest-npm

# Install specific version (when required)
RUN . "$NVM_DIR/nvm.sh" && nvm install 18.20.0
```

**Critical: Version keywords**

✅ **GOOD - Always current:**
```dockerfile
RUN nvm install node  # Current stable
RUN nvm install --lts  # Current LTS
RUN nvm install node --latest-npm  # Nightly/latest
```

❌ **BAD - Becomes outdated:**
```dockerfile
RUN nvm install 18.20.0  # Specific version, will be old
RUN nvm install 18  # Major version, not latest
```

**Standard tools:**
```dockerfile
RUN npm install -g pnpm typescript ts-node
```

## LSP Server Installation

### rust-analyzer

**Install via rustup:**
```dockerfile
RUN rustup component add rust-analyzer
```

**Or via cargo (latest):**
```dockerfile
RUN cargo install rust-analyzer
```

### pyright (Python)

**Install via npm:**
```dockerfile
RUN npm install -g pyright
```

**Or via pip:**
```dockerfile
RUN pip3 install pyright
```

### typescript-language-server

**Install via npm:**
```dockerfile
RUN npm install -g typescript-language-server typescript
```

### Claude Code LSP Plugins

When user requests LSP plugins from marketplace:

```markdown
Add these plugins in Sandbox.toml:

[claude.plugins]
plugins = [
  "rust-analyzer-lsp@claude-plugins-official",
  "pyright-lsp@claude-plugins-official",
  "typescript-lsp@claude-plugins-official"
]
```

Note: LSP servers must be installed in container. Plugins just configure Claude Code to use them.

## CLI Tools Installation

### Tools List

**Standard tools to install:**
- ripgrep, fd, eza, jq, just
- repomix, scc, sg (ast-grep)
- bfs, xan, rga, pdfgrep, fq
- shellcheck, zizmor, git-cliff, has

### Installation Methods

**Via apt (if available):**
```dockerfile
RUN apt-get update && apt-get install -y \
    ripgrep \
    fd-find \
    jq \
    pdfgrep \
    shellcheck \
    && rm -rf /var/lib/apt/lists/*

# Create symlinks where needed
RUN ln -s $(which fdfind) /usr/local/bin/fd
```

**Via cargo:**
```dockerfile
RUN cargo install \
    eza \
    just \
    repomix \
    scc \
    bfs \
    xan \
    git-cliff \
    ast-grep \
    ripgrep_all \
    zizmor \
    has
```

**Via download (for binaries like fq):**
```dockerfile
RUN wget https://github.com/wade

Related in Backend & APIs