Here is a fairly clear description of the clean install!
A clean install basically means that almost all data is wiped from the phone before installing ROMs. This can be done in the device's Recovery menu, which is accessed by long pressing and holding the Volume Up + Power button simultaneously when the device is off. Before we start, rename the ROM to be installed to update.zip (for MiRecovery, not necessary for TWRP) and copy it to the root of the device's storage, not to a folder, not to the SD card!
MiRecovery
Select English language when entering MiRecovery
Select the Wipe & Reset menu
In this menu, select Wipe Cache and then Wipe User Data
After Back to Main menu, press Install update.zip to System
When you're done you just need to restart your phone and you'll be greeted by a nice new system.
Note: After closing the bootloader, several MiRecovery types have been released with no menu at all and the latest one with Data reset will be presented soon!
TWRP
Go to the Wipe menu
Select the Advanced Wipe option
Tick the boxes below:
- Dalvik / ART Cache
- cache
- Data
- System
Pull the slider at the bottom
When you are done, go back to the main menu and select Reboot
Restart in Recovery
Select the Install option
Browse to the zip file you uploaded (it can be any name), click on it and drag the slider
When you're done, press Wipe cache/dash, then Reboot System
Once rebooted, you are greeted with a nice clean system.