[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M79Z9SKMTPWJX5NJPPSNBMBE":3,"skill-same:01M79Z9SKMTPWJX5NJPPSNBMBE":62},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":31,"commitSha":32,"skillDirectory":33,"forksCount":14,"repositoryHtmlUrl":34,"repositoryHomepageUrl":6,"ownerHtmlUrl":35,"ownerBlogUrl":36,"ownerDescription":37,"updatedAt":38,"install":39,"resources":51},"01M79Z9SKMTPWJX5NJPPSNBMBE","go-database",null,"Database patterns for Go services: database\u002Fsql, connection management, transactions, migrations, query builders, and ORM usage (sqlc, GORM, ent). Use when: \"database access\", \"SQL query\", \"connection pool\", \"transactions\", \"database migration\", \"sqlc\", \"GORM\", \"ent\", \"prepared statement\", \"repository pattern\". Not for: in-memory structures (go-data-structures), SQL security (go-security-audit), query profiling (go-performance-review).","kongnakornna\u002Fgolangapi","kongnakornna","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F10528904?v=4","01M79Z5JQPPV5CWQHXS235Q9MD","Kongnakorn Jantakun","01M79Z5JRHJJJ6PR2DGQS4P985",0,"MIT","https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fgo-agent-skills\u002Fskills\u002F(data)\u002Fgo-database\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: go-database\ndescription: >\n  Database patterns for Go services: database\u002Fsql, connection management,\n  transactions, migrations, query builders, and ORM usage (sqlc, GORM, ent).\n  Use when: \"database access\", \"SQL query\", \"connection pool\",\n  \"transactions\", \"database migration\", \"sqlc\", \"GORM\", \"ent\", \"prepared\n  statement\", \"repository pattern\".\n  Not for: in-memory structures (go-data-structures), SQL security\n  (go-security-audit), query profiling (go-performance-review).\nuser-invocable: true\nlicense: MIT\ncompatibility: Designed for Claude Code or similar AI coding agents working on Go projects. Requires the Go toolchain. sqlc, golang-migrate and Docker are optional.\nallowed-tools: Read Edit Write Glob Grep Bash(go:*) Bash(gofmt:*)\nmetadata:\n  author: eduardo-sl\n  version: \"1.2.1\"\n---\n\n# Go Database Patterns\n\nDatabase access is where most Go services spend their complexity budget.\nGet connection management, transactions, and query patterns right.\n\nDetailed reference material, loaded on demand:\n\n- `references\u002Fquery-patterns.md` — full query\u002Fscan\u002Frows patterns, null\n  handling, N+1 avoidance, connection-leak examples.\n- `references\u002Ftooling.md` — repository pattern implementation, sqlc\n  annotated queries, migration tooling and rules.\n\nRead a reference file only when the summary below is not enough.\n\n## 1. Connection Management\n\nConfigure the pool explicitly — the default is unbounded connections:\n\n```go\nfunc OpenDB(dsn string) (*sql.DB, error) {\n    db, err := sql.Open(\"postgres\", dsn)\n    if err != nil {\n        return nil, fmt.Errorf(\"open db: %w\", err)\n    }\n\n    db.SetMaxOpenConns(25)\n    db.SetMaxIdleConns(10)\n    db.SetConnMaxLifetime(5 * time.Minute)\n    db.SetConnMaxIdleTime(1 * time.Minute)\n\n    if err := db.PingContext(context.Background()); err != nil {\n        return nil, fmt.Errorf(\"ping db: %w\", err)\n    }\n\n    return db, nil\n}\n```\n\n| Setting | Guideline |\n|---|---|\n| `MaxOpenConns` | Match your DB's max connections \u002F number of app instances |\n| `MaxIdleConns` | 40-50% of MaxOpenConns |\n| `ConnMaxLifetime` | 5-10 minutes (prevents stale connections behind load balancers) |\n| `ConnMaxIdleTime` | 1-2 minutes |\n\n## 2. Query Rules\n\n1. **Parameterized queries only** — string concatenation into SQL is an\n   injection vulnerability, no exceptions.\n2. **Always pass context** — use the `*Context` variants\n   (`QueryContext`, `QueryRowContext`, `ExecContext`) so queries respect\n   cancellation and timeouts.\n3. **`defer rows.Close()`** immediately after the error check, and check\n   `rows.Err()` after the iteration loop.\n4. **Handle `sql.ErrNoRows` explicitly** with `errors.Is`, mapping it to\n   a domain error like `ErrUserNotFound`.\n\n```go\nvar user User\nerr := db.QueryRowContext(ctx,\n    \"SELECT id, name, email FROM users WHERE id = $1\", id,\n).Scan(&user.ID, &user.Name, &user.Email)\n\nif errors.Is(err, sql.ErrNoRows) {\n    return nil, ErrUserNotFound\n}\nif err != nil {\n    return nil, fmt.Errorf(\"get user %s: %w\", id, err)\n}\n```\n\nMulti-row iteration patterns: `references\u002Fquery-patterns.md`.\n\n## 3. Transactions\n\nUse a helper that guarantees rollback on error:\n\n```go\nfunc WithTx(ctx context.Context, db *sql.DB, fn func(tx *sql.Tx) error) error {\n    tx, err := db.BeginTx(ctx, nil)\n    if err != nil {\n        return fmt.Errorf(\"begin tx: %w\", err)\n    }\n\n    if err := fn(tx); err != nil {\n        if rbErr := tx.Rollback(); rbErr != nil {\n            return fmt.Errorf(\"rollback failed: %v (original: %w)\", rbErr, err)\n        }\n        return err\n    }\n\n    if err := tx.Commit(); err != nil {\n        return fmt.Errorf(\"commit tx: %w\", err)\n    }\n    return nil\n}\n```\n\nSet isolation explicitly for critical operations:\n`sql.TxOptions{Isolation: sql.LevelSerializable}`.\n\n## 4. Structure and Tooling\n\n- **Repository pattern:** define the interface at the consumer side,\n  implement it with concrete database access, map driver errors to\n  domain errors at this boundary.\n- **sqlc:** prefer it for raw-SQL projects — generates type-safe Go from\n  annotated SQL, catching query\u002Fschema mismatches at build time.\n- **Migrations:** use a tool (`goose`, `golang-migrate`, `atlas`), one\n  migration per change, forward-only in production, with `down` SQL, run\n  as a separate step — not at server startup.\n\nImplementations and examples: `references\u002Ftooling.md`.\n\n## 5. Common Pitfalls\n\n- **Null columns:** use `sql.NullString`\u002F`sql.NullInt64` or pointer\n  fields (`*string`, nil = SQL NULL). Scanning NULL into a plain string\n  errors at runtime.\n- **N+1 queries:** a query inside a loop over query results. Replace\n  with a JOIN or a batch query (`WHERE id = ANY($1)`).\n- **Connection leaks:** any early `return` between `Query` and\n  `defer rows.Close()` leaks a connection from the pool.\n\nWorked examples of each pitfall: `references\u002Fquery-patterns.md`.\n\n## Verification Checklist\n\n1. Connection pool configured with explicit limits (`MaxOpenConns`, `MaxIdleConns`, lifetimes)\n2. All queries use parameterized placeholders, never string concatenation\n3. All `QueryContext` results have `defer rows.Close()` immediately after error check\n4. `rows.Err()` checked after row iteration loop\n5. `sql.ErrNoRows` handled explicitly with `errors.Is`\n6. Transactions use a helper that guarantees rollback on error\n7. Context propagated to all database calls (`*Context` variants)\n8. Nullable columns use `sql.NullString` \u002F `sql.NullInt64` or pointer types\n9. No N+1 query patterns — use JOINs or batch queries\n10. Migrations are versioned, reversible, and run separately from app startup\n","# Go Database Patterns\n\nDatabase access is where most Go services spend their complexity budget.\nGet connection management, transactions, and query patterns right.\n\nDetailed reference material, loaded on demand:\n\n- `references\u002Fquery-patterns.md` — full query\u002Fscan\u002Frows patterns, null\n  handling, N+1 avoidance, connection-leak examples.\n- `references\u002Ftooling.md` — repository pattern implementation, sqlc\n  annotated queries, migration tooling and rules.\n\nRead a reference file only when the summary below is not enough.\n\n## 1. Connection Management\n\nConfigure the pool explicitly — the default is unbounded connections:\n\n```go\nfunc OpenDB(dsn string) (*sql.DB, error) {\n    db, err := sql.Open(\"postgres\", dsn)\n    if err != nil {\n        return nil, fmt.Errorf(\"open db: %w\", err)\n    }\n\n    db.SetMaxOpenConns(25)\n    db.SetMaxIdleConns(10)\n    db.SetConnMaxLifetime(5 * time.Minute)\n    db.SetConnMaxIdleTime(1 * time.Minute)\n\n    if err := db.PingContext(context.Background()); err != nil {\n        return nil, fmt.Errorf(\"ping db: %w\", err)\n    }\n\n    return db, nil\n}\n```\n\n| Setting | Guideline |\n|---|---|\n| `MaxOpenConns` | Match your DB's max connections \u002F number of app instances |\n| `MaxIdleConns` | 40-50% of MaxOpenConns |\n| `ConnMaxLifetime` | 5-10 minutes (prevents stale connections behind load balancers) |\n| `ConnMaxIdleTime` | 1-2 minutes |\n\n## 2. Query Rules\n\n1. **Parameterized queries only** — string concatenation into SQL is an\n   injection vulnerability, no exceptions.\n2. **Always pass context** — use the `*Context` variants\n   (`QueryContext`, `QueryRowContext`, `ExecContext`) so queries respect\n   cancellation and timeouts.\n3. **`defer rows.Close()`** immediately after the error check, and check\n   `rows.Err()` after the iteration loop.\n4. **Handle `sql.ErrNoRows` explicitly** with `errors.Is`, mapping it to\n   a domain error like `ErrUserNotFound`.\n\n```go\nvar user User\nerr := db.QueryRowContext(ctx,\n    \"SELECT id, name, email FROM users WHERE id = $1\", id,\n).Scan(&user.ID, &user.Name, &user.Email)\n\nif errors.Is(err, sql.ErrNoRows) {\n    return nil, ErrUserNotFound\n}\nif err != nil {\n    return nil, fmt.Errorf(\"get user %s: %w\", id, err)\n}\n```\n\nMulti-row iteration patterns: `references\u002Fquery-patterns.md`.\n\n## 3. Transactions\n\nUse a helper that guarantees rollback on error:\n\n```go\nfunc WithTx(ctx context.Context, db *sql.DB, fn func(tx *sql.Tx) error) error {\n    tx, err := db.BeginTx(ctx, nil)\n    if err != nil {\n        return fmt.Errorf(\"begin tx: %w\", err)\n    }\n\n    if err := fn(tx); err != nil {\n        if rbErr := tx.Rollback(); rbErr != nil {\n            return fmt.Errorf(\"rollback failed: %v (original: %w)\", rbErr, err)\n        }\n        return err\n    }\n\n    if err := tx.Commit(); err != nil {\n        return fmt.Errorf(\"commit tx: %w\", err)\n    }\n    return nil\n}\n```\n\nSet isolation explicitly for critical operations:\n`sql.TxOptions{Isolation: sql.LevelSerializable}`.\n\n## 4. Structure and Tooling\n\n- **Repository pattern:** define the interface at the consumer side,\n  implement it with concrete database access, map driver errors to\n  domain errors at this boundary.\n- **sqlc:** prefer it for raw-SQL projects — generates type-safe Go from\n  annotated SQL, catching query\u002Fschema mismatches at build time.\n- **Migrations:** use a tool (`goose`, `golang-migrate`, `atlas`), one\n  migration per change, forward-only in production, with `down` SQL, run\n  as a separate step — not at server startup.\n\nImplementations and examples: `references\u002Ftooling.md`.\n\n## 5. Common Pitfalls\n\n- **Null columns:** use `sql.NullString`\u002F`sql.NullInt64` or pointer\n  fields (`*string`, nil = SQL NULL). Scanning NULL into a plain string\n  errors at runtime.\n- **N+1 queries:** a query inside a loop over query results. Replace\n  with a JOIN or a batch query (`WHERE id = ANY($1)`).\n- **Connection leaks:** any early `return` between `Query` and\n  `defer rows.Close()` leaks a connection from the pool.\n\nWorked examples of each pitfall: `references\u002Fquery-patterns.md`.\n\n## Verification Checklist\n\n1. Connection pool configured with explicit limits (`MaxOpenConns`, `MaxIdleConns`, lifetimes)\n2. All queries use parameterized placeholders, never string concatenation\n3. All `QueryContext` results have `defer rows.Close()` immediately after error check\n4. `rows.Err()` checked after row iteration loop\n5. `sql.ErrNoRows` handled explicitly with `errors.Is`\n6. Transactions use a helper that guarantees rollback on error\n7. Context propagated to all database calls (`*Context` variants)\n8. Nullable columns use `sql.NullString` \u002F `sql.NullInt64` or pointer types\n9. No N+1 query patterns — use JOINs or batch queries\n10. Migrations are versioned, reversible, and run separately from app startup\n",{"name":5,"license":15,"metadata":24,"description":27,"allowed-tools":28,"compatibility":29,"user-invocable":30},{"author":25,"version":26},"eduardo-sl","1.2.1","Database patterns for Go services: database\u002Fsql, connection management, transactions, migrations, query builders, and ORM usage (sqlc, GORM, ent). Use when: \"database access\", \"SQL query\", \"connection pool\", \"transactions\", \"database migration\", \"sqlc\", \"GORM\", \"ent\", \"prepared statement\", \"repository pattern\". Not for: in-memory structures (go-data-structures), SQL security (go-security-audit), query profiling (go-performance-review).\n","Read Edit Write Glob Grep Bash(go:*) Bash(gofmt:*)","Designed for Claude Code or similar AI coding agents working on Go projects. Requires the Go toolchain. sqlc, golang-migrate and Docker are optional.",true,"main","19f4d52a98d557f3a645a2cfbbeb5bd54f28831d",".github\u002Fskills\u002Fgo-agent-skills\u002Fskills\u002F(data)\u002Fgo-database","https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi","https:\u002F\u002Fgithub.com\u002Fkongnakornna","http:\u002F\u002Fcmoniot.trueddns.com:52160","Technical Skills and Expertise\r\nLanguages and Frameworks\r\nFrontend: HTML, JavaScript, TypeScript, React, Vue, Angular, Next.js\r\nBackend: Node.js,Python,Golang","2026-10-06 23:01:46",{"source":8,"skillName":5,"commands":40,"prompt":50,"zipAvailable":30},[41,44,47],{"tool":42,"command":43},"npx","npx skills add kongnakornna\u002Fgolangapi --skill go-database",{"tool":45,"command":46},"bunx","bunx skills add kongnakornna\u002Fgolangapi --skill go-database",{"tool":48,"command":49},"pnpm","pnpm dlx skills add kongnakornna\u002Fgolangapi --skill go-database","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fgo-agent-skills\u002Fskills\u002F(data)\u002Fgo-database\u002FSKILL.md",[52,58],{"path":53,"resourceType":54,"resourceTypeDesc":55,"sizeBytes":56,"sourceHtmlUrl":57},"references\u002Fquery-patterns.md","REFERENCE","参考文档",3260,"https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fgo-agent-skills\u002Fskills\u002F(data)\u002Fgo-database\u002Freferences\u002Fquery-patterns.md",{"path":59,"resourceType":54,"resourceTypeDesc":55,"sizeBytes":60,"sourceHtmlUrl":61},"references\u002Ftooling.md",2688,"https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fgo-agent-skills\u002Fskills\u002F(data)\u002Fgo-database\u002Freferences\u002Ftooling.md",[63,71,78,85,92,99],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":67,"licenseFileUrl":6,"sourceHtmlUrl":68,"categories":69,"keywords":70,"publishedAt":19},"01M7A0M9RJJ3383VEFYKABWV15","tb-writing-plans","Use when you have a spec or requirements for a multi-step task, before touching code","Apache-2.0","https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Ftb-writing-plans\u002FSKILL.md",[],[],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":67,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":19},"01M7A0M4JKY4DEDRP1CBHT00WV","tb-using-git-worktrees","Use when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback","https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Ftb-using-git-worktrees\u002FSKILL.md",[],[],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":67,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":19},"01M7A0KZ5HRAQAAT2KXR6146Q7","tb-test-driven-development","Use when implementing any feature or bugfix, before writing implementation code","https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Ftb-test-driven-development\u002FSKILL.md",[],[],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":67,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":19},"01M7A0KW92W3F18E2MRP8H62P2","tb-subagent-driven-development","Use when executing implementation plans with independent tasks in the current session","https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Ftb-subagent-driven-development\u002FSKILL.md",[],[],{"skillNo":93,"name":94,"nameZh":6,"description":95,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":67,"licenseFileUrl":6,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":19},"01M7A0KKYQCHYYRHA5J5BAP24M","tb-scrutinize","Outsider-perspective end-to-end review of a plan, PR, or code change. First questions intent and whether a simpler\u002Fmore elegant approach would achieve the same goal, then traces the actual code path (not just the diff) to verify the change does what it claims. Output is concise, actionable, and every call carries its rationale. Trigger on \u002Ftb-scrutinize and proactively whenever the user asks to review, audit, sanity-check, or get a second opinion on a plan, PR, diff, design doc, or proposed code change.","https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Ftb-scrutinize\u002FSKILL.md",[],[],{"skillNo":100,"name":101,"nameZh":6,"description":102,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":67,"licenseFileUrl":6,"sourceHtmlUrl":103,"categories":104,"keywords":105,"publishedAt":19},"01M7A0KFDR1V3RW7SW1XNHP82P","tb-requesting-code-review","Use when completing tasks, implementing major features, or before merging to verify work meets requirements","https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Ftb-requesting-code-review\u002FSKILL.md",[],[]]