In general, the reefs are pretty close to the beaches along the Kenyan coast, but I'm not sure if they are so close that you could swim there.
E.g. in Diani Beach (the most popular one in Kenya) the reef is a 30 minute swim from the beach and at Nyali beach the reef is 2 kilometers from the beach.
However, especially at the popular beaches, there are many locals who could take you with a boat inexpensively.
Kenya is also great for deep sea diving by the way. The coral reefs in Kenya have a great reputation.