Développement d'interfaces utilisateur terminales

VérifiéSûr

Expert en développement d'interfaces utilisateur terminal, incluant les applications console interactives, les bibliothèques TUI multiplateformes et les mises en page terminal réactives. Utilisez cette compétence pour créer des applications terminal interactives, des tableaux de bord et des outils en ligne de commande avec une interface riche.

Spar Skills Guide Bot
DeveloppementAvancé
02/06/2026
Claude Code
#tui#terminal-ui#command-line#interactive-cli#cross-platform

Recommandé pour

Synthèse automatique

Ce skill permet de développer des interfaces utilisateur en terminal (TUI) interactives, en utilisant des bibliothèques comme Bubbletea, ratatui, Rich ou Textual.

Points forts

  • Couverture large de bibliothèques TUI pour Go, Rust, Python et Node.js.
  • Explications claires des concepts fondamentaux : capacités terminales, systèmes de disposition, composants interactifs.
  • Exemple concret avec Bubbletea en Go illustrant le pattern modèle-vue-mise à jour.

Limites

  • Ne couvre pas la configuration spécifique de chaque plateforme (Windows, macOS, Linux) en profondeur.
  • Les exemples sont limités à Go ; les utilisateurs d'autres langages doivent adapter.
  • Pas de gestion avancée des erreurs ou des cas d'échec typiques.
Quand l'utiliser

Utilisez ce skill pour concevoir des applications terminal riches, des tableaux de bord interactifs ou des assistants en ligne de commande nécessitant une interface structurée.

Quand l'éviter

Évitez ce skill pour des scripts simples ou des CLIs sans interaction utilisateur complexe ; préférez alors des approches de programmation script classique.

Analyse de sécurité

Sûr
Score qualité92/100

The skill provides educational content about TUI development, including library references and code examples. It does not instruct any destructive action, data exfiltration, or execution of arbitrary commands. No tools are declared, and no risky operations are present.

Aucun point d'attention détecté

Comment cette analyse est faite

Exemples

Create a TUI dashboard
Help me build a TUI dashboard in Go using Bubbletea that displays real-time system metrics (CPU, memory, disk) with a refresh rate of 1 second.
Design a responsive terminal layout
How can I create a responsive terminal layout with Flexbox in ratatui (Rust) that adapts when the terminal window is resized?
Build an interactive CLI menu
I need an interactive CLI menu with checkboxes and progress bars using Python's Textual library. Can you provide an example?

name: tui description: Expert terminal user interface development including interactive console applications, cross-platform TUI libraries, and responsive terminal layouts

User Input

$ARGUMENTS

You MUST consider the user input before proceeding (if not empty).

Outline

You are a Terminal User Interface (TUI) expert specializing in interactive console applications, cross-platform terminal libraries, and responsive terminal layouts. Use this skill when the user needs help with:

  • Creating interactive terminal applications
  • Building command-line interfaces with rich UI
  • Implementing terminal-based dashboards and tools
  • Cross-platform TUI development
  • Terminal event handling and input processing
  • Layout management and responsive design in terminals

TUI Libraries and Frameworks

1. Go TUI Libraries

  • Bubbletea: Modern, idiomatic Go TUI framework
  • tview: Rich interactive widgets and flexible layouts
  • tcell: Low-level terminal manipulation library
  • termui: Dashboard and monitoring UI components
  • lipgloss: Styling and colors for terminal applications

2. Rust TUI Libraries

  • ratatui: Modern Rust TUI library (successor to tui-rs)
  • crossterm: Cross-platform terminal handling
  • tui-rs: Original terminal UI library
  • iced: GUI and TUI hybrid framework

3. Python TUI Libraries

  • Rich: Rich text and beautiful formatting
  • Textual: Modern TUI framework for Python
  • curses: Traditional terminal interface library
  • urwid: Flexible console UI library

4. Node.js TUI Libraries

  • Inquirer.js: Interactive command-line prompts
  • Blessed: Terminal interface library
  • ink: React for CLIs
  • oclif: CLI framework with rich output

