hypershift / rules
Cursor rule551 starsChanged 6 months agoApache-2.0View on GitHub
Go Best Practices
Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.
Of the Cursor rule files we read, the 4,183 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository26 other files it gives its agents.
- AGENTS.mdAGENTS.md
- api/AGENTS.mdAGENTS.md
- control-plane-operator/AGENTS.mdAGENTS.md
- .cursor/rules/code-formatting.mdcCursor rule
- .cursor/rules/code-review.mdcCursor rule
- .cursor/rules/create-jira-items.mdcCursor rule
- .cursor/rules/debug-aro-hcp-e2e.mdcCursor rule
- .cursor/rules/git-commit-format.mdcCursor rule
- .cursor/rules/restructure-commits.mdcCursor rule
- create-cpo-overrideSkill
- Debug ClusterSkill
- e2e-analyzeSkill
- Effective GoSkill
- feature-developmentSkill
- fix-hypershift-repo-robot-prSkill
- Git Commit FormatSkill
- konflux-buildSkill
- Konflux Archived PipelineRunsSkill
- pr-reportSkill
- restructure-commitsSkill
- test-tag-pipelineSkill
- triage-leaked-infraSkill
- update-konflux-tasksSkill
- validate-pr-override-imagesSkill
- Git Commit FormatSkill
- restructure-commitsSkill
The file
Show its rules and text
We split this 100-go-mistakes.mdc into the rules it gives an agent
37 rules. About 0 are common, 26 are distinctive, and 11 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈26
Distinctive · estimate
This author's own choices. Worth a look.
11
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 8
Do not over-nest control flow (e.g., nested if or for blocks).
- Very specific: line 9
Avoid init() functions unless absolutely necessary.
- Distinctive: line 10
Keep functions small and focused.
- Distinctive: line 11
Prefer composition over inheritance (via embedding).
- Distinctive: line 12
Use the functional options pattern for constructors where flexibility is needed.
- Distinctive: line 16
Avoid defining interfaces until you need them.
- Distinctive: line 17
Do not return interfaces from constructors or public APIs.
- Distinctive: line 19
Keep interfaces small and focused (generally 1–2 methods).
- Distinctive: line 23
Avoid embedding pointer types unless necessary.
- Distinctive: line 25
Use value receivers when the method doesn't mutate state or require pointer semantics.
- Very specific: line 29
Do not use util, common, or similarly vague package names.
- Distinctive: line 30
Avoid package name collisions by using clear, unique names.
- Distinctive: line 31
Do not expose unnecessary symbols (keep exported API minimal).
- Distinctive: line 36
Avoid memory leaks from slicing large arrays.
- Distinctive: line 37
Always check the capacity when copying or appending slices.
- Distinctive: line 42
Always initialize maps before use.
- Very specific: line 43
Check existence with the two-value assignment (val, ok := m[key]).
- Distinctive: line 48
Always check errors — don’t ignore them.
- Distinctive: line 50
Avoid panics except in truly unrecoverable cases.
- Very specific: line 51
Use errors.Is and errors.As for error comparison in Go 1.20+.
- Very specific: line 55
Always defer cancel() when using context.WithCancel.
- Distinctive: line 56
Do not leak goroutines — ensure they exit cleanly.
- Distinctive: line 57
Avoid data races — use mutexes or channels appropriately.
- Distinctive: line 58
Never close a channel from the receiving side.
- Distinctive: line 63
Use table-driven tests where possible.
- Distinctive: line 64
Avoid global state in tests.
- Very specific: line 65
Use t.Helper() in helper functions to improve error tracebacks.
- Distinctive: line 69
Keep imports grouped and ordered: stdlib, external, internal.
- Distinctive: line 70
Avoid magic numbers — use named constants.
- Distinctive: line 71
Prefer explicit over implicit — especially in exported APIs.
- Distinctive: line 75
Only use generics when they simplify code or add real flexibility.
- Distinctive: line 76
Avoid over-engineering with type parameters.
- Very specific: line 81
Avoid using default int unless the size is appropriate.
- Very specific: line 83
Avoid precision issues with float32/float64 — prefer math/big if needed.
- Very specific: line 87
Prefer any to interface{} in Go 1.18+, but avoid both unless necessary
- Very specific: line 88
Do not rely on map or slice comparison — use reflect.DeepEqual or a library.
- Distinctive: line 89
Avoid relying on goroutine scheduling or map iteration order.
≈ “Common” is an estimate: at least 1 in 5 of the 6,668 Cursor rule 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
---
description: Go Best Practices
globs: *.go,!*.pb.go
alwaysApply: false
---
## General Best Practices
- Avoid variable shadowing.
- Do not over-nest control flow (e.g., nested `if` or `for` blocks).
- Avoid `init()` functions unless absolutely necessary.
- Keep functions small and focused.
- Prefer composition over inheritance (via embedding).
- Use the functional options pattern for constructors where flexibility is needed.
## Interfaces
- Avoid defining interfaces until you need them.
- Do not return interfaces from constructors or public APIs.
- Define interfaces on the consumer side, not the producer side.
- Keep interfaces small and focused (generally 1–2 methods).
## Structs and Methods
- Avoid embedding pointer types unless necessary.
- Don’t overuse getters/setters — prefer public fields when it makes sense.
- Use value receivers when the method doesn't mutate state or require pointer semantics.
## Packages and Imports
- Do not use `util`, `common`, or similarly vague package names.
- Avoid package name collisions by using clear, unique names.
- Do not expose unnecessary symbols (keep exported API minimal).
## Slices
- Distinguish between nil and empty slices.
- Avoid memory leaks from slicing large arrays.
- Always check the capacity when copying or appending slices.
- Preallocate slice capacity when size is known ahead of time.
## Maps
- Always initialize maps before use.
- Check existence with the two-value assignment (`val, ok := m[key]`).
- Be aware that ranging over a map is in random order.
## Error Handling
- Always check errors — don’t ignore them.
- Wrap errors with context when rethrowing.
- Avoid panics except in truly unrecoverable cases.
- Use `errors.Is` and `errors.As` for error comparison in Go 1.20+.
## Goroutines and Concurrency
- Always `defer cancel()` when using `context.WithCancel`.
- Do not leak goroutines — ensure they exit cleanly.
- Avoid data races — use mutexes or channels appropriately.
- Never close a channel from the receiving side.
## Testing and Debugging
- Name tests consistently: `TestXxx`, `BenchmarkXxx`, `ExampleXxx`.
- Use table-driven tests where possible.
- Avoid global state in tests.
- Use `t.Helper()` in helper functions to improve error tracebacks.
## Code Style and Tools
- Keep imports grouped and ordered: stdlib, external, internal.
- Avoid magic numbers — use named constants.
- Prefer explicit over implicit — especially in exported APIs.
## Go 1.18+ Generics
- Only use generics when they simplify code or add real flexibility.
- Avoid over-engineering with type parameters.
- Be cautious with constraint complexity — keep things readable.
## Numbers and Types
- Avoid using default `int` unless the size is appropriate.
- Watch for integer overflows and underflows.
- Avoid precision issues with `float32`/`float64` — prefer `math/big` if needed.
## Miscellaneous
- Prefer `any` to `interface{}` in Go 1.18+, but avoid both unless necessary
- Do not rely on map or slice comparison — use `reflect.DeepEqual` or a library.
- Avoid relying on goroutine scheduling or map iteration order.
Does 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.

