Courts must take care not to “overreact in unprecedented times”, a former director of public prosecutions has said, amid concerns that lengthy sentences being imposed during the coronavirus crisis could be excessive.

With courts prioritising coronavirus-related prosecutions, Ken Macdonald QC said acts such as deliberately spitting at police officers or service workers was “more than a nuisance, it is deliberately dangerous and I’m not surprised the courts are jailing the worst offenders in this category”.

But of lesser offences, he said: “Prison isn’t the places for nuisances, especially during a pandemic when confinement is so risky and difficult for the authorities to manage. Courts should avoid the inclination to overreact in unprecedented times. Filing up our prisons during a pandemic with people who clearly need psychiatric help rather than punishment is a poor criminal justice policy.”

Lord McDonald’s intervention comes after Max Hill QC, the director of public prosecutions, said crimes relating to Covid-19 were “an immediate priority – anybody jeopardising the safety of the public will face the full force of the law”.

Interim guidance published by the Sentencing Council this month instructs judges to treat “activity relating to transmission of Covid-19 … as an aggravating feature” of common assault offences .

Reports of prison sentences imposed in recent coronavirus-related cases include:

A woman in Bolton was jailed for 22 weeks for “pretending to fall over” at a Superdrug store. She had recently avoided going to prison for assaulting a nurse and was said to have mental health issues.

A Leeds man who coughed and spat at police after attempting to jump a physical distancing queue at a Poundland shop was jailed for six months last week.

In Burnley, a man who spat at police officers, claiming he was infected with coronavirus, while they detained him for being drunk and disorderly was jailed for a year.

One criminal justice expert said the issue was reminiscent of controversy over sentencing after the 2011 riots.

But in the middle of lockdown, it is difficult to know how representative such cases are. Those involving stiffer sentences inevitably attract more publicity. Precise charges and past convictions are not always reported.

Magistrates and judges are in unfamiliar territory because not only they are working in difficult – and potentially hazardous – circumstances during the lockdown, but they are also enforcing new legislation, the Assaults on Emergency Workers Act 2018, which increases penalties in such situations.

Magistrate hearings during the pandemic are mainly being conducted by full-time district judges rather than lay magistrates. Some claim district judges are more “case-hardened” than their part-time counterparts.

John Bache, the chair of the Magistrates Association in England and Wales, said: “It is right that cases involving attempts or threats to deliberately transmit coronavirus are treated very seriously and the sentencing guideline on assault has recently been updated to make it clear that this should be considered as an aggravating factor.

“Each individual case is, however, always treated on its own merits and sentencers must also consider a range of other issues, including mitigating factors and the current conditions within the prison estate, before deciding on the appropriate sentence for the individual involved.”

A number of longer sentences have been imposed in the north-west. Thomas Sherrington, a criminal barrister at St John’s Buildings chambers in Manchester, said: “On the face of it, 12 months for spitting is a lot … People are being dealt with harshly [but] you would probably say there’s no chance of appealing to a court; there’s a pandemic and people have been dying.”

James Mulholland QC, vice-chair of the Criminal Bar Association, said deterrent sentences may be necessary. He said: “Sentencing in the time of Covid-19 puts an added weight of responsibility on magistrates … [they need to respect] both the principle that the punishment should fit the crime, with the need to deter others from harmful antisocial activities, and that these do not outweigh the consideration of the individual circumstances and context of any single offence taken with an offender’s previous history of offending or clean record.”

Rosalind Comyn, apolicy and campaigns officer at Liberty, which has published a “know your rights” guide for the coronavirus lockdown, said: “The health and safety of everyone, including emergency service workers, is paramount. But that end will be better met if instead of prioritising enforcement and sanctions, the government focused on educating people and facilitating compliance to the new rules.”

• This article was amended on 20 April 2020 because an earlier version said that “interim guidance published by the Sentencing Council this month instructs judges to treat ‘activity relating to transmission of Covid-19 … as an aggravating feature’ of any offence”. The relevant offence covered by this guidance is common assault.