[noun] + に気をつける [verb (dictionary form)] + ように気をつける [verb ない-form] + ように気をつける
に気をつける means "to be careful of", "to watch out for", "to look after". The thing you watch out for goes before it as a noun with に.
The noun takes に, never を. The を is already inside the expression, on き気.
To say what you take care to do, or not to do, put a verb in front with ように. The verb is in the dictionary form or the ない-form.
気をつけて with no object is what you say to someone leaving: "take care", "go safely". きをつけてください気をつけてください is the polite version, and おきをつけて気をつけて is politer still.