Context Engineering for AI-Assisted Codebases: A Hands-On Tutorial
A step-by-step guide to
@libar-dev/delivery-process— annotate your TypeScript, generate living docs, and give AI agents structured context instead of stale Markdown.
Test Environment
Section titled “Test Environment”This tutorial was executed end-to-end on a clean machine. Every CLI output shown below is captured verbatim from the test run.
| Property | Value |
|---|---|
| Date | 2026-02-21 |
| Node.js | v22.17.1 |
| npm | 11.6.1 |
| Package | @libar-dev/delivery-process v1.0.0-pre.0 |
| OS | macOS (Darwin 25.2.0) |
| Preset | libar-generic |
Introduction
Section titled “Introduction”You have 50 TypeScript files. An AI coding agent asks: “What depends on UserService?” Today, you point it at a stale README or a Confluence page from last quarter. The agent guesses at imports and hallucinates relationships that do not exist.
Context engineering solves this by making code the single source of truth for delivery state. Instead of maintaining separate documents that drift within days, you place structured annotations directly in your source files. A CLI then extracts those annotations, generates living documentation, and answers queries with typed JSON — all derived from code, all regenerated in seconds.
What you will build
Section titled “What you will build”A small TypeScript project with three annotated implementation files, two Gherkin feature specs, and one design stub. By the end, the system will have:
- Extracted 11 patterns, their relationships, and 5 business rules from your source files
- Generated 26 documentation files including architecture diagrams, roadmaps, pattern registries, and business rule references
- Answered structured CLI queries about dependency chains, blocking analysis, bounded contexts, and pattern metadata
What you will learn
Section titled “What you will learn”| Part | Topic | What You Do | Time |
|---|---|---|---|
| 1 | Project Setup | Initialize a project with all dependencies | 3 min |
| 2 | Configuration | Configure sources, output, and presets | 3 min |
| 3 | First Annotation | Annotate one file and see it detected | 5 min |
| 4 | Adding Richness | Layer in architecture, enrichment, and shape tags | 7 min |
| 5 | Relationships | Connect multiple files into a dependency graph | 7 min |
| 6 | Doc Generation | Generate pattern registry and roadmap | 5 min |
| 7 | Gherkin Specs | Write plan-level specs with business rules | 8 min |
| 8 | Design Stubs | Describe future implementations | 4 min |
| 9 | Full Generation | Generate all 26 docs + reference docs + linting | 7 min |
| 10 | Advanced Queries | Query project state with advanced CLI commands | 5 min |
Total: ~55 minutes | Prerequisites: Node.js >= 18, npm