Core TUI Concepts

1. Terminal Capabilities

  • Screen size detection: Handle resizing and variable dimensions
  • Color support: ANSI colors, 256-color, RGB
  • Input handling: Keyboard, mouse, clipboard events
  • Cross-platform: Windows (cmd/PowerShell), macOS (Terminal.app), Linux (xterm/gnome-terminal)
  • Performance: Efficient rendering and event loops

2. Layout Systems

  • Grid layouts: CSS Grid-like arrangements
  • Flexbox: Flexible box layouts
  • Absolute positioning: Precise coordinate placement
  • Responsive design: Adaptive layouts for different terminal sizes
  • Scrolling: Viewports and content pagination

3. Interactive Components

  • Menus and navigation: Keyboard-driven interfaces
  • Forms and input: Text fields, checkboxes, radio buttons
  • Tables and lists: Sortable, filterable data displays
  • Progress indicators: Bars, spinners, status displays
  • Dialogs: Modals, confirmations, notifications

TUI Development Patterns

Bubbletea (Go) Example

package main

import (
    "fmt"
    "strings"
    tea "github.com/charmbracelet/bubbletea"
    "github.com/charmbracelet/lipgloss"
)

type model struct {
    choices []string
    cursor  int
    selected string
}

func initialModel() model {
    return model{
        choices: []string{"Option 1", "Option 2", "Option 3"},
        cursor:  0,
    }
}

func (m model) Init() tea.Cmd {
    return nil
}

func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
    switch msg := msg.(type) {
    case tea.KeyMsg:
        switch msg.Type {
        case tea.KeyUp:
            if m.cursor > 0 {
                m.cursor--
            }
        case tea.KeyDown:
            if m.cursor < len(m.choices)-1 {
                m.cursor++
            }
        case tea.KeyEnter:
            m.selected = m.choices[m.cursor]
            return m, tea.Quit
        }
    }
    return m, nil
}

func (m model) View() string {
    s := strings.Builder{}
    s.WriteString("What should we buy at the market?\n\n")

    for i, choice := range m.choices {
        cursor := " "
        if m.cursor == i {
            cursor = ">"
        }
        s.WriteString(fmt.Sprintf("%s %s\n", cursor, choice))
    }

    s.WriteString("\nPress q to quit.\n")
    return s.String()
}

func main() {
    p := tea.NewProgram(initialModel())
    if _, err := p.Run(); err != nil {
        fmt.Printf("Alas, there's been an error: %v", err)
    }
}

Ratatui (Rust) Example

use ratatui::{
    backend::CrosstermBackend,
    layout::{Constraint, Direction, Layout},
    style::{Color, Modifier, Style},
    text::Span,
    widgets::{Block, Borders, List, ListItem, Paragraph},
    Terminal,
};

struct App {
    items: Vec<String>,
    selected: usize,
}

impl App {
    fn new() -> Self {
        Self {
            items: vec![
                "Item 1".to_string(),
                "Item 2".to_string(),
                "Item 3".to_string(),
            ],
            selected: 0,
        }
    }

    fn next(&mut self) {
        self.selected = (self.selected + 1) % self.items.len();
    }

    fn previous(&mut self) {
        self.selected = if self.selected > 0 {
            self.selected - 1
        } else {
            self.items.len() - 1
        };
    }
}

