method_enterprise_builder_planning / rules
Cursor rule2 starsChanged 9 months agoMITView on GitHub
Reference guide for architectural patterns, decision trees, and Architecture Decision Records (ADR) in enterprise systems. Use this tree to select the correct architectural pattern: When to use: Single deployment unit with clear module boundaries. Easier to operate, test, and refactor than microservices. Preferred starting architecture. Non-negotiable rules: - Modules communicate only through public interfaces, never through internal types - No circular dependencies between modules - Database schema per module (logical separation minimum, physical preferred) - Each module independently testable in…
Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.
Of the Cursor rule files we read, the 4,263 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository7 other files it gives its agents.
- .cursor/rules/ENTERPRISE_COMPLIANCE.mdCursor rule
- .cursor/rules/ENTERPRISE_MICROTASK_PLANNER.mdCursor rule
- .cursor/rules/ENTERPRISE_SCALABILITY.mdCursor rule
- .cursor/rules/ENTERPRISE_SECURITY.mdCursor rule
- .cursor/rules/ENTERPRISE_TESTING.mdCursor rule
- METHOD-ENTERPRISE-BUILDER-PLANNINGCursor rule
- method-enterprise-builder-planningSkill
The file
We split this ENTERPRISE_ARCHITECTURE.md into the rules it gives an agent
8 rules. About 0 are common, 8 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈8
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
- Distinctive: line 9
Use this tree to select the correct architectural pattern:
- Distinctive: line 59
No circular dependencies between modules
- Distinctive: line 106
All external dependencies injected through ports
- Distinctive: line 113
When to use: Read and write models are significantly different in complexity or performance requirements.
- Distinctive: line 128
Read models are rebuilt from events if corrupted
- Distinctive: line 160
Use when: ≤3 services involved, low coupling required
- Distinctive: line 165
Use when: ≥4 services, complex compensation logic, compliance audit required
- Distinctive: line 198
Use C4 model for all architecture documentation:
≈ “Common” is an estimate: at least 1 in 5 of the 7,111 Cursor rule 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.
Files
ENTERPRISE_ARCHITECTURE
Reference guide for architectural patterns, decision trees, and Architecture Decision Records (ADR) in enterprise systems.
Architectural Pattern Decision Tree
Use this tree to select the correct architectural pattern:
Is the system a single product by one team?
├── YES → Is domain complexity high (many business rules)?
│ ├── YES → Modular Monolith (start here, extract later)
│ └── NO → Simple Layered Architecture
└── NO → Are teams fully autonomous per bounded context?
├── YES → Microservices
└── NO → Modular Monolith with service interfacesDoes the system require event replay or audit of all state changes?
├── YES → Event Sourcing + CQRS
└── NO → Are reads and writes radically different in load?
├── YES → CQRS (without full Event Sourcing)
└── NO → Standard repository patternAre there long-running, distributed transactions across services?
├── YES → Saga Pattern (Choreography or Orchestration)
└── NO → Local ACID transactionsPattern Specifications
Modular Monolith (recommended for most enterprise systems)
When to use: Single deployment unit with clear module boundaries. Easier to operate, test, and refactor than microservices. Preferred starting architecture.
Structure:
src/
├── core/ ← Shared infrastructure (no business logic)
├── modules/
│ ├── billing/ ← Complete billing domain
│ │ ├── domain/
│ │ ├── application/
│ │ ├── infrastructure/
│ │ └── interface/
│ └── users/ ← Complete users domain
└── shared/ ← Cross-cutting concernsNon-negotiable rules:
- Modules communicate only through public interfaces, never through internal types
- No circular dependencies between modules
- Database schema per module (logical separation minimum, physical preferred)
- Each module independently testable in isolation
ADR required: Yes — document why Modular Monolith was chosen over Microservices.
Microservices
When to use: Teams are independent, deployment cadences differ significantly, services have radically different scaling needs.
Non-negotiable rules:
- Each service owns its own database (no shared DB)
- Service communication via async events (preferred) or sync REST/gRPC with Circuit Breaker
- Each service independently deployable and rollback-able
- Service contracts (OpenAPI / AsyncAPI) versioned and backward compatible
Required patterns:
- Circuit Breaker (Resilience4j / Polly / opossum)
- Bulkhead (isolate thread pools per downstream service)
- Retry with exponential backoff + jitter
- Dead Letter Queue for failed async messages
- Distributed tracing (OpenTelemetry)
ADR required: Yes — document service boundaries and why each service is separate.
Hexagonal Architecture (Ports & Adapters)
When to use: Business logic must be testable without external infrastructure. Long-term maintainability is a priority.
Structure:
domain/ ← Pure business logic, zero dependencies
application/ ← Use cases, orchestration
ports/
├── inbound/ ← Interfaces that trigger use cases (e.g., HTTP, CLI, Queue)
└── outbound/ ← Interfaces the app calls externally (DB, email, API)
adapters/
├── inbound/ ← HTTP controllers, CLI handlers, message consumers
└── outbound/ ← DB repositories, email clients, external API clientsNon-negotiable rules:
- Domain layer has ZERO imports from infrastructure
- All external dependencies injected through ports
- Business logic unit-testable without any infrastructure
CQRS (Command Query Responsibility Segregation)
When to use: Read and write models are significantly different in complexity or performance requirements.
Pattern:
Command side: Query side:
├── Command handlers ├── Query handlers
├── Domain aggregates ├── Read models (denormalized)
├── Write DB (normalized) └── Read DB (optimized projections)
└── Event publisher ──────────────────────→ Event handler
└── Projects to read DBNon-negotiable rules:
- Commands validate all inputs before executing
- Commands are idempotent (same command twice = same result)
- Read models are rebuilt from events if corrupted
- Eventual consistency between write and read sides is explicitly documented
Event Sourcing
When to use: Full audit trail of all state changes is required (financial, compliance, regulated systems).
Core concepts:
- State is derived from a sequence of immutable events
- Current state = replay of all events from beginning
- Snapshots optimize replay performance (every N events)
- Events are immutable — never deleted or modified
Event store requirements:
- Append-only writes
- Optimistic concurrency control (version numbers)
- Efficient range queries by aggregate ID and version
- Snapshot support for long-lived aggregates
ADR required: Yes — Event Sourcing significantly increases complexity. Document the justification.
Saga Pattern
When to use: Distributed transactions span multiple services or databases.
Choreography Saga
- Services emit events and react to other services' events
- Simpler to implement, harder to debug
- Use when: ≤3 services involved, low coupling required
Orchestration Saga
- Central saga orchestrator coordinates all steps
- Easier to debug and monitor
- Use when: ≥4 services, complex compensation logic, compliance audit required
Compensation template:
Step 1: Reserve inventory → Compensation: Release inventory
Step 2: Charge payment → Compensation: Refund payment
Step 3: Create shipment → Compensation: Cancel shipment
Step 4: Send confirmation → Compensation: Send cancellationCircuit Breaker Pattern
States:
CLOSED ──[N failures in window]──→ OPEN ──[timeout]──→ HALF-OPEN
↑ │
└─────────────[success]───────────────────────────────────┘Configuration defaults for enterprise:
failureThreshold: 5 failures in 60 seconds
openDuration: 30 seconds
halfOpenMaxCalls: 3
successThreshold: 2 consecutive successesC4 Model — Diagram Levels
Use C4 model for all architecture documentation:
| Level | Audience | Shows |
| L1: System Context | Non-technical stakeholders | System + external actors |
| L2: Container | Technical stakeholders | Applications, databases, services |
| L3: Component | Developers | Major components within a container |
| L4: Code | Implementers | Classes, functions (generated from code) |
Minimum required: L1 and L2 for every system. L3 for critical services.
ADR Archive Template
Maintain ADRs in docs/adr/ directory:
docs/
└── adr/
├── ADR-001-modular-monolith.md
├── ADR-002-postgresql-as-primary-db.md
├── ADR-003-event-sourcing-for-audit.md
└── ADR-NNN-[decision-slug].mdNumbering: Sequential integers, never reused. Deprecated ADRs are marked Status: Superseded by ADR-NNN, not deleted.
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
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.

