Declarative .mdcQuy tắc Cursor/Claude/Windsurf & quy trình làm việc n8nKỹ năng đặc vụĐã kiểm tra rò rỉ bí mật

Đi 1.27 + gqlgen + pgx/v5 Kỹ năng vi dịch vụ bộ nhớ thấp

Kỹ năng kỹ thuật khai báo CLAUDE.md và .mdc để xây dựng phần phụ trợ <50MB RSS Go GraphQL với trình phân giải gqlgen tại thời gian biên dịch và các kết nối pgxpool bị giới hạn.

Tệp quy tắc IDE & Tác nhân khai báo

---
description: Go 1.27, gqlgen GraphQL resolvers, and pgx/v5 PostgreSQL pool patterns for sub-50MB microservices
globs: backend/**/*.{go,graphqls,yml}
alwaysApply: false
---

# Go 1.27 + gqlgen + pgx/v5 Production Architecture

- Configure `pgxpool` with `MaxConns = 10`, `MinConns = 1`, and `MaxConnIdleTime = 5 * time.Minute` to keep microservice RAM under 40–60 MB RSS.
- Propagate `context.Context` with explicit timeouts (`context.WithTimeout(ctx, 5*time.Second)`) across every SQL query and outbound HTTP request.
- Use parameterized `$1, $2` placeholders exclusively in `pgx` queries; never concatenate raw user input into SQL strings.
- Project localized JSONB payloads directly in PostgreSQL (`COALESCE(translations->$1, translations->'en')`) instead of unmarshaling all 26 locales in Go memory.
- Compile production binaries with `-ldflags='-s -w'` and bind internal API listeners strictly to `127.0.0.1:<PORT>` behind Nginx.

## Verification Check
```bash
go vet ./... && go build -ldflags='-s -w' ./cmd/server
```

Ghi chú Thiết lập Cộng đồng & Đánh giá Sản xuất (0)

Chưa có ghi chú cộng đồng nào. Chia sẻ mẹo cấu hình sản xuất của bạn bên dưới.

Đăng ghi chú thiết lập hoặc mẹo xác minh

Trình kiểm tra lược đồ tài nguyên và công cụ MCP

Mã định danh công cụ/tài nguyênThông số đầu vàoHành vi thực thi
bounded_pgxpool_configinternal/db/*.goEnforces MaxConns <= 10, context deadlines, and single-query JSONB projection.
compile_time_gqlgen_resolversgraph/*.goPrevents reflection bottlenecks and N+1 resolver loops.