Route Dispatching Logic for the learn Skill in AI Engineering from Scratch
The route dispatching logic for the learn skill maps portable skill aliases defined in site/data.js to specific learning-path manifests, dynamically constructing parameterized lesson URLs that direct users to the correct starting module.
The rohitg00/ai-engineering-from-scratch repository implements a sophisticated routing layer that transforms simple skill invocations into structured learning experiences. Understanding the route dispatching logic for the learn skill reveals how the platform bridges portable skill commands with curated educational content through a multi-step resolution process.
Skill Registry and Alias Mapping
The dispatching process begins in site/data.js, where each portable skill is registered with three critical properties that define how different clients interact with the learning system.
The configuration object includes:
codex: The plain-text command displayed in the Codex UIclaudeCode: The URL fragment used by Claude Code (e.g.,/learn-agent-skills)portableFallback: A human-readable description for text-only environments
Example entry from site/data.js:
"learn-agent-skills": {
"codex": "learn-agent-skills, or choose it from /skills",
"claudeCode": "/learn-agent-skills",
"portableFallback": "Use learn-agent-skills to start or resume the Agent Skills Engineering path."
}
Learning-Path Manifest Resolution
When a request arrives at the route specified in claudeCode, the system resolves the corresponding learning-path manifest stored in learning-paths/agent-skills.json. This JSON file contains the canonical identifier and metadata required to locate the first lesson.
The manifest structure includes:
{
"id": "agent-skills",
"summary": "Build portable skills that agents can discover and invoke.",
"codex": "learn-agent-skills, or choose it from /skills",
"claudeCode": "/learn-agent-skills",
"portableFallback": "Use learn-agent-skills to start or resume the Agent Skills Engineering path."
}
Dynamic URL Construction
After retrieving the learning-path ID from the manifest, the router constructs a parameterized URL following the pattern:
lesson?path=<lesson-path>&learningPath=<learning-path-id>
For the learn-agent-skills entry, the system redirects to the first lesson located at phases/13-tools-and-protocols/22-skills-and-agent-sdks, producing:
lesson?path=phases%2F13-tools-and-protocols%2F22-skills-and-agent-sdks&learningPath=agent-skills
Plain-Text Fallback Handling
For clients unable to render HTML or follow query-string links, the dispatching logic returns the portableFallback string from site/data.js. This ensures chatbots and terminal-based interfaces can still communicate the skill's purpose and invocation method.
Example fallback behavior:
# Plain-text invocation
> learn-agent-skills
# System response using portableFallback:
"Use learn-agent-skills to start or resume the Agent Skills Engineering path."
Implementation Files and Testing
The routing implementation spans three primary files according to the source code:
site/data.js: Defines portable-skill entries and their routing aliaseslearning-paths/agent-skills.json: Contains the learning-path manifest and canonical IDsskills/learn-agent-skills/SKILL.md: Documents the human-readable skill description
To test the dispatching logic manually:
# Direct URL access (Claude Code style)
curl https://ai-engineering-from-scratch.vercel.app/learn-agent-skills
# Redirects to: lesson?path=phases%2F...&learningPath=agent-skills
Summary
- The route dispatching logic originates in
site/data.js, which maps skill aliases to learning-path metadata - Each skill entry contains three routing directives:
codex,claudeCode, andportableFallback - The system resolves learning-path manifests to obtain canonical IDs before constructing lesson URLs
- URLs follow the pattern
lesson?path=<encoded-path>&learningPath=<id>to load the correct starting module - Portable fallback strings ensure compatibility with text-only clients that cannot process HTML redirects
Frequently Asked Questions
How does the learn skill route differ from standard page routing?
Standard routing serves static content directly, while the learn skill route implements a two-step dispatch: first resolving the skill alias against site/data.js, then querying the learning-path manifest to dynamically generate the lesson URL with appropriate query parameters.
What is the purpose of the portableFallback field in site/data.js?
The portableFallback field provides a plain-text description for environments that cannot render HTML or follow hyperlinks, ensuring that chatbots and terminal-based AI assistants can still convey the skill's function and proper invocation syntax to users.
Where is the learn skill dispatching logic implemented?
The dispatching logic is implemented across the routing layer that reads site/data.js for skill mappings and learning-paths/*.json for manifest resolution, ultimately constructing the parameterized lesson URLs that load the correct educational content.
How do I add a new learn skill to the repository?
Create a new entry in site/data.js with unique codex and claudeCode values, add a corresponding manifest file in learning-paths/, and ensure the portableFallback text clearly describes the skill's purpose for text-only interfaces.
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:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →