Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

terminal-concepts

БесплатноБез исполняемых скриптовНе проверен

Comprehensive guide for building CLI and TUI applications - terminal internals, design principles, and battle-tested patterns When building CLI/TUI apps…

shepherdjerredот shepherdjerred★ 85 звёзд на GitHub

Об этом скилле

Terminal Concepts for Developers

Overview

This agent provides comprehensive guidance for building and developing terminal applications (CLI tools and TUIs). Learn how terminals work, design principles from proven programs, and practical patterns for creating robust, user-friendly command-line applications.

Philosophy: Focus on timeless concepts and learn from battle-tested programs like git, vim, tmux, less, ripgrep, and fzf.

Target Audience: Developers at all levels building terminal applications in any language.

What Developers Need to Know

Building terminal applications requires understanding several interconnected concepts:

  1. Terminal Fundamentals: How TTYs, PTYs, streams, and buffering work
  2. CLI Design: User-facing interface principles (arguments, output, errors)
  3. TUI Architecture: Interactive full-screen applications
  4. Common Pitfalls: Issues developers face and how to avoid them

Learning from Proven Programs

The best way to understand terminal application design is to study programs that have stood the test of time:

  • git: Consistent subcommand interface, porcelain vs plumbing separation
  • vim: Modal editing, robust state management
  • tmux: Client-server architecture, session management
  • less: Pager pattern, search and navigation
  • ripgrep: Sensible defaults, performance-focused design
  • fzf: Interactive filtering, minimal interface
  • cargo: Clear progress indicators, helpful error messages

Throughout this guide, we'll reference these programs to illustrate concepts.


Part 1: Terminal Fundamentals for Developers

Understanding the Terminal Stack

When you build a terminal application, you're working within a layered system:

┌─────────────────────────────────┐
│   Terminal Emulator             │ ← User sees (renders text, sends input)
│   (iTerm2, Alacritty, etc.)     │
└─────────────────────────────────┘
              ↕ (PTY)
┌─────────────────────────────────┐
│   Shell (bash, zsh, fish)       │ ← Interprets commands
└─────────────────────────────────┘
              ↕ (fork/exec)
┌─────────────────────────────────┐
│   Your Program                  │ ← Your CLI/TUI application
└─────────────────────────────────┘

TTYs and PTYs

TTY (Teletypewriter): Originally physical devices, now refers to the terminal driver in the operating system.

PTY (Pseudo-Terminal): A pair of virtual devices that emulate a TTY:

  • Master side: Terminal emulator reads/writes here
  • Slave side: Your program sees this as stdin/stdout/stderr

Why This Matters for Developers:

  • Your program receives input filtered through the TTY driver
  • Some control characters are intercepted by the OS (Ctrl-C, Ctrl-Z)
  • Buffering behavior differs between TTY and pipes
  • You need to detect if you're running in a TTY vs pipe

Terminal Modes: Cooked vs Raw

Cooked Mode (Canonical Mode):

  • Default mode for most programs
  • OS provides line editing (backspace, Ctrl-U, Ctrl-W)
  • Input delivered to your program line-by-line after Enter
  • Control characters handled by OS (Ctrl-C sends SIGINT)

Raw Mode:

  • Character-by-character input (no line buffering)
  • Your program receives every keypress including Ctrl-C
  • Required for TUIs (vim, less, htop)
  • Your program must implement all input handling

When to Use Each:

  • Cooked mode: Normal CLI tools (git, cargo, npm)
  • Raw mode: Interactive TUIs, line editors

Standard Streams and File Descriptors

Every process has three standard streams:

Stream FD Purpose Examples
stdin 0 Input from user or pipe Reading commands, file content
stdout 1 Primary output Results, listings, JSON
stderr 2 Errors, logs, diagnostics Error messages, warnings, debug

Critical Design Principle: Separate stdout and stderr properly.

Why This Matters:

# User wants to pipe your output
your-tool | jq .         # Only works if output goes to stdout

# User wants to capture errors
your-tool 2> errors.log  # Only works if errors go to stderr

Examples from Proven Programs:

  • git: Errors to stderr, porcelain output to stdout
  • ripgrep: Matches to stdout, warnings to stderr
  • cargo: Build status to stderr, --message-format=json to stdout

Detecting TTY vs Pipe

Your program must detect its output destination to format appropriately:

Concept (language-agnostic):

if isatty(stdout):
    # Human is watching - use colors, progress bars
    enable_colors()
    show_progress()
else:
    # Piped to another program - plain output
    disable_colors()
    no_progress()

Real-world examples:

  • ls --color=auto: Colors only for TTY
  • git status: Full output for TTY, shorter for pipes
  • ripgrep: Colors and summaries for TTY, plain matches for
Полный SKILL.md на GitHub

Установить terminal-concepts в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

references/buffering.mdreferences/cli-design.mdreferences/control-characters.mdreferences/escape-codes.mdreferences/output-and-errors.mdreferences/terminal-fundamentals.mdreferences/tui-development.md

FAQ

Что делает скилл terminal-concepts?

Comprehensive guide for building CLI and TUI applications - terminal internals, design principles, and battle-tested patterns When building CLI/TUI apps, implementing argument parsing, handling terminal input/output, escape codes, buffering, signals, or asking about terminal development concepts

Как установить скилл terminal-concepts?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл terminal-concepts запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить terminal-concepts с