fn ui(f: &mut Frame, app: &App) {
    let chunks = Layout::default()
        .direction(Direction::Vertical)
        .margin(1)
        .constraints(
            [
                Constraint::Percentage(50),
                Constraint::Percentage(50),
            ]
            .as_ref(),
        )
        .split(f.size());

    let items: Vec<ListItem> = app
        .items
        .iter()
        .enumerate()
        .map(|(i, item)| {
            let style = if i == app.selected {
                Style::default().bg(Color::LightBlue)
            } else {
                Style::default()
            };
            ListItem::new(Span::styled(item.as_str(), style))
        })
        .collect();

    let list = List::new(items)
        .block(Block::default().borders(Borders::ALL).title("List"));
    f.render_widget(list, chunks[0]);

    let paragraph = Paragraph::new(format!("Selected item: {}", app.items[app.selected]))
        .block(Block::default().borders(Borders::ALL).title("Details"));
    f.render_widget(paragraph, chunks[1]);
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let stdout = io::stdout();
    let backend = CrosstermBackend::new(stdout, TerminalOptions::default())?;
    let mut terminal = Terminal::new(backend)?;
    
    let mut app = App::new();
    
    loop {
        terminal.draw(|f| ui(f, &app))?;
        
        if let Event::Key(key) = event::read()? {
            match key {
                KeyEvent::Left => app.previous(),
                KeyEvent::Right => app.next(),
                KeyEvent::Char('q') => break,
                _ => {}
            }
        }
    }
    
    Ok(())
}

Rich (Python) Example

from rich.console import Console
from rich.layout import Layout
from rich.panel import Panel
from rich.table import Table
from rich.progress import Progress, SpinnerColumn, TextColumn

console = Console()

# Create a layout
layout = Layout()
layout.split_column(
    Layout(name="header", size=3),
    Layout(name="main"),
    Layout(name="footer", size=3)
)

# Create a table
table = Table(title="Projects")
table.add_column("ID", style="cyan", no_wrap=True)
table.add_column("Name", style="magenta")
table.add_column("Status", style="green")

table.add_row("1", "Project Alpha", "Active")
table.add_row("2", "Project Beta", "Complete")

# Main loop
with console.screen() as screen:
    while True:
        layout["header"].update(Panel("Dashboard", style="bold blue"))
        layout["main"].update(Panel(table))
        layout["footer"].update(Panel("Press 'q' to quit"))
        
        console.print(layout)
        
        # Handle input (simplified)
        if console.input("Continue? (y/n): ").lower() == 'n':
            break

Input Handling Patterns

Cross-Platform Input Events

// Go with Bubbletea - platform-abstracted
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
    switch msg := msg.(type) {
    case tea.KeyMsg:
        switch msg.Type {
        case tea.KeyCtrlC:
            return m, tea.Quit
        case tea.KeyUp, tea.KeyCtrlP:
            // Up arrow or Ctrl+P
            if m.cursor > 0 {
                m.cursor--
            }
        case tea.KeyDown, tea.KeyCtrlN:
            // Down arrow or Ctrl+N
            if m.cursor < len(m.items)-1 {
                m.cursor++
            }
        case tea.KeyEnter:
            m.selected = m.items[m.cursor]
        }
    case tea.WindowSizeMsg:
        m.width = msg.Width
        m.height = msg.Height
    }
    return m, nil
}

Complex Input Handling

// Rust with crossterm
use crossterm::{
    event::{self, Event, KeyCode, KeyEvent},
    execute,
    terminal::{disable_raw_mode, enable_raw_mode},
};

fn handle_input() -> Result<(), Box<dyn std::error::Error>> {
    enable_raw_mode()?;
    
    loop {
        match event::read()? {
            Event::Key(KeyEvent { code, .. }) => match code {
                KeyCode::Char('q') => break,
                KeyCode::Up => handle_up(),
                KeyCode::Down => handle_down(),
                KeyCode::Enter => handle_select(),
                KeyCode::Esc => handle_escape(),
                _ => {}
            },
            Event::Resize(_, _) => redraw_ui(),
            Event::Mouse(_) => handle_mouse_event(),
        }
    }
    
    disable_raw_mode()?;
    Ok(())
}

Layout and Responsive Design

Responsive Layout Algorithm

type LayoutConstraints struct {
    MinWidth  int
    MaxWidth  int
    MinHeight int
    MaxHeight int
}

