How can I make a minecraft command block kill only aggressive mob

You can kill all aggressive mobs by setting the difficulty to peaceful.

/difficulty 0

Or you could /kill @e[type=X] where 'X' are mobs that are hostile.

/kill @e[type=cave_spider]
/kill @e[type=enderman]
and so on...