Skip to content
OpenSmartRoute
Skillv1.0.0

chalk-advanced

Style terminal output with Chalk. Use when adding colors to CLI output, formatting log messages, building styled terminal UIs, or creating developer tools with colored output.

by terminalskills(0) 0 installs
Free
Sign in to install

Free account. Installing gives you the manifest plus copy-paste snippets.

See reviews

About

Imported from terminalskills/skills (skills/chalk-advanced/SKILL.md). Install upstream with npx skills add terminalskills/skills --skill chalk-advanced. Copyright stays with the author (Apache-2.0).

Chalk

Overview

Chalk styles terminal strings with colors, bold, underline, and backgrounds. ESM-only since v5. Chain styles fluently. Widely used in CLIs for status messages, errors, and formatted output.

Instructions

Step 1: Basic Styling

import chalk from 'chalk'

console.log(chalk.green('✓ Success'))
console.log(chalk.red.bold('✗ Error: file not found'))
console.log(chalk.yellow('⚠ Warning: deprecated API'))
console.log(chalk.blue.underline('https://example.com'))
console.log(chalk.gray('  (verbose details)'))

// Background colors
console.log(chalk.bgRed.white.bold(' ERROR ') + ' Something went wrong')
console.log(chalk.bgGreen.black.bold(' PASS ') + ' All tests passed')

Step 2: Composable Styles

// Define reusable styles
const styles = {
  error: chalk.red.bold,
  success: chalk.green,
  warn: chalk.yellow,
  info: chalk.blue,
  dim: chalk.gray,
  highlight: chalk.cyan.bold,
  label: chalk.bgBlue.white.bold,
}

function log(level: keyof typeof styles, msg: string) {
  const prefix = {
    error: '✗', success: '✓', warn: '⚠', info: 'ℹ', dim: '·', highlight: '→',
  }
  console.log(`${styles[level](prefix[level] || '·')} ${msg}`)
}

log('success', 'Project created')
log('error', 'Build failed')
log('info', `Using ${styles.highlight('TypeScript')} template`)

Step 3: CLI Output Formatting

// Table-like output
function printStats(stats: Record<string, number>) {
  const maxKey = Math.max(...Object.keys(stats).map(k => k.length))
  for (const [key, value] of Object.entries(stats)) {
    const label = chalk.gray(key.padEnd(maxKey))
    const val = value > 0 ? chalk.green(value.toString()) : chalk.red(value.toString())
    console.log(`  ${label}  ${val}`)
  }
}

printStats({ 'Files changed': 12, 'Lines added': 847, 'Lines removed': 231, Warnings: 0, Errors: 0 })

Guidelines

  • Chalk v5+ is ESM-only. Use import chalk from 'chalk', not require.
  • Chalk respects NO_COLOR and FORCE_COLOR env vars automatically.
  • Chain methods: chalk.red.bold.underline('text') — order doesn't matter.
  • Use template literals: chalk`{red Error:} {bold ${message}}`
  • For complex terminal UIs, combine with ora (spinners) and cli-table3 (tables).

Use it

Copy one of these into your project. Installing also returns the manifest and these snippets.

yaml
targets:
  - https://api.opensmartroute.ai/api/v1/registry/terminalskills-skills-chalk-advanced/manifest   # or paste the manifest below

Manifest

An Open Capability Manifest: the router reads it to know what this does, what it costs and when to pick it.

terminalskills-skills-chalk-advanced.ocm.jsonjson
{
  "ocm": "1",
  "id": "terminalskills-skills-chalk-advanced",
  "kind": "skill",
  "name": "chalk-advanced",
  "description": "Style terminal output with Chalk. Use when adding colors to CLI output, formatting log messages, building styled terminal UIs, or creating developer tools with colored output.",
  "publisher": "terminalskills",
  "version": "1.0.0",
  "capabilities": {
    "domains": [
      "general"
    ],
    "tags": [
      "skill-md",
      "chalk",
      "cli",
      "terminal",
      "colors",
      "formatting",
      "skills-sh"
    ],
    "languages": [
      "en"
    ]
  },
  "quality_prior": 0.6,
  "examples": [
    "Style terminal output with Chalk. Use when adding colors to CLI output, formatting log messages, building styled terminal UIs, or creating developer tools with colored output."
  ],
  "primary": false,
  "metadata": {
    "source": {
      "provider": "skills.sh",
      "repository": "https://github.com/terminalskills/skills",
      "path": "skills/chalk-advanced/SKILL.md",
      "ref": "HEAD",
      "url": "https://github.com/terminalskills/skills/blob/HEAD/skills/chalk-advanced/SKILL.md",
      "key": "terminalskills/skills/skills/chalk-advanced/SKILL.md"
    },
    "compatibility": "Node.js 16+",
    "license": "Apache-2.0"
  },
  "instructions": "# Chalk\n\n## Overview\n\nChalk styles terminal strings with colors, bold, underline, and backgrounds. ESM-only since v5. Chain styles fluently. Widely used in CLIs for status messages, errors, and formatted output.\n\n## Instructions\n\n### Step 1: Basic Styling\n\n```typescript\nimport chalk from 'chalk'\n\nconsole.log(chalk.green('✓ Success'))\nconsole.log(chalk.red.bold('✗ Error: file not found'))\nconsole.log(chalk.yellow('⚠ Warning: deprecated API'))\nconsole.log(chalk.blue.underline('https://example.com'))\nconsole.log(chalk.gray('  (verbose details)'))\n\n// Background colors\nconsole.log(chalk.bgRed.whit",
  "cost": {
    "context_tokens": 563
  }
}

Fetch it by URL: GET /api/v1/registry/terminalskills-skills-chalk-advanced/manifest?version=1.0.0

Reviews

Star ratings from people who tried it. One review per account; edit yours any time.

No reviews yet. Install it, try it, and be the first to rate it.