gorm-session

Configure GORM sessions for SQL generation, prepared statement caching, and batch operations.

Updated Apr 4, 2026
One-click install
npx skills add https://github.com/liurida/gorm-development-skill --skill gorm-session
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: gorm-session
Source: https://github.com/liurida/gorm-development-skill/tree/main/session
Command: npx skills add https://github.com/liurida/gorm-development-skill --skill gorm-session

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Provide precise, session-scoped control over GORM database operations to avoid accidental global updates, enable safe bulk imports, improve performance with prepared statements, and aid debugging by generating SQL without execution.

Core Features & Use Cases

  • Enables DryRun mode to generate SQL for inspection and debugging without executing it.
  • Supports prepared statement caching, session isolation (NewDB), and context-aware timeouts for robust performance and safety.
  • Useful for bulk imports, migrations, performance tuning, and controlled maintenance scripts where skipping hooks or allowing global updates must be done deliberately.

Quick Start

Create a GORM session that enables prepared statement caching, sets a timeout context, and runs a dry-run query to inspect generated SQL.

Frequently Asked Questions about gorm-session

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate SQL without executing it in GORM for debugging?

You can generate SQL without execution in GORM by enabling DryRun mode within a session. This allows you to inspect the generated queries for debugging and performance tuning without modifying the database.

What is the best way to skip hooks during bulk operations with GORM?

To skip hooks during bulk operations in GORM, configure a custom session with the SkipHooks option. This allows controlled maintenance scripts and bulk imports to bypass callback execution for improved speed.

How do I cache prepared statements for GORM database operations?

You can cache prepared statements in GORM by applying the prepared statement configuration within a new session. This improves performance by reusing compiled queries across multiple database operations.

Can I configure batch sizes for bulk imports using GORM sessions?

Yes, you can configure batch sizes for bulk imports in GORM by setting the batch size parameter at the session level. This controls how many records are processed per insertion during large data migrations.

How do I isolate session state to avoid accidental global updates in GORM?

You isolate session state in GORM by using the NewDB session configuration. This creates a fresh session scope that prevents conditions from leaking, avoiding accidental global updates across your application.

Does GORM support context-aware timeouts for database sessions?

Yes, GORM supports context-aware timeouts by passing a configured context to the session. This ensures database operations respect deadline limits for robust performance and safety during execution.