Skip to content

feat: enable automatic prefix colors by default#581

Open
GermanJablo wants to merge 3 commits intoopen-cli-tools:mainfrom
GermanJablo:feat-default-prefix-colors
Open

feat: enable automatic prefix colors by default#581
GermanJablo wants to merge 3 commits intoopen-cli-tools:mainfrom
GermanJablo:feat-default-prefix-colors

Conversation

@GermanJablo
Copy link

@GermanJablo GermanJablo commented Mar 6, 2026

Summary

  • Changes the default --prefix-colors from reset (no colors) to auto, so each command gets a distinct prefix color out of the box.
  • Sets the auto-cycling palette to cyan, magenta, green, yellow, blue.
  • Fixes the logger's colorText fallback to handle non-Chalk values in defaults.prefixColors gracefully.

Motivation

Running concurrently "cmd1" "cmd2" "cmd3" today produces uncolored prefixes — all [0], [1], [2] look the same unless the user explicitly passes -c auto or a color list. Colored prefixes are one of the most useful visual cues when scanning interleaved output, yet they require opting in.

This PR makes colors the default. Users who prefer uncolored output can pass -c reset.

Color choice rationale

The previous ACCEPTABLE_CONSOLE_COLORS list had 16 entries including colors that are problematic as defaults:

  • white / grey blend into the terminal's default text color on most themes, looking effectively uncolored.
  • red is universally associated with errors; using it for normal output creates a false sense of alarm.
  • bg* colors (background-colored text) are visually heavy and distracting for everyday use.

The chosen 5-color palette avoids all of these: each color is clearly distinguishable, reads well on both dark and light backgrounds, and carries no semantic baggage. This is the same set of colors used by turborepo, which served as inspiration for the selection.

Default pool vs allowed colors

ACCEPTABLE_CONSOLE_COLORS controls what auto picks from — it is not a whitelist. Manually specified colors via --prefix-colors remain completely unrestricted: any valid Chalk color name (red, bgCyan, greenBright, …), hex value (#23de43), or modifier (bold, inverse, …) works exactly as before. This distinction is now documented in the source.

Changes

File What changed
lib/defaults.ts prefixColors: 'reset''auto'
lib/prefix-color-selector.ts ACCEPTABLE_CONSOLE_COLORS → 5-color palette with updated JSDoc
lib/logger.ts colorText fallback: ?? this.chalk.reset for safety
lib/prefix-color-selector.spec.ts New test asserting palette matches the expected 5 colors
docs/cli/prefixing.md Updated to describe the new default behavior

Testing

pnpm test -- --run lib/prefix-color-selector.spec.ts

To see the colors locally:

pnpm build && node dist/bin/index.js "echo cmd1" "echo cmd2" "echo cmd3" "echo cmd4" "echo cmd5" "echo cmd6" "echo cmd7"

Commands 6 and 7 cycle back to cyan and magenta. Manual colors still work:

node dist/bin/index.js -c "red,bgCyan,white" "echo a" "echo b" "echo c"

All 583 tests pass (582 existing + 1 new). Lint and type checks clean.

Screenshots to visualize the colors

image

Example from the repo:

image

Verify that ACCEPTABLE_CONSOLE_COLORS follows the same color
sequence used by turborepo: cyan, magenta, green, yellow, blue.
Change the default prefix color from 'reset' (no color) to 'auto',
so that each command gets a distinct color out of the box.

Set ACCEPTABLE_CONSOLE_COLORS to turborepo's 5-color palette
(cyan, magenta, green, yellow, blue) which cycles on repeat.
This list only controls what 'auto' picks from — manually specified
colors (via --prefix-colors) are unrestricted and accept any valid
Chalk color name, hex value, or modifier.
@coveralls
Copy link

coveralls commented Mar 6, 2026

Coverage Status

coverage: 100.0%. remained the same
when pulling 0f12f9b on GermanJablo:feat-default-prefix-colors
into 008b526 on open-cli-tools:main.

Copy link
Member

@gustavohenke gustavohenke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely on board with most changes in this PR.

Change from reset to auto default could be backed by analytics, but we don't have these at the moment.
Still, I'm inclined to accept it as a breaking change, it's just curious how it was never requested before.

Remove turborepo references from JSDoc and test.
Test now validates palette properties (no bg/white/grey/black/red
colors) instead of asserting a specific color list.
@GermanJablo GermanJablo force-pushed the feat-default-prefix-colors branch from 1e4102c to 0f12f9b Compare March 8, 2026 21:31
@GermanJablo GermanJablo requested a review from gustavohenke March 8, 2026 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants