httpx

httpx is a cursor rule for Cursor from steph-dove/klaussy-agents. It costs 0 tokens per session (1,110 once invoked), scanned A, original, MIT.

Repository coding rules illustrated with examples from the httpx Python library. They describe conventions such as using named tuples for structured data and enums for categories.

In plain words
What is it for?
Use them when editing the referenced Python code and deciding how to represent structured values or categories.
Why use it?
They help an agent match the existing code style instead of introducing inconsistent patterns.

Cursor rule for Cursor

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 rules/steph-dove/klaussy-agents/httpx
Clone the repo
git clone --depth 1 https://github.com/steph-dove/klaussy-agents

Made for: Cursor.

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 httpx

README.md
[![agentmods](https://agentmods.dev/badge/rules/steph-dove/klaussy-agents/httpx.svg)](https://agentmods.dev/rules/steph-dove/klaussy-agents/httpx)
Your own site
<a href="https://agentmods.dev/rules/steph-dove/klaussy-agents/httpx"><img src="https://agentmods.dev/badge/rules/steph-dove/klaussy-agents/httpx.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 1,110 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.00000 $0.01110
Opus 5 $0.00000 $0.00555
Sonnet 5 $0.00000 $0.00222
Haiku 4.5 $0.00000 $0.00111

Measured yesterday against content hash 2b13fccc1290, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

httpx 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 yesterday.

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.

examples/httpx/.cursor/rules/httpx.mdc · 120 lines

How it starts

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

Conventions

  • Data classes: NamedTuple: Use NamedTuple for structured data. 2/2 structured classes use this pattern. Example context from httpx/_urlparse.py (lines 153-163):
    # the stdlib 'ipaddress' module for IP address validation.
    IPv4_STYLE_HOSTNAME = re.compile(r"^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$")
    IPv6_STYLE_HOSTNAME = re.compile(r"^\[.*\]$")
    
    
    class ParseResult(typing.NamedTuple):
        scheme: str
        userinfo: str
        host: str
        port: int | None
        path: str
    
  • lowercase constant naming: Name constants using lowercase style. Example context from httpx/_multipart.py (lines 269-273):
            """
            boundary_length = len(self.boundary)
            length = 0
    
            for field in self.fields:
    
  • Enum usage: Enum: Use Python enums for categorical values. Found 2 enum class(es). Types: Enum (1), IntEnum (1). Example context from httpx/_client.py (lines 120-130):
    ACCEPT_ENCODING = ", ".join(
        [key for key in SUPPORTED_DECODERS.keys() if key != "identity"]
    )
    
    
    class ClientState(enum.Enum):
        # UNOPENED:
        #   The client has been instantiated, but has not been used to send a request,
        #   or been opened by entering the context of a `with` block.
        UNOPENED = 1
        # OPENED:
    
  • Custom decorator pattern: @click.option: Use custom decorator @click.option (17 usages). Example context from httpx/_main.py (lines 310-320):
        ctx.exit()
    
    
    @click.command(add_help_option=False)
    @click.argument("url", type=str)
    @click.option(
        "--method",
        "-m",
        "method",
        type=str,
        help=(
    
  • Limited exception chaining: Preserve exception context: use raise X from Y or raise X from None. Example context from httpx/_decoders.py (lines 73-79):
                if was_first_attempt:
                    self.decompressor = zlib.decompressobj(-zlib.MAX_WBITS)
                    return self.decode(data)
                raise DecodingError(str(exc)) from exc
    
        def flush(self) -> bytes:
            try:
    
  • Context manager usage: Manage resource lifecycles using context managers (e.g., Use context managers for resource management. 24 with statements. Types: http_client (5).). Example context from httpx/_main.py (lines 476-482):
            method = "POST" if content or data or files or json else "GET"
    
        try:
            with Client(proxy=proxy, timeout=timeout, http2=http2, verify=verify) as client:
                with client.stream(
                    method,
                    url,
    
  • Configuration via os.environ direct access: Use os.environ direct access. Example context from httpx/_config.py (lines 31-37):
        import certifi
    
        if verify is True:
            if trust_env and os.environ.get("SSL_CERT_FILE"):  # pragma: nocover
                ctx = ssl.create_default_context(cafile=os.environ["SSL_CERT_FILE"])
            elif trust_env and os.environ.get("SSL_CERT_DIR"):  # pragma: nocover
                ctx = ssl.create_default_context(capath=os.environ["SSL_CERT_DIR"])
    
  • High type annotation coverage: Standardize on typing: Type annotations are commonly used in this codebase. 396/396 functions have at least one type annotation.. Example context from httpx/_decoders.py (lines 32-42):
    except ImportError:  # pragma: no cover
        zstandard = None  # type: ignore
    
    
    class ContentDecoder:
        def decode(self, data: bytes) -> bytes:
            raise NotImplementedError()  # pragma: no cover
    
        def flush(self) -> bytes:
            raise NotImplementedError()  # pragma: no cover
    
  • Manual validation (ValueError/TypeError): Validate inputs and parameters: Use Manual validation (ValueError/TypeError) for input validation. 17/17 validation patterns use this approach.. Example context from httpx/_urls.py (lines 95-101):
                for key, value in kwargs.items():
                    if key not in allowed:
                        message = f"{key!r} is an invalid keyword argument for URL()"
                        raise TypeError(message)
                    if value is not None and not isinstance(value, allowed[key]):
                        expected = allowed[key].__name__
                        seen = type(value).__name__
    

Read the full file on GitHub · 120 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. yesterday First seen · 120 lines · 0 tokens per session scan A 2b13fccc1290

Subscribe to this mod's changes

httpx is a cursor rule published in the GitHub repository steph-dove/klaussy-agents (16 stars, last pushed 8d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,110 tokens. 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-09-03.