go-skills

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

830 stars

Best use case

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

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

Teams using go-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/go-skills/SKILL.md --create-dirs "https://raw.githubusercontent.com/llama-farm/llamafarm/main/.claude/skills/go-skills/SKILL.md"

Manual Installation

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

How go-skills Compares

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

Frequently Asked Questions

What does this skill do?

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

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

# Go Skills for LlamaFarm CLI

Shared Go best practices for LlamaFarm CLI development. These guidelines ensure idiomatic, maintainable, and secure Go code.

## Tech Stack

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

## Directory Structure

```
cli/
  cmd/           # Command implementations
    config/      # Configuration types and loading
    orchestrator/ # Service management
    utils/       # Shared utilities
    version/     # Version and upgrade handling
  internal/      # Internal packages
    tui/         # TUI components
    buildinfo/   # Build information
```

## Quick Reference

### Error Handling
- Always wrap errors with context: `fmt.Errorf("operation failed: %w", err)`
- Use sentinel errors for expected conditions: `var ErrNotFound = errors.New("not found")`
- Check errors immediately after function calls

### Concurrency
- Use `sync.Mutex` for shared state protection
- Use `sync.RWMutex` when reads dominate writes
- Use channels for goroutine communication
- Always use `defer` for mutex unlocks

### Testing
- Use table-driven tests for comprehensive coverage
- Use interfaces for mockability
- Test file names: `*_test.go` in same package

### Security
- Never log credentials or tokens
- Redact sensitive headers in debug logs
- Validate all external input
- Use `context.Context` for cancellation

## Checklist Files

| File | Description |
|------|-------------|
| [patterns.md](patterns.md) | Idiomatic Go patterns |
| [concurrency.md](concurrency.md) | Goroutines, channels, sync |
| [error-handling.md](error-handling.md) | Error wrapping, sentinels |
| [testing.md](testing.md) | Table-driven tests, mocks |
| [security.md](security.md) | Input validation, secure coding |

## Go Proverbs to Remember

1. "Don't communicate by sharing memory; share memory by communicating"
2. "Errors are values"
3. "A little copying is better than a little dependency"
4. "Clear is better than clever"
5. "Design the architecture, name the components, document the details"

## Common Patterns in This Codebase

### HTTP Client Interface
```go
type HTTPClient interface {
    Do(req *http.Request) (*http.Response, error)
}
```

### Process Management with Mutex
```go
type ProcessManager struct {
    mu        sync.RWMutex
    processes map[string]*ProcessInfo
}
```

### Cobra Command Pattern
```go
var myCmd = &cobra.Command{
    Use:   "mycommand",
    Short: "Brief description",
    RunE: func(cmd *cobra.Command, args []string) error {
        // Implementation
        return nil
    },
}
```

### Bubbletea Model Pattern
```go
type myModel struct {
    // State fields
}

func (m myModel) Init() tea.Cmd { return nil }
func (m myModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { /* ... */ }
func (m myModel) View() string { return "" }
```

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.

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.

cli-skills

830
from llama-farm/llamafarm

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

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.