Since Kenya intervened in Somalia in October 2011, insecurity has spiraled out of control, with attacks (largely targeting Kenyans) becoming commonplace occurrences in Nairobi, the coast, and parts of North Eastern.
These fall into two broad categories: large-scale and sophisticated (some foiled, some successful), and amateurish low-grade and low casualty.
Last September's attack on the Westgate shopping mall, and more recently that on the village of Mpeketoni in Lamu County, fall into the large-scale category. Sandwiched between these are those targeting Matatus - public transport taxis in Eastleigh, a Nairobi suburb popular with the Somalis - and other public facilities like the Gikomba (East Africa's largest open air market).
The government's response to the attacks has been at best impotent and at worst, misguided. First, they instituted 'Nyumba Kumi' (know thy neighbor) - the ten houses initiative.
The concept of Nyumba Kumi, borrowed from Tanzania, was predicated on dividing the households into groups of ten, and people in those households hold each other accountable through sharing information on any suspicious activities.
While the concept looks neat in theory, in practice, it is not the most effective way of addressing the ever-mutating threat of terrorists - people with no return address.
It might work in some rural settings where the residents tend to be less mobile, but not in urban areas like Nairobi and Mombasa where residency is fluid and transient due to the economic pressures.
Second, the government conducted what it called Operation Usalama Watch. This was a large state-led profiling of the Kenya-Somali community. The community became the de facto scapegoat for all the attacks, despite the fact that it bore the brunt of most of them. This tactic also ignored the debatable efficacy of collectively punishing an entire community for the crimes of a few.
During the operation over 4000 Somalis were arrested and held in Kasarani football stadium. Over two months later some are still there in dehumanizing conditions. The security sweep touched a raw nerve and exacerbated the already fraught relations between the community and the state. The security situation also barely improved.
The recent attack in Mpeketoni Lamu was preceded by Western travel advisories recommending that tourists avoid certain popular coastal regions. This was interpreted by the Kenyan authorities as being a cynical effort by Western countries to sabotage the country's already ailing tourism industry.
As a response, the government announced rafts of measures to encourage local tourism to offset the departure of many foreigners.
The anti-western rhetoric from the Kenyatta government is largely a continuation of the Jubilee Alliance election campaign - the Kenyatta/Ruto ticket was carried to State House on the crest of an anti-ICC and anti-western wave.
The nature of these attacks can be divided into three categories: First, some are the work of Al Shabaab Central. They bear all the hallmarks of the group's previous work, and they have claimed responsibility. For example, the Westgate attack.
Second, some are carried out by Al Shabaab cells in Kenya - hence their amateurish and ineffective nature. They achieve little apart from sowing fear.
Third are attacks which are the work of opportunistic criminal groups that take advantage of the prevailing situation to act against a business rival, or similar.
Until we work out which attack was undertaken by which groups - which can only be achieved through a thorough and meticulous study - all are too easily bundled together as 'Al Shabaab'.
A shift in tactics
Since Westgate, Al Shabaab has carried out two sophisticated attacks - one was foiled, and another one missed its target. In one incident on 23rd April two militants detonated a Vehicle Borne Improvised Explosive Device (VBIED) in Pangani Police station (near Eastleigh).
Two police officers were killed. According to the authorities, the target was not the police station, but elsewhere in the Central Business District.
On 11th March, Kenya's Anti-Terror Police detonated a pick-up laden with explosives in Chamgamwe Mombasa. The target of the attack was the police station. The police found six pipe bombs attached to a mobile phone detonator, and plastic explosives.
These two unsuccessful attacks demonstrate that the group has found Kenya to be vulnerable and that they are keen to carry out more 'spectacular' attacks.
The regional military intervention in Somalia pushed Al Shabaab out of Mogadishu and diminished its capacity by denying them their critical revenue source - the port of Kismayo. However, the supposed defeat of the group was greatly exaggerated.
The great existential threat to Al Shabaab was the internal contest between the transnational jihadis and the Somali nationalists. But the battle for the 'soul' of Al Shabaab was won by the current leader, Ahmed Godane, who is aligned with the former group.
He gained the leadership by expelling all he disagreed with regarding the group's strategic vision. Al Shabaab is now a de facto transnational jihadi movement.
However, despite its diminished capacity, conducting an attack in a neighbouring country is a low cost affair. Bleeding Kenya through multiple attacks in far-flung vulnerable areas like Mpeketoni will make the country look unsafe, at least from the all-important outsider perspective.
Domestic political implications
After the recent attacks the Kenyan president addressed the nation and said; "The attack in Lamu was well planned, orchestrated, and politically motivated ethnic violence against a Kenyan community, with the intention of profiling and evicting them for political reasons ...
This therefore, was not an Al Shabaab terrorist attack. Evidence indicates that local political networks were involved in the planning and execution of the heinous attacks."
However, Al Shabaab had already claimed responsibility, saying; "The Kenyan government is fighting a losing war and has turned its vengeance on the Muslims in Kenya. As such, the Mpeketoni Raid was carried out in response to:
(a) Kenyan government's brutal oppression of Muslims in Kenya through coercion, intimidation and extrajudicial killings of Muslim scholars, particularly in Mombasa, and the violation of Muslim honour and sanctity.
(b) Kenyan military's continued invasion and occupation of our Muslim lands and the massacre of innocent Muslims in Somalia.
(c) In addition to that, the town raided by the Mujahideen was originally a Muslim town before it was invaded and occupied by Christian settlers".
The statement from the president was curious considering the prevailing tense political/ethnic climate in Kenya.
The opposition leader Raila Odinga arrived in Kenya after three months stay at Boston University, upon his return he demanded a national dialogue, something the president initially accepted, before changing his mind.
This occurred after his deputy William Ruto poured cold water on the plan, reckoning that what Odinga is was after was not talks but a coalition government.
Odinga has replied that his group will be touring the country holding rallies and, more specifically, coordinating Kenyans to attend a 'Saba Saba'-style rally on July 7th - a date that has great historical significance in Kenya's democratic struggle.
The president's address after Mpeketoni added fuel to an already polarized national political fire. But, ironically, he has contributed to a situation that he, in the aftermath of Westgate, identified was what terrorist were after: "[a] closed, fearful and fractured society where trust, unity and enterprise are hard to muster."
The leadership's blatant political point scoring on matters of national security is not only gratuitous, but also dangerous, and will only hand the initiative to a group that is facing multiple threats. This is not an effective way to fight terrorism.
Throwing accusations at the political opposition, large-scale ethnic profiling and detainment of Somalis cannot solve what is a serious security problem in Kenya.
Instead, any counter-terrorism effort should be linked with a clearly defined Somalia exit plan. The current open-ended stay by Kenya forces will only lead to mission creep and the window between when Kenya was seen as a liberator and invader closed a long time ago.
The president needs to define what the end-state in Somalia looks like. Insisting that we shall stay the course may sound like an admirable policy; in practice it is unsustainable given growing domestic insecurity.
Abdullahi Boru Halakhe is a Horn of Africa Analyst.