go-pro
Idiomatic Go with proper error handling, concurrency patterns, slog, generics, and clean package design. Use when implementing, debugging, refactoring, or reviewing Go code; designing package boundaries; resolving race conditions or goroutine leaks; setting up table-driven tests; choosing between channels and mutexes; or tuning module layout. Applies to any Go work unless a more specific role overrides.
What this skill does
# Go Pro Senior-level Go expertise for production projects. Focuses on idiomatic patterns, simplicity, and Go's design philosophy. ## When Invoked 1. Review `go.mod` and `.golangci.yml` for project conventions 2. For build system setup, invoke the **just-pro** skill 3. Apply Go idioms and established project patterns ## Core Standards **Required:** - All exported identifiers have doc comments - All errors checked and handled (no `_ = err`) - NO `panic()` for recoverable errors - golangci-lint passes with project configuration - Table-driven tests for multiple cases **Foundational Principles:** - **Single Responsibility**: One package = one purpose, one function = one job - **No God Objects**: Split large structs; if it has 10+ fields or methods, decompose - **Dependency Injection**: Pass dependencies, don't create them internally - **Small Interfaces**: 1-3 methods max; compose larger behaviors from small interfaces --- ## Project Setup (Go 1.25+) ### Version Management Pin Go version with [mise](https://mise.jdx.dev): `mise use [email protected]` (creates `.mise.toml` — commit it). Team members run `mise install`. See **mise** skill for setup. ### New Project Quick Start ```bash # Initialize go mod init github.com/org/project go mod edit -go=1.25 # Add toolchain dependencies (tracked in go.mod) go get -tool github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest go get -tool golang.org/x/tools/cmd/goimports@latest go get -tool golang.org/x/vuln/cmd/govulncheck@latest # Copy configs from this skill's references/ directory: # references/gitignore → .gitignore # references/golangci-v2.yml → .golangci.yml # For build system, invoke just-pro skill # Verify just check # Or: go tool golangci-lint run ``` ### Developer Onboarding ```bash git clone <repo> && cd <repo> just setup # Runs mise trust/install + go mod download just check # Verify everything works ``` Or manually: ```bash mise trust && mise install # Get pinned Go version go mod download # Get dependencies ``` **Why `go get -tool`?** Tools versioned in go.mod = reproducible builds, same versions for all devs, no separate installation needed. --- ## Build System **Invoke the `just-pro` skill** for build system setup. It covers: - Simple repos vs monorepos - Hierarchical justfile modules - Go-specific templates (`references/package-go.just`) **Why just?** Consistent toolchain frontend between agents and humans. Instead of remembering `go tool golangci-lint run --fix`, use `just fix`. --- ## Quality Assurance **Auto-Fix First** - Always try auto-fix before manual fixes: ```bash just fix # Or: go tool golangci-lint run --fix && go tool goimports -w . ``` **Verification:** ```bash just check # Or: go tool golangci-lint run && go test -race ./... && go tool govulncheck ./... ``` --- ## Quick Reference ### Error Handling | Pattern | Use | |---------|-----| | `return err` | Propagate unchanged (internal errors) | | `fmt.Errorf("context: %w", err)` | Wrap with context (cross-boundary) | | `errors.Is(err, target)` | Check specific error | | `errors.As(err, &target)` | Extract typed error | **Sentinel Errors** - Define package-level errors for expected conditions: ```go var ErrNotFound = errors.New("not found") var ErrInvalidInput = errors.New("invalid input") ``` ### Generics ```go // Constrained generics - prefer specific constraints func Map[T, U any](items []T, fn func(T) U) []U { result := make([]U, len(items)) for i, item := range items { result[i] = fn(item) } return result } // Type constraints - use interfaces type Ordered interface { ~int | ~int64 | ~float64 | ~string } func Max[T Ordered](a, b T) T { if a > b { return a } return b } // Avoid: overly generic signatures that lose type safety // Prefer: concrete types until generics are clearly needed ``` ### Structured Logging (slog) ```go import "log/slog" // Package-level logger with context func NewService(logger *slog.Logger) *Service { return &Service{ log: logger.With("component", "service"), } } // Structured logging with levels s.log.Info("request processed", "method", r.Method, "path", r.URL.Path, "duration", time.Since(start), ) s.log.Error("operation failed", "err", err, "user_id", userID, ) ``` ### Iterators (Go 1.23+) ```go import "iter" // Return iterators for large collections func (db *DB) Users() iter.Seq[User] { return func(yield func(User) bool) { rows, _ := db.Query("SELECT * FROM users") defer rows.Close() for rows.Next() { var u User rows.Scan(&u.ID, &u.Name) if !yield(u) { return } } } } // Consume with range for user := range db.Users() { process(user) } // Seq2 for key-value pairs func (m *Map[K, V]) All() iter.Seq2[K, V] ``` ### Concurrency | Pattern | Use | |---------|-----| | `sync.WaitGroup` | Wait for goroutines | | `sync.Mutex` / `RWMutex` | Protect shared state | | `context.Context` | Cancellation/timeouts | | `errgroup.Group` | Concurrent with error collection | ```go // Context-aware work func DoWork(ctx context.Context, arg string) error { select { case <-ctx.Done(): return ctx.Err() default: } // ... work } ``` ### Testing ```go // Table-driven tests with subtests func TestParse(t *testing.T) { tests := []struct { name string input string want Result wantErr bool }{ {name: "valid", input: "foo", want: Result{Value: "foo"}}, {name: "empty", input: "", wantErr: true}, {name: "special", input: "a@b", want: Result{Value: "a@b"}}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { got, err := Parse(tt.input) if (err != nil) != tt.wantErr { t.Errorf("Parse() error = %v, wantErr %v", err, tt.wantErr) return } if got != tt.want { t.Errorf("Parse() = %v, want %v", got, tt.want) } }) } } // Testify for complex assertions import "github.com/stretchr/testify/assert" import "github.com/stretchr/testify/require" func TestService(t *testing.T) { require.NoError(t, err) // Fail fast assert.Equal(t, expected, actual) // Continue on failure assert.Len(t, items, 3) assert.Contains(t, items, target) } ``` ### Pointer vs Value Receivers ```go // Use pointer receivers when: // - Method modifies the receiver // - Receiver is large (avoid copy) // - Consistency: if any method needs pointer, use pointer for all func (s *Service) UpdateConfig(cfg Config) { s.cfg = cfg } // Use value receivers when: // - Receiver is small (int, string, small struct) // - Method is read-only and receiver is immutable func (p Point) Distance(other Point) float64 { ... } ``` ### Package Organization ``` project/ ├── cmd/appname/main.go # Entry point ├── internal/ # Private packages │ ├── api/ # Handlers │ └── domain/ # Business logic ├── go.mod ├── .golangci.yml └── justfile ``` **Rules:** One package = one purpose. Use `internal/` for implementation. Avoid `util`, `common`, `helpers` packages. --- ## DX Patterns ### Doctor Recipe with Version Validation Doctor scripts should validate that toolchain versions meet requirements, not just check existence: ```just # Validate toolchain versions meet requirements doctor: #!/usr/bin/env bash set -euo pipefail echo "Checking toolchain..." # Validate Go version (requires 1.25+) GO_VERSION=$(go version | grep -oE 'go[0-9]+\.[0-9]+' | sed 's/go//') if [[ "$(printf '%s\n' "1.25" "$GO_VERSION" | sort -V | head -1)" != "1.25" ]]; then echo "FAIL: Go $GO_VERSION < 1.25 required" exit 1 fi echo "✓ Go $GO_VERSION" # Add more version checks as
Related in Design
contribute
IncludedLocal-only OSS contribution command center. Auto-refreshes the user's in-flight PR and issue state on invoke so conversations start with full context — no need to brief Claude on what's in flight. Helps the user find issues to contribute to on GitHub, builds per-repo dossiers of what each upstream expects (CLA, DCO, branch convention, AI policy, draft-first, review bots, issue templates), runs deterministic gates before any external action so AI-assisted contributions don't reach maintainers as slop. State is markdown-only: candidate files at ~/.contribute-system/candidates/, repo dossiers at ~/.contribute-system/research/, append-only event log at ~/.contribute-system/log.jsonl. No database, no cloud calls. Use when the user asks about their PRs / issues / contributions, wants to find new work to take on, claim an issue, build/refresh a repo's dossier, or draft a Design Issue or PR. Trigger with "/contribute", "what's my PR status", "find a contribution", "claim issue X", "draft a Design Issue for Y", "refresh dossier for Z".
architectural-analysis
IncludedUser-triggered deep architectural analysis of a codebase or scoped subtree across eight modes — information architecture, data flow, integration points, UI surfaces, interaction patterns, data model, control flow, and failure modes. This skill should be used when the user asks to "diagram this codebase," "map the architecture," "show the data flow," "give me an ERD," "trace control flow," "find the integration points," "verify the layout pattern," "audit the UX architecture," or any similar request whose primary deliverable is mermaid diagrams plus cited reports under docs/architecture/. Dispatches haiku/sonnet sub-agents in parallel for per-mode exploration, then verifies every citation mechanically before any node lands in a diagram. Not for one-off prose explanations of code (use code-explanation) or for high-level system design from scratch (use system-design).
mcp
IncludedModel Context Protocol (MCP) server development and tool management. Languages: Python, TypeScript. Capabilities: build MCP servers, integrate external APIs, discover/execute MCP tools, manage multi-server configs, design agent-centric tools. Actions: create, build, integrate, discover, execute, configure MCP servers/tools. Keywords: MCP, Model Context Protocol, MCP server, MCP tool, stdio transport, SSE transport, tool discovery, resource provider, prompt template, external API integration, Gemini CLI MCP, Claude MCP, agent tools, tool execution, server config. Use when: building MCP servers, integrating external APIs as MCP tools, discovering available MCP tools, executing MCP capabilities, configuring multi-server setups, designing tools for AI agents.
react-native-skia
IncludedDesign, build, debug, and optimise high-polish animated graphics in React Native or Expo using @shopify/react-native-skia, Reanimated, and Gesture Handler. Use when the user wants canvas-driven UI, shaders, paths, rich text, image filters, sprite fields, Skottie, video frames, snapshots, web CanvasKit setup, or performance tuning for custom motion-heavy elements such as loaders, hero art, cards, charts, progress indicators, particle systems, or gesture-driven surfaces. Also use when the user asks for fluid, glow, glass, blob, parallax, 60fps/120fps, or GPU-friendly animated effects in React Native, even if they do not explicitly say "Skia". Do not use for ordinary form/layout work with standard views.
plaid
IncludedProduct Led AI Development — guides founders from idea to launched product. Six capabilities: Idea (discover a product idea), Validate (pressure-test the idea against fatal flaws, problem reality, competition, and 2-week MVP feasibility), Plan (vision intake + document generation), Design (translate image references into a design.md spec), Launch (go-to-market strategy), and Build (roadmap execution). Use when someone says "PLAID", "plaid idea", "help me find an idea", "product idea", "idea from my business", "idea from my expertise", "plaid validate", "validate my idea", "pressure-test", "is this idea good", "find fatal flaws", "validate the problem", "plan a product", "define my vision", "generate a PRD", "product strategy", "plaid design", "design from image", "translate image to design", "create design.md", "extract design tokens", "plaid launch", "go-to-market", "launch plan", "GTM strategy", "launch playbook", "plaid build", "build the app", "start building", or "execute the roadmap".
nextjs-framer-motion-animations
IncludedAdds production-safe Motion for React or Framer Motion animations to Next.js apps, including reveal, hover and tap micro-interactions, whileInView, stagger, AnimatePresence, layout and layoutId transitions, reorder, scroll-linked UI, and lightweight route-content transitions. Use when the user asks to add, refactor, or debug Motion or Framer Motion in App Router or Pages Router codebases, especially around server/client boundaries, reduced motion, LazyMotion, bundle size, hydration, or route transitions. Avoid for GSAP-style timelines, WebGL or 3D scenes, heavy scroll storytelling, or CSS-only effects unless Motion is explicitly requested.