ddd-refiner
The ddd-refiner skill guides users through a structured interview to create or update a `.lattice/standards/ddd-principles.md` document that establishes domain-driven design guardrails for a repository. Use this skill when setting up domain design principles, defining aggregate rules, establishing patterns for entities and value objects, or when explicitly requested with phrases like "setup DDD," "define domain rules," or "help me define my domain patterns." It produces either an overlay document containing only custom deviations from defaults or a comprehensive override document, depending on team needs.
git clone --depth 1 https://github.com/techygarg/lattice /tmp/ddd-refiner && cp -r /tmp/ddd-refiner/skills/refiners/ddd-refiner ~/.claude/skills/ddd-refinerSKILL.md
# DDD Refiner ## What This Produces - **Output**: `.lattice/standards/ddd-principles.md` (or custom path from `.lattice/config.yaml` → `paths.ddd_principles`) - **Two modes**: - **Overlay** (`mode: overlay`): A slim document containing only sections that differ from the defaults. The domain-driven-design atom reads its embedded defaults first, then applies this document's sections on top. This is the expected common case. - **Override** (`mode: override`): A comprehensive standalone document that fully replaces the atom's embedded defaults. For teams with fundamentally different domain modeling principles. - **Default mode**: Overlay -- produces only what the user wants to change - **Config key**: `paths.ddd_principles` in `.lattice/config.yaml` - **Template**: Read `./assets/template.md` for the full document structure, default content, and interview guidance comments ## Scope Clarification This skill defines the *rules of domain crafting*, not the domain model itself. The domain model evolves through features; this document defines the guardrails. It covers DDD tactical patterns only -- not strategic DDD (no context mapping, no microservice topology, no bounded context integration). ## Before You Begin ### Check for existing documents Before starting the interview, check whether a custom document already exists: 1. Read `.lattice/config.yaml` -- does `paths.ddd_principles` point to a file? 2. If yes, read that file. Ask the user: - "You already have a custom DDD principles document. Would you like to **revise** it (update specific sections), **start fresh** (new interview), or **add to it** (add new sections)?" - Revise: Load the existing document, walk through only the sections the user wants to change, and update in place. - Start fresh: Proceed with the full interview flow below. - Add to it: Skip to the "New Sections" part of the interview. 3. If no config or no existing document, proceed with the full interview flow. ### Scan the repository Look for signals that inform the conversation: - **Domain folder**: Does a `domain/` (or `core/`, `model/`) folder exist? What's inside it? - **Existing aggregates**: Are there entities, value objects, aggregate roots? How are they structured? - **Anemic patterns**: Are entities data holders or do they have behavior? - **Identity patterns**: Typed IDs, raw UUIDs, database-generated IDs? - **Event patterns**: Are domain events used? What naming convention? - **Architecture docs**: Any existing DDD documentation, ADRs, domain glossaries? Share relevant findings with the user at the start: "I noticed your project already has [X patterns]. I'll use that as context." If the project is new with no code, proceed with pure defaults as the starting point. ## Choosing the Mode The first decision in the conversation. Present the three options: "How would you like to define your DDD principles? 1. **Customize specific sections** (overlay) -- Keep the defaults and change only what differs for your project. This produces a slim document. Most teams choose this. 2. **Define everything from scratch** (override) -- Walk through all sections and produce a comprehensive standalone document. 3. **Add project-specific sections only** (overlay with additions) -- Keep all defaults as-is and add new sections for your team's specific rules (e.g., ubiquitous language glossary, bounded context boundaries). The defaults cover standard DDD tactical patterns well. Option 1 is recommended unless your domain modeling approach is fundamentally different." Map the choice: - Options 1 and 3 → `mode: overlay` - Option 2 → `mode: override` ## Facilitation Approach ### Conversation style - **One section at a time.** Do not dump all questions at once. Walk through the template sequentially. - **Defaults-first.** For each section, briefly summarize the default, then ask if it matches. Do not read the entire default verbatim -- summarize the key points and ask. - **Record decisions, not discussion.** The output document reads as a specification, not meeting notes. "We discussed X and decided Y" is wrong. "Y" is right. - **Probe, don't interrogate.** Use the probing questions in the template guidance comments as follow-ups when the user's answer is ambiguous, not as a checklist. ### For overlay mode This should be fast. Many sections will be "keep as-is." 1. Present each section's default briefly (a 2-3 sentence summary, not full content). 2. Ask: "Does this match your project, or would you like to change it?" 3. If the user says it matches → skip it (section will NOT appear in the output). 4. If the user wants changes → dive into that section, discuss the specifics, record the changes. 5. At the end, ask: "Any sections you'd like to add that aren't in the defaults?" (e.g., ubiquitous language glossary, bounded context scope). 6. Only sections the user changed or added appear in the output document. ### For override mode This is thorough. Every section gets attention and appears in the output. 1. Walk through every section in full detail. 2. User confirms, modifies, or replaces each section. 3. All sections appear in the output -- defaults for unchanged ones, user's version for changed ones. ### Common scenarios - **"I agree with everything"** → No custom document needed. Tell the user: "The embedded defaults are already active and match your preferences. No custom document is needed -- the domain-driven-design atom will use the defaults automatically." - **"I agree except one section"** → Overlay mode, interview that one section only. - **"We have anemic entities and want to fix that"** → Overlay §2 (entity patterns, anemic anti-pattern is inline) + §9 (entity checks). - **"We don't use domain events yet"** → Overlay §5 (domain events) with simplified approach or removal note. Also check §1 (cross-aggregate coordination, anti-pattern is inline). - **"Our aggregates are too big"** → Overlay §1 (aggregate design, god aggregate anti-pattern
Audit and fix all Lattice documentation, README, docs/, GitHub issue templates, and CLAUDE.md to ensure they are fully aligned with the current skill inventory. Documentation drift is the most common source of user confusion in Lattice — a skill exists in the codebase but not in the docs, or a renamed skill leaves a stale reference in the bug report template. If you've made any change to skills/ and haven't run this, run it now. Use when the user says 'align docs', 'audit docs', 'update documentation', 'skill align', 'check docs are in sync', 'audit skill inventory', 'ensure docs are aligned', 'are the docs up to date', or 'what needs updating'. Standalone — does not call other skills.
Create a new Lattice skill — atom, molecule, or refiner — following all framework conventions. Writing skill files manually almost always produces convention violations: wrong section order, missing confirmation gates, defaults.md without the right structure. This skill knows all of that and guides you through it. Use whenever adding any new atom, molecule, or refiner to Lattice, or when the user says 'create a new skill', 'add an atom', 'add a molecule', 'add a refiner', 'build X for Lattice', 'new lattice skill', or 'skill forge'. Does not validate, align docs, or deploy — those are separate skills you run after.
Deep behavioral audit of a Lattice skill — proposes 3 review personas relevant to the skill, runs independent scenario analysis from each persona's perspective, then merges only the high-confidence, practical findings into a severity-ordered gap report with proposed fixes. Structural validation (conventions, cross-references) is skill-validate's job — this skill finds gaps that would realistically surface when someone actually uses the skill: missing scenario handling, ambiguous instructions, silent failure cases, and behavioral inconsistencies. Filters out theoretical edge cases, low-likelihood speculation, and findings owned by other skills. Use after writing or significantly changing any skill, or when the user says 'review this skill', 'deep review', 'does this skill work', 'find gaps in this skill', 'stress test this skill', 'review from different angles', or 'skill review'. Standalone — does not call other skills.
Validate any Lattice SKILL.md against all tier conventions — atoms, molecules, and refiners. Catches structural errors, broken cross-references, and convention violations before they reach the repo. If you just wrote or modified a Lattice skill file and haven't run this yet, run it now — manual review consistently misses the same categories of errors this skill is specifically designed to catch. Use when the user says 'validate this skill', 'check this skill', 'does this follow conventions', 'review this skill file', 'check my SKILL.md', or 'skill validate'. Reports PASS/FAIL with specific file-and-section findings and actionable fixes. Standalone — does not call other skills.
Architectural thinking partner for an existing repository — scans the codebase, conducts a structured interview, agrees on current architectural state and recommended direction, and produces a shareable insights document. Scoped to one repository, module, or folder. Does not execute transformation — it orients. Use when the user says 'assess my codebase architecture', 'what direction should my codebase go', 'architecture compass', 'understand my architecture', 'audit architecture drift', 'architectural assessment', or 'help me understand what is wrong with my codebase'.
Facilitate a structured conversation to define architecture principles for a repository. Supports multiple architecture styles: clean architecture (default), hexagonal / ports & adapters, modular monolith, or custom. Produces a formal architecture document that the corresponding atom will use. Use when setting up a new project, defining architecture standards, or when the user says 'setup architecture', 'define layers', 'architecture principles', 'help me define my architecture', 'hexagonal architecture', 'modular monolith', 'ports and adapters', or 'define my architecture style'.
Enforce architectural rules when generating or modifying code. Defaults to clean architecture; supports any architecture style via the architecture-refiner. Validates layer responsibilities, dependency direction, and structural constraints using the loaded architecture rules. Use when generating code, reviewing architecture, creating new files, or when the user mentions 'architecture', 'layers', 'structure', 'dependency rules', 'hexagonal architecture', 'ports and adapters', 'modular monolith', or 'onion architecture'. Also use when reviewing generated code for structural compliance.
Investigate, reproduce, and safely fix a bug with regression protection. Composes context, diagnosis, architecture, code quality, and testing guardrails into a reproduce-first repair workflow. Use when the user says 'fix this bug', 'debug this', 'investigate this failure', 'patch this regression', 'repair this issue', or 'why is this broken'.