You have to code for where you want it to fork at. Take a look at bcash code to see how they did it.
Bitcoin Cash is a
Hard Fork, a valid example of a Soft Fork is SegWit which has some software changes that didn't required a new chain upon its implementation.
I can't further help the OP with this, because I'm not well informed (
for now) to the "
technical side" of Soft-forks/Hard-forks as well, but this link may help:
https://en.wikipedia.org/wiki/SegWit