基于 SOC 职业分类
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/tomevault-io/skills-registry --skill golang-expert命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
| Use when this capability is needed.
> Use when this capability is needed.
Review architecture and API design for the vfs-s3 project. Use when the user mentions @architect, asks to review an issue's design, discuss module boundaries, API shape, or architectural decisions for vfs-s3. Also trigger when the user wants to create an ADR (Architecture Decision Record) or evaluate a technical approach for the project. Intended for dispatch from Codex automation or Claude routines; GitHub trigger phrase: @vfs-s3-bot please prepare design doc Use when this capability is needed.
| name | golang-expert |
| description | | Use when this capability is needed. |
Expert guidance for writing clean, idiomatic, maintainable Go code.
// BAD - over-engineered
type ProcessorFactory interface {
CreateProcessor(config Config) Processor
}
// GOOD - direct and simple
func Process(data []byte) (Result, error) {
// Direct implementation
}
// BAD - duplicated logic
func ParseUserDate(s string) time.Time { /*...*/ }
func ParseOrderDate(s string) time.Time { /*...*/ } // Same code!
// GOOD - single source of truth
func ParseDate(s string) (time.Time, error) {
return time.Parse(time.RFC3339, s)
}
Don't build for hypothetical future requirements. Only implement what's needed right now.
// BAD - over-engineered for "future flexibility"
type DataProcessor interface {
Process(data []byte) ([]byte, error)
ProcessBatch(data [][]byte) ([][]byte, error)
ProcessAsync(data []byte, callback func([]byte, error))
ProcessWithOptions(data []byte, opts ProcessOptions) ([]byte, error)
}
type ProcessOptions struct {
Format string
Compression bool
Encryption bool
Retry int
Timeout time.Duration
Logger Logger
Metrics MetricsCollector
// 20 more fields "just in case"
}
// GOOD - solve today's problem
func Process(data []byte) ([]byte, error) {
// Direct implementation of what's actually needed
}
YAGNI Anti-patterns to Avoid:
// BAD - abstraction with only one implementation
type UserRepository interface {
GetUser(id int) (*User, error)
}
type userRepositoryImpl struct { db *sql.DB }
// GOOD - just use the concrete type until you need abstraction
type UserStore struct { db *sql.DB }
func (s *UserStore) GetUser(id int) (*User, error) { /*...*/ }
The Rule of Three: Don't abstract until you see the pattern three times.
// First time: just write the code
// Second time: note the duplication, but wait
// Third time: NOW refactor to remove duplication
Delete code freely. Unused code is a liability, not an asset. Version control remembers everything.
const when possible// BAD - global state
var logger *Logger
func SetLogger(l *Logger) { logger = l }
// GOOD - dependency injection
type Service struct {
logger Logger
}
func NewService(logger Logger) *Service {
return &Service{logger: logger}
}
// Small, focused interfaces (Interface Segregation)
type Reader interface { Read(p []byte) (n int, err error) }
type Writer interface { Write(p []byte) (n int, err error) }
// Compose when needed
type ReadWriter interface {
Reader
Writer
}
// Accept interfaces, return structs
func Process(r Reader) *Result { /*...*/ }
// Wrap errors with context
if err != nil {
return fmt.Errorf("process user %d: %w", id, err)
}
// Sentinel errors for expected conditions
var ErrNotFound = errors.New("not found")
// Check with errors.Is/As
if errors.Is(err, ErrNotFound) { /*...*/ }
func TestParse(t *testing.T) {
tests := []struct {
name string
input string
want Result
wantErr bool
}{
{"valid input", "abc", Result{Value: "abc"}, false},
{"empty input", "", Result{}, true},
}
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)
}
})
}
}
// Always use context for cancellation
func Process(ctx context.Context) error {
select {
case <-ctx.Done():
return ctx.Err()
case result := <-work():
return handle(result)
}
}
// Use errgroup for parallel work
g, ctx := errgroup.WithContext(ctx)
for _, item := range items {
item := item // capture loop variable
g.Go(func() error { return process(ctx, item) })
}
return g.Wait()
Load these references as needed:
| Topic | File | When to Use |
|---|---|---|
| Functional Patterns | functional-patterns.md | DI, immutability, pure functions |
| KISS & DRY | kiss-dry.md | Simplification, code deduplication |
| Interface Design | interface-design.md | API design, interface segregation |
| Testing | testing.md | Tests, mocks, benchmarks |
| Error Handling | error-handling.md | Error patterns, wrapping, types |
| Concurrency | concurrency.md | Goroutines, channels, sync |
| Performance | performance.md | Profiling, optimization |
| Code Review | code-review-checklist.md | Review checklist |
When reviewing Go code:
When refactoring:
Source: fjacquet/pdf2md — distributed by TomeVault.