Could we write and save a code (queries) to repository, where they can be versioned over time, have a dev->stage->production workflow?
Not sure what you meant, but, If I understand it properly, you can save a question, and keep track of the changes using the question history - and you can reverse back to an early version if needed. But, if you mean having a git-like environment, I think it is very unlikely you will be able to do it on Metabase.
You may also create collections for that. Collections are very usable I think. You can create a question on the “DEV” collection. And later you may move them to “STAGE” and “PRODUCTION”. You can also track of the changes on the specific question.