An agent can edit a dozen files in a few seconds. Before you let it, your machine needs two things: a way to see exactly what it changed, and a way to go back when it breaks something. This post sets up both, plus the Python environment the later posts use. Nothing here installs an agent yet.
Open the right terminal and read the prompt
The line in front of the cursor is the prompt. It tells you which shell you are in and which folder you are standing in. PowerShell, CMD and macOS use different commands for the same job, so look at it before pasting anything.
| Terminal | How to open | Prompt looks like | Paste |
|---|---|---|---|
| Windows PowerShell | Windows + X → Terminal or Windows PowerShell. Not the Admin entry, not the (x86) entry | PS C:\Users\You> |
Ctrl + V or right-click |
| CMD | Type cmd in Start |
C:\Users\You> (no PS) |
Ctrl + V or right-click |
| macOS Terminal (zsh) | Cmd + Space → Terminal | ends with % |
Cmd + V |
Paste one line, press Enter, read the result, then paste the next. Ctrl + C
stops a command that hangs. On macOS, don’t paste comment lines starting with
#: interactive zsh does not treat them as comments by default.
The rule that saves the most time: after installing any tool, close the terminal and open a new one before checking it. The shell finds programs through PATH, and a window opened before the install still has the old PATH.
| You see | It means | Fix |
|---|---|---|
The token '&&' is not a valid statement separator |
A CMD command pasted into PowerShell | Use the PowerShell version |
'irm' is not recognized as an internal or external command |
A PowerShell command pasted into CMD | Open PowerShell |
A parameter cannot be found that matches parameter name 'fsSL' |
A macOS/Linux curl -fsSL … | bash line pasted into PowerShell |
Use the Windows command |
… is not recognized or command not found right after installing |
The old window has the old PATH | Open a new window |
Git: a checkpoint before and after every agent task
Git records the history of a folder. Each commit is a checkpoint you can return to. If the agent breaks something, you go back to the previous one.
Windows: download the x64 installer (ARM64 for ARM machines) from the official Git for Windows page and click Next through every screen, keeping the recommended PATH option. Or use winget:
winget install --id Git.Git -e --source wingetThe first time, winget may ask you to accept the source agreements. Read them and answer Y, or use the installer instead. The winget package is not maintained by the Git for Windows team and can lag behind.
macOS: run git --version. If Git is missing, xcode-select --install
installs Apple’s command line tools, which include it, or use
brew install git.
Then set your identity once. Every commit carries it, and if you ever push a project to a public GitHub repo, the email shows in the history, so a separate address is fine.
git --version
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
git config --global init.defaultBranch main
git config --listThe git config --global lines print nothing. The last command lists
user.name=Your Name (press q to leave a long list).
Two traps. git log and git diff open a pager when the output is long; the
screen ends in : or END, and q quits. And always commit with
-m "message": without it Git opens an editor, usually Vim. If you land in
it, press Esc, type :q! and Enter; the commit is cancelled.
| When | Command | What you see |
|---|---|---|
| Before handing over a task | git status |
nothing to commit, working tree clean. If files are listed, commit first |
| Take a checkpoint | git add -A then git commit -m "Checkpoint before agent task" |
[main 1a2b3c4] Checkpoint… and the number of files |
| Agent finished | git status then git diff |
Modified files and new files (under Untracked files). In the diff, - lines were removed, + lines added |
| Good | git add -A then git commit -m "What the agent did" |
A new checkpoint |
| Bad, throw it away | git restore file.py (whole folder: git restore .) |
Nothing printed; tracked files are back to the last commit |
| History | git log --oneline |
One checkpoint per line, newest first |
git restore discards the changes for good: they do not go to the recycle bin.
It also does not touch new files the agent created that were never committed;
those don’t show in git diff either, only under Untracked files in
git status. Review and delete them yourself.
An agent saying “done” is not evidence. The evidence is git diff and the
check you ran yourself.
The project folder: .gitignore first, secrets outside Git
The agent works in one folder with a clear place for rules, data, code and
results. On Windows use C:\trading-agent-lab: short, with no spaces or
accented characters (a user name with accents sometimes breaks command-line
tools), and not inside a Desktop or Documents folder that syncs to the cloud.
On macOS use ~/trading-agent-lab.
trading-agent-lab/
├─ data/ candle CSVs, anonymised journals
├─ prompts/ prompt templates
├─ src/ code
├─ tests/ tests
├─ reports/ charts, reports (reports/private/ is never committed)
├─ journal/ journal, weekly reviews
├─ .venv/ the project's own Python, never committed
├─ .env NEVER committed: keys, demo passwords
├─ .env.example variable names only
├─ .gitignore files Git ignores
└─ AGENTS.md rules for the agent.env holds secrets: API keys, bot tokens, demo account numbers and
passwords. It is never committed and never pasted into a chat. .env.example
only lists the variable names. When you create keys later, give them the least
rights possible: no withdrawals, no transfers.
.gitignore must exist before the first git add. Git’s own documentation
is explicit: files Git already tracks are not affected by .gitignore. Add
.env to it after committing .env, and the old commit still holds your keys,
readable by any agent that runs a Git command. At that point, treat the keys as
leaked: revoke them and change the demo password.
Windows PowerShell, one line at a time:
mkdir C:\trading-agent-lab
cd C:\trading-agent-lab
mkdir data, prompts, src, tests, reports, journal
git init
Set-Content -Path .gitignore -Encoding ascii -Value ".env", ".env.*", "!.env.example", ".venv/", "__pycache__/", "reports/private/"
Set-Content -Path .env.example -Encoding ascii -Value "MT5_DEMO_LOGIN=", "MT5_DEMO_SERVER=", "TELEGRAM_BOT_TOKEN="
git check-ignore -v .env
git add -A
git status
git commit -m "Project skeleton, secrets ignored"
git log --onelinemacOS:
mkdir -p ~/trading-agent-lab/{data,prompts,src,tests,reports,journal}
cd ~/trading-agent-lab
git init
printf '%s\n' '.env' '.env.*' '!.env.example' '.venv/' '__pycache__/' 'reports/private/' > .gitignore
printf '%s\n' 'MT5_DEMO_LOGIN=' 'MT5_DEMO_SERVER=' 'TELEGRAM_BOT_TOKEN=' > .env.example
git check-ignore -v .env
git add -A
git status
git commit -m "Project skeleton, secrets ignored"
git log --onelinegit check-ignore -v .env must print .gitignore:1:.env followed by the file
name; no output means .env is not blocked. git status lists only
.env.example and .gitignore: Git does not store empty folders, so the
subfolders appear once they hold files. Author identity unknown means you
skipped the identity step.
.gitignore only stops Git. Stopping the agent from reading .env is a job for
the agent’s permission settings, covered when you install it.
Python 3.14 in a virtual environment
Why 3.14 and not the newest release? The MetaTrader5 package (5.0.6231) on
PyPI only ships builds for 64-bit Windows, Python 3.6 to 3.14. There is no 3.15
build yet, so installing it on 3.15 will most likely fail to find a matching
file. Python 3.14 is in bugfix status and supported until October 2030.
Windows. The classic .exe installer is deprecated from 3.14 and won’t be
released from 3.16. The recommended way is the Python install manager, which
provides the py command: download it from python.org (or the Microsoft
Store), then in a new PowerShell window:
# Only if you did not install the manager from python.org:
winget install 9NQ7512CXL7T -e --accept-package-agreements --disable-interactivity
# Close the window, open a NEW PowerShell window, then:
py install 3.14
py list
cd C:\trading-agent-lab
py -V:3.14 -m venv .venv
.venv\Scripts\python -m pip install --upgrade pip
.venv\Scripts\python -m pip install pandas matplotlib
.venv\Scripts\python -c "import sys; print(sys.version)"
# Windows only, once per account: UTF-8 mode for Python, then reopen terminals and the agent app
[Environment]::SetEnvironmentVariable("PYTHONUTF8", "1", "User")On a machine with several versions, plain python opens the newest, so create
the venv with py -V:3.14, with -V:3.14 directly after py.
macOS. Install the Python 3.14 .pkg from python.org, then double-click
Install Certificates.command in Applications → Python 3.14.
python3.14 --version
cd ~/trading-agent-lab
python3.14 -m venv .venv
.venv/bin/python -m pip install --upgrade pip
.venv/bin/python -m pip install pandas matplotlib
.venv/bin/python -c "import sys; print(sys.version)"There is no MetaTrader5 build for macOS. On a Mac you still use Python for
CSVs and charts; the MT5 connection runs in a Windows VM or VPS. pandas and
matplotlib exist for both 3.14 and 3.15, so 3.14 on a Mac is only to match the
Windows setup.
A venv is the project’s own Python folder: packages installed there don’t
touch other projects, and if it breaks you delete it and create it again. You
don’t need to activate it: calling .venv\Scripts\python (macOS:
.venv/bin/python) uses the right interpreter. Always install with
python -m pip, never bare pip. This also avoids PowerShell blocking
Activate.ps1, since the default execution policy on personal Windows machines
is Restricted. Changing that policy is a security setting: only do it when you
understand it, not because an agent or a web page told you to.
Why PYTHONUTF8: Python 3.14 prints to the console in UTF-8, but when
output goes through a pipe (an agent reading it) or into a file, it uses the
old Windows code page, such as cp1252. Any character outside it, such as an
accented letter or an emoji, stops the script with
UnicodeEncodeError: 'charmap' codec can't encode character. Python 3.15
defaults to UTF-8; on 3.14 you switch it on yourself. The variable only applies
to programs started afterwards, so close every terminal and the agent app.
| You see | Fix |
|---|---|
winget is not recognized |
Install App Installer from the Microsoft Store, or use the python.org download |
python opens the Microsoft Store |
Start → Manage app execution aliases → toggle the Python entries |
py not found |
Open a new window; check PATH has %UserProfile%\AppData\Local\Microsoft\WindowsApps |
py says can’t open file |
An old Python launcher is installed: remove it in Installed apps |
running scripts is disabled on this system on Activate.ps1 |
Don’t activate; call .venv\Scripts\python directly |
'pip' is not recognized or No module named 'pandas' |
Install with the venv’s Python: .venv\Scripts\python -m pip install pandas matplotlib |
Node.js: only when a tool needs it
Node.js runs tools written in JavaScript and comes with npm (installs
packages) and npx (runs a package without installing it). Claude Code’s
native installer does not need Node. You need it when you install a tool
through npm (the npm route for Claude Code requires Node 22+) or run an MCP
server with npx. If you’re not sure, install it when you get there.
Pick the LTS release (v26.13.0 at the time of writing): the .msi on Windows,
the .pkg on macOS, or winget install OpenJS.NodeJS.LTS. Then, in a new
window:
node --version
npm.cmd --versionOn Windows PowerShell, plain npm --version may fail with
npm.ps1 cannot be loaded because running scripts is disabled on this system.
That’s the execution policy, not a broken install; npm.cmd does the same job.
On macOS, never sudo npm install -g: it causes permission problems and is a
security risk.
The readiness check
Run every line from inside the project folder (the prompt must show
trading-agent-lab). Fix any line that differs and run it again. Don’t install
an agent until all ten pass: a broken foundation comes back later as a
confusing error in the middle of an agent session.
| # | Check | Command (PowerShell; macOS uses .venv/bin/python) |
Expected | If not |
|---|---|---|---|---|
| 1 | Git | git --version |
git version 2.… |
Install Git, new window |
| 2 | Commit identity | git config user.name |
Your name | Rerun the git config --global lines |
| 3 | .env ignored |
git check-ignore -v .env |
.gitignore:1:.env |
Recreate .gitignore |
| 4 | A checkpoint exists | git log --oneline |
At least 1 commit | git add -A, then commit |
| 5 | Project Python | .venv\Scripts\python -c "import sys; print(sys.version)" |
Starts with 3.14 |
3.15: delete .venv and recreate it with py -V:3.14 |
| 6 | pandas computes | see below | 1.62 |
Reinstall with the venv’s python -m pip |
| 7 | matplotlib saves | see below | chart saved and a 5-point line |
Not in the project folder, or no reports/ |
| 8 | Node (if needed) | node --version |
v26.13.0 or newer LTS |
Install Node, new window |
| 9 | Second checkpoint | git add -A, git commit -m "Machine ready", git log --oneline |
2 commits | nothing to commit: line 7 did not run |
| 10 | UTF-8 (Windows) | .venv\Scripts\python -c "import sys; print(sys.flags.utf8_mode)" |
1 |
Set PYTHONUTF8, reopen terminals and the agent app |
Line 6 is arithmetic you can check by hand. Five made-up candles (not real prices) have high minus low of 2.0, 1.5, 1.5, 1.8 and 1.3: total 8.1, divided by 5 is 1.62. If it prints anything else, don’t adjust the numbers to match; check what you pasted.
.venv\Scripts\python -c "import pandas as pd; df = pd.DataFrame({'high': [101.5, 102.0, 102.4, 101.6, 100.9], 'low': [99.5, 100.5, 100.9, 99.8, 99.6]}); print(round((df['high'] - df['low']).mean(), 2))"
.venv\Scripts\python -c "import matplotlib; matplotlib.use('Agg'); import matplotlib.pyplot as plt; plt.plot([101.0, 101.8, 101.2, 100.1, 100.7], marker='o'); plt.title('Sample data, not real prices'); plt.savefig('reports/check_chart.png'); print('chart saved')"Line 7 writes reports/check_chart.png; open it and look for a line through
five points. It’s a new file, so git status shows reports/ under Untracked
files, and line 9 commits it as the second checkpoint. Screenshots that show
your user name go in reports/private/, which is ignored.
Try it: let AI read an install error without leaking anything
I'm a new trader setting up the trading-agent-lab project. Demo accounts only.
OS: [Windows 11 / Windows 10 / macOS + version]
Terminal: [Windows PowerShell (prompt starts with PS) / CMD / macOS Terminal]
What I was doing: [e.g. creating a venv with py -V:3.14 -m venv .venv]
The command I typed, verbatim:
[PASTE COMMAND]
The full output, with my user name replaced by USER and no API keys, passwords
or account numbers:
[PASTE OUTPUT]
Answer in this order:
1. What the error means, in plain words; explain each term the first time.
2. The most likely cause, and one read-only command (changes nothing) to confirm it.
3. The fix for the terminal above, one line at a time, with what I should see after each.
4. If the fix needs Administrator, sudo, a changed execution policy or disabling
antivirus, state the risk and a safer alternative first; don't treat it as required.
5. Where you are unsure (package name, version, new command), write "check the
official page" and name it; don't guess.
Never ask me for API keys, passwords, 2FA codes or account numbers.From here on, every agent task follows the same loop: git status clean,
a small task naming which files may change, then git status and git diff,
your own check with the venv’s Python, and a commit or a git restore.
Key takeaways
- Before every agent task
git statusmust be clean; afterwards readgit diff, because “done” is not evidence. - Create
.gitignorebefore the firstgit add. A committed.envmeans the keys are leaked. - Python 3.14, because
MetaTrader5ships builds only up to 3.14 on 64-bit Windows. Create the venv withpy -V:3.14 -m venv .venv. git restoreonly resets tracked files, never touches new ones, and what it discards is gone.
Comments