Go Patterns Skill
Umbrella skill for Go development: Google style, testing, concurrency, error handling,
failure modes, code review, SAP CC conventions, and quality gates. Load the references
relevant to the task.
Google Style Precedence
Use this precedence when guidance differs:
- The target repository's explicit rules and required compatibility constraints.
- The Google Go Style Guide's canonical rules.
- Google Go Style Decisions' normative guidance.
- Google Go Style Best Practices' non-canonical recommendations.
- Task-specific references below.
Prefer local consistency only where the Google guide allows judgment. Do not create
unrelated churn merely to restyle existing code. For new and nearby changed code,
follow the current pinned guidance. Record a conscious exception when repository rules,
generated-code constraints, or compatibility requirements require one.
Reference Loading Table
| Signal |
Load These Files |
Why |
| Google-specific style decisions |
Relevant sections under google-style-guide/ |
Check the pinned conventions needed for the task |
| Testing |
testing.md |
Writing, fixing, or reviewing Go tests |
| Concurrency |
concurrency.md |
Goroutines, channels, sync primitives, race conditions |
| Error handling |
error-handling.md |
Error wrapping, sentinels, custom types, errors.Is/As |
| Review patterns |
preferred-patterns.md |
Detecting code smells, over-engineering, bad Go patterns |
| Code review |
code-review.md |
Reviewing Go code or PRs for quality |
| SAP CC conventions |
sapcc-conventions.md |
Working in sapcc/* repos with go-bits |
| Quality gate |
quality-gate.md |
Running make check, linting, pre-commit validation |
Instructions
Step 1: Identify the Go Domain
Classify the task into one or more domains, then load the corresponding reference files.
Only load what is needed -- do not load all references for every task.
| Domain |
Load Reference |
When |
| Testing |
references/testing.md |
Writing, fixing, or reviewing Go tests |
| Concurrency |
references/concurrency.md |
Goroutines, channels, sync primitives, race conditions |
| Error handling |
references/error-handling.md |
Error wrapping, sentinels, custom types, errors.Is/As |
| Review patterns |
references/preferred-patterns.md |
Detecting code smells, over-engineering, bad Go patterns |
| Code review |
references/code-review.md |
Reviewing Go code or PRs for quality |
| SAP CC conventions |
references/sapcc-conventions.md |
Working in sapcc/* repos with go-bits |
| Quality gate |
references/quality-gate.md |
Running make check, linting, pre-commit validation |
Multiple domains may apply. For example, reviewing a PR that includes concurrency code
should load both code-review.md and concurrency.md.
Step 2: Load and Follow the Reference
Read the selected reference file(s) using ${CLAUDE_SKILL_DIR}/references/<name>.md.
Each reference contains the full methodology, phases, code examples, and error handling
for that domain. Follow the instructions in the reference as if they were this skill's
instructions.
Step 3: Use Domain-Specific Sub-References
Some references point to their own sub-reference files for extended patterns:
Testing sub-references:
${CLAUDE_SKILL_DIR}/references/testing/go-test-patterns.md -- Full table-driven test, helper, mock examples
${CLAUDE_SKILL_DIR}/references/testing/go-benchmark-and-concurrency.md -- b.Loop() benchmarks, synctest
Concurrency sub-references:
${CLAUDE_SKILL_DIR}/references/concurrency/concurrency-patterns.md -- Worker pool, fan-out/fan-in, pipeline, rate limiter, graceful shutdown
Error handling sub-references:
${CLAUDE_SKILL_DIR}/references/error-handling/patterns.md -- gopls tracing, HTTP handler patterns, error wrapping in middleware
Review-pattern sub-references:
${CLAUDE_SKILL_DIR}/references/preferred-patterns/code-examples.md -- Extended before/after for all 7 failure modes
Code review sub-references:
${CLAUDE_SKILL_DIR}/references/code-review/common-review-comments.md -- Go code patterns with good/bad examples
SAP CC conventions sub-references:
${CLAUDE_SKILL_DIR}/references/sapcc-conventions/sapcc-code-patterns.md -- Primary reference: code patterns, testing patterns, failure modes (merged from testing-patterns-detailed.md and preferred-patterns.md)
${CLAUDE_SKILL_DIR}/references/sapcc-conventions/library-reference.md -- Complete approved/restricted library table
${CLAUDE_SKILL_DIR}/references/sapcc-conventions/architecture-patterns.md -- Full 102-rule architecture spec
${CLAUDE_SKILL_DIR}/references/sapcc-conventions/review-standards.md -- Lead + secondary review standards (merged)
${CLAUDE_SKILL_DIR}/references/sapcc-conventions/extended-patterns.md -- Security, K8s, PR hygiene patterns
- Plus:
api-design-detailed.md, build-ci-detailed.md, error-handling-detailed.md,
go-bits-philosophy-detailed.md, pr-mining-insights.md
Quality gate sub-references:
${CLAUDE_SKILL_DIR}/references/quality-gate/common-lint-errors.json -- Linter descriptions and fix suggestions
${CLAUDE_SKILL_DIR}/references/quality-gate/makefile-targets.json -- Available make targets
${CLAUDE_SKILL_DIR}/references/quality-gate/expert-review-patterns.md -- Manual review patterns
${CLAUDE_SKILL_DIR}/references/quality-gate/examples.md -- Detailed usage examples
Step 4: Execute
Follow the loaded reference methodology. Each reference has its own phases, gates,
and completion criteria. Apply them as written.
Available Scripts
Scripts are organized by domain in sub-directories:
- Testing:
scripts/gen-table-test.sh, scripts/bench-compare.sh
- Error handling:
scripts/check-errors.sh
- Code review:
scripts/check-interface-compliance.sh
- SAP CC conventions:
scripts/check-sapcc-identify-endpoint.sh, scripts/check-sapcc-auth-ordering.sh,
scripts/check-sapcc-json-strict.sh, scripts/check-sapcc-time-now.sh, scripts/check-sapcc-httptest.sh,
scripts/check-sapcc-todo-format.sh
- Quality gate:
scripts/quality_checker.py, scripts/validate.py
- Google style snapshot:
scripts/sync-google-style-guide.py (pinned upstream refresh; requires review before revision changes)
Error Handling
Errors are domain-specific. Load the relevant reference file and check its Error Handling
section for troubleshooting guidance.
1---2name: go-patterns3version: 1.0.04description: "Go development patterns: testing, concurrency, errors, review, and conventions."5user-invocable: false6allowed-tools:7 - Read8 - Write9 - Bash10 - Grep11 - Glob12 - Edit13 - Task14 - Skill15agent: golang-general-engineer16routing:17 category: language18 force_route: true19 not_for: "'go' as a verb (go ahead, here we go, go-live, let's go), Go (the board game), pidgin/cargo english 'go do X'; only fires for the Go programming language patterns/idioms/testing or edits to .go files; SAP Commerce Cloud PHP work (use php-general-engineer agent)"20 triggers:21 - .go22 # testing triggers23 - go test24 - "*_test.go"25 - table-driven26 - t.Run27 - t.Helper28 # concurrency triggers29 - goroutine30 - channel31 - sync.Mutex32 - sync.WaitGroup33 - worker pool34 - fan-in35 - context.Context36 - "goroutine fan-out"37 # error handling triggers38 - fmt.Errorf39 - errors.Is40 - errors.As41 - "%w"42 - sentinel error43 # review pattern triggers44 - "Go failure mode"45 - "Go code smell"46 # code review triggers47 - Go code review48 - Go PR49 - Go quality50 # sapcc conventions triggers51 - sapcc52 - sap-cloud-infrastructure53 - go-bits54 - keppel55 - go-api-declarations56 - go-makefile-maker57 # quality gate triggers58 - make check59 - Go lint60 pairs_with:61 - golang-general-engineer62 - systematic-code-review63---6465# Go Patterns Skill6667Umbrella skill for Go development: Google style, testing, concurrency, error handling,68failure modes, code review, SAP CC conventions, and quality gates. Load the references69relevant to the task.7071## Google Style Precedence7273Use this precedence when guidance differs:74751. The target repository's explicit rules and required compatibility constraints.762. The Google Go Style Guide's canonical rules.773. Google Go Style Decisions' normative guidance.784. Google Go Style Best Practices' non-canonical recommendations.795. Task-specific references below.8081Prefer local consistency only where the Google guide allows judgment. Do not create82unrelated churn merely to restyle existing code. For new and nearby changed code,83follow the current pinned guidance. Record a conscious exception when repository rules,84generated-code constraints, or compatibility requirements require one.8586## Reference Loading Table8788| Signal | Load These Files | Why |89|---|---|---|90| Google-specific style decisions | Relevant sections under `google-style-guide/` | Check the pinned conventions needed for the task |91| Testing | `testing.md` | Writing, fixing, or reviewing Go tests |92| Concurrency | `concurrency.md` | Goroutines, channels, sync primitives, race conditions |93| Error handling | `error-handling.md` | Error wrapping, sentinels, custom types, errors.Is/As |94| Review patterns | `preferred-patterns.md` | Detecting code smells, over-engineering, bad Go patterns |95| Code review | `code-review.md` | Reviewing Go code or PRs for quality |96| SAP CC conventions | `sapcc-conventions.md` | Working in sapcc/* repos with go-bits |97| Quality gate | `quality-gate.md` | Running make check, linting, pre-commit validation |9899## Instructions100101### Step 1: Identify the Go Domain102103Classify the task into one or more domains, then load the corresponding reference files.104Only load what is needed -- do not load all references for every task.105106| Domain | Load Reference | When |107|--------|---------------|------|108| Testing | `references/testing.md` | Writing, fixing, or reviewing Go tests |109| Concurrency | `references/concurrency.md` | Goroutines, channels, sync primitives, race conditions |110| Error handling | `references/error-handling.md` | Error wrapping, sentinels, custom types, errors.Is/As |111| Review patterns | `references/preferred-patterns.md` | Detecting code smells, over-engineering, bad Go patterns |112| Code review | `references/code-review.md` | Reviewing Go code or PRs for quality |113| SAP CC conventions | `references/sapcc-conventions.md` | Working in sapcc/* repos with go-bits |114| Quality gate | `references/quality-gate.md` | Running make check, linting, pre-commit validation |115116Multiple domains may apply. For example, reviewing a PR that includes concurrency code117should load both `code-review.md` and `concurrency.md`.118119### Step 2: Load and Follow the Reference120121Read the selected reference file(s) using `${CLAUDE_SKILL_DIR}/references/<name>.md`.122Each reference contains the full methodology, phases, code examples, and error handling123for that domain. Follow the instructions in the reference as if they were this skill's124instructions.125126### Step 3: Use Domain-Specific Sub-References127128Some references point to their own sub-reference files for extended patterns:129130**Testing** sub-references:131- `${CLAUDE_SKILL_DIR}/references/testing/go-test-patterns.md` -- Full table-driven test, helper, mock examples132- `${CLAUDE_SKILL_DIR}/references/testing/go-benchmark-and-concurrency.md` -- b.Loop() benchmarks, synctest133134**Concurrency** sub-references:135- `${CLAUDE_SKILL_DIR}/references/concurrency/concurrency-patterns.md` -- Worker pool, fan-out/fan-in, pipeline, rate limiter, graceful shutdown136137**Error handling** sub-references:138- `${CLAUDE_SKILL_DIR}/references/error-handling/patterns.md` -- gopls tracing, HTTP handler patterns, error wrapping in middleware139140**Review-pattern** sub-references:141- `${CLAUDE_SKILL_DIR}/references/preferred-patterns/code-examples.md` -- Extended before/after for all 7 failure modes142143**Code review** sub-references:144- `${CLAUDE_SKILL_DIR}/references/code-review/common-review-comments.md` -- Go code patterns with good/bad examples145146**SAP CC conventions** sub-references:147- `${CLAUDE_SKILL_DIR}/references/sapcc-conventions/sapcc-code-patterns.md` -- Primary reference: code patterns, testing patterns, failure modes (merged from testing-patterns-detailed.md and preferred-patterns.md)148- `${CLAUDE_SKILL_DIR}/references/sapcc-conventions/library-reference.md` -- Complete approved/restricted library table149- `${CLAUDE_SKILL_DIR}/references/sapcc-conventions/architecture-patterns.md` -- Full 102-rule architecture spec150- `${CLAUDE_SKILL_DIR}/references/sapcc-conventions/review-standards.md` -- Lead + secondary review standards (merged)151- `${CLAUDE_SKILL_DIR}/references/sapcc-conventions/extended-patterns.md` -- Security, K8s, PR hygiene patterns152- Plus: `api-design-detailed.md`, `build-ci-detailed.md`, `error-handling-detailed.md`,153 `go-bits-philosophy-detailed.md`, `pr-mining-insights.md`154155**Quality gate** sub-references:156- `${CLAUDE_SKILL_DIR}/references/quality-gate/common-lint-errors.json` -- Linter descriptions and fix suggestions157- `${CLAUDE_SKILL_DIR}/references/quality-gate/makefile-targets.json` -- Available make targets158- `${CLAUDE_SKILL_DIR}/references/quality-gate/expert-review-patterns.md` -- Manual review patterns159- `${CLAUDE_SKILL_DIR}/references/quality-gate/examples.md` -- Detailed usage examples160161### Step 4: Execute162163Follow the loaded reference methodology. Each reference has its own phases, gates,164and completion criteria. Apply them as written.165166## Available Scripts167168Scripts are organized by domain in sub-directories:169170- **Testing**: `scripts/gen-table-test.sh`, `scripts/bench-compare.sh`171- **Error handling**: `scripts/check-errors.sh`172- **Code review**: `scripts/check-interface-compliance.sh`173- **SAP CC conventions**: `scripts/check-sapcc-identify-endpoint.sh`, `scripts/check-sapcc-auth-ordering.sh`,174 `scripts/check-sapcc-json-strict.sh`, `scripts/check-sapcc-time-now.sh`, `scripts/check-sapcc-httptest.sh`,175 `scripts/check-sapcc-todo-format.sh`176- **Quality gate**: `scripts/quality_checker.py`, `scripts/validate.py`177- **Google style snapshot**: `scripts/sync-google-style-guide.py` (pinned upstream refresh; requires review before revision changes)178179## Error Handling180181Errors are domain-specific. Load the relevant reference file and check its Error Handling182section for troubleshooting guidance.