Agent skill

analyzing-domains

Use when entering unfamiliar domains, modeling complex business logic, or when terms/concepts are unclear. Triggers: 'what are the domain concepts', 'define the entities', 'model this domain', 'DDD', 'ubiquitous language', 'bounded context'. Also invoked by develop during research phase.

Stars 5
Forks 2

Install this agent skill to your Project

npx add-skill https://github.com/axiomantic/spellbook/tree/main/skills/analyzing-domains

SKILL.md

Domain Analysis

Reasoning Schema

Before analysis: domain being explored, stakeholder terminology, existing system context, integration boundaries.

After analysis: ubiquitous language captured, entity boundaries defined, aggregate roots identified, context map complete, agent recommendations justified.

Invariant Principles

  1. Language Is the Model: Ubiquitous language IS the domain model. Misaligned terminology → misaligned code.
  2. Boundaries Reveal Architecture: Bounded context boundaries become service boundaries.
  3. Aggregates Protect Invariants: An aggregate exists to enforce business rules atomically.
  4. Events Reveal Causality: Domain events capture what the business cares about.
  5. Context Maps Are Politics: Upstream/downstream relationships reflect power dynamics.
  6. Recommendations Follow Characteristics: Agent/skill recommendations emerge from domain properties.

Inputs / Outputs

Input Required Description
problem_description Yes Natural language description of the problem space
stakeholder_vocabulary No Terms already used by domain experts
Output Type Description
domain_glossary Inline Ubiquitous language definitions
context_map Mermaid Bounded contexts and relationships
entity_sketch Mermaid Entities, value objects, aggregates
agent_recommendations Table Recommended skills with justification

Domain Analysis Framework

Phase 1: Language Mining

Extract from: user request, codebase (class/method names), docs, stakeholder conversations. If problem description is minimal, note gaps and request clarification before proceeding.

Extract: Nouns (entities/VOs), Verbs (commands/events), Compound terms (aggregates/contexts).

Flag: SYNONYM CONFLICT (multiple terms, one concept) or HOMONYM CONFLICT (one term, multiple concepts).

Phase 2: Ubiquitous Language

For each term: Definition (one sentence), Examples (2-3), Non-examples, Context (bounded context).

Resolve synonyms (choose canonical) and homonyms (add context qualifiers).

Phase 3: Entity vs Value Object

Question Entity Value Object
Has lifecycle? Yes No (immutable)
Identity matters? Yes No (only attributes)

Phase 4: Aggregate Boundary Detection

Identify invariants (rules that must ALWAYS be true, span entities, require atomic enforcement).

Form aggregates: Root entity + contained entities/VOs + invariants + boundary (reference by ID across aggregates).

Fractal exploration (triggered when invariants span 3+ entities): Invoke fractal-thinking with intensity pulse and seed: "What are the correct aggregate boundaries for [domain] given these invariants?". Use the synthesis for multi-angle boundary validation.

Phase 5: Domain Event Identification

For each state change: What happened? (past tense), Who cares? (handlers), What data?

Phase 6: Bounded Context Mapping

Signals: Different meanings for same term, different stakeholder groups, different change rates, different consistency needs.

Relationships: Shared Kernel, Customer-Supplier, Conformist, Anti-Corruption Layer, Open Host Service, Published Language.

Phase 7: Agent Recommendations

Characteristic Signal Recommended Skill
Complex state machines Multiple status fields designing-workflows
Multiple bounded contexts Different vocabularies brainstorming
Security-sensitive PII, auth gathering-requirements (Hermit)
Complex aggregates Many invariants test-driven-development

Example

  1. Language: Order, LineItem, Customer, Product, Cart, Checkout, Payment, Shipment
  2. Synonyms: Customer = User = Buyer → canonical: "Customer"
  3. Entities: Order (tracked by ID), Customer (tracked by ID)
  4. Value Objects: Money, Address, LineItem (immutable snapshot)
  5. Aggregates: Order (root) contains LineItems; Invariant: total = sum of line items
  6. Events: OrderPlaced, OrderShipped, PaymentReceived
  7. Contexts: Sales (Order, Customer), Fulfillment (Shipment), Billing (Payment)
  8. Recommendation: Medium complexity (matches multiple Phase 7 rows) → design doc first, develop Phase 1-4

All gates must pass before analysis is complete. If ANY gate fails, revise.

Gate Criteria
Language complete All terms defined
Conflicts resolved No unresolved synonyms/homonyms
Entities classified Every noun categorized
Aggregates bounded Every entity in one aggregate
Events identified State changes have domain events in past tense
Context map complete All contexts with relationships
</CRITICAL>


Self-Check

  • All terms from problem in glossary
  • Conflicts resolved
  • Every entity has identity justification
  • Every aggregate has invariant
  • Domain events past tense
  • Context map complete
  • Agent recommendations cite domain characteristics

If ANY unchecked: revise before completing.


<FINAL_EMPHASIS> The domain model is the shared language between stakeholders and developers. Get the language right and code follows. Get boundaries right and architecture emerges. Domain analysis IS implementation at the conceptual level. </FINAL_EMPHASIS>

Expand your agent's capabilities with these related and highly-rated skills.

axiomantic/spellbook

spellbook-auditing

Meta-audit skill for spellbook development. Spawns parallel subagents to factcheck docs, optimize instructions, find token savings, and identify MCP candidates. Produces actionable report.

5 2
Explore
axiomantic/spellbook

documentation-updates

Use after modifying library skills, library commands, or agents to ensure CHANGELOG, README, and docs are updated

5 2
Explore
axiomantic/spellbook

project-encyclopedia

[DEPRECATED] Use project-level AGENTS.md files instead. Previously used for first-session codebase onboarding and persistent glossary creation.

5 2
Explore
axiomantic/spellbook

reviewing-impl-plans

Use when reviewing implementation plans before execution. Triggers: 'is this plan solid', 'review the plan', 'check before I start building', 'anything missing from this plan', 'will this plan work', 'audit the implementation plan'. NOT for: reviewing design documents (use reviewing-design-docs) or creating plans (use writing-plans).

5 2
Explore
axiomantic/spellbook

session-resume

Session resume protocol and session repairs handling. Loaded when spellbook_session_init returns resume_available: true, or when session_init returns a repairs array. Triggers: 'resume', 'continue', 'where were we', session resume, session repairs.

5 2
Explore
axiomantic/spellbook

brainstorming

Use when exploring design approaches, generating ideas, or making architectural decisions. Triggers: 'explore options', 'what are the tradeoffs', 'how should I approach', 'let's think through', 'sketch out an approach', 'I need ideas for', 'how would you structure', 'what are my options'. Also invoked by develop when design decisions are needed.

5 2
Explore

Didn't find tool you were looking for?

Be as detailed as possible for better results