Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Project Overview

This file provides guidance to AI agents when working with code in this repository.

Project Overview

AI Engineering Book - a knowledge base for building production-grade AI systems using hybrid LLM+SLM methodology. Content is authored as MyST Markdown notebooks paired with Jupyter notebooks via Jupytext.

Common Commands

# Restore environment from lock file
uv sync --frozen

# Sync notebooks after editing .md or .ipynb files
uv run jupytext --sync

# Run link validation tests
uv run pytest tools/tests/test_file.py --cov=tools.tests.test_file --cov-report=term-missing

# Check broken links in markdown files
uv run tools/scripts/check_broken_links.py --pattern "*.md"

# Validate frontmatter against .vadocs/ config chain (ADR-26042)
uv run python -m tools.scripts.check_frontmatter [PATHS...] [--format {md,ipynb}]

# Validate all ADRs and auto-fix index
uv run tools/scripts/check_adr.py --fix

# Validate a commit message (used by commit-msg hook)
uv run tools/scripts/validate_commit_msg.py .git/COMMIT_EDITMSG

# Generate CHANGELOG from git history and prepend to CHANGELOG file
uv run tools/scripts/generate_changelog.py <prev-tag>..HEAD --version <next-version> --prepend CHANGELOG

# Build documentation site
npm install -g mystmd && myst build --html

# Manage external research repos (research/)
uv run tools/scripts/manage_external_repos.py list                          # Show all repos
uv run tools/scripts/manage_external_repos.py update                        # Pull all repos
uv run tools/scripts/manage_external_repos.py update --parallel             # Parallel pull
uv run tools/scripts/manage_external_repos.py setup <url> [--dir <dir>]    # Clone new repo
uv run tools/scripts/manage_external_repos.py list --dirs                   # Show registered directories
uv run tools/scripts/manage_external_repos.py register <path> <desc>        # Register new directory
uv run tools/scripts/manage_external_repos.py unregister <path>             # Remove directory from registry

Architecture

The repository is organized around a five-layer AI system architecture:

Critical Conventions

When you implemented a plan in /plan mode, save it to misc/plan/plan__<descriptive_slug>.md, ONLY then start implementation. After the plan is fully implemented, move it to misc/plan/implemented/. This is needed to save the history of the decisions made between context switches.

Implementation Plans for Handoff: Plans in misc/plan/ may be executed by another agent that has zero context from the brainstorm session. A plan is a standalone specification — the executing agent must NOT need to re-brainstorm or ask clarifying questions. Every plan must contain:

  1. Full context section — current state analysis with directory trees, file breakdowns (section-by-section with line numbers), and a content mapping table showing what moves where and why

  2. Cross-reference map — list ALL files that reference the changed files, with exact line numbers, current (broken) paths, and what they should become. Include a final-state cross-reference diagram showing all link relationships

  3. Rationale for each task — explain WHY each change is being made, not just WHAT to do. The executing agent needs to understand the intent to make correct decisions when edge cases arise

  4. Complete file content — for new files and rewritten files, provide the FULL content inline in the plan. Never say “create file with appropriate content” or “slim down the file” — show exactly what goes in

  5. Exact edit operations — for modifying existing files, provide the exact old_string (with 3+ lines of context BEFORE and AFTER) and the new_string for every edit tool call. The executing agent must be able to copy-paste without reading the target file first

  6. Content removal list — when splitting files, explicitly list which sections are removed, which are kept, and where the removed content went. Use checkmarks (✅ kept, ✗ moved) for clarity

  7. Commands with expected output — every git mv, ls, grep, verification command must include the expected output so the executing agent can detect failures

  8. Self-review section — a checklist the plan author ran before handoff: spec coverage, placeholder scan, cross-reference consistency, scope check

Track intentional tech debt in misc/plan/techdebt.md with date, location, and migration path.

MyST Notebooks:

Python:

Content Frontmatter (ADR-26042, supersedes ADR-26023):

ADR frontmatter template (canonical field order):

id: <NNNNN>
title: "<Title>"
authors:
  - name: Vadim Rudakov
    email: rudakow.wadim@gmail.com
date: <YYYY-MM-DD>
description: "<one-line elevator pitch>"
tags: [<primary-tag>, ...]
status: <proposed|accepted|rejected|superseded|deprecated>
superseded_by: <ADR-NNNNN or null>
options:
  type: adr
  birth: <YYYY-MM-DD>
  version: <semver>

Tool Configuration (ADR-26029, ADR-26036):

ADRs and Evidence Artifacts:

Configuration:

Containerization:

Ephemeral Files:

Living Documents:

Evidence Source Hygiene:

PyYAML Token Gotcha:

CI/CD Pipeline

Two GitHub Actions workflows:

  1. quality.yml - Runs on all pushes/PRs:

    • Runs check_broken_links tests when script, tests, or paths.py change

    • Runs jupytext tests when sync/verify scripts, tests, or paths.py change

    • Validates links in changed .md files

  2. deploy.yml - Validates notebook sync on all branches, deploys to GitHub Pages on main only

The pipeline verifies that .md and .ipynb pairs are synchronized before allowing deployment.

Development Workflow

Jupytext sync runs as a pre-commit lint step. The .aider.conf.yml also configures auto-linting for Aider sessions.

Tooling & Quality Gates:

Python version: 3.13+ (locked in .python-version) Package manager: uv (never use pip directly)

Tool-Driven Instructional Feedback (ADR-26050):

TDD Approach (Tests First):

Test Quality Standards (Non-Brittle Tests):

Quality & Testing Standards (Adversary Testing):

Commit Conventions (ADR-26024):

Pre-commit Hooks:

Safe Editing:

Precise Targeting Protocol (Anti-Extrapolation Rule): When resolving validation errors (e.g., from check-link-format.py or check_frontmatter.py):

  1. No Global Cleanups: Never assume a few errors in one file imply a systemic issue in a directory. Do NOT run “fix-all” scripts followed by global git add commands (e.g., git add path/**/*.md) to resolve point-errors.

  2. Mandatory Error-to-Pair Mapping: Before staging any fix, the agent MUST explicitly list the mapping: Error in [File A] →\rightarrow Fix [File A] →\rightarrow Stage [File A] AND [Paired File A.ipynb].

  3. Minimum Viable Stage: Stage ONLY the files explicitly mentioned in the error logs and their mandatory Jupytext pairs.

  4. Forbidden Globs: The use of glob patterns in git add to fix specific validation errors is strictly prohibited unless the error log explicitly lists every file in that glob as broken.

Safe Git Commands:

Symlinks:

Design Principles:

Documentation:

Script Suite (ADR-26045, supersedes ADR-26011):

Telegram Channel Posts

Posts for the @ai_learning Telegram channel are stored in misc/pr/tg_channel_ai_learning/.

Naming convention: YYYY_MM_DD_<topic_slug>.md

Language: Russian

Post structure:

  1. Bold headline

  2. Problem statement (with 💡 icon)

  3. Technical explanation (with 🧠 icon if applicable)

  4. Solution description (with ⚙️ icon)

  5. Key features list (with ✅ checkmarks)

  6. Usage examples in code blocks

  7. Documentation link

  8. Hashtags (e.g., #Python #LLM #ai_engineering_handbook)