Module 05 · 9 min
Choose a mode
Governed, Direct and Ask only: what each does with your files, when to use it, and how to choose for one request.
By the end of this module you can
- Choose the right mode for a piece of work
- Switch modes, or choose for one request whatever the mode
- Explain why Direct needs Git, and what happens to it under a contract
The mode decides what a plain request does with your files. There are three modes, and Governed is the default.
The three modes
| Mode | What it does | Use it for |
|---|---|---|
| Governed (default) | Starts with a plan for your approval. The change is built in an isolated copy, tested and reviewed, and reaches your files only when you accept the diff | Changes you care about |
| Direct, ask each write | Works in your real files and asks before each write | Small changes you are watching |
| Direct, auto | Works in your real files; writes apply as they come | Quick work in a repository you can undo with Git |
| Ask only | Answers questions. A change is offered, never started by itself | Learning a codebase |
Direct needs the folder to be a Git repository, because Git is how you undo a direct change: git diff shows what changed, and git restore puts it back.
In Ask only, Albert offers a change and waits. In the browser, Start a governed change? shows the request it would send, with Yes, plan it and Do it directly.
Switching
| Where | How to switch |
|---|---|
| Terminal | /mode. In the terminal interface, Tab also moves to the next mode, and the prompt shows the folder, the model and the mode |
| Browser | The mode chip under the message box |
| VS Code | The Governed, Direct and Ask only buttons above the message box |
The mode applies to plain requests. /plan always starts a governed change, and /do always starts a direct one, whatever the mode. In the terminal, /direct auto <request> applies each write without asking.
Direct under a contract
Direct mode works in your real files, outside the isolated copy that the contract's checks rely on. So when a repository declares a contract and you start a direct change, AlbertCode SWE stops and asks:
- governed: run it as a governed change instead, under the contract (the default);
- disregard: go ahead directly, only if
allow_admin_overridepermits it, recorded either way; - cancel.
Practise
Fit the mode to the work
Each mode suits a kind of work. Match the mode to what the guide says it is for.
Try every mode on one repository
Use a Git repository: Direct needs one, because Git is how you undo a direct change.
- 1
Switch to Ask only:
/mode ask - 2
Ask a question, then ask for a change and see that Albert only offers it:
Where is the session cookie set, and how long does it last? - 3
Make a direct change. Approve the write, check it with
git diff, then put it back withgit restore:/do Fix the typo in README.md - 4
In the terminal interface, press Tab a few times and watch the mode in the prompt change. Then finish in Governed:
/mode governed
Check your understanding
6 questions. Answer 5 correctly to complete the module. Checked here, in your browser.