request-correlation

request-correlation is a skill for Claude Code, Codex from robhowley/py-pit-skills. It costs 86 tokens per session (1,071 once invoked), scanned A, original, MIT.

A request-tracking setup that gives each web request, background job, command-line task, and asynchronous task a shared correlation ID—a label connecting related log entries.

In plain words
What is it for?
Use it when adding request IDs to HTTP handling, outgoing HTTP calls, background workers, asynchronous tasks, and application logs.
Why use it?
It makes one operation traceable across services and jobs, so you can follow what happened without manually passing tracking values through every function.

Skill for Claude CodeCodex

Part of the py-pit plugin — 16 skills, 1 hook shipped together

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/robhowley/py-pit-skills/request-correlation
Any agent
npx skills add robhowley/py-pit-skills --skill request-correlation
Clone the repo
git clone --depth 1 https://github.com/robhowley/py-pit-skills

Made for: Claude Code, Codex.

Or install py-pit, the plugin that ships this one along with the rest of its 16 skills, 1 hook.

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 request-correlation

README.md
[![agentmods](https://agentmods.dev/badge/skills/robhowley/py-pit-skills/request-correlation.svg)](https://agentmods.dev/skills/robhowley/py-pit-skills/request-correlation)
Your own site
<a href="https://agentmods.dev/skills/robhowley/py-pit-skills/request-correlation"><img src="https://agentmods.dev/badge/skills/robhowley/py-pit-skills/request-correlation.svg" alt="Measured on agentmods" height="20"></a>
Per session 86 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,071 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.00086 $0.01071
Opus 5 $0.00043 $0.00535
Sonnet 5 $0.00017 $0.00214
Haiku 4.5 $0.00009 $0.00107

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

Security

Grade A, and why

request-correlation 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.

skills/request-correlation/SKILL.md · 183 lines

How it starts

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

Skill: request-correlation

Core stance

Every request or job must produce a traceable log story.

A single correlation ID must propagate through:

  • HTTP handlers
  • service functions
  • outbound HTTP calls
  • background jobs and async tasks

The correlation ID must appear automatically in logs.

Infrastructure vs. convention: Some rules are wired once at app startup (middleware, logging config, HTTP client factory). Others are conventions followed everywhere (raise don't log in services, never pass correlation as a function argument). Keep them separate in your mental model -- the infrastructure makes the conventions effortless.

Canonical locations

Correlation infrastructure must live in predictable modules.

Use:

{pkg_name}/observability/correlation.py
{pkg_name}/observability/logging.py

Do not duplicate correlation logic elsewhere.

Rules

1. Wire correlation at entrypoints

Entrypoints include HTTP requests, background job workers, CLI tasks, and async task roots.

For HTTP requests, use a functional middleware to read x-request-id if present, otherwise generate one, then set it into context:

import uuid
from fastapi import Request
from {pkg_name}.observability.correlation import correlation_id

@app.middleware("http")
async def correlation_middleware(request: Request, call_next):
    cid = request.headers.get("x-request-id") or str(uuid.uuid4())
    correlation_id.set(cid)
    response = await call_next(request)
    response.headers["x-request-id"] = cid
    return response

Prefer @app.middleware("http") over BaseHTTPMiddleware — the class-based approach can swallow exceptions and interfere with streaming responses.

For job workers and CLI entrypoints, set correlation_id before executing the task -- either from a passed value or a freshly generated one.

2. Store correlation in contextvars

Correlation must live in a contextvars.ContextVar.

Never store it on request objects or pass it through every function argument.

Read the full file on GitHub · 183 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 · 183 lines · 86 tokens per session scan A 83fb3acb8c36

Subscribe to this mod's changes

request-correlation is a skill published in the GitHub repository robhowley/py-pit-skills (5 stars, last pushed 5mo ago), licensed MIT. It adds 86 tokens to every session and 1,071 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-31.

Related

Other skills, from other repositories

python

Use when building FastAPI applications, implementing async endpoints, setting up Pydantic schemas, working with SQLAlchemy, or writing pytest tests for Python backend services.

MadAppGang/claude-code · 34 tokens

database

Relational database authority — PostgreSQL, async ORM (SQLAlchemy 2 / asyncpg), Alembic schema migrations, Supabase Python and JS clients, query optimisation, index strategy, connection pooling, transaction patterns, and bulk operations across Python and Node stacks.

LuuOW/meridian-mcp · 54 tokens

crudauth

Use when building or modifying authentication in a FastAPI app with crudauth (the crudauth PyPI package) — covers CRUDAuth, the AuthUserMixin / makeauthidentity user model, IdentityConfig, currentuser(...) gates, session + bearer transports, OAuth (Google/GitHub), email verification / password reset / change, custom…

benavlabs/crudauth · 188 tokens

FastAPI Testing Patterns

FastAPI application testing with TestClient, dependency injection overrides, async testing, database testing with SQLAlchemy, and OpenAPI validation.

PramodDutta/qaskills · 31 tokens

pytest

Advanced Python unit testing framework for customer support tech enablement, covering FastAPI, SQLAlchemy, PostgreSQL, async operations, mocking, fixtures, parametrization, coverage, and comprehensive testing strategies for backend support systems.

manutej/luxor-claude-marketplace · 44 tokens

alembic

Comprehensive Alembic database migration management for customer support systems.

manutej/luxor-claude-marketplace · 16 tokens