Generic parameter 'D' could not be inferred

You're not alone in wanting to do this, but prior to Swift 5.7, Swift cannot infer a type from a default parameter.

If I have understood the proposal correctly (I did not read the entire thing), a Swift Evolution proposal to do this was accepted in April 2022, and implemented in Swift 5.7:

The alternative in the meantime is to implement a helper function which omits the default argument:

public static func execute<T: Decodable>(command: some ShellCommand) throws -> T { ... }

From this, call your original function and pass it your default parameter. Not ideal, but works.