jpskill.com
🛠️ 開発・MCP コミュニティ

chalk-advanced

Chalkを使ってターミナルの出力をスタイリングし、CLIの色付け、ログメッセージの整形、ターミナルUIの構築、開発者ツールでの色付き出力などを実現するSkill。

📜 元の英語説明(参考)

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.

🇯🇵 日本人クリエイター向け解説

一言でいうと

Chalkを使ってターミナルの出力をスタイリングし、CLIの色付け、ログメッセージの整形、ターミナルUIの構築、開発者ツールでの色付き出力などを実現するSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o chalk-advanced.zip https://jpskill.com/download/14730.zip && unzip -o chalk-advanced.zip && rm chalk-advanced.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/14730.zip -OutFile "$d\chalk-advanced.zip"; Expand-Archive "$d\chalk-advanced.zip" -DestinationPath $d -Force; ri "$d\chalk-advanced.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して chalk-advanced.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → chalk-advanced フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
1

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

Chalk

概要

Chalk は、ターミナルの文字列に色、太字、下線、背景などのスタイルを適用します。v5 以降は ESM のみです。スタイルは流れるようにチェーンできます。ステータスメッセージ、エラー、フォーマットされた出力のために CLI で広く使用されています。

手順

ステップ 1: 基本的なスタイリング

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)'))

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

ステップ 2: 組み合わせ可能なスタイル

// 再利用可能なスタイルを定義します
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`)

ステップ 3: CLI 出力のフォーマット

// テーブルのような出力
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 })

ガイドライン

  • Chalk v5+ は ESM のみです。require ではなく import chalk from 'chalk' を使用してください。
  • Chalk は NO_COLOR および FORCE_COLOR 環境変数を自動的に尊重します。
  • メソッドチェーン: chalk.red.bold.underline('text') — 順序は関係ありません。
  • テンプレートリテラルを使用してください: chalk`{red Error:} {bold ${message}}`
  • 複雑なターミナル UI の場合は、ora (スピナー) および cli-table3 (テーブル) と組み合わせてください。
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

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).