본문으로 건너뛰기
cccskills
무료GitHub에 공개

golang-database

Implement Go database access with context, pool tuning, transaction boundaries, and repository seams. Use when building repositories, tuning `sql.DB` or `pgx`, or reviewing DB transaction flow in Go.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

실행 점수 미검증

설치 방법 보기

포함된 파일(4)

  • SKILL.md3.2 KB
  • evals/evals.json1.8 KB
  • references/connection-tuning.md1.6 KB
  • references/repository-pattern.md1.8 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Golang Database

Priority: P0 (CRITICAL)

Rules

  • Prefer explicit SQL or generated query layers when performance and shape matter.
  • Configure the pool; defaults are rarely enough for real traffic.
  • Pass context.Context as the first argument to every query path.
  • Strict Parameterization: Always use parameterized placeholders (?, $1); never interpolate user strings into queries.
  • Dynamic IN Batching: Generate safe placeholders (strings.Repeat("?,", len(ids))) or sqlx.In and partition lists into chunks ≤ 1,000 items to avoid driver parameter limits.
  • Explicit Column Aliasing: Always alias duplicate column names in multi-table queries (e.g. m.code AS code); drivers map by name and silently collide on joins.
  • Transaction Boundaries: Manage transactions at the service layer using withTx(ctx, db, fn) with mandatory defer tx.Rollback(). Keep transactions short and focused on writes.
  • Streaming & Keyset Pagination: Stream large result sets using rows.Next() directly into models to prevent unbounded memory allocation.

Recipe

  1. Choose the access layer: database/sql, pgx, sqlx, sqlc, or ORM only if standardized.
  2. Tune the pool: max open, max idle, connection lifetime, and idle lifetime.
  3. Hide storage details behind repository methods or query services.
  4. Close rows and inspect rows.Err().
  5. Wrap multi-step writes in one transaction using a withTx helper with defer tx.Rollback().
  6. Chunk large slice lookups: partition slices into batches of ≤ 1,000 before running IN queries.

Verify

  • Query methods accept context.Context.
  • Pool settings are explicit.
  • Rows are closed and iteration errors checked (rows.Err()).
  • Large IN (...) queries chunk parameters into batches of ≤ 1,000.
  • Joined queries use explicit column aliases without SELECT *.
  • Transaction scope matches one business action and uses defer tx.Rollback().
  • Retry/idempotency policy is clear for contested writes.

Anti-Patterns

  • No global db var: inject DB connection via constructor.
  • No context-less queries: use QueryContext/ExecContext; bare queries ignore timeouts.
  • No string concatenation in SQL: never build dynamic clauses with fmt.Sprintf or +.
  • No unbounded IN lists: avoid passing un-chunked slices with > 1,000 items into a single query.
  • No SELECT * on Joins: avoid unaliased duplicate column names across joined tables.
  • No leaked rows: always defer rows.Close() and check rows.Err().
  • No transaction split-brain: handler, repo, and service cannot each open their own transaction for one unit of work.

References

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Upgrade an Android project to Android Gradle Plugin (AGP) 9. Use when migrating to AGP 9, updating Gradle build files, migrating to built-in Kotlin, or adopting the new AGP DSL.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

HoangNguyen0403/agent-skills-standard5812026년 10월 24일 업데이트

Apply Clean Architecture layering, modularization, and Unidirectional Data Flow in Android projects. Use when setting up project structure, placing code in layers, configuring feature/core modules, or implementing UDF patterns; defer Compose state and ViewModel/StateFlow implementation to their specific skills.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

HoangNguyen0403/agent-skills-standard5812026년 10월 24일 업데이트

Implement WorkManager and background processing correctly on Android. Use when creating Worker classes, scheduling tasks, choosing between WorkManager and Foreground Services, or setting up Hilt in workers; defer FCM and notification delivery to android-notifications.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

HoangNguyen0403/agent-skills-standard5812026년 10월 24일 업데이트

Build high-performance declarative UI with Jetpack Compose. Use when writing Composable functions, optimizing recomposition, hoisting state, or working with LazyColumn and side effects; defer deep-link and navigation routing to android-navigation.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

HoangNguyen0403/agent-skills-standard5812026년 10월 24일 업데이트

Migrate an Android XML View to Jetpack Compose following a structured 10-step workflow. Use when converting XML layouts to Compose, setting up Compose in an existing View-based project, or incrementally adopting Compose.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

HoangNguyen0403/agent-skills-standard5812026년 10월 24일 업데이트

Write correct coroutine scopes, lifecycle collection, and dispatcher injection in Android production code. Use for suspend functions, coroutine scopes, and dispatcher mechanics; defer ViewModel StateFlow/LiveData architecture, Fragment lifecycle recipes, persistence/notifications, and unit-test recipes to their specific skills.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

HoangNguyen0403/agent-skills-standard5812026년 10월 24일 업데이트

HoangNguyen0403의 스킬 모두 보기

이 스킬의 문제 신고