Allowed Dependencies for Python, TypeScript, Rust, and Julia in AI Engineering From Scratch

The AI Engineering From Scratch curriculum restricts Python to numpy, torch, h5py, zstandard, and safetensors; TypeScript to hono, zod, ws, and @hono/node-server; Rust to the standard library only; and Julia to Random, Statistics, LinearAlgebra, and Printf from the standard library.

The rohitg00/ai-engineering-from-scratch repository enforces a strict dependency allowlist to ensure every lesson focuses on core algorithmic implementation rather than black-box abstractions. These constraints are formally defined in the Dependencies table of the repository’s [AGENTS.md](https://github.com/rohitg00/ai-engineering-from-scratch/blob/main/AGENTS.md) file and validated by automated CI checks.

The Complete Dependency Allowlist

The curriculum adopts a "stdlib-first" philosophy. Below is the definitive breakdown of permitted packages for each language.

Python Dependencies

The Python track allows five external packages in addition to the full standard library:

  • numpy – for numerical computing foundations
  • torch – for tensor operations and autograd basics
  • h5py – for HDF5 dataset handling
  • zstandard – for compression utilities
  • safetensors – for secure tensor serialization

TypeScript Dependencies

TypeScript lessons run on Node.js 20+ and may import four specific packages:

  • hono – lightweight web framework
  • zod – schema validation
  • ws – WebSocket support (only when WebSockets are explicitly required)
  • @hono/node-server – Node.js adapter for Hono

Rust Dependencies

Rust is restricted to the standard library only. All lessons must compile as single-file programs using rustc --edition 2021 without external crates. This constraint forces manual implementation of data structures and algorithms that might otherwise be imported from crates.io.

Julia Dependencies

Julia lessons may use four specific standard library modules:

  • Random – pseudorandom number generation
  • Statistics – statistical functions
  • LinearAlgebra – matrix operations and solvers
  • Printf – formatted output

Notably, Julia external packages (those requiring Pkg.add) are prohibited to ensure portability.

Why Standard Library First?

The restriction exists to guarantee three pedagogical outcomes:

  • Algorithmic transparency: Learners must implement linear algebra, tensor operations, and neural network components manually before using optimized libraries.
  • CI portability: Every lesson runs in the minimal environment defined by scripts/audit_lessons.py, eliminating version conflicts and dependency hell.
  • Cross-platform consistency: Code functions identically across Linux, macOS, and Windows without external binary dependencies.

Enforcement via CI Pipeline

Violations are caught automatically. The repository includes scripts/audit_lessons.py, which scans each lesson’s code/ directory for disallowed imports. The audit runs during continuous integration, rejecting any pull request that introduces packages outside the allowlist defined in AGENTS.md.

Practical Code Examples

Below are minimal snippets demonstrating correct import patterns for each language.

Python: NumPy and PyTorch

import numpy as np        # allowed: numpy

import torch              # allowed: torch

# Example: simple tensor addition

a = torch.tensor([1, 2, 3])
b = torch.tensor([4, 5, 6])
print(a + b)              # → tensor([5, 7, 9])

TypeScript: Hono and Zod

import { Hono } from "hono";          // allowed: hono
import { z } from "zod";              // allowed: zod

const app = new Hono();

app.get("/", (c) => c.text("Hello, AI curriculum!"));

export default {
  fetch: app.fetch,
};

Rust: Standard Library Only

fn main() {
    // stdlib only – no external crates
    let numbers = vec![1, 2, 3];
    let sum: i32 = numbers.iter().sum();
    println!("Sum = {}", sum);
}

Julia: Linear Algebra

using LinearAlgebra   # allowed: LinearAlgebra (stdlib)

A = [1 2; 3 4]
b = [5, 6]

x = A \ b           # solve linear system using stdlib

println("Solution: ", x)

Summary

  • Python: numpy, torch, h5py, zstandard, safetensors, and the standard library.
  • TypeScript: hono, zod, ws, @hono/node-server, and Node.js 20+ built-ins.
  • Rust: Standard library only (rustc --edition 2021).
  • Julia: Random, Statistics, LinearAlgebra, Printf (stdlib modules only).
  • Validation: Enforced by scripts/audit_lessons.py against the rules in AGENTS.md.

Frequently Asked Questions

What happens if I use a package not in the allowlist?

The CI pipeline will fail. scripts/audit_lessons.py parses import statements in each lesson’s code/ folder and rejects any external dependencies not explicitly listed in AGENTS.md. You must refactor the code to use only permitted packages or implement the functionality manually.

Why is Rust restricted to the standard library while Python gets external packages?

The curriculum uses Python’s scientific stack (numpy and torch) to establish baseline tensor concepts before requiring manual implementation in Rust. This staged approach lets learners verify mathematical correctness with established tools before tackling memory management and algorithmic optimization in Rust without crate assistance.

Can I request new dependencies for the curriculum?

Generally, no. The AGENTS.md file defines the allowlist as intentionally minimal to maintain the "from scratch" philosophy. If a standard library function can achieve the goal, external packages are refused. Exceptions would require modifying the audit script and updating the dependency table in AGENTS.md.

Is the full Node.js standard library available for TypeScript lessons?

Yes. The TypeScript constraint allows the complete Node.js 20+ standard library in addition to the four specified packages. This provides filesystem access, HTTP modules, and other system capabilities without requiring additional npm dependencies.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →