0
Programming Foundations
Phase 0Module 5 of 14

CLI

Servers have no GUI. Git, Docker, kubectl, and cloud tools are all CLI-first. Agents execute shell commands as tools.

CLI is texting your computer precise instructions — faster than clicking, works over remote connections.

Visual Workflows

Start here — study each diagram, then use + / to zoom if needed.

Overview

100%
Loading diagram...

Scroll inside the frame · use + / − to zoom

100%
Loading diagram...

Scroll inside the frame · use + / − to zoom

Key Takeaways

  • 1.The CLI lets you control your computer through text commands — essential for servers, deployment, and AI agent tools.
  • 2.Format: command [options] [arguments].
  • 3.Pipes (|) chain commands.
  • 4.Exit code 0 = success.
  • 5.Build Python CLIs with typer or click.

Real Example

Scenario

You need a command to ingest new documents into your RAG knowledge base.

What you would do

Build `rag-cli ingest ./docs` — it chunks PDFs, embeds them, and stores in the vector DB. Your agent calls this same CLI as a tool.

Practice Task

Run echo "hello world" | wc -w to pipe output between commands. Then run ls | head -3 to list only the first 3 files. Check the exit code with echo $?.

Commands

Commands to Remember

  • command --help # show available options for a command
  • cmd1 | cmd2 # pipe output of cmd1 into cmd2
  • echo $? # print exit code of the last command
  • chmod +x script.sh # make a script file executable
  • ./script.sh # run the script

Cheat Sheet

Quick recap

quick ref
  • Format: command [flags] [arguments]
  • Pipe (|) chains commands — output of one feeds the next
  • Exit code 0 = success · non-zero = failure
  • Build Python CLIs with typer, click, or argparse
  • Agents can run shell commands as tools — validate inputs against injection
  • Servers have no GUI — git, docker, kubectl are all CLI-first

Common Mistakes

  • Not validating input before shell commands
  • Ignoring exit codes
  • No --help on custom tools