Agent skill

Horse Dependency Injection

by HashLoad in HashLoad/horse

Guide for managing request-scoped contextual services and IoC (dependency injection) in Delphi and Lazarus.

MITAuto-check passedDevelopment

Install Horse Dependency Injection

skills CLI
$ npx skills add HashLoad/horse --skill horse-dependency-injection -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install HashLoad/horse horse-dependency-injection --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/HashLoad/horse.git skills-src && mkdir -p .claude/skills && cp -r skills-src/doc/skills/horse-dependency-injection .claude/skills/horse-dependency-injection && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
horse-dependency-injection
GitHub stars
1.4k
Token cost
~985 tokens
SKILL.md length
300 words
Files
1
Skills in repo
23
Repo updated
First seen
Licence
MIT

At a glance

Guide for managing request-scoped contextual services and IoC (dependency injection) in Delphi and Lazarus.

  • Works in 4 steps: Request Scope Architecture → Direct Instance Injection (Add) → Lazy Factory Injection (AddFactory) → …
  • Tasks that involve Design patterns
  • SKILL.md covers 1. Request Scope Architecture, 2. Direct Instance Injection…, 3. Lazy Factory Injection… and 4. Best Practices for…
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Horse Dependency Injection is an agent skill from HashLoad/horse. Guide for managing request-scoped contextual services and IoC (dependency injection) in Delphi and Lazarus.

Its SKILL.md is about 990 tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Development, covering Design patterns. The repository describes itself as: Fast, opinionated, minimalist web framework for Delphi. The licence is MIT.

When your agent uses it

  • Tasks that involve Design patterns

Example prompts

  • “/horse-dependency-injection”

Workflow steps

4 steps, taken from the step headings in SKILL.md.

  1. Request Scope Architecture
  2. Direct Instance Injection (Add)
  3. Lazy Factory Injection (AddFactory)
  4. Best Practices for Dependency Injection in Horse

What it can do on your machine

Read from SKILL.md and the folder at commit d4351a5. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are pascal).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Horse Dependency Injection loads about 985 tokens when it runs. Until then it costs about 34 tokens; SKILL.md has 300 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~34
When it runs · the whole SKILL.md, loaded when a task matches
~985

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from HashLoad/horse at commit d4351a5, republished under its MIT licence (© HashLoad). 300 words, ~985 tokens.

