Git Basics & Sandbox Isolation
Lab Playbook 2
Learn to isolate your codebase by creating branches and staging/committing files for AI agent tasks
In this lab playbook, you will master Sandbox Isolation. AI agents make edits directly inside the file system. Before delegating any code generation or modification tasks, you must isolate the environment using Git branches. This allows you to review, stage, reject, or commit code changes safely and prevent local history pollution.
test_case.md file. Here, the student learns to direct an agent to branch, edit, and commit code inside an isolated sandbox.Sandbox Scoping (QE Setup)
To protect your primary development directories, you should scope agent tasks to a dedicated sandbox folder. Instead of using git clone or a remote repository, you will create a local sandboxed duplicate of the training folder initialized on Day 1.
# 1. Create a sandbox workspace folder
mkdir -p ~/workspace/sandbox
# 2. Duplicate the Day 1 training folder into the sandbox directory (no remote cloning!)
cp -R ~/workspace/training-folder ~/workspace/sandbox/training-folder
# For Windows PowerShell, use:
# xcopy /E /I ~/workspace/training-folder ~/workspace/sandbox/training-folder
# 3. Enter the local sandbox folder
cd ~/workspace/sandbox/training-folderThe project workspace has been duplicated locally. If the AI agent runs rogue commands or deletes files, your primary Day 1 development workspace remains completely unaffected.
Branch Creation (QE Instruction)
Instruct the agent to switch out of the default branch and create a dedicated branch for their edits.
Please check the current git status of our repository. After that, create a new branch named 'qe/feature-login-tests' and switch to it. Finally, run git branch to verify you are on the new branch.I'll verify the status and switch to a separate work branch. **Step 1 β Check repository status** ```bash $ git status On branch main nothing to commit, working tree clean ``` **Step 2 β Create and switch to new branch** ```bash $ git checkout -b qe/feature-login-tests Switched to a new branch 'qe/feature-login-tests' ``` **Step 3 β Verify active branch** ```bash $ git branch main * qe/feature-login-tests ``` β Isolation branch 'qe/feature-login-tests' successfully created and active.
qe/feature-login-tests. Correct the agent if it attempts to edit code directly on the master or main branches.Staging Files (QE Instruction)
Now that the agent is on an isolated branch, you can guide them to stage modifications. You must explicitly audit which files the agent proposes to add or update.
test_case.md file from Day 1.Please check git status to verify modified changes. Stage only the modified 'test_case.md' requirements file using git add, then verify it has been staged successfully.I will locate modified changes and stage test_case.md. **Step 1 β Verify modified files** ```bash $ git status On branch qe/feature-login-tests Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git restore <file>..." to discard changes in working directory) modified: test_case.md no changes added to commit (use "git add" and/or "git commit -a") ``` **Step 2 β Stage test_case.md** ```bash $ git add test_case.md ``` **Step 3 β Verify staging status** ```bash $ git status On branch qe/feature-login-tests Changes to be committed: (use "git restore --staged <file>..." to unstage) modified: test_case.md ``` β Successfully staged the modified 'test_case.md'. No other files have been modified or staged.
State Preservation & Verification
Preserve the work state by committing. The commit history acts as your rollback ledger. If the agent fails a future code iteration, you can instantly revert to this clean commit.
Please commit the staged changes with the message "docs: update login test requirements for sandbox scoping". After committing, display the latest commit log details.Staging is verified. I'll preserve this state.
**Step 1 β Commit staged changes**
```bash
$ git commit -m "docs: update login test requirements for sandbox scoping"
[qe/feature-login-tests ed38a5b] docs: update login test requirements for sandbox scoping
1 file changed, 5 insertions(+), 2 deletions(-)
```
**Step 2 β Show latest commit**
```bash
$ git log -n 1
commit ed38a5bd1634b8c6f1a8c91d84b5cc223a54b9f2 (HEAD -> qe/feature-login-tests)
Author: Agentic QE <qe-orchestrator@shieldmutual.co.uk>
Date: Wed Jul 1 18:44:00 2026 +0100
docs: update login test requirements for sandbox scoping
```
β
Commit successfully saved. Ready for further tasks.The commit message you wrote does not follow our repository standards.
Please amend the commit message to be precisely: docs: update login test requirements for sandbox scoping
To do this, run: git commit --amend -m "docs: update login test requirements for sandbox scoping"Please run git status to ensure our working directory is clean, and git branch to confirm the active branch name.Running final verification checks: **Step 1 β git status** ```bash $ git status On branch qe/feature-login-tests nothing to commit, working tree clean ``` **Step 2 β git branch** ```bash $ git branch main * qe/feature-login-tests ``` β Verification complete. The working tree is clean and our state is preserved on 'qe/feature-login-tests'.
The isolation checkpoint is complete. You have successfully switch Git branches, staged only targeted files, committed them, and audited logs. Should the agent fail at code editing or testing, you can roll back to ed38a5b immediately.