Strip "Command" suffix from command names automatically#61
Merged
Conversation
The default commandName() on AbstractCommand and CommandWithResult now returns the class's simple name with a trailing "Command" stripped, so the x-command tag on raised events shows the shorter, more readable form (e.g. "OpenAccount" instead of "OpenAccountCommand"). Classes whose simple name does not end in "Command" are returned as-is. https://claude.ai/code/session_01T1VTbefm3KVwWfuJx98mjx
vanrogu
added a commit
that referenced
this pull request
May 16, 2026
The default commandName() on AbstractCommand and CommandWithResult now returns the class's simple name with a trailing "Command" stripped, so the x-command tag on raised events shows the shorter, more readable form (e.g. "OpenAccount" instead of "OpenAccountCommand"). Classes whose simple name does not end in "Command" are returned as-is. https://claude.ai/code/session_01T1VTbefm3KVwWfuJx98mjx Co-authored-by: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Automatically strip the "Command" suffix from command class names when generating command names via the
commandName()method. This simplifies command naming conventions by allowing developers to use the standard*Commandsuffix without it appearing in event metadata and logs.Changes
commandName()default implementation to strip trailing "Command" suffix from class simple namecommandName()default implementation to strip trailing "Command" suffix from class simple nameRaiseDomainCommand→RaiseDomainRaiseOutboundCommand→RaiseOutboundImplementation Details
The implementation uses a simple string check: if the class simple name ends with "Command", it removes that suffix. Otherwise, the name is returned unchanged. This allows:
OpenAccountCommandclass →"OpenAccount"command nameOpenAccountclass →"OpenAccount"command name (no change)commandName()method override is still respectedThis change affects command metadata stored in event tags (X_COMMAND) and improves readability of event streams and logs.
https://claude.ai/code/session_01T1VTbefm3KVwWfuJx98mjx