golang-benchmark
Golang benchmarking, profiling, and performance measurement. Use when writing, running, or comparing Go benchmarks, profiling hotโฆ
Implements GraphQL APIs in Golang using gqlgen or graphql-go. Apply when building GraphQL servers, designing schemas, writing resolvers, handling subscriptions, or integrating GraphQL with existing Go HTTP services. Also apply when the codebase imports
Claude Code
$ npx -y skills add samber/cc-skills-golang --skill golang-graphql --agent claude-code
Codex
$ npx skills add samber/cc-skills-golang --skill golang-graphql -a codex -y
Cursor
$ npx skills add samber/cc-skills-golang --skill golang-graphql -a cursor -y
Gemini CLI
$ npx skills add samber/cc-skills-golang --skill golang-graphql -a gemini-cli -y
GitHub Copilot
$ npx skills add samber/cc-skills-golang --skill golang-graphql -a github-copilot -y
OpenCode
$ npx skills add samber/cc-skills-golang --skill golang-graphql -a opencode -y
Windsurf
$ npx skills add samber/cc-skills-golang --skill golang-graphql -a windsurf -y
name: golang-graphql
description: "Implements GraphQL APIs in Golang using gqlgen or graphql-go. Apply when building GraphQL servers, designing schemas, writing resolvers, handling subscriptions, or integrating GraphQL with existing Go HTTP services. Also apply when the codebase imports `github.com/99designs/gqlgen` or `github.com/graph-gophers/graphql-go`."
user-invocable: false
license: MIT
compatibility: Designed for Claude Code, Codex or similar harness, and for projects using Golang.
metadata:
author: samber
version: "0.2.2"
openclaw:
emoji: "๐ฎ"
homepage: https://github.com/samber/cc-skills-golang
requires:
bins:
- go
install: []
skill-library-version: "0.17.89"
allowed-tools: Read Edit Write Glob Grep Bash(go:*) Bash(golangci-lint:*) Bash(git:*) Agent WebFetch mcp__context7__resolve-library-id mcp__context7__query-docs Bash(curl:*) Bash(godig:*) Bash(gopls:*) LSP mcp__gopls__*
paths:
- "**/*.go"**Persona:** You are a Go GraphQL engineer. You design schemas deliberately, batch database access to prevent N+1, and treat query complexity limits as non-optional in production.
**Modes:**
> **Community default.** A company skill that explicitly supersedes `samber/cc-skills-golang@golang-graphql` skill takes precedence.
Both major libraries are schema-first: write SDL (`.graphql` files), bind Go resolvers. Choose based on project size and team preferences.
This skill is not exhaustive โ refer to each library's official documentation and code examples for current API signatures:
| Library | Approach | Type safety | Build step | Best for | | --- | --- | --- | --- | --- | | `github.com/99designs/gqlgen` | Codegen | Compile-time | `go generate` | Large schemas, federation, strict types | | `github.com/graph-gophers/graphql-go` | Reflection | Parse-time | None | Simple schemas, fast iteration | | `github.com/graphql-go/graphql` | Code-first | Runtime | None | **Avoid** โ verbose, no SDL |
Pick **gqlgen** when: Apollo Federation is required, schema is large (100+ types), or the team wants generated stubs and zero reflection overhead.
Pick **graph-gophers** when: schema is small/medium, the build pipeline should stay simple, or a dynamic schema is needed.
For deep-dive on each library, see [gqlgen reference](./references/gqlgen.md) and [graphql-go reference](./references/graphql-go.md).
# โ Good โ explicit nullability; ID scalar for opaque identifiers
type User {
id: ID!
email: String! # non-null: the server can always return this
bio: String # nullable: may be unset
posts(first: Int = 10, after: String): PostConnection!
}
# โ Bad โ Int ID leaks implementation details, breaks client caching
type Post {
id: Int!
}**Nullability rule:** mark a field `!` only when the server can _always_ return a value. A resolver error on a non-null field nulls the parent object, causing cascade failures; nullable fields only null the field itself.
**Pagination:** use Relay cursor connections (`Connection`/`Edge`/`PageInfo`) for list fields. Avoid offset pagination on large datasets โ cursors are stable under concurrent writes.
**Mutations:** wrap results in an envelope type so clients receive business errors alongside partial results without polluting the GraphQL `errors` array:
type CreateUserPayload {
user: User
errors: [UserError!]!
}Keep resolvers thin โ they translate GraphQL inputs to domain calls and domain responses to GraphQL outputs.
// โ Good โ resolver delegates to service layer
func (r *mutationResolver) CreateUser(ctx context.Context, input model.CreateUserInput) (*model.CreateUserPayload, error) {
user, err := r.userService.Create(ctx, input.Email, input.Name)
if err != nil {
return nil, formatError(err)
}
return &model.CreateUserPayload{User: toGQLUser(user)}, nil
}
// โ Bad โ SQL in resolver, no separation of concerns
func (r *queryResolver) User(ctx context.Context, id string) (*model.User, error) {
row := r.db.QueryRowContext(ctx, "SELECT * FROM users WHERE id = $1", id)
// ...
}Use per-type resolver structs (`userResolver`, `postResolver`) rather than one monolithic resolver for all fields.
Each `User.posts` resolver fires a SQL query per user without batching โ O(n) DB calls for n users. DataLoaders solve this by coalescing per-field loads into a single batch query.
**Critical rule: DataLoaders MUST be created per-request in HTTP middleware, never globally.** A global DataLoader caches across requests โ stale data, potential cross-user data leakage.
// โ Good โ per-request DataLoader in middleware
func DataLoaderMiddleware(db *sql.DB, next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
loaders := &Loaders{
PostsByUserID: newPostsByUserIDLoader(r.Context(), db),
}
ctx := context.WithValue(r.Context(), loadersKey, loaders)
next.ServeHTTP(w, r.WithAI agent skills are reusable instruction sets that extend your coding assistant with domain-specific expertise, loaded on demand so they don't bloat your context. This repository covers Go-specific skills only (language, testing, security, observability, etc.)
Golang benchmarking, profiling, and performance measurement. Use when writing, running, or comparing Go benchmarks, profiling hotโฆ
Golang CLI application development. Use when building, modifying, or reviewing a Go CLI tool โ especially for command structure,โฆ
Golang code style conventions โ line length and breaking, variable declarations, control flow clarity, when comments help vsโฆ
Golang concurrency design โ goroutine lifecycle and leak prevention, channels and `select`, channel ownership and direction,โฆ
Idiomatic context.Context usage in Golang โ propagation through API boundaries, cancellation, timeouts and deadlines,โฆ
GitHub Actions CI/CD pipeline configuration for Golang projects โ workflow files for test, lint, SAST, coverage andโฆ
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, orโฆ
Ask which skill or flow fits your situation. A router over the skills in this repo.