agentleFS
dekozadekoza/oh-my-slop/skills/practice/enterprise-patterns/SKILL.md

enterprise-patterns

Skill4 starsChanged 9 months agoUnlicenseView on GitHub

Use when an enterprise app's infrastructure decisions are in play — where business logic lives, transaction and identity coordination, application-level (offline) concurrency, session-state placement, or remote/distribution boundaries. Domain modeling defers to domain-driven-design and database isolation/transactions to data-intensive; based on Patterns of Enterprise Application Architecture (Fowler). Triggers on: "Transaction Script vs Domain Model", "Unit of Work", "Identity Map", "optimistic vs pessimistic offline lock", "session-state placement", "Remote Facade", "generic repository everywhere".

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

7 rules. About 0 are common, 7 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈7

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When rich domain rules, aggregates, or ubiquitous language are the question, that skill owns it.

    line 29
  2. Distinctive:

    Stop and reshape when you see any of these.

    line 47
  3. Distinctive:

    Delete the pass-through or give the layer a real job.

    line 56
  4. Distinctive:

    Keep each honest: Transaction Scripts stay use-case-focused (not dumping grounds), Table Modules stay tabular (don't fake entities), Domain …

    line 69
  5. Distinctive:

    Keep transactions short and remote calls outside transaction spans.

    line 97
  6. Distinctive:

    Every session needs a clear owner, lifetime, and cleanup story before features pile on it.

    line 109
  7. Distinctive:

    When a boundary is genuinely remote, put a Remote Facade in front: coarse, batched operations translated to/from DTOs (transport shape, not …

    line 115

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Enterprise Patterns

Persistence, concurrency, session, and distribution structure for enterprise apps — the infrastructure around a domain, not the domain model itself. Reach for a small set of named patterns under concrete pressure; do not invent architecture for every feature.

Defer before you pattern

Domain modeling belongs to domain-driven-design. When rich domain rules, aggregates, or ubiquitous language are the question, that skill owns it. This skill owns where logic lives and how it reaches storage, concurrency, sessions, and remote callers. When both are loaded, keep DDD primary — decide the domain model there, then choose the persistence and workflow patterns here. Do not oscillate between "rich domain model" and "a Transaction Script is fine."

Cross-link the ground other skills already own — never restate it:

GroundOwner
N+1 / Lazy Load in the ORM (select_related/prefetch_related)django
DTO / serializer at the HTTP boundarydrf
DB transactions, isolation levels, lost-update/write-skew, derived datadata-intensive
Repository / Service Layer as domain access, Aggregatesdomain-driven-design
Latency budgets, timeouts, partial failure at remote callsproduction-readiness

Forbidden patterns — treat as review blockers

Stop and reshape when you see any of these; each is a structural defect, not a style nit:

  • Generic CRUD repository everywhere — one save/get/list/delete<T> abstraction shaped by tables instead of use cases. Shape repositories by what the application asks for.
  • ORM model doubling as aggregate, service, and DTO — one persistence class carrying domain rules, workflow, and transport shape at once. Split by responsibility.
  • Controller owning the workflow — a request handler coordinating transactions, SQL, domain rules, and external calls. Move coordination into an application/service operation.
  • Layering theater — layers that only forward calls, earning no reduction in coupling. Delete the pass-through or give the layer a real job.

Choose the business-logic pattern by force

The central decision. Pick by the actual complexity, not by habit or ORM convenience, and escalate when the forces below appear — do not start heavy:

PatternFits whenEscalate when
Transaction ScriptEach use case is short, mostly independent, few rulesDecisions or validation duplicate across scripts; invariants or lifecycle appear
Table ModuleLogic is set-oriented around tabular data; identity isn't the organizing forceThe real model is about individual objects with behavior and identity, not tables
Domain ModelSignificant rules, invariants, identity, lifecycle, collaboration(Terminal — hand the modeling to domain-driven-design)

Keep each honest: Transaction Scripts stay use-case-focused (not dumping grounds), Table Modules stay tabular (don't fake entities), Domain Models carry the behavior (not anemic). Active Record is acceptable only for simple domains that accept persistence coupling — Django's ORM is Active Record, so lean on django for its costs.

Coordinate identity and writes explicitly

  • Unit of Work — commit a logical change as one transaction with a clear owner. Keep transaction boundaries explicit in the workflow, short, and out of hidden helpers.
  • Identity Map — one in-memory object per identity per scope, so duplicate instances don't fight inside one unit of work.
  • Make loading behavior visible: when lazy loading, hidden auto-persistence, N+1, or ad-hoc saves could happen inside one work scope, decide identity scope and loading up front.

Choose application-level (offline) concurrency deliberately

Concurrency that spans a user think-time gap — a read-render-edit-save cycle across requests — is not the same as DB isolation (that's data-intensive). Name the semantics instead of relying on developer discipline:

  • Optimistic Offline Lock — conflicts possible but uncommon; detect on write (version check) and surface merge/conflict resolution intentionally. Default choice.
  • Pessimistic Offline Lock — contention expected and the block-others cost is justified.
  • Coarse-Grained Lock — lock a set of related objects together to protect one user-level edit as a unit.
  • Implicit Lock — acquire locks in shared infrastructure so callers can't forget; only when it keeps ownership, contention, and stale-lock cleanup diagnosable.

Keep transactions short and remote calls outside transaction spans.

Place session state deliberately

Choose storage by its forces, not by default:

PlacementChoose whenWatch
ClientServer statelessness / scaling mattersIntegrity + security of client-held data
ServerSimple, single-node, or sticky-sessionMemory cost, cleanup, server-farm sharing
DatabaseDurability or server-farm sharing outweighs the costAdded DB load, cleanup of stale rows

Every session needs a clear owner, lifetime, and cleanup story before features pile on it.

Keep remote boundaries coarse; don't distribute by default

  • Do not distribute objects or services across a process boundary by default — in-process is faster, simpler, and safer. Distribute only when a real boundary forces it.
  • When a boundary is genuinely remote, put a Remote Facade in front: coarse, batched operations translated to/from DTOs (transport shape, not domain objects), so callers make few round-trips. A chatty remote interface that mirrors local object collaboration is the smell. Budget latency, serialization, versioning, and partial failure at the seam.

Base patterns — reach only under concrete pressure

Name these when the specific pressure appears, never speculatively:

PatternPressure
GatewayIsolate access to an external resource or subsystem behind one interface
MapperMove data between two sides that must stay independent (neither knows the other)
Layer SupertypeReal, stable shared behavior across a layer's types
Separated InterfaceClient must depend on an interface in a different package than its impl
RegistryA few well-known objects need controlled lookup (sparingly — not global state)
Value Object / MoneyValue-equality + immutability; Money for explicit currency/rounding/arithmetic
Special CaseReplace repeated null/exceptional checks with a named object
PluginSelect or extend an implementation without editing core code
Service StubRun or test without a real remote service
Record SetTabular data is the natural interchange shape and object behavior isn't needed

Reference

FileUse when
Business logic & persistenceChoosing/escalating the business-logic pattern, Repository vs Data Mapper vs Gateway vs Active Record, Unit of Work, Identity Map, O-R mapping index
Concurrency & sessionsOffline locking semantics, transaction-boundary rules, session-state placement forces
Distribution & base patternsRemote Facade/DTO design, don't-distribute rules, the base-pattern catalog, the forbidden-pattern review checklist

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.