Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add rules/golid-ai/golid/go-handlergit clone --depth 1 https://github.com/golid-ai/golidWhat it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00000 | $0.01160 |
| Opus 5 | $0.00000 | $0.00580 |
| Sonnet 5 | $0.00000 | $0.00232 |
| Haiku 4.5 | $0.00000 | $0.00116 |
Grade A, and why
go-handler scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 154 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Go Handler Layer Patterns
Thesis: Handlers are thin translators between HTTP and services. They validate input, extract auth, delegate to services, and return JSON — nothing more.
Refrain:
Extract → Validate → Delegate → Return
Reference files: auth.go, user.go, middleware/stack.go
Before modifying a module's handler (changes to validation, auth, or route
registration), read docs/modules/{module}/spec.md for API surface and
validation rules. For cross-module request chains, also check docs/flows.md.
Structure
type XHandler struct { xService xServicer }
func NewXHandler(xService *service.XService) *XHandler { ... }
- Handlers are thin — validate input, delegate to service, return JSON.
- No business logic in handlers. No direct DB access.
- Struct field is the interface (
xServicer), constructor takes the concrete type. This is the standard pattern —make new-modulegenerates it automatically.
Service Interfaces
Handlers use unexported interfaces (authServicer, userServicer, sseHubber), not concrete service types. This enables mock-based testing. Constructor takes concrete types (callers unchanged), struct field is the interface. See handler/interfaces.go.
Scaffold Output
make new-module name=items generates:
handler/item.go— Handler with interface-typed service fieldhandler/item_test.go— Mock struct + 5 test stubs (Create success, Create validation, List, GetByID not found, Delete)- Interface entry appended to
handler/interfaces.go - Fill in test bodies for your specific validation logic and error paths.
Auth Extraction
Every protected handler starts with:
userID, err := requireUserID(c)
if err != nil { return err }
userType, err := requireUserType(c)
if err != nil { return err }
Role guards (when needed) go after extraction:
if userType != "admin" {
return apperror.Forbidden("Only admins can create items")
}
Resource-level authorization is handled by the service layer, not the handler.
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 3d ago First seen · 154 lines · 0 tokens per session scan A 09a97dd86628
go-handler is a cursor rule published in the GitHub repository golid-ai/golid (40 stars, last pushed 2mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,160 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other cursor rules, from other repositories
backend
You are an expert in Go, Gin, Gorm, Gen, Cosy (https://cosy.uozi.org/) with a deep understanding of best practices and performance optimization techniques in these technologies.
cursor-rule-template
Cursor rule "cursor-rule-template" from singchia/gospec, covering gospec —— go 后端 sdlc 规范(cursor 单文件入口), 任务路由(先看这个表,再决定要不要展开 spec/), 核心约束(不可违反,无需打开 spec 也要遵守), 架构 and 编码.
best-practices
Go Best Practices - enforces current best practices when working with Go code.
go-idiomatic-code
This rule ensures that all Go code follows idiomatic Go practices, adhering to the official Go style guide and common best practices in the Go community.
go-project-structure
This rule ensures that Go projects follow a consistent and idiomatic structure, making the codebase easier to navigate, maintain, and scale.
go-patterns
Go idioms, error handling, and tooling conventions.