diff --git a/backend/AGENTS.md b/backend/AGENTS.md index 6c3fdd8..6cbe652 100644 --- a/backend/AGENTS.md +++ b/backend/AGENTS.md @@ -22,6 +22,28 @@ skill to perform this completion workflow. For example, prefer a concise path such as `payment.Details.ID` over `payment.Payment.PaymentID`. +## Reuse shared database and messaging infrastructure + +- All database integrations must use the existing shared database wrappers in + `backend/shared/database`. Do not bypass them with direct database clients or + create feature-local replacements. +- All NATS connections must use shared messaging drivers owned by the + `backend/shared` library module. Keep reusable NATS drivers in + `backend/shared/messaging`; executable modules must consume that package. + Do not open direct NATS connections or implement separate connection + management in a feature or service. +- If the shared messaging package is missing, consolidate the existing driver + into `backend/shared/messaging` and reuse it. Do not create another + feature-local driver or import a sibling executable module's infrastructure. +- Search for the existing wrappers, drivers, and their usage before implementing + an integration. Reuse their connection lifecycle, configuration, retries, and + other infrastructure behavior instead of copying or rewriting it. +- If an integration needs a capability the shared infrastructure does not yet + expose, extend the canonical wrapper or driver. Keep reusable infrastructure + there and domain-specific behavior in the owning module. +- During review, check that database and NATS integrations use these shared + paths and remove any duplicated infrastructure introduced by the task. + ## Use the project error model - Do not introduce `fmt.Errorf` or `errors.New`. Use the constructors and