func calculateLayout(termWidth, termHeight int, items []Widget) []Rect {
    var layout []Rect
    
    // Simple responsive grid
    cols := max(1, termWidth/40) // Minimum 40 chars per column
    rows := (len(items) + cols - 1) / cols
    
    itemWidth := termWidth / cols
    itemHeight := termHeight / rows
    
    for i, item := range items {
        row := i / cols
        col := i % cols
        
        x := col * itemWidth
        y := row * itemHeight
        
        layout = append(layout, Rect{
            X: x, Y: y,
            Width: itemWidth, Height: itemHeight,
        })
    }
    
    return layout
}

Adaptive Component Layout

struct ResponsiveLayout {
    layouts: HashMap<TerminalSize, Layout>,
    current: Layout,
}

impl ResponsiveLayout {
    fn update_for_size(&mut self, size: TerminalSize) {
        self.current = self.layouts
            .get(&size)
            .unwrap_or_else(|| self.calculate_adaptive_layout(size))
    }
    
    fn calculate_adaptive_layout(&self, size: TerminalSize) -> Layout {
        if size.width < 80 {
            // Mobile-style vertical layout
            self.vertical_layout()
        } else if size.width < 120 {
            // Tablet-style mixed layout
            self.mixed_layout()
        } else {
            // Desktop-style horizontal layout
            self.horizontal_layout()
        }
    }
}

When to Use This Skill

Use this skill when you need to:

  • Create interactive terminal applications
  • Build command-line tools with rich user interfaces
  • Design terminal dashboards and monitoring tools
  • Implement cross-platform console applications
  • Handle complex user input in terminals
  • Create responsive terminal layouts
  • Build interactive system administration tools
  • Develop terminal-based productivity applications

Best Practices

1. Performance

  • Use efficient rendering (double buffering, differential updates)
  • Minimize redraws and optimize event loops
  • Handle large datasets with virtual scrolling

2. Accessibility

  • Provide keyboard navigation for all interactions
  • Support high contrast and color-blind friendly themes
  • Include clear visual indicators and status messages

3. Cross-Platform Compatibility

  • Test on Windows, macOS, and Linux terminals
  • Handle different terminal capabilities gracefully
  • Provide fallbacks for limited terminal features

4. User Experience

  • Include help text and keyboard shortcuts
  • Provide progress indicators for long operations
  • Implement undo/redo where appropriate
  • Save and restore application state

Testing TUI Applications

Unit Testing Components

func TestModelUpdate(t *testing.T) {
    tests := []struct {
        name     string
        model    model
        msg       tea.Msg
        expected  model
    }{
        {
            name:     "cursor up from first item",
            model:    model{cursor: 0, items: []string{"a", "b"}},
            msg:       tea.KeyMsg{Type: tea.KeyUp},
            expected:  model{cursor: 0, items: []string{"a", "b"}}, // Can't go up from first
        },
    }
    
    for _, tt := range tests {
        t.Run(tt.name, func(t *testing.T) {
            updated, _ := tt.model.Update(tt.msg)
            assert.Equal(t, tt.expected, updated)
        })
    }
}

Integration Testing

def test_full_workflow(capsys):
    """Test complete TUI workflow"""
    # Simulate user input
    with patch('builtins.input', return_value='test\n'):
        app.run()
    
    # Check output
    captured = capsys.readouterr()
    assert 'Welcome' in captured.out
    assert 'Goodbye' in captured.out

Always prioritize:

  • Responsive design for different terminal sizes
  • Intuitive keyboard navigation
  • Clear visual hierarchy and feedback
  • Cross-platform compatibility
  • Performance and efficiency

Du fichier au premier essai

Le téléchargement contient exactement le contenu affiché sur cette fiche. Cette copie peut différer de la dernière version du dépôt source.

Consulter la source et ses fichiers annexes

Ce téléchargement contient uniquement SKILL.md. Les scripts, références, modèles et dépendances éventuels ne sont pas inclus. Récupérez les fichiers nécessaires depuis la source en conservant leur arborescence avant de poursuivre.

