No, you cannot, in a democracy, write the rules in such a way to magically and automatically guarantee that bad things cannot happen, because the core conceit of democracy is that
the will of the people can happenIf your people want bad things to happen, there is no text anywhere that can prevent it.
You cannot constrain people with laws without enforcement, just as a rule. Real life isn't like code where you write it and it just happens. If you want to restrain Trump to the rules, then the people in power have to believe the rules are more important than campaign promises, and for that you need the voting public to believe it is more important to maintain rules than it is to get your pet policy goals executed on.
The entire problem is that tens of millions of Americans think rules are bad and don't see any problem with there being no rules because they often believe that everyone has the same beliefs they do. And if they don't, they should be gulag'd for being unamerican.
A democracy can agree on rules ahead of time, but that cannot ensure future compliance. As long as people have more support from "Getting things done" compared to "Breaking literal law". This administration breaks very clear cut laws. What could possibly be a law they wouldn't dare to break with their current supporters?
Those supporters don't believe in a rule of law. It's simple as that. It kills democracy. You cannot have a democracy when compromises cannot be relied on.
This was predicted when the Republican party started to court the religious fundamentalist vote. They internally complained that it would kill the party.
Bush's speech writer is cited as saying: If conservatives become convinced that they cannot win democratically, they will not abandon conservatism. They will reject democracy
America has a very large, very organized, very passionate body of people who toe the line of their fundamentalist "Christian" organizations. There are lots of different surveys on this, but the general minimum is that 10% of Americans affirmatively believe that god created the earth as it exists today, unchanging, within the past 10k years.
that belief requires you to believe all of science is a giant conspiracy in league with Satan himself to make you turn away from god. A minimum of 30 million Americans are firm believers in the conspiracies and anti-reality beliefs espoused in Chick Tracts.
The entire Satanic Panic was these people acting on this stupid belief. Chick Tracts are demonstrably false in everything they espouse, but when you have homeschooled your child and bought only the stupidest "textbooks" for them to learn from that state matter-of-factly that science is a conspiracy, of course people end up believing that earnestly. These people believe at all times that they are in a literal war with the devil. In war, all things are permissible of course. They believe, against direct evidence and literal text from the founders, that America is a Christian nation (but notably, not any of the christian faiths that existed when America was founded). These people have spent generations cultivating an entire parallel media ecosystem, an entire parallel education system, that will never ever ever confront them with reality. Go watch christian media, it's utterly insane the things it believes. Every single popular teen movie gets remade with the plot replaced with a surface level similar one where the government is executing "Christians" for being "Christian". They live in perpetual victimhood. If you have convinced yourself that equal treatment is persecution, you will do horrible things.
The CIA quite literally played on these fears as part of the red scare, playing up Communism's atheism. This is still taught by parents to children to this day.
The reason our currency says "In god we trust" and the reason we have "Under god" in our pledge is directly down to this bloc being extremely powerful and having an utter disrespect for the rule of law.