using-archipy-interceptors

Coding rules for ArchiPy interceptors, which are hooks that run around requests or remote procedure calls for shared concerns such as logging, authentication context, and metrics.

In plain words
What is it for?
Use them when configuring or writing FastAPI or gRPC interceptors, middleware, request logging, metrics, authentication context, and related cross-cutting behavior.
Why use it?
They clarify how to use built-in middleware and keep shared request handling separate from data access and business rules.

Cursor rule

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/syntaxarc/archipy-plugin/using-archipy-interceptors
Clone the repo
git clone --depth 1 https://github.com/SyntaxArc/archipy-plugin
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 378 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.00378
Opus 5 $0.00000 $0.00189
Sonnet 5 $0.00000 $0.00076
Haiku 4.5 $0.00000 $0.00038

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

Security

Grade A, and why

using-archipy-interceptors 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 2d 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.

rules/using-archipy-interceptors.mdc · 40 lines

What it actually says

Using ArchiPy Interceptors

Helpers stay pure: no database calls, no constructing adapters, no domain business rules.

Role

Interceptors are cross-cutting request/RPC/middleware hooks (metrics, auth context, logging enrichment). They are not repositories and not use-cases.

Prefer ArchiPy / AppUtils

Use ArchiPy interceptors under archipy.helpers.interceptors (FastAPI / gRPC) before inventing new ones.

Prefer AppUtils auto-registration for stock interceptors/middleware:

  • FastAPI: AppUtils.create_fastapi_app wires CORS, GZip, TrustedHost, HTTPS redirect, metrics, APM from FASTAPI config.
  • gRPC: create_grpc_app / create_async_grpc_app append exception + optional trace/metric/rate-limit interceptors from config.

Do not manually re-wire stock ArchiPy interceptors unless customizing beyond config flags.

Live: https://syntaxarc.github.io/ArchiPy/tutorials/helpers/interceptors/

Custom Interceptors

  • Live under helpers/interceptors/.
  • Keep them framework-aware but business-logic-free.
  • Wire via DI container, framework registration, or customized_interceptors= on gRPC AppUtils — do not have adapters import interceptors at module level to register themselves.
  • Sync and async variants stay separate when both exist.

Do Not

  • Embed use-case logic inside interceptors.
  • Perform multi-step domain writes here (that belongs in logics/ with atomic boundaries).
  • Leak infrastructure exceptions — map to domain/HTTP/gRPC errors at the appropriate boundary.
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. 2d ago First seen · 40 lines · 378 tokens per session scan A a71ca4c92076

Subscribe to this mod's changes

using-archipy-interceptors is a cursor rule published in the GitHub repository SyntaxArc/archipy-plugin (2 stars, last pushed 8d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 378 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-08-31.