# Route Dispatching Logic for the learn Skill in AI Engineering from Scratch

> Understand the route dispatching logic for the learn skill in AI Engineering. Map skill aliases to manifests and construct dynamic lesson URLs to guide users to the right module.

- Repository: [Rohit Ghumare/ai-engineering-from-scratch](https://github.com/rohitg00/ai-engineering-from-scratch)
- Tags: internals
- Published: 2026-09-01

---

**The route dispatching logic for the learn skill maps portable skill aliases defined in [`site/data.js`](https://github.com/rohitg00/ai-engineering-from-scratch/blob/main/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`](https://github.com/rohitg00/ai-engineering-from-scratch/blob/main/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 UI
- **`claudeCode`**: 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`](https://github.com/rohitg00/ai-engineering-from-scratch/blob/main/site/data.js):

```javascript
"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`](https://github.com/rohitg00/ai-engineering-from-scratch/blob/main/learning-paths/agent-skills.json)**. This JSON file contains the canonical identifier and metadata required to locate the first lesson.

The manifest structure includes:

```json
{
  "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`](https://github.com/rohitg00/ai-engineering-from-scratch/blob/main/site/data.js). This ensures chatbots and terminal-based interfaces can still communicate the skill's purpose and invocation method.

Example fallback behavior:

```bash

# 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`](https://github.com/rohitg00/ai-engineering-from-scratch/blob/main/site/data.js)**: Defines portable-skill entries and their routing aliases
- **[`learning-paths/agent-skills.json`](https://github.com/rohitg00/ai-engineering-from-scratch/blob/main/learning-paths/agent-skills.json)**: Contains the learning-path manifest and canonical IDs
- **[`skills/learn-agent-skills/SKILL.md`](https://github.com/rohitg00/ai-engineering-from-scratch/blob/main/skills/learn-agent-skills/SKILL.md)**: Documents the human-readable skill description

To test the dispatching logic manually:

```bash

# 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`](https://github.com/rohitg00/ai-engineering-from-scratch/blob/main/site/data.js), which maps skill aliases to learning-path metadata
- Each skill entry contains three routing directives: `codex`, `claudeCode`, and `portableFallback`
- 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`](https://github.com/rohitg00/ai-engineering-from-scratch/blob/main/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`](https://github.com/rohitg00/ai-engineering-from-scratch/blob/main/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`](https://github.com/rohitg00/ai-engineering-from-scratch/blob/main/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.