I know there is an option to dedup records from cli, but I would rather prefer to skip them from being added to the history in the first place. And also, if possible, skip saving of failed commands (exit code 1)
The latter at least is simple: see the store_failed configuration parameter.