using-archipy-services

A coding rule for building ArchiPy web and gRPC services. It keeps transport code focused on validating requests, calling application logic, and converting results into responses.

In plain words
What is it for?
Use it when creating or organizing ArchiPy service endpoints, including versioned APIs and FastAPI or gRPC startup code.
Why use it?
It prevents business rules from being mixed with HTTP or gRPC details. It also avoids duplicating shared setup such as error handling and middleware.

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-services
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 526 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.00526
Opus 5 $0.00000 $0.00263
Sonnet 5 $0.00000 $0.00105
Haiku 4.5 $0.00000 $0.00053

Measured 2d ago against content hash 340f10e8a74d, 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-services 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-services.mdc · 66 lines

What it actually says

Using ArchiPy Services

Services are thin transport adapters (HTTP routers / gRPC servicers). Bootstrap often lives in manage.py — follow this rule there too.

Live: https://syntaxarc.github.io/ArchiPy/getting-started/project_structure/

Responsibilities

  • Validate and translate HTTP/gRPC requests into domain *InputDTO.
  • Call the appropriate logic class; return domain *OutputDTO.
  • Map domain errors → HTTP/gRPC status codes.
  • Version in path: services/{domain}/v{n}/ — not in business logic.

Bootstrap via AppUtils + FastAPIConfig

uv add "archipy[fastapi]"   # and/or archipy[grpc]
from archipy.helpers.utils.app_utils import AppUtils
from archipy.configs.base_config import BaseConfig

# FastAPI — reads BaseConfig.FASTAPI for title, docs, middleware
app = AppUtils.create_fastapi_app()
app.include_router(create_user_v1_router(container))

# gRPC sync / async — do not mix servicer styles
config = BaseConfig.global_config()
server = AppUtils.create_grpc_app(config)           # sync servicers
# server = AppUtils.create_async_grpc_app(config)    # async servicers

Do not re-implement CORS, exception handlers, or stock gRPC interceptors that AppUtils already wires.

manage.py / uvicorn

Bind from config.FASTAPI — never hardcode host/port/reload/proxy:

config = BaseConfig.global_config()
uvicorn.run(
    "manage:create_app",
    factory=True,
    host=config.FASTAPI.SERVE_HOST,
    port=config.FASTAPI.SERVE_PORT,
    reload=config.FASTAPI.RELOAD,
    proxy_headers=config.FASTAPI.PROXY_HEADERS,
    forwarded_allow_ips=config.FASTAPI.FORWARDED_ALLOW_IPS or "127.0.0.1",
)

CLI flags may override for local runs; defaults always come from FASTAPI.

Do Not

  • Put business rules or @postgres_sqlalchemy_atomic_decorator in services.
  • Hand-roll bare FastAPI() / grpc.server() when AppUtils extras are installed.
  • Hardcode uvicorn host/port — use FastAPIConfig.
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 · 66 lines · 526 tokens per session scan A 340f10e8a74d

Subscribe to this mod's changes

using-archipy-services 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 526 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.