All free skills / Other majors
supports-color 11.x
Use supports-color 11.0.0 to detect terminal color capability in Node.js scripts, including stdout/stderr detection and custom stream detection.
- For
supports-color@11.0.0- Verified
- 2026-09-08, 3 examples executed
- Skill package
@modootoday/pmcp-supports-color@11.0.0
Use this skill for free
No PMCP login or subscription is required. Download the original instructions, or install the content-only archive with your project's package manager.
Download SKILL.md · Download package archive
npm install --save-dev https://pmcp.build/skills/supports-color/11/package.tgz
PMCP discovers the installed package's instructions. Connect your runtime after installation.
Archive integrity
sha512-WKyZMMQbDunwrjQYazR4z+EV3y1vpTS8MbWo9d2zTZ+EUfOGVQM8tDk7nZilS1v/cCWXpxv74000u5cjR/6ZQA==Complete instructions
Verified against supports-color@11.0.0 on 2026-09-08. 3 of 3 examples executed.
supports-color 11.0.0
Runtime and module shape
- Version 11 requires Node.js
>=22. - The package is ESM. Import it with
import, not CommonJSrequire. - The default export is an object with
stdoutandstderrproperties. Each property is either aColorSupportobject orfalse. - Do not use the older assumption that the default export itself is a color-support object. Check
supportsColor.stdoutorsupportsColor.stderrfirst.
import assert from 'node:assert/strict';
import supportsColor from 'supports-color';
assert.equal(typeof supportsColor, 'object');
assert.ok('stdout' in supportsColor);
assert.ok('stderr' in supportsColor);
for (const streamSupport of [supportsColor.stdout, supportsColor.stderr]) {
if (streamSupport !== false) {
assert.ok([1, 2, 3].includes(streamSupport.level));
assert.equal(streamSupport.hasBasic, streamSupport.level >= 1);
assert.equal(streamSupport.has256, streamSupport.level >= 2);
assert.equal(streamSupport.has16m, streamSupport.level >= 3);
}
}
Reading capability levels
A truthy color-support object has these properties:
level: 1means basic ANSI color support, including 16 colors.level: 2means 256-color support.level: 3means 16-million-color Truecolor support.hasBasic,has256, andhas16mare boolean convenience properties corresponding to those levels.
Always guard a stream result before reading its properties, because it can be false.
import assert from 'node:assert/strict';
import supportsColor from 'supports-color';
const stdout = supportsColor.stdout;
if (stdout) {
assert.equal(typeof stdout.level, 'number');
assert.equal(typeof stdout.hasBasic, 'boolean');
assert.equal(typeof stdout.has256, 'boolean');
assert.equal(typeof stdout.has16m, 'boolean');
if (stdout.level >= 3) {
assert.equal(stdout.has16m, true);
}
}
Custom stream detection
The named programmatic API is createSupportsColor (plural):
import {createSupportsColor} from 'supports-color';
The README prose for this release incorrectly calls it createSupportColor (singular). The singular spelling is not the declaration or implementation export.
Its signature is:
createSupportsColor(stream?: WriteStream, options?: {readonly sniffFlags?: boolean}): ColorSupport | false
Pass a Node WriteStream, such as process.stdout, when detecting a specific stream. sniffFlags defaults to true; set it to false when process.argv color flags must not affect the result.
import assert from 'node:assert/strict';
import {createSupportsColor} from 'supports-color';
const detected = createSupportsColor(process.stdout, {sniffFlags: false});
if (detected !== false) {
assert.ok([1, 2, 3].includes(detected.level));
assert.equal(typeof detected.hasBasic, 'boolean');
assert.equal(typeof detected.has256, 'boolean');
assert.equal(typeof detected.has16m, 'boolean');
}
Environment and command-line controls
Detection considers runtime inputs:
--colorenables color.--no-colordisables color.--color=256requests level 2.--color=16mrequests level 3.FORCE_COLOR=0,1,2,3, ortrueaffects detection.- In v11, a numeric
FORCE_COLORis treated as an exact color-support level.
These values are process context, not a separate runner API. If using createSupportsColor, set sniffFlags: false to prevent process.argv color flags from being considered.
Browser condition
The package exports Node or browser code conditionally. In Node, use the Node entry for stream detection. The browser entry exposes stdout and stderr based on navigator/Chromium user-agent data and does not expose createSupportsColor; it cannot replace Node stream detection.
Does not cover
This skill does not cover the internal terminal/platform heuristics, the exact precedence among every environment and command-line input, browser user-agent detection details, or integrating the result with a particular color-output library.