go-code-quality
Skill0 starsChanged 2 months agoMITView on GitHub
Guides agents in applying idiomatic Go architecture: explicit error handling, interface segregation, context propagation, and goroutine leak prevention.
In this repository49 other files it gives its agents.
- bug-reproducerSkill
- claim-checkerSkill
- command-failure-diagnoserSkill
- config-risk-reviewerSkill
- csv-validatorSkill
- deployment-checklist-makerSkill
- diff-reviewerSkill
- factual-summarizerSkill
- field-extractorSkill
- api-contract-testerSkill
- database-migration-helperSkill
- security-vulnerability-fixerSkill
- git-commit-stagerSkill
- git-conflict-resolverSkill
- github-actions-debuggerSkill
- github-issue-triagerSkill
- github-pr-creatorSkill
- github-pr-reviewerSkill
- go-lint-and-vetSkill
- go-testingSkill
- json-schema-converterSkill
- lint-and-typecheckSkill
- meaning-preserving-editorSkill
- meeting-notes-to-actionsSkill
- minimal-bug-fixSkill
- option-comparatorSkill
- py-code-qualitySkill
- py-lint-and-typecheckSkill
- py-testingSkill
- readme-writerSkill
- regression-test-writerSkill
- release-notes-drafterSkill
- repo-inspectorSkill
- research-briefSkill
- reversible-cleanup-plannerSkill
- rust-clippy-checkSkill
- rust-code-qualitySkill
- rust-testingSkill
- small-refactorSkill
- status-updateSkill
- step-by-step-tutorialSkill
- step-decomposerSkill
- tabular-analyzerSkill
- task-briefSkill
- test-runner-debuggerSkill
- ts-code-qualitySkill
- ts-lint-and-typecheckSkill
- ts-testingSkill
- skill-templateSkill
The file
We split this skill into the rules it gives an agent
10 rules. About 0 are common, 3 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 14
Use this skill when:
- Very specific: line 20
Do not use for testing; use go-testing.
- Very specific: line 26
If target_file is missing: ask for target file.
- Very specific: line 27
Never introduce panics for standard operational errors.
- Distinctive: line 30
Follow these numbered actions:
- Very specific: line 32
Ensure ctx context.Context is the first parameter of I/O functions.
- Very specific: line 36
Ensure every go func() has a termination condition via ctx.Done().
- Very specific: line 38
Run go build ./... and go test ./....
- Very specific: line 42
Never use panic() in package libraries.
- Distinctive: line 71
Stop and ask the user when:
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Go Code Quality & Idioms
Enforces canonical Go idioms: context.Context propagation as the first parameter, small interfaces defined by consumers, explicit error wrapping (fmt.Errorf("%w", err)), and goroutine cancellation.
1. Purpose
Refactor Go code into idiomatic, robust implementations. "Interface Segregation" means declaring 1-2 method interfaces at consumer sites rather than large producer interfaces.
2. When to Use
Use this skill when:
- Adding cancellation and timeouts to long-running Go operations via
context.Context. - Wrapping errors with
%wforerrors.Is()anderrors.As(). - Preventing goroutine leaks by ensuring channels have exits.
3. When Not to Use
- Do not use for testing; use
go-testing.
4. Required Inputs
target_file: Path to the Go file to improve.
5. Missing-Input Behavior
- If
target_fileis missing: ask for target file. - Never introduce panics for standard operational errors; use
errorreturns.
6. Procedure
Follow these numbered actions:
- Action 1: Check Context Propagation
- Ensure
ctx context.Contextis the first parameter of I/O functions.
- Ensure
- Action 2: Check Error Wrapping
- Replace generic string formatting with
fmt.Errorf("failed action: %w", err).
- Replace generic string formatting with
- Action 3: Audit Goroutine Lifecycles
- Ensure every
go func()has a termination condition viactx.Done().
- Ensure every
- Action 4: Verify Compilation & Tests
- Run
go build ./...andgo test ./....
- Run
7. Decision Rules
- Accept interfaces, return structs.
- Never use
panic()in package libraries.
8. Output Format
Emit the report using this template:
### Go Code Quality Report: [File]
- **File Modified**: `[path]`
- **Patterns Applied**: [e.g. Context Propagation, Error Wrapping]
- **Compile Status**: PASS
- **Test Status**: PASS
#### Improvements Made
- [Detail 1]
- [Detail 2]9. Verification Checklist
ctx context.Contextis first parameter on network/db functions.- Errors wrapped using
%w. - No goroutine leaks.
go test ./...passes.
10. Common Failures and Recovery
| Failure Symptom | Cause | Recovery Action |
| Goroutine hangs forever | Channel read without cancellation select | Add select { case ch <- val: case <-ctx.Done(): return }. |
11. Stop or Escalation Conditions
Stop and ask the user when:
- Changing function signatures affects exported public package APIs.
12. Examples
Example 1: Successful Execution
Input:
File: internal/fetcher.go
Goal: Add context cancellation to FetchUserOutput:
### Go Code Quality Report: internal/fetcher.go
- **File Modified**: `internal/fetcher.go`
- **Patterns Applied**: Context Propagation & Error Wrapping
- **Compile Status**: PASS
- **Test Status**: PASS
#### Improvements Made
- Updated signature: `func FetchUser(ctx context.Context, id string) (*User, error)`
- Wrapped HTTP request with `http.NewRequestWithContext(ctx, ...)`.
- Wrapped error: `fmt.Errorf("fetching user %s: %w", id, err)`.Example 2: Ambiguous or Missing Input
Input:
Fix go idioms.Output:
### Go Code Quality Report: Halted - No Target
- **Status**: Halted
Please specify the target Go file to inspect.Example 3: Expected Final Output
Output:
### Go Code Quality Report: internal/storage.go
- **File Modified**: `internal/storage.go`
- **Patterns Applied**: Consumer-Defined Interface
- **Compile Status**: PASS
- **Test Status**: PASSDoes it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

