Loading...
Loading...
Explore and analyze TUI applications to document their features for cloning. Use when asked to reverse-engineer, analyze, document, or understand a terminal UI like Claude Code, OpenCode, Codex, lazygit, or any ratatui/ncurses-based application. Launches the target TUI in tmux, systematically explores all views and keybindings, captures ASCII diagrams of each screen, and writes findings incrementally to a markdown file (survives context compaction).
npx skill4agent add gpu-cli/skills tui-clonetui-analysis-[app-name]-[timestamp].mdsource .claude/skills/tmux-cli-test/scripts/tmux_helpers.sh
TMUX_TEST_WIDTH=140
TMUX_TEST_HEIGHT=40
APP_NAME="lazygit" # Set to target app
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
OUTPUT_FILE="tui-analysis-${APP_NAME}-${TIMESTAMP}.md"
# Initialize output file with header
cat > "$OUTPUT_FILE" << 'EOF'
# [App Name] TUI Analysis
## Overview
- Purpose: [TODO]
- Technology stack: [TODO]
- Target users: [TODO]
## Screen Catalog
EOF
echo "Output file: $OUTPUT_FILE"SESSION="tui-analysis"
tmux_start "$SESSION" "$APP_NAME"
tmux_wait_for "$SESSION" "<ready-indicator>" 30
# Immediately write initial view to file
{
echo ""
echo "### Initial View"
echo "- Entry: Launch command"
echo '```'
tmux_capture "$SESSION"
echo '```'
} >> "$OUTPUT_FILE"
echo "Wrote initial view to $OUTPUT_FILE"write_screen() {
local name="$1"
local entry="$2"
local session="$3"
{
echo ""
echo "### $name"
echo "- Entry: $entry"
echo '```'
tmux_capture "$session"
echo '```'
} >> "$OUTPUT_FILE"
echo "Wrote screen '$name' to $OUTPUT_FILE"
}# Check for help screen
tmux_send "$SESSION" "?"
if tmux_wait_for "$SESSION" "help\|Help\|Keybindings" 3; then
write_screen "Help Screen" "Press ?" "$SESSION"
fi
tmux_send "$SESSION" Escape
# Explore numbered tabs
for i in 1 2 3 4 5; do
tmux_send "$SESSION" "$i"
sleep 0.3
# Check if view changed meaningfully
write_screen "Tab $i View" "Press $i" "$SESSION"
done{
echo ""
echo "## Keybindings"
echo ""
echo "| Key | Context | Action |"
echo "|-----|---------|--------|"
echo "| ? | Global | Show help |"
echo "| q | Global | Quit |"
echo "| j/k | List | Navigate up/down |"
# Add more as discovered
} >> "$OUTPUT_FILE"{
echo ""
echo "## Implementation Notes"
echo ""
echo "### Patterns Identified"
echo "- [List patterns observed]"
echo ""
echo "### Recommended Tech Stack"
echo "- [Your recommendations]"
echo ""
echo "### Complexity Assessment"
echo "- [Your assessment]"
} >> "$OUTPUT_FILE"source .claude/skills/tmux-cli-test/scripts/tmux_helpers.sh
TMUX_TEST_WIDTH=140
TMUX_TEST_HEIGHT=40
APP_NAME="lazygit"
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
OUTPUT_FILE="tui-analysis-${APP_NAME}-${TIMESTAMP}.md"
SESSION="analyze-${APP_NAME}"
# Initialize output file
cat > "$OUTPUT_FILE" << EOF
# $APP_NAME TUI Analysis
## Overview
- Purpose: Git TUI client
- Technology stack: Go + gocui/tcell
- Target users: Developers who prefer terminal git workflow
## Screen Catalog
EOF
# Launch and capture initial view
tmux_start "$SESSION" "$APP_NAME"
tmux_wait_for "$SESSION" "Status" 15
{
echo ""
echo "### Main View"
echo "- Entry: Launch command"
echo '```'
tmux_capture "$SESSION"
echo '```'
} >> "$OUTPUT_FILE"
echo "Wrote: Main View"
# Check for help
tmux_send "$SESSION" "?"
if tmux_wait_for "$SESSION" "Keybindings" 5; then
{
echo ""
echo "### Help Screen"
echo "- Entry: Press ?"
echo '```'
tmux_capture "$SESSION"
echo '```'
} >> "$OUTPUT_FILE"
echo "Wrote: Help Screen"
fi
tmux_send "$SESSION" Escape
# Explore numbered panels
for i in 1 2 3 4 5; do
tmux_send "$SESSION" "$i"
sleep 0.3
{
echo ""
echo "### Panel $i"
echo "- Entry: Press $i"
echo '```'
tmux_capture "$SESSION"
echo '```'
} >> "$OUTPUT_FILE"
echo "Wrote: Panel $i"
done
# Cleanup
tmux_send "$SESSION" q
tmux_wait_exit "$SESSION" 5
echo "Analysis complete: $OUTPUT_FILE"ls -la tui-analysis-*.md # Find the current session's file
cat tui-analysis-lazygit-20260203-141523.md # Read it{
echo ""
echo "## Color Palette"
echo ""
echo "Raw ANSI capture:"
echo '```ansi'
tmux_capture_ansi "$SESSION"
echo '```'
} >> "$OUTPUT_FILE"{
echo ""
echo "## Component Inventory"
echo ""
echo "| Component | Description | Observed In |"
echo "|-----------|-------------|-------------|"
echo "| List | Scrollable item list with selection | Main view, File picker |"
echo "| Modal | Centered overlay dialog | Commit message, Confirmation |"
echo "| Tabs | Numbered panel switcher | Top bar |"
echo "| Status bar | Bottom info line | All views |"
echo "| Progress | Loading/sync indicator | Push/pull operations |"
echo "| Input | Text entry field | Search, Commit message |"
} >> "$OUTPUT_FILE"# Resize terminal and capture
tmux resize-pane -t "$SESSION" -x 80 -y 24
sleep 0.5
{
echo ""
echo "### Compact Layout (80x24)"
echo '```'
tmux_capture "$SESSION"
echo '```'
} >> "$OUTPUT_FILE"
tmux resize-pane -t "$SESSION" -x 200 -y 50
sleep 0.5
{
echo ""
echo "### Wide Layout (200x50)"
echo '```'
tmux_capture "$SESSION"
echo '```'
} >> "$OUTPUT_FILE"{
echo ""
echo "## State Transitions"
echo ""
echo "| From | Trigger | To |"
echo "|------|---------|-----|"
echo "| Main | Enter on file | Diff view |"
echo "| Main | c | Commit dialog |"
echo "| Any | Escape | Previous view |"
echo "| Any | q | Exit confirmation |"
} >> "$OUTPUT_FILE"┌─────────────────────────────────────────┐
│ Header / Title Bar │
├────────────────┬────────────────────────┤
│ Sidebar │ Main Content │
│ │ │
│ - Item 1 │ Details here │
│ > Item 2 * │ │
│ - Item 3 │ │
├────────────────┴────────────────────────┤
│ Status Bar / Footer │
└─────────────────────────────────────────┘>*[Button][x][ ]( )(*)│─┌┐└┘├┤┬┴┼| TUI | Launch Command | Ready Text |
|---|---|---|
| Claude Code | | |
| OpenCode | | Session or prompt |
| Codex | | Ready indicator |
| lazygit | | Status |
| lazydocker | | Containers |
| htop | | CPU |
| btop | | CPU |
| k9s | | Pods |
tui-analysis-[app-name]-[timestamp].md| Dimension | Question to Answer |
|---|---|
| Layout | How is the screen divided? Panels, sidebars, modals? |
| Navigation | How do users move between views? Keys, menus, tabs? |
| Selection | Single-select? Multi-select? How is selection shown? |
| Input | Text fields? How do they behave? Validation? |
| Feedback | Loading states? Success/error messages? Progress? |
| Scrolling | What scrolls? How is scroll position indicated? |
| Focus | What can be focused? How is focus shown? |
| Shortcuts | Global vs context-specific? Discoverable? |
| Theming | Hard-coded colors or configurable? |
| Resize | Fixed layout or responsive? Minimum size? |