Verified 2026-08-05 What was checked, and when — not a guarantee it is still true.
A naive environment-variable check false-negatives in exactly the configuration that matters most, because the part of your skill that runs shell commands runs somewhere with none of those markers set. Use an ordered recipe instead: check the environment marker, then the working-directory signature, then the CLI marker. For behaviour rather than reporting, branch on which tools exist — that is the most durable signal available to a skill.
The tool surface is the most durable runtime signal available to a skill: it is what actually determines what the skill can do, it is visible without a shell, and it stays correct when environment markers are added or removed. Use environment detection to report where you are; use capability detection to decide what to do.
Measured Can change without a version bump
Markers are set by the host at spawn time and have been added and removed across releases. A detection routine that treats one missing variable as proof of a runtime will be wrong the next time the spawn contract changes. Order the checks so each one only adds coverage.
A skill spans two execution contexts. The part that runs shell commands runs in a sealed context with none of the usual markers set, so a bare environment check returns 'not Cowork' in precisely the production configuration you most needed to detect. The failure is silent and produces confidently wrong behaviour.
Check the Cowork environment marker first; if it is set you are in Cowork. Otherwise check whether the working directory matches the session-path signature, which catches the case where your skill's shell commands run somewhere the marker is absent. Otherwise check the CLI's own marker. Each step only adds coverage — a later one never contradicts an earlier one.
Part of a skill runs where the agent runs; the shell commands it issues run somewhere else with a different environment and a different filesystem view. A check performed in one tells you little about the other, which is why a single probe gives confident wrong answers.