xiaohongshu
xiaohongshu
go-idioms
Idiomatic Go patterns for errors, interfaces, concurrency, and packages. Use when: - Writing or reviewing Go code - Designing interfaces or package structure - Implementing concurrency patterns - Handling errors and context propagation - Structuring Go projects Keywords: Go, golang, error wrappin...
Full skill instructions
Boring, explicit, race-safe Go. Accept interfaces, return structs.
Always wrap with context at package boundaries:
// Use %w to preserve error chain
return fmt.Errorf("fetching user %s: %w", userID, err)
// Check wrapped errors
if errors.Is(err, sql.ErrNoRows) { ... }
var paymentErr *PaymentError
if errors.As(err, &paymentErr) { ... }
Never: %v (loses type), raw errors from exported functions, generic context.
Define interfaces in consuming package, not provider:
// notification/sender.go (consumer defines interface)
type EmailSender interface {
Send(ctx context.Context, to, subject, body string) error
}
// email/client.go (provider implements)
type Client struct { ... }
func (c *Client) Send(ctx context.Context, to, subject, body string) error { ... }
Small interfaces (1-3 methods). Compose larger from smaller:
type Reader interface { Read(p []byte) (n int, err error) }
type Writer interface { Write(p []byte) (n int, err error) }
type ReadWriter interface { Reader; Writer }
Compile-time verification:
var _ EmailSender = (*Client)(nil)
Always propagate context:
func FetchData(ctx context.Context) ([]byte, error) {
select {
case <-ctx.Done():
return nil, ctx.Err()
case result := <-dataChan:
return result, nil
}
}
Bounded concurrency (semaphore):
sem := make(chan struct{}, 10)
for _, item := range items {
sem <- struct{}{}
go func(item Item) {
defer func() { <-sem }()
process(item)
}(item)
}
Race safety: Always run go test -race ./...
internal/
user/ # Domain: single purpose
user.go
service.go
repository.go
order/ # Another domain
app/ # Dependency wiring
cmd/
api/ # Entry points
Rules:
// Constructor accepts interfaces
func NewUserService(repo UserRepository, mailer EmailSender) *UserService {
return &UserService{repo: repo, mailer: mailer}
}
// Wire in app/ package
func NewApp() *App {
repo := postgres.NewUserRepo(db)
mailer := sendgrid.NewClient(apiKey)
userSvc := user.NewUserService(repo, mailer)
return &App{UserService: userSvc}
}
interface{} / any without justificationmap, []T, sort.Slice)xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience