standard-use-case-architecture-patterns

Team rules for structuring use cases in Packmind's monorepo, a repository that contains multiple related packages. Use cases are the entry points where application requests reach the domain logic.

In plain words
What is it for?
Use it when adding or changing TypeScript use cases and their organization-, space-, or admin-level access rules.
Why use it?
It keeps contracts, inputs, outputs, permissions, and validation consistent across the codebase.

Cursor rule for Cursor

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/packmindhub/packmind/standard-use-case-architecture-patterns
Clone the repo
git clone --depth 1 https://github.com/PackmindHub/packmind

Made for: Cursor.

Per session 513 This file is loaded in full into every session.
When invoked 513 The same file — it is already loaded in full.
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.00513 $0.00513
Opus 5 $0.00257 $0.00257
Sonnet 5 $0.00103 $0.00103
Haiku 4.5 $0.00051 $0.00051

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

Security

Grade A, and why

standard-use-case-architecture-patterns 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 3d 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.

packages/.cursor/rules/packmind/standard-use-case-architecture-patterns.mdc · 23 lines

What it actually says

Standard: Use Case Architecture Patterns

This standard defines how to structure use cases in the Packmind monorepo following hexagonal architecture principles. Use cases represent the entry points to domain logic and must follow consistent p... :

  • Accept commands as single parameters in adapter methods rather than multiple individual parameters to ensure consistency and easier parameter additions
  • Define each use case contract in its own file at packages/types/src/{domain}/contracts/{UseCaseName}.ts with Command type, Response type, and UseCase interface exports
  • Export exactly three type definitions from each use case contract file: {Name}Command for input parameters, {Name}Response for return value, and I{Name}UseCase as the interface combining both
  • Extend AbstractAdminUseCase and implement executeForAdmins method for use cases requiring admin privileges, with automatic validation that the user is a member with admin role
  • Extend AbstractMemberUseCase and implement executeForMembers method for organization-scoped use cases that do NOT operate within a specific space, with automatic user and organization validation
  • Extend AbstractSpaceMemberUseCase and implement executeForSpaceMembers method for use cases operating within a specific space (command includes spaceId), with automatic user, organization, and space membership validation
  • Extend PackmindCommand for authenticated use case commands that include userId and organizationId, or extend PublicPackmindCommand for public endpoints without authentication
  • Extend SpaceMemberCommand instead of PackmindCommand for use case commands that include a spaceId to get both organizationId and spaceId typing
  • Implement IPublicUseCase interface directly with an execute method for public use cases that don't require authentication, without extending any abstract use case class
  • Never directly call Repositories in Adapter classes, repos must be called from Use Cases
  • Never spread commands as multiple arguments in hexagon or UseCase classes; always pass the complete command object to maintain type safety and reduce errors
  • Response and Commands must not be defined in the same file than the associated UseCase class
  • Restrict use case classes to expose only the execute method for public use cases or executeForMembers/executeForAdmins methods for member/admin use cases, with no other public methods
  • Reuse existing use cases through port/adapter interfaces instead of instantiating them directly within use cases
  • UseCase must be associated with a Command and Response type

Full standard is available here for further request: Use Case Architecture Patterns

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. 3d ago First seen · 23 lines · 513 tokens per session scan A 13523a83eba5

Subscribe to this mod's changes

standard-use-case-architecture-patterns is a cursor rule published in the GitHub repository PackmindHub/packmind (306 stars, last pushed 5d ago), licensed Apache-2.0. It adds 513 tokens to every session, about $0.0026 per session on Opus 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-30.