Authorities want to hold an intellectually disabled man, who has already been detained for more than 10 years after he was caught trespassing, for another three years.
The man's family, represented by human rights lawyer Tony Ellis, oppose the National Intellectual Disability Care Agency's bid.
The man - who has autism - arrested in 2006 for trespassing and smashing windows.
He has been assessed by a clinical psychologist as posing a risk of further violent behaviour.
Strict suppression orders prevent RNZ news from identifying the man, where he is detained or who his caregivers are.
The hearing is under way at the Manukau Family Court.
Authorities have applied for the man to be subjected to a further Compulsory Care Order and detained for another three years.
A clinical psychologist told the court the man posed a high risk of re-offending. He had a pattern of aggressive behaviour including making threats, assaulting staff and breaking windows.
He had violent fantasies that included stabbing and decapitating people.
He said the man has a history of challenging behaviour that includes cutting a student's neck with a knife when he was a teenager.
In 2006 he broke into his neighbour's garage with an axe and smashed the windows of a car.
He was charged with wilful damage and being unlawfully in an enclosed yard - crimes that carry maximum sentences of three months in prison - but he was found unfit to stand trial and detained to a secure mental health unit.
In court yesterday, the doctor said the man had violent fixations and believed he was on a mission for James Bond.
He had been found drawing violent pictures that included people tied to beds, being stabbed and having their heads and feet cut off.
In the time he has been locked up he has punched and slapped staff and threatened to kill people.
The doctor said the man needed a high level of support and continued to pose a risk to the public.
Man can only leave with two staff
The man is allowed to leave the facility on occasions - but only in the care of two staff.
The doctor said, despite being in compulsory care for over 10 years, the man showed no signs of being rehabilitated.
The doctor confirmed under cross-examination from Mr Ellis that the authorities could improve their standard of care. He confirmed he had spent little more than an hour with the man during his assessment interviews.
The court heard how staff had denied the man daytime naps to punish him for bad behaviour and removed his stationery when he drew violent pictures. Mr Ellis said that was "cruel" as the man's autism made him a visual person.
Mr Ellis said the institution - which RNZ News cannot name - was punishing the man and not helping to rehabilitate him.
Questions over the man's care were raised by another psychologist. The doctor, with over 45 years experience in the area of intellectual disabilities, said the provider should be compiling a list of safe places that the man could visit to improve his quality of life.
Facility has barred windows
The doctor said the man wants to move to another facility to be closer to his mother - the two have a close relationship.
She said the current facility was not helping his treatment and could be triggering violent episodes.
The doctor described the facility as dim - with barred windows and blankets put up over the windows because of the man's propensity to break them.
The doctor said after more than 10 years, his current care provider had done little and the changes promised at the facility would require a huge retraining of staff.
She confirmed to National Intellectual Disability Care Agency's lawyer, Ian Auld, the man posed a risk if he was not under supervision.
Under questioning from Judge Alan Goodwin, the doctor confirmed there was a dilemma on what to do with the man, but she said leaving him in his current facility would leave him with no motivation to change.
Today the court will hear from a further mental health expert.
The case has been the subject of a separate legal bid in the Wellington High Court where Mr Ellis is challenging the legality of the man's detention.