horse-database-pooling

horse-database-pooling is a skill for Claude Code, Codex from HashLoad/horse. It costs 30 tokens per session (1,301 once invoked), scanned A, original, MIT.

A guide to safely reusing database connections in multithreaded Horse web applications. Horse is a Delphi web framework, and connection pooling keeps a managed set of database connections available for request-handling threads.

In plain words
What is it for?
Use it to configure FireDAC or UniDAC connection pooling for Horse applications, including PostgreSQL connection setup and per-request cleanup.
Why use it?
Sharing one database connection between simultaneous requests can cause race conditions, corrupted data, and access errors. The guide explains how each request can use its own connection or safely borrow one from a pool.

Skill for Claude CodeCodex

Install

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.

agentmods
npx agentmods add skills/hashload/horse/horse-database-pooling
Any agent
npx skills add HashLoad/horse --skill horse-database-pooling
Clone the repo
git clone --depth 1 https://github.com/HashLoad/horse

Made for: Claude Code, Codex.

Wrote 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.

agentmods badge for horse-database-pooling

README.md
[![agentmods](https://agentmods.dev/badge/skills/hashload/horse/horse-database-pooling.svg)](https://agentmods.dev/skills/hashload/horse/horse-database-pooling)
Your own site
<a href="https://agentmods.dev/skills/hashload/horse/horse-database-pooling"><img src="https://agentmods.dev/badge/skills/hashload/horse/horse-database-pooling.svg" alt="Measured on agentmods" height="20"></a>
Per session 30 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,301 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce invoked
Fable 5 $0.00030 $0.01301
Opus 5 $0.00015 $0.00651
Sonnet 5 $0.00006 $0.00260
Haiku 4.5 $0.00003 $0.00130

Measured 4d ago against content hash eb5e6f86738f, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

horse-database-pooling 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.

doc/skills/horse-database-pooling/SKILL.md · 157 lines

How it starts

The opening of the file, as written. The whole thing — 157 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Horse Database Pooling

1. The Multithreaded Database Rule

Horse handles each incoming HTTP request in a separate thread. Therefore, sharing a single database connection components (like a global TFDConnection or query component placed on a global DataModule/Controller) across requests will cause race conditions, data corruption, and Access Violations.

  • Rule: Every route handler thread must instantiate its own database connection (or request one from a thread-safe connection pool) and free it immediately after use.

2. Setting Up FireDAC Connection Pooling

FireDAC provides built-in, highly optimized connection pooling. To configure and use it:

Phase A: Defining the Connection Definition (Global Setup)

Configure the connection definition globally in your application bootstrap (program block or startup class) using TFDManager:

uses
  FireDAC.Stan.Intf, FireDAC.Phys.PG, FireDAC.Comp.Client;

procedure SetupConnectionPool;
var
  LParams: TStrings;
begin
  LParams := TStringList.Create;
  try
    LParams.Values['DriverID'] := 'PG'; // PostgreSQL example
    LParams.Values['Server'] := 'localhost';
    LParams.Values['Database'] := 'my_db';
    LParams.Values['User_Name'] := 'postgres';
    LParams.Values['Password'] := 'secret';
    LParams.Values['Pooled'] := 'True'; // CRITICAL: Enables pooling
    LParams.Values['POOL_MaximumItems'] := '50'; // Set maximum connections in pool
    
    // Register the definition with FDManager
    FDManager.AddConnectionDef('MyPooledPGDef', 'PG', LParams);
  finally
    LParams.Free;
  end;
end;

Phase B: Acquiring and Releasing Connections in Handlers

In your route handlers, instantiate the TFDConnection locally, referencing the pooled definition name. Always protect resources with try...finally:

procedure GetUsersHandler(Req: THorseRequest; Res: THorseResponse; Next: TProc);
var
  LConnection: TFDConnection;
  LQuery: TFDQuery;
begin
  LConnection := TFDConnection.Create(nil);
  LQuery := TFDQuery.Create(nil);
  try
    // Reference the pooled definition - this will instantly pull a connection from the pool
    LConnection.ConnectionDefName := 'MyPooledPGDef';
    LConnection.Connected := True;
    
    LQuery.Connection := LConnection;
    LQuery.SQL.Text := 'SELECT id, name FROM users';
    LQuery.Open;
    
    // Johnson middleware takes ownership of the JSON object/array
    Res.Send(LQuery.ToJSONArray);
  finally
    LQuery.Free;
    LConnection.Free; // Automatically releases connection back to the pool
  end;
end;

Read the full file on GitHub · 157 lines

Changes

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.

  1. 4d ago First seen · 157 lines · 30 tokens per session scan A eb5e6f86738f

Subscribe to this mod's changes

horse-database-pooling is a skill published in the GitHub repository HashLoad/horse (1,371 stars, last pushed 2d ago), licensed MIT. It adds 30 tokens to every session and 1,301 once invoked, about $0.0002 per session on Opus 5. 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.