Easy Prompt
AI AgentsTextAdvanced

Classic Software Engineering Canon: AI Agent Binding Policy

A binding engineering policy distilled from Clean Code, Clean Architecture, Domain-Driven Design, and Designing Data-Intensive Applications. Enforces human-readable code, inward dependencies, explicit domain boundaries, and fault-tolerant data systems for AI-generated software.

Prompt Content

Copy and paste directly into your model or internal evaluation tool.

As an AI coding agent, you MUST adhere strictly to the binding rules (MUST) in this canon. All code generation, edits, or reviews must optimize for:

  1. Readability & Local Reasoning: Functions small, focused, single abstraction level; precise naming; no hidden side effects; commands separated from queries; comments only for external contracts.

  2. Dependency Direction: Dependencies point inward toward business logic; frameworks, databases, web types, etc., must be isolated behind ports/adapters; use-case services coordinate but do not contain domain logic.

  3. Domain Model Integrity: Each meaningful model has a Bounded Context with Ubiquitous Language; Entities protect lifecycle invariants; Value Objects are immutable; Aggregates are small and transactional boundaries.

  4. Data System Resilience: Explicitly declare source of truth, consistency, durability; handle retries, duplicates, timeouts as normal; events support replay/idempotency; schema evolution maintains backward compatibility.

Before delivery, verify against the Unified Review Checklist: Is local reasoning improved? Are dependencies inward? Is domain language visible? Are failures handled explicitly? Revise if any answer is 'no'.

Use Cases

Generating DDD-compliant domain model code via AI assistantsAutomatically detecting framework leakage during code reviewProducing resilient data pipelines with CDC/event sourcingRefactoring legacy systems into Clean Architecture layers

Reference Output

Example of a Clean Architecture-compliant order confirmation: ```python # Domain Layer - Aggregate Root class Order: def __init__(self, order_id: str, items: list[OrderItem]): self._id = order_id self._items = items self._status = OrderStatus.PENDING def confirm(self): if not self._can_confirm(): raise InvalidStateError('Cannot confirm') self._status = OrderStatus.CONFIRMED DomainEventPublisher.publish(OrderConfirmed(self._id)) # Application Layer - No Framework Types class ConfirmOrderUseCase: def __init__(self, repo: OrderRepository, publisher: EventPublisher): self.repo = repo self.publisher = publisher def execute(self, cmd: ConfirmOrderCommand) -> None: order = self.repo.find_by_id(cmd.order_id) order.confirm() self.repo.save(order) # Infrastructure - Adapter class SqlOrderRepository(OrderRepository): def find_by_id(self, id: str) -> Order: row = db.query('SELECT * FROM orders WHERE id=?', id) return Order(row['id'], [OrderItem(...)]) # Translation here ```

Scoring Rubric

- 5 pts: Fully complies with all MUSTs; clear structure, inward deps, consistent domain language - 3 pts: Violates 1–2 non-critical rules (e.g., boolean flags), but readability preserved - 1 pt: Critical failure (e.g., injecting HTTP context into domain), breaks local reasoning

Try & save

Fill variables and copy, or save as a personal template.

This template has no variables and is ready to copy.

User Rating

0 ratings
-

Your rating

Log in to rate

Comments

0

Log in to comment

Related Prompts