# How to Use MASTER-ROUTING.md for Primary Skill Selection in reverse-skill

> Master primary skill selection in reverse-skill using MASTER-ROUTING.md. Run master-route.ps1 with task hints to automatically choose the top skill directory.

- Repository: [ZhaoXu/reverse-skill](https://github.com/zhaoxuya520/reverse-skill)
- Tags: how-to-guide
- Published: 2026-08-01

---

**Run `skills/scripts/master-route.ps1` with a task hint to automatically select the highest-priority skill directory via MASTER-ROUTING.md's execution contract.**

The [`MASTER-ROUTING.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/MASTER-ROUTING.md) file in the [zhaoxuya520/reverse-skill](https://github.com/zhaoxuya520/reverse-skill) repository serves as the central routing contract that determines which skill directory should be opened first for any given reverse-engineering task. This markdown contract works in conjunction with a PowerShell automation script to parse natural language hints, evaluate them against a priority table of **R** identifiers (R0 through R38), and output a deterministic **PRIMARY** skill path.

## Understanding the Routing Chain

[`MASTER-ROUTING.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/MASTER-ROUTING.md) defines the execution flow that governs how the repository handles incoming tasks. According to the "读序" section in lines 100-106 of the source file, the complete routing chain follows this sequence:

```

RULES.md → MASTER-ROUTING.md → PRIMARY SKILL.md
   → (optional) routing.md → tool-index.md → bootstrap → ACT

```

The **execution contract** (defined in lines 5-13) requires the router to output three critical components: the PRIMARY skill path, a short rationale for the selection, and the next [`SKILL.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/SKILL.md) file to open. This contract ensures that every reverse-engineering or pentest workflow starts in the most appropriate skill area based on keyword detection and priority ordering.

## How the Routing Algorithm Works

The PowerShell implementation in `skills/scripts/master-route.ps1` implements the logic defined in [`MASTER-ROUTING.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/MASTER-ROUTING.md). The algorithm processes task hints through the following steps:

1. **Normalize input**: The script converts the user hint to lowercase (`$t`) in lines 9-10 to ensure case-insensitive matching.

2. **Pattern matching**: Lines 100-149 contain a series of regex tests that map keywords in the hint to one or more **R** identifiers (e.g., "APK" maps to R1, "Windows AD" maps to R24).

3. **Priority resolution**: The script deduplicates matches into `$uniq`, then walks a hard-coded priority list (`$priority`) in lines 156-161 to select the first matching ID as the **PRIMARY** skill.

4. **Confidence assignment**: The script assigns **high** confidence if only one R identifier matches, **medium** if several match (lines 63-70), and **low** when falling back to **R0** (generic reverse-engineering).

5. **Route scope generation**: The script writes a [`route-scope.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/route-scope.md) report containing the timestamp, hint, primary ID and label, confidence level, secondary skill list, and execution notes (lines 96-108).

The **R** to path mapping is handled by the `$map` table in lines 12-53 of `master-route.ps1`, which translates identifiers like `R2` to relative paths such as [`skills/mobile-reverse/SKILL.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/mobile-reverse/SKILL.md).

## Practical Usage Examples

### Basic Command-Line Routing

To route a task about Android reverse-engineering, execute the PowerShell script with a descriptive hint:

```powershell
powershell -File skills\scripts\master-route.ps1 -Hint "Analyze an APK, check for packer signatures"

```

The script outputs a colored console summary:

```

PRIMARY -> skills/apk-reverse/SKILL.md
Label: APK reverse | confidence: high
Wrote C:\repo\work\master-route-20230801-154200\route-scope.md
ACTION: Open PRIMARY SKILL.md now and execute ACTION REQUIRED.

```

The generated [`route-scope.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/route-scope.md) contains the structured routing decision:

```markdown

# reverse-skill Master route (PRIMARY)

- created: 2023-08-01T15:42:00.0000000Z
- hint: Analyze an APK, check for packer signatures
- primary: R1
- primary_label: APK reverse
- primary_skill: skills/apk-reverse/SKILL.md
- confidence: high
- secondary: (none)

## MUST open next

1. skills/MASTER-ROUTING.md
2. skills/apk-reverse/SKILL.md

```

### Handling Multi-Keyword Tasks

When a hint matches multiple patterns, the router selects the highest-priority match and lists others as secondary skills:

```powershell
powershell -File skills\scripts\master-route.ps1 `
    -Hint "Collect network traffic (pcap) from a Windows AD environment and look for Kerberos tickets"

```

This returns **R24** (Windows AD) as the PRIMARY with **medium** confidence, while **R21** (protocol reverse) is listed as a secondary skill because the hint matches both AD-related and PCAP-related patterns in the regex tests.

### Fallback to Generic Reverse Engineering

If the hint contains no strong keywords, the router defaults to **R0**:

```powershell
powershell -File skills\scripts\master-route.ps1 -Hint "Investigate an unknown binary"

```

The script selects the general reverse-engineering skill (R0) and adds a note to open [`routing.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/routing.md) for the full keyword matrix (lines 66-68 of `master-route.ps1`), allowing manual skill selection when automated routing lacks confidence.

## Understanding the Route-Scope Output

The [`route-scope.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/route-scope.md) file generated by `case-init.ps1` serves as the audit trail for routing decisions. This markdown file contains:

- **Primary skill**: The selected R identifier, human-readable label, and relative path to the [`SKILL.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/SKILL.md) file
- **Confidence level**: Indicates routing certainty based on keyword match uniqueness
- **Secondary skills**: All other matched R identifiers (apart from PRIMARY) for later reference
- **Next steps**: Ordered list of files to open, starting with [`MASTER-ROUTING.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/MASTER-ROUTING.md) followed by the primary [`SKILL.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/SKILL.md)

Open the indicated primary [`SKILL.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/SKILL.md) file and follow the *ACTION REQUIRED* steps inside to begin the actual reverse-engineering workflow.

## Key Files in the Routing Pipeline

| File | Purpose |
|------|---------|
| [`skills/MASTER-ROUTING.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/MASTER-ROUTING.md) | Human-readable contract containing the priority table (R0-R38) and execution steps |
| `skills/scripts/master-route.ps1` | PowerShell implementation of the keyword detection and priority algorithm |
| `skills/scripts/case-init.ps1` | Initializes cases after routing and writes the [`route-scope.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/route-scope.md) report |
| [`skills/ops/routing.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/ops/routing.md) | Full keyword matrix consulted when the router falls back to R0 |
| [`skills/tool-index.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/tool-index.md) | Central index of external tools referenced by all skills |
| [`ops/IDENTITY.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/ops/IDENTITY.md) | Defines the router's operational identity and constraints |

## Summary

- **MASTER-ROUTING.md** acts as the central execution contract that maps natural language task hints to specific skill directories using **R** identifiers (R0-R38).
- The **`master-route.ps1`** script automates this selection by scanning hints for keywords, deduplicating matches, and selecting the highest-priority match from the hard-coded priority list.
- **Confidence levels** (high, medium, low) indicate match certainty, with automatic fallback to **R0** (generic reverse-engineering) when no strong keywords are detected.
- The **route-scope.md** output file provides an auditable record of routing decisions and specifies the exact [`SKILL.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/SKILL.md) files to open next.
- This routing pipeline ensures deterministic, reproducible skill selection for reverse-engineering workflows in the `reverse-skill` repository.

## Frequently Asked Questions

### What happens if multiple R identifiers match my task hint?

When multiple patterns match, the script assigns **medium** confidence and selects the identifier that appears first in the hard-coded `$priority` array (lines 156-161 of `master-route.ps1`). All other matched IDs are listed as "secondary" skills in the [`route-scope.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/route-scope.md) output for potential later use, but only the PRIMARY skill is activated initially.

### How do I add a new skill to the MASTER-ROUTING.md priority table?

To add a new skill, you must update three components: add the new **R** identifier to the priority table in [`MASTER-ROUTING.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/MASTER-ROUTING.md) (lines 47-90), create the corresponding regex pattern in `master-route.ps1` (lines 100-149), and add the mapping entry to the `$map` table (lines 12-53) that points to your new [`SKILL.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/SKILL.md) file path.

### Can I use MASTER-ROUTING.md without the PowerShell script?

Yes. The [`MASTER-ROUTING.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/MASTER-ROUTING.md) file is human-readable and contains the full priority table with matching conditions (lines 47-90). You can manually scan the priority list (R1-R38, R0) and select the first identifier that matches your task characteristics, then open the corresponding [`SKILL.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/SKILL.md) file directly.

### What is the difference between R0 and the other routing identifiers?

**R0** represents the generic reverse-engineering fallback skill used when the `master-route.ps1` script detects no strong keyword matches (lines 66-68). Unlike specialized identifiers (R1-R38) that map to specific domains like APK reverse or Windows AD, R0 indicates broad applicability and triggers a recommendation to consult [`ops/routing.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/ops/routing.md) for the full keyword matrix to find more specific guidance.