go-service

go-service is a cursor rule for Cursor from golid-ai/golid. It costs 0 tokens per session (1,031 once invoked), scanned A, original, MIT.

Rules for writing Go service-layer code, the part of an application that applies business rules and accesses the database. They cover validation, permission checks, resource ownership, constructors, pagination, and module specifications.

In plain words
What is it for?
Use them when creating or modifying Go services that validate requests, authorize access, read or write database records, manage paginated results, or change module state.
Why use it?
They keep business logic and data access in a consistent place and prevent services from trusting callers to perform security checks correctly. They also require relevant module rules to be read before changing important state or API behavior.

Cursor rule for Cursor

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

Good fit Use them when creating or modifying Go services that validate requests, authorize access, read or write database records, manage paginated results, or change module state.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/golid-ai/golid/go-service
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/golid-ai/golid

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-service

README.md
[![agentmods](https://agentmods.dev/badge/rules/golid-ai/golid/go-service/github.svg)](https://agentmods.dev/rules/golid-ai/golid/go-service)
Your own site
<a href="https://agentmods.dev/rules/golid-ai/golid/go-service"><img src="https://agentmods.dev/badge/rules/golid-ai/golid/go-service/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 go-service

Your own site · 80×15
<a href="https://agentmods.dev/rules/golid-ai/golid/go-service"><img src="https://agentmods.dev/badge/rules/golid-ai/golid/go-service.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,031 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.01031
Opus 5 $0.00000 $0.00515
Sonnet 5 $0.00000 $0.00206
Haiku 4.5 $0.00000 $0.00103

Measured 9d ago against content hash 136bfe78e53b, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

go-service 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 9d 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-service.mdc · 99 lines

How it starts

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

Go Service Layer Patterns

Thesis: Services own business logic and data access. They are framework-agnostic, verify resource membership, and never trust the caller to have checked permissions.

Refrain: Validate → Authorize → Execute → Respond

Reference files: auth/auth.go, user/user.go

Structure

type XService struct {
    pool              *pgxpool.Pool
    paginationDefault int
    paginationMax     int
}
func NewXService(pool *pgxpool.Pool, paginationDefault, paginationMax int) *XService { ... }

This is the canonical shape for paginated CRUD services. Real services diverge based on their dependencies — NewUserService(pool, publicBaseURL), NewAuthService(pool, jwtSecret, jwtIssuer, accessDuration, refreshDuration, passwordResetTTL), NewFeatureService(pool) — but every service follows the same "concrete struct + constructor + framework-agnostic methods" rule. Match the constructor shape that fits the dependencies, not the template literally.

Before modifying a module's service (changes to status transitions, cross-module calls, or the API surface), read docs/modules/{module}/spec.md for state machine constraints and business rules. If available, also check docs/dependency-graph.md for blast radius and docs/flows.md for cross-module transaction boundaries.

  • Constructor takes *pgxpool.Pool plus whatever the service genuinely needs (pagination config for list endpoints, external service handles, frontend URL for redirects, etc.).
  • No Echo imports — services must be framework-agnostic. No echo.Context, no echo.NewHTTPError. Use apperror for errors, plain context.Context for context.
  • Define input/output structs in the same file (e.g., CreateItemInput, ItemDetail).
  • Return *Detail structs with formatted timestamps (time.RFC3339), not raw DB types.

Auth Pattern

Every method that operates on a scoped resource must verify membership, not just role:

// Resolve user → entity relationship
access, err := s.verifyResourceAccess(ctx, resourceID, userID)
// Then check specific permissions
if !access.IsAdmin { return apperror.Forbidden("...") }

Read the full file on GitHub · 99 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. 9d ago First seen · 99 lines · 0 tokens per session scan A 136bfe78e53b

Subscribe to this mod's changes

go-service 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,031 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.