[api] avoid multiple object lookups for commands