Allicin the antibiotic ingrediant in garlic will not get past your stomach as it is instantly destroyed by the acid, so no it will not harm beneficial gut flora or anything else past the stomach.
Berberine I am not familiar with.
As far as I'm aware the only thing that effects your good bugs in a bad way are bad bugs, pharma antibiotics, dehydration, low ph, and low oxygen due to acid forming fake foods.
Consuming fermented foods is more beneficial than popping probiotic pills for gut health.