Skip to content

Strip "Command" suffix from command names automatically#61

Merged
vanrogu merged 1 commit into
developfrom
claude/remove-command-suffix-s53x0
May 16, 2026
Merged

Strip "Command" suffix from command names automatically#61
vanrogu merged 1 commit into
developfrom
claude/remove-command-suffix-s53x0

Conversation

@vanrogu
Copy link
Copy Markdown
Member

@vanrogu vanrogu commented May 16, 2026

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 *Command suffix without it appearing in event metadata and logs.

Changes

  • AbstractCommand: Updated commandName() default implementation to strip trailing "Command" suffix from class simple name
  • CommandWithResult: Updated commandName() default implementation to strip trailing "Command" suffix from class simple name
  • CommandNameTest: Added comprehensive test suite covering:
    • Commands with "Command" suffix (stripped)
    • Commands without suffix (returned as-is)
    • Edge cases (only single trailing suffix stripped, multiple suffixes)
    • OutboundCommand variants
    • CommandWithResult variants
    • Overridden command names (respected as-is)
  • CommandMetadataOnEventsTest: Updated assertions to reflect new naming behavior:
    • RaiseDomainCommandRaiseDomain
    • RaiseOutboundCommandRaiseOutbound
    • Added test for commands without "Command" suffix to verify they're used as-is

Implementation 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:

  • Standard naming: OpenAccountCommand class → "OpenAccount" command name
  • Alternative naming: OpenAccount class → "OpenAccount" command name (no change)
  • Explicit override: commandName() method override is still respected

This change affects command metadata stored in event tags (X_COMMAND) and improves readability of event streams and logs.

https://claude.ai/code/session_01T1VTbefm3KVwWfuJx98mjx

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 vanrogu merged commit 13e0923 into develop May 16, 2026
1 check passed
@vanrogu vanrogu deleted the claude/remove-command-suffix-s53x0 branch May 16, 2026 15:46
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants