go-backend

go-backend is a cursor rule for Cursor from Consensys/ask-o11y-plugin. It costs 0 tokens per session (445 once invoked), scanned A, original, MIT.

A set of coding rules for Go backend services, covering logging, HTTP error messages, access checks, and OpenAPI updates. OpenAPI is a machine-readable description of an HTTP service's endpoints.

In plain words
What is it for?
Use it when building or reviewing Go HTTP handlers, role-based access control, plugin endpoints, logging, or related OpenAPI files.
Why use it?
It helps keep backend behavior consistent and avoids exposing internal error details to users. It also reminds developers to update the service description and enforce permissions in both relevant request paths.

Cursor rule for Cursor

Install

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.

agentmods
npx agentmods add rules/consensys/ask-o11y-plugin/go-backend
Clone the repo
git clone --depth 1 https://github.com/Consensys/ask-o11y-plugin

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for go-backend

README.md
[![agentmods](https://agentmods.dev/badge/rules/consensys/ask-o11y-plugin/go-backend.svg)](https://agentmods.dev/rules/consensys/ask-o11y-plugin/go-backend)
Your own site
<a href="https://agentmods.dev/rules/consensys/ask-o11y-plugin/go-backend"><img src="https://agentmods.dev/badge/rules/consensys/ask-o11y-plugin/go-backend.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 445 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What 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.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.00445
Opus 5 $0.00000 $0.00222
Sonnet 5 $0.00000 $0.00089
Haiku 4.5 $0.00000 $0.00044

Measured 3d ago against content hash bbbe334cc7bc, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

go-backend 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.

.cursor/rules/go-backend.mdc · 54 lines

What it actually says

Go Backend Patterns

Reference: CLAUDE.md is the authoritative source.

Logging — Never use fmt.Println or stdlib log

// ✅ CORRECT — use the SDK logger
p.logger.Warn("Invalid request body", "error", err)
p.logger.Error("MCP call failed", "tool", toolName, "error", err)

// ❌ WRONG
fmt.Println("error:", err)
log.Printf("error: %v", err)

HTTP Error Responses — Never leak internals

// ✅ CORRECT — generic message to client, details in log
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
    p.logger.Warn("Invalid request body", "error", err)
    http.Error(w, "Invalid request body", http.StatusBadRequest)
    return
}

// ❌ WRONG — leaks request fragments / internal error details
http.Error(w, fmt.Sprintf("Invalid request: %v", err), http.StatusBadRequest)

RBAC — Double-check pattern (list AND execute)

  1. Extract role from req.Context()
  2. Call canAccessTool(role, toolName) — return 403 if unauthorized
  3. Enforcement must happen at BOTH tool listing and tool execution

OpenAPI Spec — Update when changing HTTP endpoints

Any change to routes in pkg/plugin/plugin.go requires:

  1. Update pkg/plugin/openapi/openapi.json
  2. Run nvm use 22 && npm run validate:openapi

Multi-Org Constraints (CRITICAL)

  • SA token from backend.GrafanaConfigFromContext() is Org 1 only
  • useBuiltInMCP: true only works for Org 1 — never set it in full.yaml_
  • For multi-org: use external mcp-grafana sidecar
  • The LLM client intentionally does not send X-Grafana-Org-Id when using SA token auth
Changes

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.

  1. 3d ago First seen · 54 lines · 0 tokens per session scan A bbbe334cc7bc

Subscribe to this mod's changes

go-backend is a cursor rule published in the GitHub repository Consensys/ask-o11y-plugin (40 stars, last pushed 9d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 445 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.