The workers, who included both men and women, were clearing scrubland alongside a road in the Hawa-Abdi area, some 18 kilometres (11 miles) north outside the capital Mogadishu.
"Several gunmen attacked innocent civilians, who were clearing bushes along the road," said Mohamed Adan, a local security official, saying eight people had been killed.
Witnesses confirmed the incident, adding that several others were wounded by the gunfire.
"It was a horrible attack," said Fadumo Kulow, who passed by the site of the killing soon after. "Eight people were killed, and six others were wounded."
Ahmed Moalim, another witness, said the wounded were rushed to hospital in Mogadishu.
No group has claimed responsibility for the killings, nor was it immediately clear why the workers were attacked.
Somalia's Al-Shabaab insurgents have carried out a string of attacks against those supporting the government.