Execution Environment
Use this skill whenever prompts, agents, or instructions need to produce shell commands or environment-specific guidance.
Relationship to Copilot built-ins
- Use built-in
/env when you only need a quick snapshot of the loaded environment, instructions, tools, or shell context.
- Use this skill when shell routing and command-syntax decisions materially affect the next command or workflow.
Core Principle
Detect the execution environment first. Do not assume any specific shell or OS.
Pre-flight Config Check
Before routing commands, check whether the user has an env config:
- Check
$HOME/.copilot/env.config.md (user-level) or <project>/.github/instructions/env.config.md (project-level).
- If found, load the registered shells, routing rules, and host mappings.
- If NOT found, fall back to auto-detection only (detect shell, emit commands in its native syntax). Optionally suggest:
"For cross-platform routing rules, run /configure copilot-env or copy the template from .github/templates/env.config.template.md."
Detection Protocol
Check non-destructive signals before recommending commands:
Shell/runtime signals
- What is the current shell? (Check
$SHELL, process name, or shell-specific variables)
- What OS family is running? (
uname -s or equivalent)
- Is this a remote session? (
$SSH_CONNECTION, $SSH_TTY)
- Is this running inside a container or virtualized environment? (
/proc/version, /.dockerenv, or equivalent markers)
Path signals
- Forward-slash paths suggest Unix-family shells
- Backslash paths or drive letters suggest Windows-family shells
Tooling signals
- Does the repo have runner scripts? (Check for
Makefile, package.json scripts, pyproject.toml, shell scripts)
- Does the repo define a preferred execution pattern in its project instructions?
Routing
After detection, match the environment against the user's config:
- Identify which registered shell is active
- Look up the routing rule for that shell
- If the detected shell matches what the project expects → emit commands directly
- If mismatch detected → follow the routing rule (direct, switch-terminal, or warn)
- If no config exists → emit commands in the detected shell's native syntax
Examples
- Direct native-shell execution: Detected Bash on Linux, repo commands are
already Unix-native, no routing override exists. Emit the Bash command
directly and proceed without a shell-translation explanation.
- Switch-terminal recommendation: Detected PowerShell, but the user's
routing rules say this repo should run inside WSL. Recommend switching to the
WSL terminal instead of emitting a wrapped
wsl ... bash -lc command.
- Config-aware warning: Detected shell and repo expectations disagree, and
the user's env config says to warn rather than switch automatically. State the
mismatch and give the safe next step only.
Output Pattern
When environment choice matters, report:
Detected shell: <detected>
OS: <os family>
Execution strategy: <direct / switch terminal / use project runner>
Reason: <brief explanation>
When the environment is obvious and no guidance is needed, proceed silently.
Safety Rules
- Never emit commands in the wrong shell syntax
- Never assume a specific shell without detecting it
- Never prefix commands with shell wrappers unless the user's routing rules explicitly call for it
- Never invent runner scripts that do not exist in the project
- Never mix path syntaxes across shell families
Do Nots
- Do not reopen the question of which shell to target after detection and
routing rules already resolved it.
- Do not treat
wsl, bash -lc, or similar wrapper patterns as the default
answer when a native-shell or switch-terminal path is available.
- Do not emit a "detected environment" report when the environment is obvious
and no decision changes.
Closed Decisions
- Detection comes before command emission. Environment routing is not optional.
- User or project
env.config.md rules are authoritative when present.
- Prefer direct native-shell execution or explicit terminal switching over
wrapper-style bridging.
- This skill owns detection and routing logic; prompts should reference it
rather than re-deriving shell policy inline.
Relationship to Other Assets
- Put always-on routing rules in the
execution-environment.instructions.md instruction
- Put the detection protocol in this skill
- Let prompts reference this skill instead of re-explaining shell logic
- User-specific routing rules live in
env.config.md (not in this skill)
1---2name: execution-environment3description: Detect the current shell and OS, then choose safe command routing using the user's env config. Does not hardcode any specific shell — reads routing rules from the user's env.config.md.4---56# Execution Environment78Use this skill whenever prompts, agents, or instructions need to produce shell commands or environment-specific guidance.910## Relationship to Copilot built-ins1112- Use built-in `/env` when you only need a quick snapshot of the loaded environment, instructions, tools, or shell context.13- Use this skill when shell routing and command-syntax decisions materially affect the next command or workflow.1415## Core Principle1617> Detect the execution environment first. Do not assume any specific shell or OS.1819## Pre-flight Config Check2021Before routing commands, check whether the user has an env config:22231. Check `$HOME/.copilot/env.config.md` (user-level) or `<project>/.github/instructions/env.config.md` (project-level).242. If found, load the registered shells, routing rules, and host mappings.253. If NOT found, fall back to auto-detection only (detect shell, emit commands in its native syntax). Optionally suggest:26 > "For cross-platform routing rules, run `/configure copilot-env` or copy the template from `.github/templates/env.config.template.md`."2728## Detection Protocol2930Check non-destructive signals before recommending commands:3132### Shell/runtime signals3334- What is the current shell? (Check `$SHELL`, process name, or shell-specific variables)35- What OS family is running? (`uname -s` or equivalent)36- Is this a remote session? (`$SSH_CONNECTION`, `$SSH_TTY`)37- Is this running inside a container or virtualized environment? (`/proc/version`, `/.dockerenv`, or equivalent markers)3839### Path signals4041- Forward-slash paths suggest Unix-family shells42- Backslash paths or drive letters suggest Windows-family shells4344### Tooling signals4546- Does the repo have runner scripts? (Check for `Makefile`, `package.json` scripts, `pyproject.toml`, shell scripts)47- Does the repo define a preferred execution pattern in its project instructions?4849## Routing5051After detection, match the environment against the user's config:52531. Identify which registered shell is active542. Look up the routing rule for that shell553. If the detected shell matches what the project expects → emit commands directly564. If mismatch detected → follow the routing rule (direct, switch-terminal, or warn)575. If no config exists → emit commands in the detected shell's native syntax5859## Examples6061- **Direct native-shell execution:** Detected Bash on Linux, repo commands are62 already Unix-native, no routing override exists. Emit the Bash command63 directly and proceed without a shell-translation explanation.64- **Switch-terminal recommendation:** Detected PowerShell, but the user's65 routing rules say this repo should run inside WSL. Recommend switching to the66 WSL terminal instead of emitting a wrapped `wsl ... bash -lc` command.67- **Config-aware warning:** Detected shell and repo expectations disagree, and68 the user's env config says to warn rather than switch automatically. State the69 mismatch and give the safe next step only.7071## Output Pattern7273When environment choice matters, report:7475```text76Detected shell: <detected>77OS: <os family>78Execution strategy: <direct / switch terminal / use project runner>79Reason: <brief explanation>80```8182When the environment is obvious and no guidance is needed, proceed silently.8384## Safety Rules8586- Never emit commands in the wrong shell syntax87- Never assume a specific shell without detecting it88- Never prefix commands with shell wrappers unless the user's routing rules explicitly call for it89- Never invent runner scripts that do not exist in the project90- Never mix path syntaxes across shell families9192## Do Nots9394- Do not reopen the question of which shell to target after detection and95 routing rules already resolved it.96- Do not treat `wsl`, `bash -lc`, or similar wrapper patterns as the default97 answer when a native-shell or switch-terminal path is available.98- Do not emit a "detected environment" report when the environment is obvious99 and no decision changes.100101## Closed Decisions102103- Detection comes before command emission. Environment routing is not optional.104- User or project `env.config.md` rules are authoritative when present.105- Prefer direct native-shell execution or explicit terminal switching over106 wrapper-style bridging.107- This skill owns detection and routing logic; prompts should reference it108 rather than re-deriving shell policy inline.109110## Relationship to Other Assets111112- Put always-on routing rules in the `execution-environment.instructions.md` instruction113- Put the detection protocol in this skill114- Let prompts reference this skill instead of re-explaining shell logic115- User-specific routing rules live in `env.config.md` (not in this skill)