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.
npx agentmods add skills/evandersondev/darto/darto-write-middlewarenpx skills add evandersondev/darto --skill darto-write-middlewaregit clone --depth 1 https://github.com/evandersondev/dartoWrote 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.
[](https://agentmods.dev/skills/evandersondev/darto/darto-write-middleware)<a href="https://agentmods.dev/skills/evandersondev/darto/darto-write-middleware"><img src="https://agentmods.dev/badge/skills/evandersondev/darto/darto-write-middleware.svg" alt="Measured on agentmods" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00086 | $0.01119 |
| Opus 5 | $0.00043 | $0.00560 |
| Sonnet 5 | $0.00017 | $0.00224 |
| Haiku 4.5 | $0.00009 | $0.00112 |
Grade A, and why
darto-write-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 5d 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.
How it starts
The opening of the file, as written. The whole thing — 146 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Write middleware in Darto
A middleware receives the same Context as handlers, plus a Next callback.
Call await next() to continue the pipeline; return without calling next()
to short-circuit (reject the request).
typedef Middleware = FutureOr<void> Function(Context c, Next next);
typedef Next = Future<void> Function();
Writing one (factory pattern)
Define a function that returns a Middleware closure. This lets the
middleware take configuration:
Middleware timer() => (Context c, Next next) async {
final sw = Stopwatch()..start();
await next(); // run downstream
print('${c.req.method} ${c.req.path} ${sw.elapsedMilliseconds}ms');
};
Short-circuit (reject before the handler)
Set a response and return without calling next():
Middleware requireAdmin() => (Context c, Next next) async {
if (c.user?['role'] != 'admin') {
c.forbidden({'error': 'Admins only'});
return; // pipeline stops here
}
await next();
};
Sharing data with handlers
Use per-request state, set before next() and read downstream:
Middleware loadUser() => (Context c, Next next) async {
c.set('userId', '42'); // or: c.user = {...}
await next();
};
// in a handler: final id = c.get<String>('userId');
Registering middleware
Pick the narrowest scope that fits:
// Global — runs on every request. Call use() once per middleware.
app.use(logger());
app.use(timer());
// Path-scoped — runs on matching paths. Call mount() once per middleware.
app.mount('/api/*', cors());
app.mount('/api/*', jwtMiddleware);
// Route-level — only this route (the required middleware list):
app.get('/admin', [requireAdmin()], handler);
app.post('/upload', [bodyLimit(maxSize: 5 * 1024 * 1024)], handler);
Order matters: middleware runs in registration order, outermost first.
Built-in middleware
Darto ships many; each lives in its own sub-library, imported individually:
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.
- 5d ago First seen · 146 lines · 86 tokens per session scan A 7332106ff69b
darto-write-middleware is a skill published in the GitHub repository evandersondev/darto (43 stars, last pushed 1mo ago), licensed MIT. It adds 86 tokens to every session and 1,119 once invoked, about $0.0004 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.
Other skills, from other repositories
Express/Fastify Backend Patterns
Use this skill when building Node.js HTTP APIs with Express or Fastify and you want safe request validation, predictable error handling, and maintainable routing/service layering.
backend
Backend development with Node.js, Express, NestJS, and server patterns.
horse-database-pooling
Guide for setting up thread-safe database connection pooling (FireDAC / UniDAC) in multithreaded Horse applications.
horse-dependency-injection
Guide for managing request-scoped contextual services and IoC (dependency injection) in Delphi and Lazarus.
horse-integration-tests
Guide for writing automated integration tests for Horse endpoints using DUnit/DUnitX and THTTPClient.
horse-mvc-architecture
Guide for structuring corporate Horse applications using Clean MVC (Model-View-Controller) principles and decoupling HTTP layers from business logic.