Git, Notebooks & the Command Line
Good tools make AI work faster and safer: notebooks for exploration, git for history, and the command line for automation. This lesson covers the workflow most AI engineers converge on.
Notebooks: great for exploring, risky for shipping
Jupyter notebooks (or VS Code notebooks, Colab) are ideal for poking at data, trying prompts and plotting results.
| Use notebooks for | Move to .py modules for |
|---|---|
| Inspecting data, chunks, embeddings | Anything imported by your app |
| Trying prompt variants side by side | Eval runners and pipelines |
| Plotting metrics | Code that needs tests and code review |
Pitfalls: hidden state (cells run out of order), secrets pasted into cells, and huge outputs bloating the file. Restart and run all before trusting a result. Tools like nbstripout remove outputs before committing.
# A notebook pattern: import your real code instead of copy-pasting it
%load_ext autoreload
%autoreload 2
from app.retrieval import retrieve # edits to the module reload automaticallyGit essentials
git init
git add -A && git commit -m "baseline RAG pipeline"
git switch -c try-hybrid-search # experiment on a branch
git diff # what changed?
git log --oneline --graphFor AI projects, version your prompts and eval datasets with your code. When quality changes, git log prompts/ evals/ tells you why. Tag releases: git tag v1.3-prompt-qa7.
What not to commit: .env, model weights and large datasets (use Git LFS, DVC or object storage), notebook outputs containing data, and caches.
The command line
# Inspect data quickly
head -n 3 data/train.jsonl
wc -l data/*.jsonl
jq '.messages[-1].content' data/train.jsonl | head # query JSON lines
# Find things
grep -rn "temperature" src/
# Run your evals
python -m evals.run --dataset evals/golden.jsonl --prompt prompts/qa_v7.txtWrite small CLIs for repeatable tasks (indexing, evaluating, exporting). argparse or typer makes this easy:
# evals/run.py
import typer
app = typer.Typer()
@app.command()
def main(dataset: str, prompt: str, limit: int = 0):
"""Run the eval suite and print a summary."""
...
if __name__ == "__main__":
app()A productive daily loop
Put eval results in commit messages ("hybrid search: recall@5 0.71 → 0.84"). Future you will thank you.
Other tools worth knowing
- Docker: package your app with its exact dependencies; standard for deployment (Module 5).
- pytest: unit tests for parsing, chunking and prompt-building functions, which are deterministic code even if the model isn't.
- Pre-commit hooks: run formatters (ruff/black) and secret scanners (gitleaks) automatically before each commit.
- Make or just: short aliases for long commands (
make eval,make index).