# How the Routing Matrix in `skills/routing.md` Dispatches Tasks to the Correct Skill Module

> Learn how the routing matrix in skills/routing.md dispatches tasks using a three-dimensional lookup for precise skill module assignment and multi-skill pipelines.

- Repository: [ZhaoXu/reverse-skill](https://github.com/zhaoxuya520/reverse-skill)
- Tags: internals
- Published: 2026-08-16

---

**The routing matrix in [`skills/routing.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/routing.md) uses a three‑dimensional lookup (Target Type → User Intent → Toolchain) to map incoming requests to skill paths, with fallback to primary keyword routing and support for multi‑skill pipeline execution.**

The `reverse-skill` repository implements a hierarchical routing system to dispatch cybersecurity and reverse‑engineering tasks. At its core, [`skills/routing.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/routing.md) functions as a fallback decision table that bridges fast keyword matching with exhaustive scenario‑based skill selection.

## Primary Routing vs. Matrix Fallback

The dispatch process operates in two layers to balance speed and coverage.

### Layer 1: Keyword‑Based Primary Routing

The system first consults [`skills/MASTER-ROUTING.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/MASTER-ROUTING.md) via `scripts/master-route.ps1`. If a strong keyword match exists, it returns a **PRIMARY** route (e.g., `R0`) and executes immediately.

```powershell

# Fast path: direct keyword match

.\skills\scripts\master-route.ps1 -Hint "Extract hidden strings from a PE file"

```

This avoids the overhead of parsing the full matrix for common tasks.

### Layer 2: Three‑Dimensional Matrix Lookup

When primary routing fails, the engine falls back to [`skills/routing.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/routing.md). The matrix is organized by three axes:

| Axis | Description | Example Values |
|------|-------------|--------------|
| **Target Type** | What object the task operates on | `binary`, `network`, `memory` |
| **User Intent** | What the user wants to accomplish | `strings`, `exploit`, `analysis` |
| **Toolchain** | Preferred or required execution environment | `powershell`, `python`, `pwn-chain` |

The algorithm walks rows until finding the first intersection match across all three columns.

## Path Crossing: Multi‑Skill Pipeline Dispatch

Some requests require sequential execution across multiple skills. The "路径交叉" (Path Crossing) section in [`routing.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/routing.md) defines valid combinations.

For example, a CTF challenge might need:

1. `pwn-chain` → initial exploitation
2. `reverse-engineer` → binary analysis

The dispatcher builds a pipeline and executes each skill's entry point in order.

```powershell

# Build multi-skill pipeline from path crossing rules

$pipeline = @(
    Get-SkillPath -Target 'binary' -Intent 'exploit' -Toolchain 'pwn-chain',
    Get-SkillPath -Target 'binary' -Intent 'analysis' -Toolchain 'reverse-engineer'
)

foreach($skillPath in $pipeline){
    & "$skillPath\scripts\run.ps1"
}

```

## Path Resolution and Skill Loading

Selected rows contain relative paths like `../CTF-Sandbox-Orchestrator/...`. The dispatcher resolves these against the `skills/` directory, then loads the target module's [`SKILL.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/SKILL.md) and executes its `scripts/run.ps1` or equivalent entry point.

```powershell

# Programmatic three-axis lookup implementation

$matrix = Import-Csv -Path "$PSScriptRoot\..\skills\routing.md" -Delimiter '|'

function Get-SkillPath {
    param($Target, $Intent, $Toolchain)

    foreach($row in $matrix){
        if($row.Target -match $Target -and `
           $row.Intent -match $Intent -and `
           $row.Toolchain -match $Toolchain){
            return $row.Path.Trim()
        }
    }
    throw "No matching skill found in routing.md"
}

```

## Key Files in the Dispatch Chain

| File | Role |
|------|------|
| [`skills/routing.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/routing.md) | Three‑dimensional fallback matrix |
| [`skills/MASTER-ROUTING.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/MASTER-ROUTING.md) | Fast keyword‑based primary routing |
| [`skills/SKILL.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/SKILL.md) | Global entry that orchestrates layer 1 → layer 2 → sub‑skill |
| `skills/scripts/master-route.ps1` | CLI helper implementing both routing layers |
| [`docs/ARCHITECTURE.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/docs/ARCHITECTURE.md) | System diagram including routing matrix placement |
| [`CTF-Sandbox-Orchestrator/references/router-matrix.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/CTF-Sandbox-Orchestrator/references/router-matrix.md) | Extended cross‑module routing for CTF pipelines |

## Summary

- The **routing matrix** in [`skills/routing.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/routing.md) provides exhaustive three‑axis matching when fast keyword routing fails
- **Primary routing** via [`MASTER-ROUTING.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/MASTER-ROUTING.md) shortcuts common tasks for performance
- **Path crossing** enables declarative multi‑skill pipelines for complex workflows
- Relative paths are resolved against `skills/` to load module‑specific [`SKILL.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/SKILL.md) files and execute their entry scripts
- The `master-route.ps1` script provides the unified interface for both routing layers

## Frequently Asked Questions

### How does the routing matrix handle ambiguous or overlapping matches?

The matrix processes rows sequentially and returns the **first** match where all three axes intersect. Design your most specific rules early in the file to ensure correct priority.

### Can I add custom toolchains to the routing matrix?

Yes. Add new rows to [`skills/routing.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/routing.md) with your custom `Toolchain` value, then implement the corresponding skill module under `skills/<toolchain>/` with a standard [`SKILL.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/SKILL.md) and `scripts/` entry point.

### What happens when no route matches at either layer?

When both [`MASTER-ROUTING.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/MASTER-ROUTING.md) and [`routing.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/routing.md) return no match, `master-route.ps1` throws a terminating error with the task hint logged for diagnostics. The system does not provide a default fallback to prevent unintended execution.

### Is the routing matrix used for real‑time task scheduling or only static dispatch?

The current implementation in `reverse-skill` performs static dispatch at invocation time. The matrix is loaded from disk and evaluated synchronously; there is no runtime task queue or scheduler in the open‑source core.