/protean:coverage-analysisfrom protean
Analyzes Protean domain code to identify untested code paths, catalogs testable elements (aggregate methods, invariants, events, handlers, value object operations, entity management), compares against existing tests, produces a gap report with severity classification, and generates missing tests.
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.
Analyze Protean domain code to identify untested business logic and generate missing tests in a single pass.
| Output | Purpose |
|---|---|
| Testable element catalog | Every aggregate method, invariant, event, handler, VO operation |
| Existing test inventory | What current tests already cover |
| Gap report | Untested code paths classified by severity |
| Generated tests | Missing tests following generate-test-scaffold patterns |
| Category | What to catalog | How to detect |
|---|---|---|
| Aggregate factory methods | @classmethod that returns cls(...) | Look for classmethods on aggregates |
| State-change methods | Instance methods that mutate self.field | Assignments to self.status, self.field, etc. |
| Events raised | self.raise_(EventClass(...)) calls | Grep for raise_ in aggregate methods |
| User-defined invariants | @invariant.pre / @invariant.post | Decorator usage on aggregate methods |
| Business rules | Guard conditions that raise errors | if ... raise ValueError/ValidationError |
| Command handlers | @handle(CommandClass) methods | Handler methods in @domain.command_handler |
| Event handlers | @handle(EventClass) methods | Handler methods in @domain.event_handler |
| Value object operations | Custom methods on VOs | Non-dunder instance methods on @domain.value_object |
| Entity management | add_<entities>() / remove_<entities>() | Aggregate methods managing child entities |
Before analyzing, identify:
domain = Domain(...))Read all domain files and build a structured inventory per aggregate:
# For each aggregate, catalog:
{
"Ticket": {
"factory_methods": ["create"],
"state_change_methods": ["assign", "close", "escalate_priority"],
"events_raised": {
"create": ["TicketCreated"],
"assign": ["TicketAssigned"],
"close": ["TicketClosed"],
},
"invariants": ["assigned_ticket_must_have_assignee"],
"business_rules": {
"assign": ["status must not be closed"],
"close": ["status must not be open"],
},
},
"Priority": {
"vo_operations": ["escalate"],
"business_rules": {"escalate": ["cannot escalate beyond critical"]},
},
}
Read all test files and map what is already tested:
{
"Ticket": {
"factory_methods_tested": ["create"], # covered
"state_changes_tested": ["assign"], # close NOT tested
"events_verified": ["TicketCreated"], # TicketClosed NOT verified
"invariants_tested": [], # NONE tested
"business_rules_tested": {}, # NONE tested
}
}
What counts as "tested":
isinstance(aggregate._events[N], EventClass) AND checks event field valuespytest.raisesdomain.process(Command(...)) and verifies persisted state. The test conftest sets command_processing to "sync", as in generate-test-scaffold Step 7Compare catalog against inventory. Classify each gap:
| Severity | Criteria |
|---|---|
| HIGH | Core behavior untested: aggregate methods, invariants, handler orchestration, cross-aggregate side effects |
| MEDIUM | Partial coverage: missing negative tests, event data unverified, entity operations untested |
| LOW | Nice-to-have: VO operations, computed properties, lifecycle tests |
For each gap, generate tests following generate-test-scaffold patterns:
| Gap type | Test class pattern | Scaffold reference |
|---|---|---|
| Aggregate method | Test{Aggregate}Behavior | generate-test-scaffold Step 2 |
| Invariant / business rule | Test{Aggregate}BusinessRules | generate-test-scaffold Step 3 |
| Command handler | TestHandlerProcessing | generate-test-scaffold Step 4 |
| Event handler side effect | TestCrossAggregateFlow | generate-test-scaffold Step 5 |
| End-to-end lifecycle | TestLifecycle | generate-test-scaffold Step 6 |
Use _events.clear() to isolate event assertions when testing a method after a factory that also raises events.
## Coverage Analysis Report
### Domain Elements Cataloged
- Aggregates: [list with method counts]
- Commands: [list]
- Events: [list]
- Handlers: [list]
### Coverage Summary
- Tested: X/Y testable elements (Z%)
- Gaps found: N (H high, M medium, L low)
### Gaps (by severity)
#### HIGH
1. [description]: generated test class: `TestXxx`
#### MEDIUM
1. [description]: generated test class: `TestXxx`
#### LOW
1. [description]: generated test class: `TestXxx`
### Generated Tests
[Complete test code for all gaps]
Do not report missing tests for framework-guaranteed behavior:
@domain.value_objectrequired, max_length, min_value, choices): Protean Layer 1domain.registry: guaranteed if decorator is usedmeta_.part_of associations, meta_.stream_category: framework wiring.payload dict access: framework featurecheck and resolve what it reportsWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
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".Other plugins' skills for the same job