backend-golang

backend-golang is a cursor rule for Cursor from madebyaris/poinf-of-sales. It costs 0 tokens per session (1,014 once invoked), scanned A, original, MIT.

Backend coding rules for a Go-based restaurant point-of-sale system. They define package organization, HTTP handler patterns, safe SQL queries, error handling, and when to use database transactions.

In plain words
What is it for?
Use them when adding or changing Go models, handlers, middleware, routes, database access, or shared backend utilities.
Why use it?
They reduce inconsistent code and help avoid common backend problems such as SQL injection, ignored missing records, and incomplete multi-table updates.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/. Also seen: positional $N argument.

Good fit Use them when adding or changing Go models, handlers, middleware, routes, database access, or shared backend utilities.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/madebyaris/poinf-of-sales/backend-golang
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.

Clone the repo
git clone --depth 1 https://github.com/madebyaris/poinf-of-sales

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 backend-golang

README.md
[![agentmods](https://agentmods.dev/badge/rules/madebyaris/poinf-of-sales/backend-golang/github.svg)](https://agentmods.dev/rules/madebyaris/poinf-of-sales/backend-golang)
Your own site
<a href="https://agentmods.dev/rules/madebyaris/poinf-of-sales/backend-golang"><img src="https://agentmods.dev/badge/rules/madebyaris/poinf-of-sales/backend-golang/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for backend-golang

Your own site · 80×15
<a href="https://agentmods.dev/rules/madebyaris/poinf-of-sales/backend-golang"><img src="https://agentmods.dev/badge/rules/madebyaris/poinf-of-sales/backend-golang.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 1,014 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00000 $0.01014
Opus 5 $0.00000 $0.00507
Sonnet 5 $0.00000 $0.00203
Haiku 4.5 $0.00000 $0.00101

Measured 13d ago against content hash de4d70f53d3a, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-12, from the pricing page.

Security

Grade A, and why

backend-golang 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 13d 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/backend-golang.mdc · 146 lines

How it starts

The opening of the file, as written. The whole thing — 146 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Backend Development Guidelines (Golang)

Code Organization

Package Structure

Follow the backend/internal/ package layout:

  • models/ - Data structures and DTOs
  • handlers/ - HTTP request handlers
  • middleware/ - HTTP middleware functions
  • database/ - Database connection and utilities
  • api/ - Route definitions and setup
  • utils/ - Shared utility functions

Handler Pattern

All handlers follow the pattern in handlers/orders.go:

type OrderHandler struct {
    db *sql.DB
}

func NewOrderHandler(db *sql.DB) *OrderHandler {
    return &OrderHandler{db: db}
}

func (h *OrderHandler) GetOrders(c *gin.Context) {
    // Implementation
}

Database Operations

Raw SQL Usage

  • Use parameterized queries to prevent SQL injection
  • Follow the patterns in handlers/orders.go for database operations
  • Always handle sql.ErrNoRows explicitly
  • Use transactions for multi-table operations

Example Query Pattern:

func (h *Handler) getRecord(id uuid.UUID) (*Model, error) {
    var record Model
    query := `SELECT id, field1, field2 FROM table WHERE id = $1`
    
    err := h.db.QueryRow(query, id).Scan(&record.ID, &record.Field1, &record.Field2)
    if err == sql.ErrNoRows {
        return nil, fmt.Errorf("record not found")
    }
    if err != nil {
        return nil, fmt.Errorf("database error: %w", err)
    }
    
    return &record, nil
}

Authentication & Security

JWT Middleware

Use the authentication middleware from middleware/auth.go:

  • Protected routes must use authMiddleware
  • Role-based access with RequireRoles([]string{"admin", "manager"})
  • Extract user info with GetUserFromContext(c)

Error Handling

Follow the API response pattern from models/models.go:

c.JSON(http.StatusBadRequest, models.APIResponse{
    Success: false,
    Message: "User-friendly error message",
    Error:   stringPtr("error_code"),
})

Read the full file on GitHub · 146 lines

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. 13d ago First seen · 146 lines · 1,014 tokens per session scan A de4d70f53d3a

Subscribe to this mod's changes

backend-golang is a cursor rule published in the GitHub repository madebyaris/poinf-of-sales (142 stars, last pushed 1y ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,014 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.