plugins/mcp-companion/skills/extract-aggregate/SKILL.md
This skill should be used for planning when the user asks to create a workflow or domain model from an existing or legacy codebase, including requests like "reverse engineer the codebase", "document or model a legacy application", or "build a workflow from this code". Recommend isolating one DDD aggregate at a time, using one Qlerify workflow per aggregate, and following this skill's steps when PLANNING the work. This is a planning/preparation skill that should usually run BEFORE workflow-creation or sync in reverse-engineering scenarios. Produces a standalone aggregate plan (root entity, related entities, value objects, commands, optional domain events, read models, attributes, invariants, external references) for review before modeling in Qlerify.
npx skillsauth add qlerify/qlerify-plugins extract-aggregateInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Extract a single DDD aggregate from an existing or legacy codebase and describe it as a standalone aggregate, suitable for import into Qlerify.
Use this as a planning step first when reverse-engineering:
Use this skill proactively when the user wants workflows/models from existing code — for example:
If the user has not specified which aggregate or which codebase, ask before scanning. You need both:
{AGGREGATE_NAME} — the aggregate to extract (e.g. Order, Subscription, Cart){CODEBASE_NAME} — the repo, service, or module to extract it fromMost business applications have two command layers:
When modeling the aggregate in isolation, peel away the service layer to expose the underlying aggregate commands.
Concretely: if the codebase has a service or orchestrator that coordinates another module and then calls a method on
the {AGGREGATE_NAME} module, the aggregate command is that method call — not the orchestration name. The
orchestration stays outside; the aggregate only knows about the data it receives.
Search for the aggregate module and its entry points:
src/domain/{AGGREGATE_NAME}/, src/modules/{AGGREGATE_NAME}/, **/{AGGREGATE_NAME}.ts, **/{AGGREGATE_NAME}.cs, **/{AGGREGATE_NAME}.javaExtract the following. Keep everything scoped to the {AGGREGATE_NAME} boundary — cross-aggregate orchestration lives
outside.
The top-level entity through which all mutations enter. Identify it by:
Children with their own identity and individual lifecycle (add / update / remove).
Children that are replaced wholesale (set-replacement semantics), with no independent lifecycle. They may still have technical IDs in the implementation — treat them as VOs anyway if the domain semantics are set-replacement.
Each command represents a distinct state change of the aggregate.
One event per command, forming 1:1 pairs. Aim for 8–20 events per aggregate (not a strict rule).
Queries needed by the client. These can contain computed or derived fields (totals, counts) that exist on API responses but not on entity models. When a field is clearly projection-only (totals, rollups), prefer listing it here instead of also on entity/VO attribute tables. Include short descriptions of calculated fields if not obvious.
All fields for every entity and VO:
Order.items: LineItem[]), not database formparent_id or FK fields unless they are domain-significantBusiness rules, for example:
For each aggregate command, extract tests that validate the command's behavior at the aggregate boundary. Use business language, not code identifiers or framework details.
Fields pointing to other aggregates by ID only (e.g. customerId → Customer in a separate bounded context).
Model only the {AGGREGATE_NAME} aggregate boundary.
Cross-aggregate orchestration (e.g. completing one aggregate triggering creation of another, external rule evaluation computing values passed in) lives outside — note that it exists, but do not model it.
Model the aggregate as a domain/type model, not a persistence model. Avoid database terms like foreign keys, join tables, and cascade deletes unless they are needed to explain a business rule.
Include a minimal description of the hierarchy of entity / VO relationships.
Produce a single structured response with these sections. This format is optimized for import into Qlerify and for human review in an event storming session.
# {AGGREGATE_NAME} Aggregate
## Summary
One-paragraph description of what this aggregate represents and its role.
## Hierarchy
Tree of entity / VO relationships, e.g.:
- {AGGREGATE_NAME} (root)
- items: LineItem[] (entity)
- shippingAddress: Address (value object)
- adjustments: Adjustment[] (value object, set-replaced)
## Aggregate Root: {AGGREGATE_NAME}
Short description.
### Attributes
| Name | Type | Required | Default | Description |
|------|------|----------|---------|-------------|
| ... | ... | ... | ... | ... |
## Related Entities
### {EntityName}
Short description.
#### Attributes
| Name | Type | Required | Default | Description |
|------|------|----------|---------|-------------|
| ... | ... | ... | ... | ... |
## Value Objects
### {ValueObjectName}
Short description + set-replacement note.
#### Attributes
| Name | Type | Required | Default | Description |
|------|------|----------|---------|-------------|
| ... | ... | ... | ... | ... |
## Commands
| Command | Triggered By | Fields | Notes |
|------------|-------------------|--------|-------|
| PlaceOrder | customer checkout | ... | ... |
## Domain Events (1:1 with commands)
| Event | Emitted After | Carries |
|-------------|---------------|---------|
| OrderPlaced | PlaceOrder | ... |
## Read Models / Queries
| Name | Returns | Computed Fields |
|------|---------|-----------------|
| ... | ... | ... |
## Invariants
- ...
## External References
| Field | Points To | Bounded Context |
|------------|-----------|---------------------|
| customerId | Customer | Customer Management |
## Out of Scope (noted for reference only)
- Cross-aggregate orchestration X that calls into this aggregate
- External rule engine Y that computes values passed into commands
After producing the aggregate description, treat it as a planning artifact and ask the user to review it before implementation. Then offer these follow-up paths:
varchar, write string; if it uses @relation, write
Order.items: LineItem[].customerId field is enough; do not pull in Customer internals.development
Generate production-ready code from a Qlerify domain model. Use when the user asks to "generate code from the model", "implement the workflow", "scaffold from Qlerify", "build the aggregate", "code up the domain model", "create the app from the model", or after a workflow has been modeled or extracted and the next step is producing runnable code on a target tech stack. Pairs with the workflow-creation skill (which produces the model) and the sync skill (which keeps model and code aligned over time).
tools
Create, extend, validate, and improve Qlerify workflow diagrams and domain models, including domain events, roles, read models, commands, policies, aggregates, entities, value objects, attributes, given-when-then scenarios, bounded contexts, and invariants. Use when the task involves event storming, event modeling, domain-driven design (DDD), specification-driven development (SDD), model-driven development (MDD), software modeling, domain modeling, process modeling, legacy modernization, reverse-engineering code into a model, generating code from a model, or any direct use of the Qlerify modeling tools.
development
This skill should be used when the user asks to "sync domain model", "update Qlerify", "push changes to Qlerify", "sync schemas", "sync entities", "sync domain events", or after implementing features that add or change entities, API endpoints, domain events, database schemas, migrations, or Prisma/GraphQL types. For brownfield/legacy codebases with unclear boundaries, isolate one aggregate at a time before running broad sync operations (the workflow-creation skill's Phase 0 covers aggregate extraction). Syncs the local codebase's domain model with Qlerify.
tools
This skill should be used when the user asks to "save to file", "download", "export", "store in file", or any request that involves getting data from Qlerify and saving it locally. Bypasses AI processing and is ~100x faster than MCP tools for large data exports.