Your coding agent — what it is, and what it may touch
By the end of this lesson you will have a coding agent — Claude Code or Codex CLI — installed and starting in its learning mode, a written rule that keeps it out of your .env files, and drops.js, a first function it wrote that you read before accepting.
Build Your First Tool opens with "ask your agent". Here is what that means, how to install the one this track uses, and the permissions to set before it touches anything of yours.
What it does
It predicts code that fits your description and the files around it. It has read an enormous amount of code, so its predictions are often right — and it is predicting, not knowing, which is the whole reason this academy teaches reviewing.
Two consequences worth carrying:
- It is strongest on the ordinary path — the code that has been written a million times before.
- It is weakest at the edges — empty results, error cases, unusual units, the first and last element. Exactly where the bugs are.
An agent, not a chat window
The tool this track uses is an agent: it reads your files, edits them, and runs commands in your terminal — node play.js, git diff, a test suite. So it can run your code, read the error and try again without you copying anything back and forth.
What it still cannot do is know what you meant. It can run a check and report success when the check tests the wrong thing, or "fix" an error by deleting the line that raised it. A confident wrong answer looks exactly like a confident right one, and running the code does not change that. You decide what counts as working — Build Your First Tool turns that decision into tests the agent must pass — and you read what it changed.
The main path: an agent in the terminal
This track works with two agents that run in your terminal, and each needs the paid plan or the API key from lesson 1: Claude Code, whose commands the lessons show first, and Codex CLI, which follows every lesson the same way. Pick the one you pay for, and install it with the command for your system:
# Claude Code — macOS, Linux, WSL
curl -fsSL https://claude.ai/install.sh | bash
# Claude Code — Windows PowerShell
irm https://claude.ai/install.ps1 | iex
# Codex CLI — macOS, Linux, WSL
curl -fsSL https://chatgpt.com/codex/install.sh | sh
# Codex CLI — Windows PowerShell
powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"
Then the same check as every install in unit 1: open a new terminal and run claude --version or codex --version. A version number means it works.
Start it from inside the folder you want it to work on — that folder is its workspace:
cd your-course-folder
claude
For Codex, type codex in place of claude. The first run opens your browser to log in. After that you type in plain English: what does play.js do?
The other path: the agent mode of an editor — Cursor, or VS Code with GitHub Copilot. The habits are identical; the menus differ.
What it may do without asking
How much the agent does before asking you is set by its mode, and each agent names its modes differently.
In Claude Code it is the permission mode. Shift+Tab cycles through them, and the current one is shown under the prompt.
- Manual asks before every edit and before any command that could change something, each shown as a diff or a command line you approve or refuse. Learn in this one.
- Accept edits changes files without asking and still asks before most commands. Fine once you read
git diffbefore every commit. - Plan reads and proposes, and changes nothing until you approve the plan.
/planswitches to it directly. - Auto runs almost everything without asking, with a safety check in the background. Recent versions start new sessions in auto, so switch to Manual for this course.
In Codex it is the permissions preset, which /permissions switches:
- Read Only reads your files, and asks before every edit and before any command that writes or uses the network. Learn in this one.
- Default edits files and runs commands inside the folder without asking, and asks before anything outside it or on the network.
- Full Access asks for nothing at all.
Codex's plan mode sits beside the preset: Shift+Tab or /plan turns it on, and the line under the prompt says Plan mode.
Three lists to decide once, not in the moment:
- Let it run without asking: reading files,
git status,git diff, the project's tests. - Always ask: installing a package, deleting files,
git push, anything that deploys. - Never: reading your
.envfiles, pasting a key into the chat, or a setting that skips every check on your own machine — Claude Code's bypass-permissions mode (--dangerously-skip-permissions) or Codex's Full Access. Those are for throwaway containers.
Close the secrets drawer before there is a secret
Build Your First Tool gives you an API key, kept in a file called .env.local. Your agent never needs to read it, so say so before the file exists.
Claude Code can enforce it. In your course folder, create .claude/settings.json:
{
"permissions": {
"defaultMode": "manual",
"deny": ["Read(./.env)", "Read(./.env.*)"]
}
}
The first line starts every session here in Manual; /permissions shows every rule in force. The deny rules win over everything else, in every mode: Claude Code's file tools, and commands it recognises such as cat, will not open those files. It is a seatbelt, not a lock — a script that opens the file itself is not covered, and Manual mode is what shows you that attempt so you can refuse it. The Build Your First Tool starter ships with the same rule.
Codex has no rule like that in its default setup: its sandbox controls where commands write and whether they reach the network, and Read Only still reads every file in the folder. The nearest working approach is a written rule plus your review. In your course folder, create AGENTS.md, the file Codex reads at the start of every session, with one line:
Never read, print or edit .env files, and never ask me to paste a key.
That is advice the model usually follows, not a lock, so the review is yours: read every command before you approve it. To start every session in Read Only, put these two lines in ~/.codex/config.toml, in your home folder:
sandbox_mode = "read-only"
approval_policy = "on-request"
The Build Your First Tool starter's AGENTS.md carries the same rule, and Claude Code reads that file too.
The loop, in one line
Plan, prompt, read the diff, verify, commit small. Build Your First Tool unit 2 is entirely about this. For now, know that "read the diff" sits in the middle on purpose: between getting the code and trusting it.
Try it now
- Install your agent and run
claude --versionorcodex --versionin a new terminal. - In your course folder, create the file from the section above —
.claude/settings.jsonfor Claude Code,AGENTS.mdfor Codex — and start the agent. Claude Code's line under the prompt says manual mode; in Codex, type /status: its Permissions line says Read Only, and its Agents.md line names the file you just wrote.
The prompt
Your first prompt to the agent asks for a plan before any code. Paste it, then approve each step only after reading it:
Before you write anything, tell me in three lines which file you will
create, what the function will be called, and the one command you will
run. Wait for my yes.
Then write a function that takes an array of daily closes and returns
the largest single-day percentage drop, in drops.js, with no
dependencies. Run it with node on [100, 97, 99, 94] and show me the
output. Install nothing and touch no other file.
You wrote something like this by hand in unit 2 — compare, and say which is better and why. If its file holds a line you have not met, such as module.exports = … or require(…), ask the agent what that line does before you say yes; asking is part of reading, and "it makes the function usable from another file" is an answer you can check. A good answer reports the fall from 99 to 94, and stops for you before the new file exists. Claude Code in Manual stops a second time, to run node drops.js; Codex in Read Only runs a command that only reads without asking, so it may stop just once.
Check it yourself
claude --versionorcodex --versionin a new terminal prints a version number.- The agent stopped for your yes before creating the file, showing you its content first.
git statuslistsdrops.jsand the file you made — the.claudefolder orAGENTS.md— as new, and nothing you did not ask for.- The output is a drop of about 5.05%, the day from 99 to 94. Your agent may print it as
5.05,-5.05%or5.0505...: the sign and the formatting can differ from ours, and the check is the day from 99 to 94. - In Claude Code, type /permissions: both deny rules are listed, with the settings file they came from. In Codex, ask "which rules do you follow in this folder?": your line from
AGENTS.mdcomes back.
Break it on purpose
Create .env.local with one fake line, EODHD_API_KEY=not-a-real-key, and ask the agent to show you what is in it. It should refuse — by a deny rule in Claude Code, by your written rule in Codex. If it prints the line, or proposes a command that would, the protection is not working. In Claude Code, fix the rule now, while the key is fake. In Codex, you have just seen what advice is worth when the model decides to ignore it: that is why you read every command before you approve it.
Compare with ours
Our drops.js
function largestDrop(closes) {
let worst = 0;
for (let i = 1; i < closes.length; i++) {
const change = closes[i] / closes[i - 1] - 1;
if (change < worst) worst = change;
}
return worst;
}
console.log((largestDrop([100, 97, 99, 94]) * 100).toFixed(2) + "%"); // -5.05%
Two edges to check in whatever your agent wrote: the loop starts at i = 1, as yours did in unit 2, and a list that only rises gives back 0 rather than an invented drop. Ask yours what it does with [100, 101, 102].
Checkpoint
git add -A would record .env.local, fake key and all. So first delete the fake file (rm .env.local, or delete it in your editor; lesson 19, "Committing on purpose", brings it back and makes git ignore such files properly), then check what is left:
git status
It should list drops.js and the file you made for your agent (the .claude folder with Claude Code, AGENTS.md with Codex), and nothing starting with .env. If anything else is listed, ask the agent why before you go on. Then:
git add -A
git commit -m "Deny .env files to the agent, and a first function it wrote and I read"
Then answer this lesson's questions.