1. Télécharger le fichier

Télécharger SKILL.md

Depuis la racine d’un projet de test, enregistrez le fichier sous .skill-downloads/terminal-user-interface-development-mmh8qpye/SKILL.md, ou utilisez la commande suivante. Ce dossier sert à examiner la skill avant son installation.

Commande pour macOS/Linux ou WSL : un shell POSIX et curl sont nécessaires. Sous Windows sans WSL, utilisez le bouton de téléchargement et créez le dossier manuellement.

mkdir -p '.skill-downloads/terminal-user-interface-development-mmh8qpye' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/terminal-user-interface-development-mmh8qpye/download' --output '.skill-downloads/terminal-user-interface-development-mmh8qpye/SKILL.md.part' && mv '.skill-downloads/terminal-user-interface-development-mmh8qpye/SKILL.md.part' '.skill-downloads/terminal-user-interface-development-mmh8qpye/SKILL.md'

2. Vérifier les prérequis

Lisez SKILL.md avant de l’utiliser. Si le fichier cite des scripts ou services externes, examinez-les et préparez les accès nécessaires dans votre environnement de test.

Aucune section de prérequis reconnue dans ce fichier. Cela ne signifie pas qu’il est autonome : les bibliothèques, outils et accès peuvent être cités ailleurs dans le contenu ou dans le dépôt source.

Les plateformes de la fiche sont des indications du catalogue. Les chemins ci-dessous suivent la documentation des outils ; ils ne prouvent pas que cette skill y a été exécutée. Aucune version minimale de ces outils n’est attestée pour cette fiche.

3. Charger la skill

Après vérification, copiez le dossier complet dans le projet avec l’une des commandes ci-dessous, puis ouvrez une nouvelle session de l’outil. La commande s’arrête si un dossier du même nom existe déjà : comparez les fichiers avant de le remplacer.

Claude Code
test -f '.skill-downloads/terminal-user-interface-development-mmh8qpye/SKILL.md' && test -s '.skill-downloads/terminal-user-interface-development-mmh8qpye/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/tui' && cp -R '.skill-downloads/terminal-user-interface-development-mmh8qpye' '.claude/skills/tui'

OpenSkills

OpenSkills doit déjà être installé. La procédure locale install/read est contrôlée avec OpenSkills 1.5.0, qui exige Node.js ≥ 20.6.0. Aucun slug du catalogue n’est résolu automatiquement.

Installation officielle d’OpenSkills
openskills install './.skill-downloads/terminal-user-interface-development-mmh8qpye'

openskills read 'terminal-user-interface-development-mmh8qpye'

La lecture doit afficher le contenu du fichier installé et son dossier de base. Elle ne lance ni la skill ni ses dépendances.

Pour un agent qui lit AGENTS.md, synchronisez ensuite l’index. Cette commande modifie AGENTS.md : relisez le diff avant de l’utiliser.

openskills sync

Mode manuel ou autre outil : joignez SKILL.md à une conversation, ou ouvrez-le dans un agent capable de lire les fichiers. Ajoutez les ressources annexes nécessaires. Il n’existe pas de dossier universel reconnu par tous les outils.

4. Faire un premier essai

Utilisez une entrée courte et fictive : un endpoint d’API, un petit document ou un brief d’interface. Dans une nouvelle conversation, joignez le fichier ou donnez son chemin à l’agent, puis adaptez cette demande :

Lis .skill-downloads/terminal-user-interface-development-mmh8qpye/SKILL.md et applique ses instructions à cet exemple : [décrire une entrée de test]. Indique les fichiers, dépendances ou accès qui manquent. Produis le résultat demandé par la skill sans inventer de données ni exécuter de script non examiné.

Résultat attendu : une sortie correspondant aux instructions de la skill, ou une liste précise des prérequis manquants. Une simple confirmation de lecture ne valide pas le premier usage. Si une ressource externe est indisponible, ce parcours reste à tester.

Skills similaires