You can use
SecureCmdOptionParse to evaluate macro conditions for use in an addon.
In your case, you would use
local action, target = SecureCmdOptionParse("[@player] Swiftmend") which should return the strings "Swiftmend" and "player" if valid, and both nil if not valid.