Claude-skill-registry go-skills
Shared Go best practices for LlamaFarm CLI. Covers idiomatic patterns, error handling, and testing.
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/go-skills" ~/.claude/skills/majiayu000-claude-skill-registry-go-skills && rm -rf "$T"
manifest:
skills/data/go-skills/SKILL.mdsource content
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
for shared state protectionsync.Mutex - Use
when reads dominate writessync.RWMutex - Use channels for goroutine communication
- Always use
for mutex unlocksdefer
Testing
- Use table-driven tests for comprehensive coverage
- Use interfaces for mockability
- Test file names:
in same package*_test.go
Security
- Never log credentials or tokens
- Redact sensitive headers in debug logs
- Validate all external input
- Use
for cancellationcontext.Context
Checklist Files
| File | Description |
|---|---|
| patterns.md | Idiomatic Go patterns |
| concurrency.md | Goroutines, channels, sync |
| error-handling.md | Error wrapping, sentinels |
| testing.md | Table-driven tests, mocks |
| security.md | Input validation, secure coding |
Go Proverbs to Remember
- "Don't communicate by sharing memory; share memory by communicating"
- "Errors are values"
- "A little copying is better than a little dependency"
- "Clear is better than clever"
- "Design the architecture, name the components, document the details"
Common Patterns in This Codebase
HTTP Client Interface
type HTTPClient interface { Do(req *http.Request) (*http.Response, error) }
Process Management with Mutex
type ProcessManager struct { mu sync.RWMutex processes map[string]*ProcessInfo }
Cobra Command Pattern
var myCmd = &cobra.Command{ Use: "mycommand", Short: "Brief description", RunE: func(cmd *cobra.Command, args []string) error { // Implementation return nil }, }
Bubbletea Model Pattern
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 "" }