cli-skills

CLI best practices for LlamaFarm. Covers Cobra, Bubbletea, Lipgloss patterns for Go CLI development.

830 stars

Best use case

cli-skills is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

CLI best practices for LlamaFarm. Covers Cobra, Bubbletea, Lipgloss patterns for Go CLI development.

Teams using cli-skills should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/cli-skills/SKILL.md --create-dirs "https://raw.githubusercontent.com/llama-farm/llamafarm/main/.claude/skills/cli-skills/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/cli-skills/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How cli-skills Compares

Feature / Agentcli-skillsStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

CLI best practices for LlamaFarm. Covers Cobra, Bubbletea, Lipgloss patterns for Go CLI development.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# CLI Skills for LlamaFarm

Framework-specific patterns for the LlamaFarm CLI. These guidelines extend the [shared Go skills](../go-skills/SKILL.md) with Cobra, Bubbletea, and Lipgloss best practices.

## Tech Stack

- Go 1.24+
- Cobra (CLI framework)
- Bubbletea (TUI framework)
- Lipgloss (terminal styling)
- Bubbles (TUI components)

## Directory Structure

```
cli/
  cmd/             # Cobra command implementations
    config/        # Configuration types and loading
    orchestrator/  # Service management and process control
    utils/         # Shared utilities (HTTP, output, logging)
    version/       # Version and upgrade handling
  internal/        # Internal packages (not exported)
    tui/           # Reusable TUI components
    buildinfo/     # Build-time information
```

## Quick Reference

### Cobra Commands
- Use `RunE` over `Run` for error handling
- Register flags in `init()` functions
- Use persistent flags for shared options
- Validate arguments with `Args` field

### Bubbletea TUI
- Implement `Init()`, `Update()`, `View()` interface
- Use message types for state changes
- Return `tea.Cmd` for async operations
- Keep state immutable in `Update()`

### Lipgloss Styling
- Define styles as package-level constants
- Use `lipgloss.NewStyle()` for styling
- Handle terminal width dynamically
- Support color themes via style variables

## Shared Go Skills

This skill extends the base Go skills. See:

| Link | Description |
|------|-------------|
| [go-skills/SKILL.md](../go-skills/SKILL.md) | Overview and quick reference |
| [go-skills/patterns.md](../go-skills/patterns.md) | Idiomatic Go patterns |
| [go-skills/concurrency.md](../go-skills/concurrency.md) | Goroutines, channels, sync |
| [go-skills/error-handling.md](../go-skills/error-handling.md) | Error wrapping, sentinels |
| [go-skills/testing.md](../go-skills/testing.md) | Table-driven tests, mocks |
| [go-skills/security.md](../go-skills/security.md) | Input validation, secure coding |

## CLI-Specific Checklists

| File | Description |
|------|-------------|
| [cobra.md](cobra.md) | Cobra command patterns, flags, validation |
| [bubbletea.md](bubbletea.md) | Bubbletea Model/Update/View patterns |
| [performance.md](performance.md) | CLI-specific optimizations |

## Key Patterns in This Codebase

### Command Registration Pattern
```go
var myCmd = &cobra.Command{
    Use:   "mycommand [args]",
    Short: "Brief description",
    Long:  `Extended description with examples.`,
    Args:  cobra.MaximumNArgs(1),
    RunE: func(cmd *cobra.Command, args []string) error {
        // Implementation with error returns
        return nil
    },
}

func init() {
    rootCmd.AddCommand(myCmd)
    myCmd.Flags().StringVar(&flagVar, "flag", "default", "Flag description")
}
```

### TUI Model Pattern
```go
type myModel struct {
    viewport viewport.Model
    textarea textarea.Model
    width    int
    height   int
    err      error
}

func (m myModel) Init() tea.Cmd {
    return tea.Batch(m.textarea.Focus(), doAsyncWork())
}

func (m myModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
    var cmds []tea.Cmd
    switch msg := msg.(type) {
    case tea.WindowSizeMsg:
        m.width = msg.Width
        m.height = msg.Height
    case tea.KeyMsg:
        switch msg.String() {
        case "ctrl+c":
            return m, tea.Quit
        }
    }
    return m, tea.Batch(cmds...)
}

func (m myModel) View() string {
    return lipgloss.JoinVertical(lipgloss.Left,
        m.viewport.View(),
        m.textarea.View(),
    )
}
```

### Output API Pattern
```go
// Use the output API for consistent messaging
utils.OutputInfo("Starting service %s...", serviceName)
utils.OutputSuccess("Service started successfully")
utils.OutputError("Failed to start service: %v", err)
utils.OutputProgress("Downloading model...")
utils.OutputWarning("Service already running")
```

### Service Orchestration Pattern
```go
// Ensure services are running before operations
factory := GetServiceConfigFactory()
config := factory.ServerOnly(serverURL)
orchestrator.EnsureServicesOrExitWithConfig(config, "server")

// Or with multiple services
config := factory.RAGCommand(serverURL)
orchestrator.EnsureServicesOrExitWithConfig(config, "server", "rag", "universal-runtime")
```

## Guidelines

1. **User Experience First**: CLI should feel responsive and provide clear feedback
2. **Graceful Degradation**: Handle missing services, network errors, and timeouts gracefully
3. **Consistent Output**: Use the output API for all user-facing messages
4. **Cross-Platform**: Test on macOS, Linux, and Windows
5. **Terminal Compatibility**: Test with different terminal emulators and sizes

Related Skills

typescript-skills

830
from llama-farm/llamafarm

Shared TypeScript best practices for Designer and Electron subsystems.

server-skills

830
from llama-farm/llamafarm

Server-specific best practices for FastAPI, Celery, and Pydantic. Extends python-skills with framework-specific patterns.

runtime-skills

830
from llama-farm/llamafarm

Universal Runtime best practices for PyTorch inference, Transformers models, and FastAPI serving. Covers device management, model loading, memory optimization, and performance tuning.

react-skills

830
from llama-farm/llamafarm

React 18 patterns for LlamaFarm Designer. Covers components, hooks, TanStack Query, and testing.

rag-skills

830
from llama-farm/llamafarm

RAG-specific best practices for LlamaIndex, ChromaDB, and Celery workers. Covers ingestion, retrieval, embeddings, and performance.

python-skills

830
from llama-farm/llamafarm

Shared Python best practices for LlamaFarm. Covers patterns, async, typing, testing, error handling, and security.

go-skills

830
from llama-farm/llamafarm

Shared Go best practices for LlamaFarm CLI. Covers idiomatic patterns, error handling, and testing.

generate-subsystem-skills

830
from llama-farm/llamafarm

Generate specialized skills for each subsystem in the monorepo. Creates shared language skills and subsystem-specific checklists for high-quality AI code generation.

config-skills

830
from llama-farm/llamafarm

Configuration module patterns for LlamaFarm. Covers Pydantic v2 models, JSONSchema generation, YAML processing, and validation.

common-skills

830
from llama-farm/llamafarm

Best practices for the Common utilities package in LlamaFarm. Covers HuggingFace Hub integration, GGUF model management, and shared utilities.

electron-skills

830
from llama-farm/llamafarm

Electron patterns for LlamaFarm Desktop. Covers main/renderer processes, IPC, security, and packaging.

designer-skills

830
from llama-farm/llamafarm

Designer subsystem patterns for LlamaFarm. Covers React 18, TanStack Query, TailwindCSS, and Radix UI.