Agent Skills › poteto/noodle › go-best-practices

go-best-practices

GitHub

提供 Go 语言生产环境最佳实践,涵盖生命周期管理、并发处理、配置加载及测试规范。指导代码编写、审查与重构,确保高可用性与可维护性。

.agents/skills/go-best-practices/SKILL.md poteto/noodle

触发场景

Go code review Go refactoring go best practices

安装

npx skills add poteto/noodle --skill go-best-practices -g -y
更多选项

非标准路径

npx skills add https://github.com/poteto/noodle/tree/main/.agents/skills/go-best-practices -g -y

不安装直接使用

npx skills use poteto/noodle@go-best-practices

指定 Agent (Claude Code)

npx skills add poteto/noodle --skill go-best-practices -a claude-code -g -y

安装 repo 全部 skill

npx skills add poteto/noodle --all -g -y

预览 repo 内 skill

npx skills add poteto/noodle --list

SKILL.md

Frontmatter
{
    "name": "go-best-practices",
    "description": "Production Go patterns — lifecycle, concurrency, config, testing, CI. Use when writing, reviewing, or refactoring Go code. Triggers on Go code review, Go refactoring, or 'go best practices'."
}

Go Best Practices

Pattern When to apply
Minimal main New binaries
Single bootstrap App wiring across modes
Ordered shutdown Long-running processes
Non-blocking fanout Channel-based event systems
Concurrency testing Any goroutine code
Layered config Multi-source configuration
Cross-platform paths File/config path resolution
Secure debug logging HTTP client instrumentation
Golden test matrices Rendering / output components
Focused linters CI pipeline setup

Read references/patterns.md for code examples.

Rules

  1. main.go is a stub. Call cmd.Execute() and nothing else. Gate diagnostics (pprof) behind env vars.

  2. One bootstrap path. All modes (interactive, headless, test) share the same initialization function. Two paths will drift.

  3. Ordered shutdown. Cancel dependents before their dependencies, then run independent cleanup in parallel under a timeout context. WaitGroup the parallel phase.

  4. Never block the sender. Non-blocking channel sends with an explicit drop policy. Log drops at debug level. Document the policy.

  5. Test concurrency mechanically. testing/synctest for deterministic timing, goleak.VerifyNone for leak detection, dedicated regression tests for timer/channel deadlocks.

  6. Explicit config precedence. Global → project → flags. Walk up from CWD to discover project configs, reverse so closest wins, deep-merge.

  7. Centralize platform paths. One function per concern. Resolution order: env override → XDG → platform default → fallback.

  8. Redact secrets in debug logs. Wrap http.RoundTripper. Filter headers matching authorization, api-key, token, secret. Gate on debug level to skip allocation in prod.

  9. Golden tests over matrices. Cross dimensions (layout × theme × size) as parallel subtests. Sweep continuous ranges to catch off-by-one bugs.

  10. Focused linters, not all linters. Enable what catches real bugs (bodyclose, noctx, tparallel). Disable noisy defaults. Add project-specific checks as scripts. Always -race in tests.

版本历史

  • 82d2921 当前 2026-11-19 21:08

同 Skill 集合

.agents/skills/adversarial-review/SKILL.md
.agents/skills/ast-grep/SKILL.md
.agents/skills/brain/SKILL.md
.agents/skills/codex/SKILL.md
.agents/skills/commit/SKILL.md
.agents/skills/debugging/SKILL.md
.agents/skills/execute/SKILL.md
.agents/skills/find-skills/SKILL.md
.agents/skills/frontend-design/SKILL.md
.agents/skills/interaction-design/SKILL.md
.agents/skills/make-interfaces-feel-better/SKILL.md
.agents/skills/meditate/SKILL.md
.agents/skills/noodle/SKILL.md
.agents/skills/oops/SKILL.md
.agents/skills/plan/SKILL.md
.agents/skills/quality/SKILL.md
.agents/skills/react-best-practices/SKILL.md
.agents/skills/refine/SKILL.md
.agents/skills/reflect/SKILL.md
.agents/skills/review/SKILL.md
.agents/skills/ruminate/SKILL.md
.agents/skills/schedule/SKILL.md
.agents/skills/skill-creator/SKILL.md
.agents/skills/testing/SKILL.md
.agents/skills/todo/SKILL.md
.agents/skills/unslop/SKILL.md
.agents/skills/worktree/SKILL.md
examples/minimal/.agents/skills/execute/SKILL.md
examples/minimal/.agents/skills/schedule/SKILL.md
examples/multi-skill/.agents/skills/execute/SKILL.md
examples/multi-skill/.agents/skills/schedule/SKILL.md
skills/skill-creator/SKILL.md
.agents/skills/ts-best-practices/SKILL.md
examples/multi-skill/.agents/skills/deploy/SKILL.md
examples/multi-skill/.agents/skills/test/SKILL.md

元信息

文件数
0
版本
82d2921
Hash
21c459bf
收录时间
2026-11-19 21:08

首页 - Wiki
Copyright © 2011-2026 iteam. Current version is 2.156.0. UTC+08:00, 2026-11-20 05:29
浙ICP备14020137号-1