Loading lesson...
Loading lesson...
cd, ls, and pwd commands with confidencepip and npm from the command lineEvery command has a location, an action, a target and observable output, so pwd, cd and ls each leave a confirmation the next one depends on. Running a script at the fourth step without those three means acting on a directory you have only assumed you are in.
Every shell command has a location, an action, a target, and observable output. POSIX.1-2024 names this contract; GNU Coreutils implements it.
Module 2 ended with the : perceive, think, act, observe. Before you can build anything that runs that loop, you need fluency with the environment where agent code lives. This module gives you exactly the command-line skills required to install, configure, and run agent frameworks.
Next: The Terminal and Why You Need It.
A terminal(also called a shell or command line) is a text-based interface to your computer's operating system. On macOS and Linux this is usually bash or zsh; on Windows it is PowerShell or Command Prompt. You type commands and the operating system executes them. The terminal is faster than clicking through menus, scriptable for automation, and often the only interface available on remote servers.
Most frameworks, from LangGraph to CrewAI to the Anthropic SDK, are installed and run from the command line. Python and Node.js are managed from the command line. API (Application Programming Interface) keys are set as environment variables in the terminal. If you want to build AI agents, the command line is non-negotiable. This module covers exactly what you need and nothing more.
Open the terminal on your system: on macOS, use Spotlight (Cmd + Space) and type "Terminal." On Windows, search for "PowerShell." On Linux, the keyboard shortcut varies by distribution, but Ctrl + Alt + T works on most.
Your first four commands cover the majority of daily navigation. pwdprints your current working directory, the full path to where you are in the file system. ls lists the files and directories at your current location.ls -la adds hidden files (those beginning with a dot, such as.env and .gitignore) and file permissions. clearclears the screen so you can see your last output without scrolling.
Next: Navigating and Managing Files.
cd (change directory) moves you to a different location. cd Desktopmoves into a folder called Desktop inside your current location. cd ..moves up one level to the parent directory. cd ~ returns to your home directory from anywhere. cd /absolute/path moves to an exact location regardless of where you start.
mkdir my-agent creates a new directory called my-agent. touch main.pycreates an empty file called main.py. These two commands together are how you start every new project: create a directory, move into it, and create your first files.
rm removes files permanently. There is no recycle bin on the command line.rm old-file.txt deletes a file; rm -rf old-directory/ deletes a directory and everything inside it. The -r flag means recursive (apply to all contents) and -f means force (do not ask for confirmation). Double-check the path before running this command. Many engineers have lost important work this way.
Common misconception
“rm -rf is fine to run as long as you are in the right directory.”
Being in the right directory is necessary but not sufficient. rm -rf deletes the directory path you specify, which may be relative or absolute. Running rm -rf . deletes your entire current directory. Running rm -rf / (on systems without protection) would delete the entire file system. Always verify the exact path you are targeting before executing any rm command. A safer habit is to print the path first using echo and confirm it is what you expect.
Next: Environment Variables and the .env Pattern.
An is a named value stored in the operating system's environment, accessible to any process running in that session. Environment variables configure applications without hardcoding sensitive values like API keys into source code. export GREETING="hello" sets a variable for the current terminal session. echo $GREETING prints its value. The variable disappears when you close the terminal.
The PATH variable is a colon-separated list of directories where the operating system searches for executable programmes. When you type python, the OS searches each directory in PATH in order until it finds an executable named python. Running echo $PATH shows you the current list. You can prepend a new directory with export PATH="/opt/my-tool/bin:$PATH". To make this permanent, add that line to ~/.zshrc (zsh) or ~/.bashrc (bash).
Hardcoding API keys in source code is a serious security risk. The standard practice is to store secrets in a .env file at the project root. This file contains key-value pairs: ANTHROPIC_API_KEY=sk-ant-xxxx. The file must be added to .gitignore immediately. In Python, the python-dotenvlibrary reads this file into environment variables at runtime with a single call toload_dotenv().
Credentials committed to a repository are among the most common ways an leaks. The two commands that prevent the same mistake from happening to you are:touch .env to create the file, and echo ".env" >> .gitignoreto exclude it from version control. Run both before writing any credentials.
Next: Package Managers: Pip and Npm.
pip is the package installer for Python. pip install anthropicdownloads and installs the Anthropic SDK from the Python Package Index (PyPI).pip install -r requirements.txt installs all packages listed in a requirements file, which is how you reproduce an environment on a new machine.pip list shows what is installed; pip show anthropicshows version and dependency information for a specific package.
npm is the package manager for Node.js. npm init -ycreates a package.json file that describes your project and its dependencies. npm install @anthropic-ai/sdk downloads and installs the Anthropic SDK for Node.js and records it in package.json. npm install(with no package name) installs all dependencies listed in package.json, which is how you set up an existing project after cloning it.
Installing Python packages globally, meaning without a , is a common mistake that causes dependency conflicts between projects. The next module covers virtual environments in detail. For now, be aware that the pip commands above should always be run inside an activated virtual environment.
Common misconception
“pip install just downloads a package. It does not affect anything else.”
pip install modifies the Python environment it targets. If you run it without an active virtual environment, it modifies your system Python or your user Python installation. This can break other projects that depend on different versions of the same package. The fix is always to create and activate a virtual environment (covered in Module 4) before running any pip install command.
Next: Reading Error Messages.
The terminal displays two types of output: standard output (stdout) and standard error (stderr). Both appear in the terminal by default. Error messages in Python are called tracebacks, and they read from the bottom up: the last line states the error type and cause; the lines above show the call stack leading to that error.
A that ends with anthropic.AuthenticationError: invalid x-api-keytells you exactly what happened: the API key is wrong or missing. The lines above show where in the code the error occurred and which library function raised it. Start at the bottom, identify the error type, read the message, then look at the file and line number in your own code (not in the library code) to find where to fix it.
ModuleNotFoundError: No module named 'anthropic' means the package is not installed in the current Python environment. The fix is pip install anthropic, run inside an activated virtual environment. This is the most common error beginners encounter, and understanding its cause prevents hours of confusion.
The four messages under the entry card each name a different missing precondition, the name, the place, the permission or the environment, and only one of them is settled by editing the command you typed.
Four shell messages name four different missing preconditions: the name, the place, the permission, the environment. Read the last line first, then confirm the precondition before retyping anything.
A colleague tells you that the -f in rm -rf build/ is the flag that makes the deletion permanent, so leaving it off would let you recover the directory afterwards. What does this module say -f actually does?
You add a directory to PATH with export PATH=/opt/my-tool/bin:$PATH, confirm the change with echo $PATH, and your tool runs. The next morning you open a fresh terminal and the tool is not found. What does this module give as the reason?
A script fails with a traceback whose last line reads anthropic.AuthenticationError: invalid x-api-key, and the lines above it name files inside the anthropic library. Where does this module tell you to look for the fix?
The Open Group Base Specifications Issue 7, 2018 edition
Section 2, Shell Command Language (POSIX)
Authoritative standard for shell command behaviour across POSIX-compliant systems. Quoted in Section 3.1 to establish that the commands taught here are portable across macOS, Linux, and any server you are likely to deploy to.
OWASP Secrets Management Cheat Sheet
cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html
Industry standard guidance on handling API keys and other secrets in development and production. Quoted in Section 3.3 to establish the .env pattern as a recognised security control rather than informal best practice.
pip.pypa.io/en/stable/user_guide/
Official documentation for the Python package installer. Referenced in Section 3.4 as the authoritative reference for pip install, pip list, pip show, and requirements file management.
docs.npmjs.com
Official reference for the Node.js package manager. Referenced in Section 3.4 for npm init, npm install, and package.json management.
github.com/theskumar/python-dotenv
The standard library for loading .env files in Python projects. Referenced in Section 3.3 as the implementation of the .env pattern in Python agent code.
You can now navigate the filesystem, install packages with pip and npm, and store secrets in environment variables instead of source code. The next module puts these skills to work: you will configure a local Python environment, install the Anthropic SDK, and send your first API call to Claude - the foundation every agent framework builds on.
Module 3 of 40 in the AI Agents course, and the third of the five Foundations modules