Go from never having used a coding agent to working productively and safely with one. The learner should understand what an agent is and how it differs from a chat assistant. They should choose a tool, set up a protected first project, describe tasks the agent can do well, and follow and verify its work. They should recover from bad changes, manage context, and plan bigger changes. They should also use tests as the definition of done and run everyday workflows (bug fixes, features, writing tests, codebase exploration, scripts, small tools, refactors). Throughout, they should keep secrets and systems safe and keep their own understanding growing instead of outsourcing it.
Command output and exit codes
card 4 of 6
Seeing both channels and the exit code
builds on: Terminal basics: where you are and running things
In the first run, the normal result appears on screen and the exit code is `0`. In the second run, nothing appears on screen, because the complaint went to stderr and `2>` sent it into `err.txt`. The exit code is `1`. `cat` prints the file, so you can read the error.
$ python convert.py data.csv 2> err.txt
Wrote 120 rows to out.csv
$ echo $?
0
$ python convert.py nope.csv 2> err.txt
$ echo $?
1
$ cat err.txt
error: nope.csv not found
Terms on this card
- stderr
- Short for standard error: the channel for a program's errors and warnings.
- exit code
- A number a program returns when it finishes. 0 means success; any other number means it did not succeed. What each non-zero number means is up to the program.
- `2>`
- Sends a command's standard error into a file instead of the screen, e.g. `2> err.txt`.
- `cat`
- A command that prints a file's contents to the terminal.
- cat
- A terminal command that prints a file's contents.
Lesson goal: Tell normal output from error output. Explain that a command reports success (exit code 0) or failure (non-zero), which is how an agent decides whether a step 'worked'. ·
the whole lesson