After doing some research, I guess the cure for this is to write vertical sliced stories that are very small in scope.
The problem that I see with this is that you can have multiple user stories that are quite similar but limited in scope.
How do you ensure that each dev who works on the story can complete the story without developing tech debt around multiple implementations of the same logic? How do you prevent integration headaches?
For example, if an app is a react/redux app on the front-end with a rails API and relational database.
If the vertical story is "As a user, I want to be able to add counters to my shopping cart." and "As a user I want to be able to remove counters from my shopping cart." And there's no previous logic to handle this on the front or the backend. How do you ensure if you split these tickets that the two devs who work on the ticket don't just waste time doing the same thing but in different ways?