design-cli-output
정보
이 스킬은 개발자가 CLI 도구의 터미널 출력을 설계할 때 chalk 색상, 유니코드 글리프, 다양한 상세도 수준(일반, 상세, 간소, JSON)과 같은 기능을 활용할 수 있도록 돕습니다. 색상 팔레트, 상태 표시기, 리포터 아키텍처, 그리고 다양한 터미널 간 호환성 보장에 대한 지침을 제공합니다. 새로운 CLI 리포터를 구축하거나, 기존 도구에 서술형 출력을 추가하거나, 여러 명령어 간 출력을 표준화할 때 사용하세요.
빠른 설치
Claude Code
추천npx skills add pjt222/agent-almanac -a claude-code/plugin add https://github.com/pjt222/agent-almanacgit clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/design-cli-outputClaude Code에서 이 명령을 복사하여 붙여넣어 스킬을 설치하세요
문서
Design CLI Output
Design consistent, multi-level terminal output for a command-line tool.
When to Use
- Building a new reporter module for a CLI tool
- Adding warm or narrative output alongside standard transactional output
- Standardizing output format across multiple commands
- Designing JSON machine output parallel to human-readable output
- Choosing colors, glyphs, and verbosity levels for a new terminal tool
Inputs
- Required: CLI tool name and primary audience (developers, operators, end users)
- Required: Commands that need output formatting
- Optional: Whether a "ceremony" or narrative output variant is desired
- Optional: Branding constraints (color palette, tone)
Procedure
Step 1: Define the Color Palette
Use chalk to create a named palette object:
Standard palette (transactional output):
let chalk;
try { chalk = (await import('chalk')).default; }
catch { chalk = new Proxy({}, { get: () => (s) => s }); }
// Status colors
const ok = chalk.green; // success
const fail = chalk.red; // errors
const warn = chalk.yellow; // warnings
const info = chalk.cyan; // identifiers, names
const dim = chalk.dim; // secondary info, paths
const bold = chalk.bold; // headers
Warm palette (ceremony/narrative output):
const C = {
flame: chalk.hex('#FF6B35'), // active elements, fire
amber: chalk.hex('#FFB347'), // arriving items, warm highlights
spark: chalk.hex('#FFF4E0'), // individual items (sparks/skills)
ember: chalk.hex('#8B4513'), // cold/dormant states
warm: chalk.hex('#D4A574'), // neutral warm text
dim: chalk.dim, // background, secondary
fail: chalk.red, // errors stay red (honest)
};
Palette design rules:
- Always provide a no-color fallback (the Proxy pattern above)
- Use hex colors for custom palettes (
chalk.hex('#FF6B35')) - Keep the fail/error color red regardless of palette theme
- Name palette entries by semantic role, not visual appearance
Got: A palette object with named entries and a no-color fallback.
If fail: If chalk is unavailable (piped output, CI), the Proxy fallback returns strings unchanged. Test with NO_COLOR=1 environment variable.
Step 2: Choose Status Indicators
Select Unicode glyphs or ASCII characters for status communication:
ASCII (maximum compatibility):
+ created/installed (green)
- removed/deleted (red)
= skipped/unchanged (dim)
! error/warning (red)
Unicode (richer, needs UTF-8 terminal):
✦ item/skill/practice (spark)
◉ active/burning state
◎ cooling/embers state
○ cold/dormant state
◌ available/not installed
✗ failed item
✓ success (use sparingly — not all terminals render it well)
Selection criteria:
- ASCII for tools that run in CI or piped contexts
- Unicode for tools with interactive terminal users
- Offer both via a
--asciiflag orNO_COLORdetection - Test glyphs in: macOS Terminal, Windows Terminal, VS Code terminal, SSH sessions
Got: A glyph set that communicates status at a glance without relying on color alone.
If fail: If a glyph renders as ? or a box in testing, replace with the ASCII equivalent. The +/-/=/! set works everywhere.
Step 3: Design Verbosity Levels
Every command should support four output levels:
| Level | Flag | Audience | Content |
|---|---|---|---|
| Default | (none) | Human at terminal | Formatted, colored, informative |
| Verbose | --verbose or --ceremonial | Human wanting detail | Per-item breakdown, arrival sequences |
| Quiet | --quiet | Scripts, CI | Minimal lines, status icons, no decoration |
| JSON | --json | Machine consumers | Structured, parseable, complete |
Implementation pattern:
function output(data, options) {
if (options.json) {
console.log(JSON.stringify(data, null, 2));
return;
}
if (options.quiet) {
for (const item of data.items) {
const icon = item.ok ? '+' : '!';
console.log(`${icon} ${item.id}`);
}
return;
}
// Default (or verbose) human output
printFormatted(data, { verbose: options.verbose });
}
JSON output rules:
- Always valid JSON (no mixing with human text)
- Include all data the human output shows, plus machine-useful fields
- Use consistent key naming across commands
- Exit code 0 for success, 1 for errors (regardless of output mode)
Got: Four clear output levels with consistent behavior across commands.
If fail: If verbose mode is too noisy, make it opt-in (--ceremonial) rather than a graduated verbosity level.
Step 4: Establish Voice Rules
Define the tone and style that all output functions follow. This prevents inconsistency across commands.
Example voice rules (from the campfire reporter):
- Present tense, active voice: "mystic arrives" not "mystic has been installed"
- No exclamation marks: Quiet confidence. The tool doesn't shout.
- Metaphor replaces jargon: "practices" not "dependencies" (only for ceremony mode)
- Failures are honest, not catastrophic: "A spark was lost" not "ERROR: installation failed with exit code 1"
- Closing line reflects state: Every operation ends with a status summary
- No emoji: Unicode glyphs carry visual weight without being decorative
- Every word carries information: If a word doesn't add understanding, remove it
Voice rules for standard (non-ceremony) output:
- Concise, factual lines
- Status icon + item ID + context
- Summary line with counts
- Error messages suggest corrective actions
Got: A written set of 3-7 voice rules that output functions must follow.
If fail: If rules feel arbitrary, test them: write the same output with and without each rule. If removing a rule doesn't change the output quality, the rule isn't needed.
Step 5: Implement Reporter Functions
Organize output into a reporter module with focused functions:
// reporter.js — standard output
export function printResults(results) { ... }
export function printItemTable(items) { ... }
export function printDetections(detections) { ... }
export function printAudit(auditResults) { ... }
export function printDryRun() { ... }
export function warn(msg) { ... }
export function error(msg) { ... }
export { chalk };
Each function follows the same structure:
- Handle empty/null input gracefully
- Compute layout (column widths, padding)
- Output with palette colors
- Summary line at the bottom
For ceremony output, create a separate module:
// campfire-reporter.js — warm narrative output
export function printArrival({ teamId, agents, results, ceremonial }) { ... }
export function printScatter({ teamId, agents, results }) { ... }
export function printTend(fires) { ... }
export function printCampfireList({ teams, state, reg }) { ... }
export function printFireSummary({ team, fireData, reg }) { ... }
export function printJson(data) { ... }
Got: Reporter functions that are independently usable — each handles its own formatting without depending on caller state.
If fail: If functions grow beyond ~50 lines, extract helpers. A reporter function should be easy to review in isolation.
Step 6: Test Output Across Environments
Verify output renders correctly in different contexts:
# With colors (interactive terminal)
node cli/index.js list --domains
# Without colors (piped)
node cli/index.js list --domains | cat
# With NO_COLOR environment variable
NO_COLOR=1 node cli/index.js list --domains
# JSON mode (parseable)
node cli/index.js campfire --json | jq .
# In CI (typically no TTY)
CI=true node cli/index.js audit
Check for:
- Colors display correctly in interactive mode
- No ANSI escape codes leak into piped/redirected output
- JSON is valid (pipe to
jq .to verify) - Unicode glyphs render in the target terminals
- Column alignment holds with varying content widths
Got: Output is correct in all five contexts.
If fail: If ANSI codes leak, ensure chalk respects NO_COLOR. If Unicode breaks, provide an ASCII fallback mode.
Validation
- Color palette has a no-color fallback
- Status indicators work in both color and no-color modes
- All four verbosity levels produce useful output
- JSON output is valid and parseable by
jq - Voice rules are documented and followed consistently
- Reporter functions handle empty/null input gracefully
- Output tested in: terminal, piped, NO_COLOR, CI
Pitfalls
- Mixing human text with JSON: In
--jsonmode, output only valid JSON. A single stray line (like "DRY RUN") breaks JSON parsers. If the command must show both, separate them clearly or suppress the human text in JSON mode. - Hardcoded column widths: Content length varies. Use
Math.max(...items.map(i => i.id.length))to compute padding dynamically. - Color without meaning: If color is the only way to distinguish success from failure, colorblind users and piped output lose information. Always pair color with a text indicator (
+,OK,ERR). - Ceremony in the wrong context: Warm narrative output is appropriate for interactive terminal sessions. In CI, scripts, or
--quietmode, it adds noise. Gate ceremony output behind explicit flags. - Forgetting the summary line: Users scan the last line first. Every operation should end with a one-line summary (counts of success/failure/skipped).
Related Skills
scaffold-cli-command— the commands that use this outputtest-cli-application— testing that output matches expectationsbuild-cli-plugin— plugins report results through this output system
GitHub 저장소
연관 스킬
content-collections
메타이 스킬은 콘텐츠 콜렉션(Content Collections)을 위한 프로덕션 검증된 설정을 제공합니다. 콘텐츠 콜렉션은 Markdown/MDX 파일을 Zod 검증이 포함된 타입 안전한 데이터 콜렉션으로 변환해주는 TypeScript 최우선 도구입니다. 블로그, 문서 사이트 또는 콘텐츠 중심의 Vite + React 애플리케이션을 구축할 때 타입 안전성과 자동 콘텐츠 검증을 보장하기 위해 사용하세요. Vite 플러그인 구성과 MDX 컴파일부터 배포 최적화 및 스키마 검증에 이르기까지 모든 것을 다룹니다.
polymarket
메타이 스킬은 개발자들이 Polymarket 예측 시장 플랫폼을 활용한 애플리케이션을 구축할 수 있도록 지원하며, 거래 및 시장 데이터를 위한 API 통합 기능을 포함합니다. 또한 WebSocket을 통한 실시간 데이터 스트리밍을 제공하여 실시간 거래와 시장 활동을 모니터링할 수 있습니다. 이를 통해 거래 전략을 구현하거나 실시간 시장 업데이트를 처리하는 도구를 생성하는 데 활용할 수 있습니다.
creating-opencode-plugins
메타이 스킬은 개발자들이 명령어, 파일, LSP 작업 등 25개 이상의 이벤트 유형에 연결되는 OpenCode 플러그인을 만들 수 있도록 돕습니다. JavaScript/TypeScript 모듈을 위한 플러그인 구조, 이벤트 API 명세, 구현 패턴을 제공합니다. OpenCode AI 어시스턴트의 라이프사이클을 사용자 정의 이벤트 기반 로직으로 가로채거나, 모니터링하거나, 확장해야 할 때 사용하세요.
sglang
메타SGLang은 RadixAttention 프리픽스 캐싱을 활용하여 JSON, 정규식, 에이전트 워크플로우를 위한 고속 구조화 생성에 특화된 고성능 LLM 서빙 프레임워크입니다. 특히 반복되는 프리픽스가 있는 작업에서 상당히 빠른 추론 속도를 제공하여 복잡한 구조화 출력 및 다중 턴 대화에 이상적입니다. 제약 디코딩이 필요하거나 광범위한 프리픽스 공유가 있는 애플리케이션을 구축할 때는 vLLM과 같은 대안보다 SGLang을 선택하십시오.
