You just have to reformat your hard drive and reinstall a clean version of the operating system.
The first thing you should do before hitting the streets to sell your old Mac is clear it of any and all personal data. You don't want to accidentally sell your computer to a stranger when you are still logged into iCloud.
If you already have your new Mac on hand, you can transfer all of your data from your old Mac or use an older Time Machine backup. If you don’t have your new Mac, just make sure to back up your data before you get what you need on the your new Mac
The software you have on yours is licensed to you, which means it doesn't get transferred to the new owner of your computer. In order to avoid complications with the new owner attempting to download and install software that is licensed by you, make sure to sign out of everything your personal information is connected to.