correlation-id-middleware

correlation-id-middleware is a skill for Claude Code, Codex from StefanTheCode/dotnet-ai-toolkit. It costs 100 tokens per session (698 once invoked), scanned A, original, MIT.

A skill for adding correlation-ID middleware to ASP.NET Core. A correlation ID is a request identifier that can be carried through logs and calls to other services.

In plain words
What is it for?
Use it to add or review request IDs in ASP.NET Core applications, including response headers, Serilog logs, downstream HTTP calls, and messaging.
Why use it?
It makes it easier to connect log entries and downstream requests that belong to the same incoming request, even without full distributed tracing.

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/stefanthecode/dotnet-ai-toolkit/correlation-id-middleware
Any agent
npx skills add StefanTheCode/dotnet-ai-toolkit --skill correlation-id-middleware
Clone the repo
git clone --depth 1 https://github.com/StefanTheCode/dotnet-ai-toolkit

Made for: Claude Code, Codex.

Per session 100 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 698 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.00100 $0.00698
Opus 5 $0.00050 $0.00349
Sonnet 5 $0.00020 $0.00140
Haiku 4.5 $0.00010 $0.00070

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

Security

Grade A, and why

correlation-id-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 3d 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.

skills/correlation-id-middleware/SKILL.md · 58 lines

How it starts

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

Correlation-ID Middleware

Give every request a correlation id that shows up in every log line, propagates to downstream HTTP/messaging, and ties a user's request together across services — even where full tracing isn't set up.

Input — point it at your project

Works on a target: a project or GitHub URL. Check for existing setup and the HTTP/logging stack: grep -rn "CorrelationId\|X-Correlation\|HttpContext.TraceIdentifier\|UseSerilog\|HttpClient" --include=*.cs <target>.

Middleware

public class CorrelationIdMiddleware(RequestDelegate next)
{
    public const string Header = "X-Correlation-ID";
    public async Task Invoke(HttpContext ctx)
    {
        var id = ctx.Request.Headers.TryGetValue(Header, out var v) && !string.IsNullOrEmpty(v)
            ? v.ToString() : Activity.Current?.TraceId.ToString() ?? Guid.NewGuid().ToString();

        ctx.Items[Header] = id;
        ctx.Response.Headers[Header] = id;                       // echo back to caller
        using (Serilog.Context.LogContext.PushProperty("CorrelationId", id))  // enrich all logs
            await next(ctx);
    }
}
app.UseMiddleware<CorrelationIdMiddleware>();   // early in the pipeline

Propagate to downstream calls

A DelegatingHandler that copies the id onto outbound HttpClient requests:

public class CorrelationHandler(IHttpContextAccessor http) : DelegatingHandler
{
    protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage req, CancellationToken ct)
    {
        if (http.HttpContext?.Items[CorrelationIdMiddleware.Header] is string id)
            req.Headers.TryAddWithoutValidation(CorrelationIdMiddleware.Header, id);
        return base.SendAsync(req, ct);
    }
}
// builder.Services.AddHttpClient<T>().AddHttpMessageHandler<CorrelationHandler>();

For messaging, put the id in message headers (publish) and restore it (consume).

Principles

  • Reuse the W3C trace id when present — don't invent a parallel id that competes with real tracing; correlation id complements it for log-grep-ability.
  • Accept an inbound id (from a gateway/caller) before generating a new one.
  • Enrich logs once via LogContext so every line carries it automatically.
  • Echo it in the response so clients can report it in bug tickets.

Read the full file on GitHub · 58 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 3d ago First seen · 58 lines · 100 tokens per session scan A 77a5b07e0bf3

Subscribe to this mod's changes

correlation-id-middleware is a skill published in the GitHub repository StefanTheCode/dotnet-ai-toolkit (19 stars, last pushed 24d ago), licensed MIT. It adds 100 tokens to every session and 698 once invoked, about $0.0005 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.

Related

Other skills, from other repositories

github-ci-fix-onboarding

Onboards and troubleshoots GitHub PR CI fixing by configuring GitHub CLI authentication, a non-exposed GitHub token, a matching local checkout, and a ready coding agent before running fixgithubprci. Use for first-time setup, failed prerequisites, demos, or action-shaped requests to onboard the user onto the local…

Tracer-Cloud/opensre · 85 tokens

greptimedb-development-docker-image

Builds a development-only GreptimeDB Docker image from a local debug binary for local-cluster testing, and optionally pushes it to a development registry. Use when the user asks to package, build, tag, publish, or cross-build a non-release GreptimeDB or GreptimeDB Enterprise image for debugging.

GreptimeTeam/greptimedb · 71 tokens

greptimedb-release

Runbook for publishing a new GreptimeDB version (tag + GitHub release + docs release-note PR) on the upstream GreptimeTeam/greptimedb repo. Use when asked to "release" / "publish" a GreptimeDB version (e.g. v1.1.0, v1.0.3).

GreptimeTeam/greptimedb · 75 tokens

yandex-cloud

Read Yandex Cloud through its REST API. Applies to any question about VMs, metrics, logs, audit events, Kubernetes, managed databases, serverless, networking or any other Yandex Cloud resource. Never shell out to the yc CLI — it is not how this agent reaches Yandex Cloud and is usually not installed.

Tracer-Cloud/opensre · 71 tokens

morning-report

Weather + news morning briefing: fetch live weather and headlines, compose a plain-text briefing, deliver it. Multi-step; load before acting.

Tracer-Cloud/opensre · 32 tokens

github-security-fix

Remediate GitHub security / Dependabot / CodeQL / code-quality alerts via fixgithubsecurityalert.

Tracer-Cloud/opensre · 27 tokens