horse-writing-middleware

horse-writing-middleware is a skill for Claude Code, Codex from HashLoad/horse. It costs 25 tokens per session (337 once invoked), scanned A, original, MIT.

A guide to writing middleware for the Horse web framework, where request-processing functions can run before and after a route handler.

In plain words
What is it for?
Adding headers, checking authentication, sending an immediate unauthorized response, and passing valid requests to the next middleware or endpoint.
Why use it?
It explains how to add request or response changes and how to stop a request when validation fails. This avoids accidentally allowing later handlers to run when access should be denied.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Adding headers, checking authentication, sending an immediate unauthorized response, and passing valid requests to the next middleware or endpoint.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/hashload/horse/horse-writing-middleware
About the project

Horse is a lightweight web framework for Delphi and Lazarus programs, providing tools for building HTTP servers and APIs. It is for developers who need routing, request handling, middleware, streaming, WebSockets, and related server features in those languages. Its catalogue skills support working with the framework.

HashLoad/horse · 1,373 stars · on GitHub

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.

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

README.md
[![agentmods](https://agentmods.dev/badge/skills/hashload/horse/horse-writing-middleware/github.svg)](https://agentmods.dev/skills/hashload/horse/horse-writing-middleware)
Your own site
<a href="https://agentmods.dev/skills/hashload/horse/horse-writing-middleware"><img src="https://agentmods.dev/badge/skills/hashload/horse/horse-writing-middleware/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for horse-writing-middleware

Your own site · 80×15
<a href="https://agentmods.dev/skills/hashload/horse/horse-writing-middleware"><img src="https://agentmods.dev/badge/skills/hashload/horse/horse-writing-middleware.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 25 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 337 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
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.1 $0.00025 $0.00337
Opus 5 $0.00013 $0.00169
Sonnet 5 $0.00005 $0.00067
Haiku 4.5 $0.00003 $0.00034

Measured 10d ago against content hash 37bb1b7bc505, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

horse-writing-middleware 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 10d 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-writing-middleware/SKILL.md · 48 lines

What it actually says

Writing Custom Horse Middlewares

Middleware Signature

A custom middleware is a procedure that receives THorseRequest, THorseResponse, and a callback procedure Next.

procedure MyCustomMiddleware(Req: THorseRequest; Res: THorseResponse; Next: TProc);
begin
  // 1. Logic BEFORE the request reaches the endpoint handler
  Req.Headers.AddOrSetValue('X-Processed-By', 'MyMiddleware');
  
  // 2. Call Next to delegate execution to the subsequent middleware or route handler
  Next;
  
  // 3. Logic AFTER the route handler completes its execution
  Res.Headers.AddOrSetValue('X-Execution-Finished', 'True');
end;

Terminating Execution Early

If a validation fails (e.g., authentication is missing), do NOT call Next. Set the status and send the response immediately. This halts the pipeline execution.

procedure AuthMiddleware(Req: THorseRequest; Res: THorseResponse; Next: TProc);
var
  LToken: string;
begin
  LToken := Req.Headers.Items['Authorization'];
  
  if LToken.IsEmpty then
  begin
    // Halt execution by sending response and omitting the Next call
    Res.Send('Unauthorized').Status(THTTPStatus.Unauthorized);
    Exit;
  end;
  
  // Token is valid, proceed with pipeline
  Next;
end;
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. 10d ago First seen · 48 lines · 25 tokens per session scan A 37bb1b7bc505

Subscribe to this mod's changes

horse-writing-middleware is a skill published in the GitHub repository HashLoad/horse (1,373 stars, last pushed today), licensed MIT. It adds 25 tokens to every session and 337 once invoked, about $0.0001 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.