using-archipy-adapters

A set of rules for connecting ArchiPy applications to services such as Redis, PostgreSQL, Kafka, and object storage through adapters. It also covers ports, test doubles, and where domain-specific adapter code belongs.

In plain words
What is it for?
Use it when adding service integrations, defining interfaces for dependency injection, or creating small domain wrappers around ArchiPy adapters. It also helps structure optional in-memory test versions.
Why use it?
It keeps outside services behind clear boundaries, so application logic does not depend directly on database or service clients. This makes code easier to replace and test.

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-adapters
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 548 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.00548
Opus 5 $0.00000 $0.00274
Sonnet 5 $0.00000 $0.00110
Haiku 4.5 $0.00000 $0.00055

Measured yesterday against content hash 525e241b02c3, 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-adapters 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.

rules/using-archipy-adapters.mdc · 80 lines

How it starts

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

Using ArchiPy Adapters

Live: https://syntaxarc.github.io/ArchiPy/tutorials/adapters/

Prefer ArchiPy First

Install the matching extra and use the shipped adapter:

uv add "archipy[redis]"
# examples: postgres, sqlalchemy, sqlalchemy-async, kafka, scylladb, minio, keycloak, ...
from archipy.adapters.redis.adapters import RedisAdapter

redis = RedisAdapter()  # reads BaseConfig.global_config().REDIS

Inject *Port abstractions into logics/repositories — not concrete adapters when DI is used.

Domain Adapter Shape

Domain adapters live under the domain repository — not a top-level adapters/ package:

repositories/<domain>/
├── adapters/
│   └── <domain>_<purpose>_adapter.py   # e.g. user_db_adapter.py
└── <domain>_repository.py

Thin wrappers around ArchiPy adapters (or external clients). Own entity construction and query building. Depend on ArchiPy ports when wrapping library adapters; add a local ABC only when the domain needs a custom contract. Optional in-memory mock only if BDD needs it (Redis ships RedisMock).

Ports

from abc import ABC, abstractmethod

class CachePort(ABC):
    @abstractmethod
    def get(self, key: str) -> str | None: ...

    @abstractmethod
    def set(self, key: str, value: str, ttl: int | None = None) -> None: ...

Implementations and mocks must satisfy the same port.

Boundary Errors

Catch specific client/driver errors and map to domain errors with raise ... from e. Never bare except Exception unless the client exposes no typed root error:

try:
    await self._client.produce(topic, message)
except KafkaError as e:
    raise KafkaProduceError("Failed to produce message") from e

Never leak raw driver exceptions into logics/services.

Sync vs Async

  • Sync and async are separate classes — do not mix async def into a sync adapter class.
  • Prefer the ArchiPy async extra when the app is async end-to-end.

Config

Adapters should read settings from BaseConfig.global_config() (or injected config), not from scattered env reads inside methods.

Read the full file on GitHub · 80 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 · 80 lines · 548 tokens per session scan A 525e241b02c3

Subscribe to this mod's changes

using-archipy-adapters 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 548 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.