A 20-year-old man has appeared in court accused of plotting a terrorist attack after he was allegedly caught with a recipe for mustard gas.