/protean:queryfrom protean
Defines an immutable Protean query DTO for read-side CQRS operations. Queries carry parameters to fetch data from projections and are dispatched via domain.dispatch(). Use when modeling read requests like GetOrderById or SearchOrders.
Ships in protean. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
A query is an immutable DTO that carries a read intent: the parameters needed to fetch data from a projection. Queries are the read-side counterpart to commands: a command asks to change state, a query asks to read it.
A query is defined with @domain.query(part_of="<Projection>"):
from protean import Domain
from protean.fields import Identifier, String
domain = Domain()
@domain.projection
class OrderSummary:
order_id: Identifier(identifier=True)
customer_name: String(max_length=100)
@domain.query(part_of="OrderSummary")
class GetOrderById:
order_id: Identifier(required=True)
part_of with the projection (read model) the query targets, not an aggregate: @domain.query(part_of="OrderSummary")GetOrderById, SearchOrders, ListActiveUsers (not imperative like commands)IncorrectUsageError; create a new instance insteadValidationError immediately, before dispatchHasOne, HasMany, or Referencequery_handler and dispatch with domain.dispatch(query) (see the query-handler skill)| Field/Option | Purpose | Required |
|---|---|---|
part_of | Associate the query with a projection | Yes (unless abstract) |
abstract | Mark as an abstract base query | No |
from protean.fields import (
String, Integer, Float, Boolean,
DateTime, Date, Identifier,
List, Dict, ValueObject,
)
from protean import Domain, current_domain, read
from protean.fields import Identifier, Integer, String
domain = Domain()
@domain.projection
class OrderSummary:
order_id: Identifier(identifier=True)
customer_name: String(max_length=100)
status: String(max_length=20)
@domain.query(part_of="OrderSummary")
class SearchOrders:
status: String()
page: Integer(default=1, min_value=1)
page_size: Integer(default=20, min_value=1)
@domain.query_handler(part_of="OrderSummary")
class OrderSummaryQueryHandler:
@read(SearchOrders)
def search(self, query: SearchOrders):
view = current_domain.view_for(OrderSummary)
return (
view.query.filter(status=query.status)
.order_by("order_id")
.offset((query.page - 1) * query.page_size)
.limit(query.page_size)
.all()
.items
)
domain.init(traverse=False)
with domain.domain_context():
repo = domain.repository_for(OrderSummary)
repo.add(OrderSummary(order_id="ORD-001", customer_name="Ada", status="placed"))
repo.add(OrderSummary(order_id="ORD-002", customer_name="Bo", status="shipped"))
repo.add(OrderSummary(order_id="ORD-003", customer_name="Cy", status="placed"))
# Construct (validated, immutable); dispatch returns the handler's result
query = SearchOrders(status="placed")
result = domain.dispatch(query)
assert [summary.order_id for summary in result] == ["ORD-001", "ORD-003"]
page_two = domain.dispatch(SearchOrders(status="placed", page=2, page_size=1))
assert [summary.order_id for summary in page_two] == ["ORD-003"]
query-handler: Answers queries via @read and domain.dispatch()projection: The read model a query targetscommand: The write-side counterpart (intent to change state)projector: Populates the projection that queries read fromcheck and resolve what it reportsWhat SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub proteanhq/protean --plugin protean39 skills in this plugin
/add-commandAdd a complete command flow to an existing aggregate. It creates a command class, a FastAPI API endpoint, and a command handler with repository logic. This is the primary workflow for adding write operations to a Protean domain. Use when the user wants to "add a command", "add an action", "add an operation", "expose a write endpoint", "create a command flow", "wire up a POST endpoint", "add a new operation to an aggregate", or describes an action like "I want users to be able to [verb] a [thing]" (e.g., "place an order", "register a user", "cancel a reservation"). This workflow composes the command, command-handler, and api-endpoint element skills./add-domain-service-flowBuild a domain service flow in Protean for business logic that spans two or more aggregates. Domain services are stateless, encapsulate cross-aggregate business rules, and run pre/post invariants for validation. They are used when business logic doesn't naturally belong to a single aggregate. Wire them into command handlers or application services for persistence. Use when the user asks to "add a domain service", "implement cross-aggregate logic", "coordinate multiple aggregates", "add a business operation spanning aggregates", "validate across aggregates", or when they describe scenarios like "placing an order checks inventory and reserves stock", "transferring funds between accounts", "scheduling involves both resource and calendar"./add-eventAdd a complete event flow to an existing aggregate. It creates a domain event, adds or updates an aggregate method that raises the event via self.raise_(), and wires an event handler that processes the event and performs specified side effects (such as syncing state across aggregates, sending notifications, or triggering downstream processes). This is the primary workflow for adding reactive, event-driven behavior to a Protean domain. Use when the user wants to "add an event", "add a domain event", "add a reaction to a state change", "add a side effect", "create an event flow", "wire an event handler", "add event-driven behavior", "react to a state change", "sync aggregates on event", or describes something that happened or should happen (like "when an order is placed, reduce inventory", "after payment is confirmed, send a notification", "when a user registers, create a welcome email", "notify the warehouse when an order ships"). This workflow composes the event, aggregate, and event-handler element skills./add-fieldAdd fields to Protean domain elements (aggregates, entities, value objects). Guides you through selecting the right field type, configuring validations, and placing fields correctly. Use when the user asks to "add a field", "add an attribute", "add a property", "I need to store [data]", "add a new field to [aggregate/entity]", or describes data that needs to be tracked. Covers simple fields, association fields (HasOne, HasMany, ValueObject), field validation, custom validators, and choosing between field types for different use cases./add-read-modelBuild a complete read model in Protean, a projection populated by a projector that reacts to domain events. Covers single-aggregate projections (flattened view of one aggregate), cross-aggregate projections (combining data from multiple aggregates), and choosing between database-backed and cache-backed storage. Use when the user asks to "add a read model", "create a projection with projector", "build a query view", "add a CQRS read side", "create a denormalized view", "build a reporting view", "add a dashboard query model", or when they need to combine data from multiple aggregates into one queryable structure./add-saga-flowBuild a complete saga in Protean using a process manager that coordinates a multi-step flow across several aggregates. The saga reacts to domain events, issues commands to drive each aggregate forward, tracks its own state, and closes on a terminal handler with a compensating path for failures. Use when the user asks to "add a saga", "coordinate a multi-step process", "orchestrate a workflow across aggregates", "manage order fulfillment", "add a process manager flow", "compensate on failure", "roll back a distributed transaction", or when they describe a flow like "reserve stock, take payment, then ship, and undo the reservation if payment fails".Other plugins' skills for the same job