horse-zero-allocation

horse-zero-allocation is a skill for Claude Code, Codex from HashLoad/horse. It costs 32 tokens per session (814 once invoked), scanned A, original, MIT.

Programming guidance for reducing heap memory allocations in Horse applications, especially under heavy concurrency.

In plain words
What is it for?
It is for building routers, middleware, and request handlers with string slicing, object pooling, and other allocation-conscious techniques.
Why use it?
Fewer allocations can reduce memory-manager contention and avoid unnecessary string copying.

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-zero-allocation
Any agent
npx skills add HashLoad/horse --skill horse-zero-allocation
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-zero-allocation

README.md
[![agentmods](https://agentmods.dev/badge/skills/hashload/horse/horse-zero-allocation.svg)](https://agentmods.dev/skills/hashload/horse/horse-zero-allocation)
Your own site
<a href="https://agentmods.dev/skills/hashload/horse/horse-zero-allocation"><img src="https://agentmods.dev/badge/skills/hashload/horse/horse-zero-allocation.svg" alt="Measured on agentmods" height="20"></a>
Per session 32 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 814 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.00032 $0.00814
Opus 5 $0.00016 $0.00407
Sonnet 5 $0.00006 $0.00163
Haiku 4.5 $0.00003 $0.00081

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

Security

Grade A, and why

horse-zero-allocation 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-zero-allocation/SKILL.md · 86 lines

How it starts

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

Horse Zero-Allocation Programming

To write custom routers, high-performance middlewares, or request handlers that scale under extreme concurrency, you must minimize or eliminate memory allocations on the dynamic heap. Heap allocations require global memory manager locks, which cause lock contention and page faults across multi-threaded applications.


1. Zero-Allocation String Slicing (Avoid String Copying)

Using functions like Copy(MyString, Start, Length) or string concatenation (+) allocates new string segments on the heap. Under heavy concurrency, this degrades performance.

  • Rule: Use index/pointer boundaries (such as PChar) or specialized slice types to perform string matches and parsing.
  • Idiomatic Example: Create or use a slice structure (like THorseBufferSlice in the Horse RouterTree) to match paths without generating new sub-strings.
type
  TZeroAllocSlice = record
    Buffer: PChar;
    Start: Integer;
    Length: Integer;
    function Compare(const AString: string): Boolean;
  end;

function TZeroAllocSlice.Compare(const AString: string): Boolean;
var
  I: Integer;
begin
  if Length <> System.Length(AString) then
    Exit(False);
    
  for I := 0 to Length - 1 do
    if (Buffer + Start + I)^ <> AString[I + 1] then
      Exit(False);
      
  Result := True;
end;

2. Using the Stack (Records and Static Arrays)

Avoid creating temporary class instances or dynamic arrays (array of Byte) inside loop structures or high-frequency handler routines. These require heap overhead and reference-counting locks.

  • Stack Allocation (Records): Declare local data carriers as record rather than class. Records are allocated automatically on the fast thread stack and cleaned up instantly upon exit.
  • Static Arrays: For local buffers (such as socket buffers or event arrays), declare static arrays with fixed sizes:
// Correct (Stack allocation - fast, zero page faults)
procedure ProcessEvents;
var
  LEvents: array[0..255] of epoll_event; // Allocated on the stack
begin
  // Process up to 256 events directly
end;

// Incorrect (Heap allocation - slow thread lock contention)
procedure ProcessEventsBad;
var
  LEvents: array of epoll_event;
begin
  SetLength(LEvents, 256); // Hits the memory manager heap
end;

Read the full file on GitHub · 86 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 · 86 lines · 32 tokens per session scan A 3faf16d49c2c

Subscribe to this mod's changes

horse-zero-allocation is a skill published in the GitHub repository HashLoad/horse (1,371 stars, last pushed 2d ago), licensed MIT. It adds 32 tokens to every session and 814 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.