/skill:env-check — Shell Environment Detection
Purpose: Detect the current execution environment and determine how to route shell commands safely. Does NOT hardcode any specific shell, host, or OS — reads the user's shell configuration for routing rules.
Pre-flight Required Config
Before proceeding, verify:
Check ~/.claude/env.config.md exists.
If not, halt:
This skill requires ~/.claude/env.config.md.
Set it up interactively:
/skill:configure env
Or copy the template and edit manually:
cp claude/env-check/env.config.template.md ~/.claude/env.config.md
Scan for <FILL IN> placeholders in required sections: shells, routing_rules.
If found: list unfilled fields and suggest /skill:configure env --recheck.
If healthy, proceed silently.
Arguments
- (no argument) — detect current environment and report
<command-or-pattern> — evaluate how a specific command should be routed in the current environment
Workflow
Step 1: Read User Config
Read ~/.claude/env.config.md. Extract:
- Registered shells — which shells the user works with (e.g., bash, zsh, pwsh, fish)
- Routing rules — per-shell or per-host rules for how to emit commands
- Host mappings (optional) — which machines use which shells
- Terminal switching rules (optional) — when to recommend switching terminals vs wrapping
Step 2: Detect Current Environment
Check non-destructive signals:
| Signal |
How to detect |
| Current shell |
$SHELL, $PSVersionTable, $0, or process name |
| OS family |
uname -s or equivalent |
| Path style |
Forward-slash vs backslash, /home/ vs C:\ |
| Inside remote session? |
$SSH_CONNECTION, $SSH_TTY |
| Inside container/WSL? |
/proc/version, $WSL_DISTRO_NAME, /.dockerenv |
| Project runner scripts |
Scan for Makefile, package.json scripts, pyproject.toml, shell scripts |
Step 3: Match Against User Config
Compare detected environment against the user's routing rules:
- Identify which registered shell is active
- Look up the routing rule for that shell
- Determine if the current environment matches what the project expects
Step 4: Report (When Needed)
If environment choice matters (ambiguous or mismatched), report:
Detected shell: <shell name>
OS: <os family>
Execution strategy: <direct / switch terminal / use project runner>
Reason: <brief explanation from routing rules>
If the environment is obvious and no routing guidance is needed, proceed silently.
Step 5: Emit Guidance
Based on the routing match:
- Direct execution — emit commands in the detected shell's syntax
- Terminal switch recommended — tell the user which terminal to switch to and why, per their routing rules
- Runner script available — use the project's runner script
- Mismatch detected — explain the mismatch between current shell and project expectations
When to Use Silently vs Report
- Report when: shell choice is ambiguous, the detected shell doesn't match project expectations, or the user explicitly invoked
/skill:env-check
- Stay silent when: another skill calls this as a sub-check and the environment is unambiguous
CRITICAL: Do Not Guess
- Do NOT hardcode shell names (PowerShell, WSL, bash, zsh) in the detection logic. The user's
env.config.md defines which shells they use.
- Do NOT assume a specific OS. Detect it.
- Do NOT emit commands in the wrong shell syntax.
- Do NOT recommend terminal switching unless the user's routing rules specify it.
- Do NOT invent runner scripts that don't exist in the project.
- Do NOT prefix commands with shell wrappers (e.g.,
wsl, bash -c) unless the user's routing rules explicitly call for it.
1---2name: env-check-23description: Detect the current shell environment and choose safe command routing. Use when working across different shells, OSes, or remote hosts. Reads user-specific shell config from ~/.claude/env.config.md.4---567# /skill:env-check — Shell Environment Detection89**Purpose:** Detect the current execution environment and determine how to route shell commands safely. Does NOT hardcode any specific shell, host, or OS — reads the user's shell configuration for routing rules.1011## Pre-flight Required Config1213Before proceeding, verify:14151. Check `~/.claude/env.config.md` exists.16 If not, halt:17 > This skill requires `~/.claude/env.config.md`.18 >19 > Set it up interactively:20 > ```21 > /skill:configure env22 > ```23 >24 > Or copy the template and edit manually:25 > ```26 > cp claude/env-check/env.config.template.md ~/.claude/env.config.md27 > ```28292. Scan for `<FILL IN>` placeholders in required sections: `shells`, `routing_rules`.30 If found: list unfilled fields and suggest `/skill:configure env --recheck`.31323. If healthy, proceed silently.3334## Arguments3536- (no argument) — detect current environment and report37- `<command-or-pattern>` — evaluate how a specific command should be routed in the current environment3839## Workflow4041### Step 1: Read User Config4243Read `~/.claude/env.config.md`. Extract:44- **Registered shells** — which shells the user works with (e.g., bash, zsh, pwsh, fish)45- **Routing rules** — per-shell or per-host rules for how to emit commands46- **Host mappings** (optional) — which machines use which shells47- **Terminal switching rules** (optional) — when to recommend switching terminals vs wrapping4849### Step 2: Detect Current Environment5051Check non-destructive signals:5253| Signal | How to detect |54|---|---|55| Current shell | `$SHELL`, `$PSVersionTable`, `$0`, or process name |56| OS family | `uname -s` or equivalent |57| Path style | Forward-slash vs backslash, `/home/` vs `C:\` |58| Inside remote session? | `$SSH_CONNECTION`, `$SSH_TTY` |59| Inside container/WSL? | `/proc/version`, `$WSL_DISTRO_NAME`, `/.dockerenv` |60| Project runner scripts | Scan for `Makefile`, `package.json` scripts, `pyproject.toml`, shell scripts |6162### Step 3: Match Against User Config6364Compare detected environment against the user's routing rules:65661. Identify which registered shell is active672. Look up the routing rule for that shell683. Determine if the current environment matches what the project expects6970### Step 4: Report (When Needed)7172If environment choice matters (ambiguous or mismatched), report:7374```75Detected shell: <shell name>76OS: <os family>77Execution strategy: <direct / switch terminal / use project runner>78Reason: <brief explanation from routing rules>79```8081If the environment is obvious and no routing guidance is needed, proceed silently.8283### Step 5: Emit Guidance8485Based on the routing match:8687- **Direct execution** — emit commands in the detected shell's syntax88- **Terminal switch recommended** — tell the user which terminal to switch to and why, per their routing rules89- **Runner script available** — use the project's runner script90- **Mismatch detected** — explain the mismatch between current shell and project expectations9192## When to Use Silently vs Report9394- **Report** when: shell choice is ambiguous, the detected shell doesn't match project expectations, or the user explicitly invoked `/skill:env-check`95- **Stay silent** when: another skill calls this as a sub-check and the environment is unambiguous9697## CRITICAL: Do Not Guess9899- Do NOT hardcode shell names (PowerShell, WSL, bash, zsh) in the detection logic. The user's `env.config.md` defines which shells they use.100- Do NOT assume a specific OS. Detect it.101- Do NOT emit commands in the wrong shell syntax.102- Do NOT recommend terminal switching unless the user's routing rules specify it.103- Do NOT invent runner scripts that don't exist in the project.104- Do NOT prefix commands with shell wrappers (e.g., `wsl`, `bash -c`) unless the user's routing rules explicitly call for it.