config-and-di

config-and-di is a cursor rule for Cursor from SyntaxArc/archipy-plugin. It costs 981 tokens per session, scanned A, original, MIT.

Rules for configuring an ArchiPy application and wiring dependency injection, a way to provide services and settings to code instead of constructing them everywhere.

In plain words
What is it for?
Use them to define application settings, configure FastAPI and its server, set environment-variable overrides, and make configuration available throughout the app.
Why use it?
They centralize environment settings, server options, and shared configuration while keeping secrets out of source control.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc).

Good fit Use them to define application settings, configure FastAPI and its server, set environment-variable overrides, and make configuration available throughout the app.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/syntaxarc/archipy-plugin/config-and-di
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.

Clone the repo
git clone --depth 1 https://github.com/SyntaxArc/archipy-plugin

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 config-and-di

README.md
[![agentmods](https://agentmods.dev/badge/rules/syntaxarc/archipy-plugin/config-and-di/github.svg)](https://agentmods.dev/rules/syntaxarc/archipy-plugin/config-and-di)
Your own site
<a href="https://agentmods.dev/rules/syntaxarc/archipy-plugin/config-and-di"><img src="https://agentmods.dev/badge/rules/syntaxarc/archipy-plugin/config-and-di/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for config-and-di

Your own site · 80×15
<a href="https://agentmods.dev/rules/syntaxarc/archipy-plugin/config-and-di"><img src="https://agentmods.dev/badge/rules/syntaxarc/archipy-plugin/config-and-di.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 981 This file is loaded in full into every session.
When invoked 981 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00981 $0.00981
Opus 5.5 $0.00392 $0.00392
Sonnet 5.5 $0.00196 $0.00196
Haiku 4.5 $0.00098 $0.00098

Measured 4d ago against content hash f50aec46a72f, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

config-and-di 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.

rules/config-and-di.mdc · 86 lines

How it starts

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

Config and Dependency Injection

BaseConfig

import logging

from archipy.configs.base_config import BaseConfig
from archipy.configs.environment_type import EnvironmentType

logger = logging.getLogger(__name__)


class AppConfig(BaseConfig):
    """Application configuration. Inherits ArchiPy sections (REDIS, FASTAPI, UVICORN, GRPC, ...)."""

    def customize(self) -> None:
        """Apply service-specific defaults after sources load."""
        super().customize()
        self.FASTAPI.PROJECT_NAME = "my-service"
        self.UVICORN.RELOAD = self.ENVIRONMENT == EnvironmentType.LOCAL


config = AppConfig()
BaseConfig.set_global(config)
logger.info("Config loaded for environment: %s", config.ENVIRONMENT)
  • Call BaseConfig.set_global(config) once at bootstrap (typically importing app_config from the DI container).
  • Read elsewhere via BaseConfig.global_config().
  • Document required env vars in .env.example; never commit secrets.
  • Env overrides use nested delimiter: FASTAPI__PROJECT_NAME, FASTAPI__SERVE_PORT, UVICORN__RELOAD, …
  • Preserve ArchiPy's settings-source priority: secret files → Vault → pyproject → TOML → environment → .env → defaults. Do not add scattered os.environ reads that bypass it.
  • Raise ConfigurationError / InvalidArgumentError from archipy.models.errors for config validation failures; do not invent ad-hoc config exceptions.

FastAPIConfig (config.FASTAPI) and UvicornConfig (config.UVICORN)

config.FASTAPI drives AppUtils.create_fastapi_app and the bind address; config.UVICORN holds the server settings that AppUtils.uvicorn_config() turns into uvicorn.run arguments (archipy >= 5.25.0; the same names on FASTAPI are deprecated):

Area Fields
Bind (FASTAPI) SERVE_HOST, SERVE_PORT
Server (UVICORN) RELOAD, WORKERS_COUNT, TIMEOUT_KEEP_ALIVE, TIMEOUT_GRACEFUL_SHUTDOWN, BACKLOG, LIMIT_*, WS_*, ACCESS_LOG, DATE_HEADER, SERVER_HEADER
Proxy (UVICORN) PROXY_HEADERS, FORWARDED_ALLOW_IPS
TLS (UVICORN) SSL_KEYFILE, SSL_CERTFILE (set together), SSL_CA_CERTS
App / docs PROJECT_NAME, OPENAPI_URL, DOCS_URL, RE_DOC_URL, …
Middleware flags GZIP_MIDDLEWARE_IS_ENABLED, TRUSTED_HOST_MIDDLEWARE_*, HTTPS_REDIRECT_MIDDLEWARE_IS_ENABLED, CORS fields

Read the full file on GitHub · 86 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 Changed · +4 lines · +184 tokens per session f50aec46a72f
  2. 1mo ago Changed · +1 lines · +18 tokens per session 895b13587d36
  3. 1mo ago Changed · +1 tokens per session 2f2298199aae
  4. 2mo ago Changed · +6 lines · +127 tokens per session 779c386428a4
  5. 2mo ago First seen · 75 lines · 651 tokens per session scan A 91fa45cfc6b7

Subscribe to this mod's changes

config-and-di is a cursor rule published in the GitHub repository SyntaxArc/archipy-plugin (3 stars, last pushed 5d ago), licensed MIT. It adds 981 tokens to every session, about $0.0039 per session on Opus 5.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

config-and-di compared with cursor rules from other repositories

config-and-di next to 6 cursor rules from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
config-and-diSyntaxArc/archipy-pluginCursor rule35d agoMITA981Cursor
python-flask-json-guide-cursorrules-prompt-filePatrickJS/awesome-cursorrulesCursor rule41k5mo agoCC0-1.0A185Cursor
py-fast-apiPatrickJS/awesome-cursorrulesCursor rule41k5mo agoCC0-1.0A720Cursor
python-django-best-practices-cursorrules-prompt-fiPatrickJS/awesome-cursorrulesCursor rule41k5mo agoCC0-1.0A698Cursor
pythonPatrickJS/awesome-cursorrulesCursor rule41k5mo agoCC0-1.0A734Cursor
python-fastapi-best-practices-cursorrules-prompt-fPatrickJS/awesome-cursorrulesCursor rule41k5mo agoCC0-1.0A486Cursor
fastapiPatrickJS/awesome-cursorrulesCursor rule41k5mo agoCC0-1.0A427Cursor