Download SKILL.mdSave it as .claude/skills/horse-dependency-injection/SKILL.md (or your agent's skills folder).
name
horse-dependency-injection
description
Guide for managing request-scoped contextual services and IoC (dependency injection) in Delphi and Lazarus.

Horse Contextual Dependency Injection (Request Scope)

1. Request Scope Architecture

The Services property in THorseRequest provides a thread-safe, request-scoped Inversion of Control (IoC) container. This container manages the lifecycle of classes and objects that need to exist only during the execution of a single HTTP request (e.g., database connections, repository patterns, user context).

  • Ownership: The container takes ownership (doOwnsValues := True) of registered instances.
  • Automatic Disposal: All registered service instances are automatically destroyed when the request finishes, eliminating memory leaks and removing the need for manual try/finally blocks inside route handlers.

2. Direct Instance Injection (Add)

Use Add to register an already instantiated object. The container takes ownership and will destroy the instance when the request ends.

pascal
procedure SetContextMiddleware(Req: THorseRequest; Res: THorseResponse; Next: TProc);
var
  LUserContext: TUserContext;
begin
  LUserContext := TUserContext.Create;
  LUserContext.UserId := Req.Headers['X-User-ID'];
  
  // Register the instance
  Req.Services.Add(TUserContext, LUserContext);
  Next();
end;

procedure GetProfileHandler(Req: THorseRequest; Res: THorseResponse; Next: TProc);
var
  LUserContext: TUserContext;
begin
  // Resolve and use the registered service
  LUserContext := TUserContext(Req.Services.Resolve(TUserContext));
  Res.Send('Profile data for user: ' + LUserContext.UserId);
end;

3. Lazy Factory Injection (AddFactory)

Use AddFactory to register a factory delegate. The object will only be instantiated at the exact moment Resolve is called (Lazy Loading). Once instantiated, it is cached for subsequent resolves in the same request and destroyed at the end.

This is highly recommended for heavy resources (like database connections) that might not be needed in every execution path of a route.

pascal
procedure RegisterDatabaseMiddleware(Req: THorseRequest; Res: THorseResponse; Next: TProc);
begin
  // Register the factory method
  Req.Services.AddFactory(TFDConnection,
    function: TObject
    begin
      Result := TFDConnection.Create(nil);
      TFDConnection(Result).ConnectionDefName := 'PooledPGDef';
      TFDConnection(Result).Connected := True;
    end);
  Next();
end;

procedure QueryUsersHandler(Req: THorseRequest; Res: THorseResponse; Next: TProc);
var
  LConnection: TFDConnection;
  LQuery: TFDQuery;
begin
  // The connection is physically created and opened only on the next line!
  LConnection := TFDConnection(Req.Services.Resolve(TFDConnection));
  
  LQuery := TFDQuery.Create(nil);
  try
    LQuery.Connection := LConnection;
    LQuery.SQL.Text := 'SELECT id, name FROM users';
    LQuery.Open;
    Res.Send(LQuery.ToJSONArray);
  finally
    LQuery.Free;
  end; // LConnection is automatically freed by the container when the request ends!
end;

4. Best Practices for Dependency Injection in Horse

  1. Avoid Global Resolving: Never resolve services outside the active request flow. The Services container belongs exclusively to the thread handling the current THorseRequest.
  2. Cast Returned Objects: The Resolve method returns a raw TObject to preserve compatibility across old Delphi versions. You must cast it to your concrete class (e.g., TMyService(Req.Services.Resolve(TMyService))).
  3. One Registry Per Class Type: Only one instance or factory can be registered per class type in the same request. Registering a class that is already registered will raise an exception.
  4. No Manual Frees: Do not call .Free or FreeAndNil on objects resolved from Req.Services that you want to persist until the end of the request.

© HashLoad, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in doc/skills/horse-dependency-injection of HashLoad/horse.

Open the folder on GitHubat commit d4351a5

Compare with similar skills

Horse Dependency Injection next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Horse Dependency Injection compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Horse Dependency Injection this skillHashLoad/horse1.4k—~985Automated safety check: PassMIT
Vercel Composition Patternssupabase/supabase111k59 repos~726Automated safety check: PassMIT
Swiftui View RefactorDimillian/Skills4k5 repos~2kAutomated safety check: PassMIT
RTK Rust Design Patternsrtk-ai/rtk83k—~1.9kAutomated safety check: PassApache-2.0
Effect Client WrapperUsefulSoftwareCo/executor4.1k1 repos~1.4kAutomated safety check: PassMIT
Architecture PatternsKartikLabhshetwar/better-shot2.4k2 repos~1.4kAutomated safety check: PassCustom licence

Similar skills

  • Official

    React composition patterns that scale. An agent skill from supabase/supabase.

    111k GitHub starsUsed in 59 repos~726 tokens
    DevelopmentAuto-check passed
  • Swiftui View Refactor

    Dimillian/Skills

    Refactor and review SwiftUI view files with strong defaults for small dedicated subviews, MV-over-MVVM data flow, stable view trees, explicit dependency injection, and correct Observation usage.

    4k GitHub starsUsed in 5 repos~2k tokens
    DevelopmentAuto-check passed
  • Describes seven Rust design patterns for the RTK CLI filter modules, with when to use each, RTK examples, and notes on when a pattern is overkill.

    83k GitHub stars~1.9k tokensUpdated today
    DevelopmentAuto-check passed
  • Effect Client Wrapper

    UsefulSoftwareCo/executor

    Pattern for wrapping third-party SDK clients (Stripe, Resend, AWS, etc.) with Effect.

    4.1k GitHub starsUsed in 1 repo~1.4k tokens
    DevelopmentAuto-check passed
  • Architecture Patterns

    KartikLabhshetwar/better-shot

    Deep dive into software architecture for macOS. An agent skill from KartikLabhshetwar/better-shot.

    2.4k GitHub starsUsed in 2 repos~1.4k tokens
    DevelopmentAuto-check passed
  • GitVersion .NET Development

    GitTools/GitVersion

    Gives repository-specific .NET guidance for GitVersion: build and test commands, central package management, project layout and coding conventions.

    3.1k GitHub stars~1.7k tokensUpdated yesterday
    DevelopmentAuto-check passed

More from HashLoad/horse

All 23 skills in this repo
  • Horse App Structure

    HashLoad/horse

    Guide for setting up Horse applications, bootstrap program (.dpr), basic console initialization, and registering modules.

    1.4k GitHub stars~716 tokensUpdated yesterday
    Auto-check passed
  • Guide for setting up thread-safe database connection pooling (FireDAC / UniDAC) in multithreaded Horse applications.

    1.4k GitHub stars~1.4k tokensUpdated yesterday
    Auto-check passed
  • Horse Files Streams

    HashLoad/horse

    Guide to handling file uploads (multipart), downloads, and stream lifetime management in the Horse framework.

    1.4k GitHub stars~601 tokensUpdated yesterday
    Auto-check passed
  • Horse Grpc

    HashLoad/horse

    Guidelines and workflows for developing and maintaining gRPC services, HTTP/2 h2c transport, and Protobuf serialization within the Horse framework.

    1.4k GitHub stars~776 tokensUpdated yesterday
    Auto-check passed
  • Guide for writing automated integration tests for Horse endpoints using DUnit/DUnitX and THTTPClient.

    1.4k GitHub stars~964 tokensUpdated yesterday
    Auto-check passed
  • Guide for ensuring Lazarus and Free Pascal (FPC) compatibility, addressing anonymous methods differences, JSON units, and compiler directives.

    1.4k GitHub stars~806 tokensUpdated yesterday
    Auto-check passed

Categories

Questions about Horse Dependency Injection

What does Horse Dependency Injection do?

Guide for managing request-scoped contextual services and IoC (dependency injection) in Delphi and Lazarus. Horse Dependency Injection is an agent skill from HashLoad/horse. Guide for managing request-scoped contextual services and IoC (dependency injection) in Delphi and Lazarus.

When should I use Horse Dependency Injection?

Horse Dependency Injection fits situations like: tasks that involve Design patterns.

How do I install Horse Dependency Injection in Claude Code?

Run `npx skills add HashLoad/horse --skill horse-dependency-injection -a claude-code`. Or copy the skill folder (doc/skills/horse-dependency-injection in HashLoad/horse) into .claude/skills/horse-dependency-injection in your project. Claude Code loads it when a task matches its description.

How do I install Horse Dependency Injection in Codex?

Run `npx skills add HashLoad/horse --skill horse-dependency-injection -a codex`. Or copy the skill folder (doc/skills/horse-dependency-injection in HashLoad/horse) into .agents/skills/horse-dependency-injection in your project. Codex loads it when a task matches its description.

Can I use Horse Dependency Injection in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add HashLoad/horse --skill horse-dependency-injection -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/horse-dependency-injection, .gemini/skills/horse-dependency-injection, .github/skills/horse-dependency-injection and .opencode/skills/horse-dependency-injection in your project.

What does Horse Dependency Injection need to run?

SKILL.md names no scripts, command-line tools or credentials: Horse Dependency Injection is instructions for the agent only.

Does Horse Dependency Injection access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Horse Dependency Injection safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Horse Dependency Injection use?

Horse Dependency Injection is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Horse Dependency Injection use?

About 985 tokens (SKILL.md is roughly 3.9k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Horse Dependency Injection?

Skills that share tags, products or a category with Horse Dependency Injection: Vercel Composition Patterns (supabase/supabase, 111k stars), Swiftui View Refactor (Dimillian/Skills, 4k stars), RTK Rust Design Patterns (rtk-ai/rtk, 83k stars) and Effect Client Wrapper (UsefulSoftwareCo/executor, 4.1k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Horse Dependency Injection?

HashLoad (a GitHub organization) maintains it in HashLoad/horse, which has 1,377 GitHub stars. The repository holds 23 skills in this directory. The repository was last updated on October 7, 2026.

Source: HashLoad/horse on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.