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/wangqiqi/cursor-ai-rules/go-performancegit clone --depth 1 https://github.com/wangqiqi/cursor-ai-rulesWrote 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.
[](https://agentmods.dev/rules/wangqiqi/cursor-ai-rules/go-performance)<a href="https://agentmods.dev/rules/wangqiqi/cursor-ai-rules/go-performance"><img src="https://agentmods.dev/badge/rules/wangqiqi/cursor-ai-rules/go-performance.svg" alt="Measured on agentmods" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00000 | $0.01552 |
| Opus 5 | $0.00000 | $0.00776 |
| Sonnet 5 | $0.00000 | $0.00310 |
| Haiku 4.5 | $0.00000 | $0.00155 |
Grade A, and why
go-performance 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 4d 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 — 260 lines — stays where its author put it; the contents beside it link to each section on GitHub.
🚀 Go 性能优化
type AtomicCounter struct { count int64 }
func (c *AtomicCounter) Increment() { atomic.AddInt64(&c.count, 1) }
func (c *AtomicCounter) Get() int64 { return atomic.LoadInt64(&c.count) }
// ✅ 推荐:Worker Pool 模式 type WorkerPool struct { workers int taskChan chan func() quitChan chan struct{} wg sync.WaitGroup }
func NewWorkerPool(workers int) WorkerPool { wp := &WorkerPool{ workers: workers, taskChan: make(chan func(), workers2), quitChan: make(chan struct{}), }
wp.start()
return wp
}
func (wp *WorkerPool) start() { for i := 0; i < wp.workers; i++ { wp.wg.Add(1) go func() { defer wp.wg.Done() for { select { case task := <-wp.taskChan: task() case <-wp.quitChan: return } } }() } }
func (wp *WorkerPool) Submit(task func()) { select { case wp.taskChan <- task: case <-wp.quitChan: return } }
func (wp *WorkerPool) Stop() { close(wp.quitChan) wp.wg.Wait() }
## 🔒 安全实践
### 输入验证和清理
```go
import (
"html"
"net/url"
"regexp"
"strings"
"unicode/utf8"
)
// ✅ 推荐:输入验证和清理
type UserInputValidator struct {
usernameRegex *regexp.Regexp
emailRegex *regexp.Regexp
}
func NewUserInputValidator() *UserInputValidator {
return &UserInputValidator{
usernameRegex: regexp.MustCompile(`^[a-zA-Z0-9_]{3,50}$`),
emailRegex: regexp.MustCompile(`^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$`),
}
}
func (v *UserInputValidator) ValidateUsername(username string) error {
if username == "" {
return errors.New("username is required")
}
if utf8.RuneCountInString(username) > 50 {
return errors.New("username too long")
}
if !v.usernameRegex.MatchString(username) {
return errors.New("username contains invalid characters")
}
return nil
}
func (v *UserInputValidator) ValidateEmail(email string) error {
if email == "" {
return errors.New("email is required")
}
if len(email) > 254 {
return errors.New("email too long")
}
email = strings.TrimSpace(strings.ToLower(email))
if !v.emailRegex.MatchString(email) {
return errors.New("invalid email format")
}
return nil
}
func (v *UserInputValidator) SanitizeInput(input string) string {
// HTML转义
input = html.EscapeString(input)
// URL编码处理
if strings.Contains(input, "%") {
if decoded, err := url.QueryUnescape(input); err == nil {
input = decoded
}
}
// 移除控制字符
input = strings.Map(func(r rune) rune {
if r < 32 || r == 127 {
return -1
}
return r
}, input)
return strings.TrimSpace(input)
}
// ✅ 推荐:SQL注入防护
func (r *UserRepository) GetUserByIDSafe(ctx context.Context, id int64) (*User, error) {
// 使用参数化查询自动防止SQL注入
query := `SELECT id, username, email, created_at FROM users WHERE id = $1`
var user User
err := r.db.QueryRowContext(ctx, query, id).Scan(
&user.ID, &user.Username, &user.Email, &user.CreatedAt,
)
if err == sql.ErrNoRows {
return nil, ErrUserNotFound
}
if err != nil {
return nil, fmt.Errorf("failed to get user: %w", err)
}
return &user, nil
}
密码安全处理
import (
"crypto/rand"
"crypto/subtle"
"golang.org/x/crypto/argon2"
"golang.org/x/crypto/bcrypt"
)
// ✅ 推荐:安全的密码哈希
type PasswordHasher struct {
time uint32
memory uint32
threads uint8
keyLen uint32
}
func NewPasswordHasher() *PasswordHasher {
return &PasswordHasher{
time: 1,
memory: 64 * 1024, // 64MB
threads: 4,
keyLen: 32,
}
}
func (h *PasswordHasher) HashPassword(password string) ([]byte, error) {
// 生成盐值
salt := make([]byte, 32)
if _, err := rand.Read(salt); err != nil {
return nil, err
}
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.
- 4d ago First seen · 260 lines · 0 tokens per session scan A 09494da2819e
go-performance is a cursor rule published in the GitHub repository wangqiqi/cursor-ai-rules (15 stars, last pushed 3mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,552 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
adapter-features
Database-specific features must be implemented in the specialized adapter only. Base adapters (postgres, mysql, etc.) must remain database-agnostic.
unit-tests-tdd
TDD required for behavior changes; ≥80% package coverage on touched packages; unit-test conventions.
integration-tests
Human-readable integration test requests; helpers vs httptest; suites/ vs per-DB placement.
code-style
Formatting, lint, comments language.
shared-libraries
Shared libraries - condition framework, inventory containers, file-backed DB, itinerary, references.
go-conventions
Go conventions for all Go code (modules, naming, errors, logging, metrics).