# How Reverse‑Skill Routes AI Agents for Cybersecurity Tasks: A Technical Deep‑Dive

> Discover how Reverse-Skill routes AI agents for cybersecurity using a prioritized JSON table, regex matching, and scoring to select the optimal skill path. Learn the technical details.

- Repository: [ZhaoXu/reverse-skill](https://github.com/zhaoxuya520/reverse-skill)
- Tags: deep-dive
- Published: 2026-09-02

---

**Reverse‑Skill routes AI agents by matching user hints against regex‑based keyword rules in a prioritized JSON routing table, scoring each candidate route, and selecting the highest‑scoring match as the PRIMARY skill path.**

The open‑source [zhaoxuya520/reverse‑skill](https://github.com/zhaoxuya520/reverse‑skill) repository implements a deterministic, platform‑neutral routing system that connects natural‑language cybersecurity requests to specialized AI skills. This article explains how the routing engine works, how to extend it, and how to interpret its outputs.

---

## How the Routing Table Defines AI Agent Paths

All routing logic stems from [`skills/config/routing.json`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/config/routing.json), the single source of truth for AI agent routing. Each entry in this file declares a route with four core fields:

- **`label`** — a human‑readable description (e.g., "APK reverse", "Forensic memory acquisition").
- **`skill`** — a relative path to the skill's implementation markdown (e.g., [`apk-reverse/SKILL.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/apk-reverse/SKILL.md)).
- **`keywords`** — an array of regex‑driven matching rules with `must`, `mustAll`, and `exclude` patterns.
- **Priority ordering** — a separate `priority` array listing route IDs from most to least specific (R1, R2, …, R0).

The file also declares a **`fallbackId`** (`R0`) that triggers when no keyword rule scores positively. According to the source, "the priority list orders the routes from most specific to most generic," ensuring deterministic tie‑breaking.

---

## How the Routing Engine Parses Hints and Scores Routes

The entry point [`skills/scripts/master-route.sh`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/scripts/master-route.sh) executes an embedded Python snippet that implements the full scoring algorithm. The engine follows three precise steps:

1. **Normalization** — lower‑cases the user hint supplied via `--hint "<task>"`.
2. **Rule evaluation** — iterates every route, applying regexes in sequence:
   - `must` — at least one pattern must match.
   - `mustAll` — every pattern in the array must match.
   - `exclude` — if any pattern matches, the route is disqualified.
3. **Score computation** — aggregates matches into a numeric score, then selects the highest‑scoring route according to the `priority` ordering. If all scores are zero, the fallback `R0` is elected PRIMARY.

The script writes a `route‑scope.md` artefact containing the chosen route ID, label, confidence level, secondary matches, diagnostic notes, and a direct file path to the skill markdown.

---

## Routing Contract and Analyst Workflow

The [`skills/MASTER-ROUTING.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/MASTER-ROUTING.md) document formalizes the post‑routing contract:

- The analyst **must** open the PRIMARY skill markdown immediately (the "ACTION REQUIRED" line).
- Case initialization and scope checks are enforced before execution.
- The routing matrix in markdown must stay synchronized with [`routing.json`](https://github.com/zhaoxuya520/reverse-skill/blob/main/routing.json) — drift breaks determinism.

This contract ensures that AI agent routing remains auditable and reproducible across operating environments.

---

## Practical Examples of AI Agent Routing

### Routing an Android APK Analysis Request

```bash
bash skills/scripts/master-route.sh --hint "Analyze this apk for root detection and certificate pinning"

```

*Excerpt from `route‑scope.md`:*

```

PRIMARY -> skills/apk-reverse/SKILL.md
Label: APK reverse | confidence: high

```

The hint matches the `must` regex for R1 (`\bapk\b|smali|jadx|apktool|...`), granting it the highest score.

### Routing a Penetration Test Request

```bash
bash skills/scripts/master-route.sh --hint "Run nmap and look for vulnerable services"

```

*Excerpt:*

```

PRIMARY -> skills/pentest-tools/SKILL.md
Label: Pentest tools | confidence: high

```

Keywords `nmap|sqlmap|...` defined under R11 score positively, making it PRIMARY.

### Falling Back to Generic Reverse Engineering

```bash
bash skills/scripts/master-route.sh --hint "I need help reverse‑engineering an unknown binary"

```

*Excerpt:*

```

PRIMARY -> skills/reverse-engineering/SKILL.md
Label: General reverse-engineering | confidence: low
NOTE: No strong keyword hit; open routing.md full matrix

```

No route exceeds the fallback threshold, so R0 is selected with low confidence.

---

## Extending and Validating the Routing System

Adding a new cybersecurity skill requires only two edits to [`skills/config/routing.json`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/config/routing.json):

1. Append a new route entry with unique ID, label, skill path, and keyword rules.
2. Insert the route ID into the `priority` array at the appropriate specificity rank.

The verification script `verify-routing-coherence.ps1` (Windows) or its Bash counterpart detects mismatches between the JSON priority array and any markdown tables, preventing silent routing bugs. This guarantees identical behavior across Windows PowerShell and Linux Bash implementations.

---

## Summary

- **Single source of truth**: [`skills/config/routing.json`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/config/routing.json) holds all route definitions, regex patterns, and priority ordering.
- **Scoring algorithm**: [`master-route.sh`](https://github.com/zhaoxuya520/reverse-skill/blob/main/master-route.sh) normalizes hints, evaluates `must`/`mustAll`/`exclude` rules, and selects the highest‑priority match.
- **Deterministic fallback**: Route `R0` captures unclassified requests to prevent routing failures.
- **Extensibility**: New skills require only JSON edits; coherence verifiers catch priority drift.
- **Cross‑platform parity**: Bash and PowerShell implementations share identical logic and validation.

---

## Frequently Asked Questions

### What file controls which AI agent handles a cybersecurity task?

The routing table at [`skills/config/routing.json`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/config/routing.json) defines every available AI agent path, its associated skill markdown, and the regex rules that trigger selection. No other configuration file influences routing behavior.

### How does Reverse‑Skill handle ambiguous or vague user hints?

When no keyword rule produces a positive score, the engine defaults to the `fallbackId` (R0), typically mapped to a general reverse‑engineering skill. The resulting `route‑scope.md` marks confidence as "low" and advises opening the full routing matrix for manual selection.

### Can I add custom cybersecurity skills without modifying the routing engine?

Yes. Adding a skill only requires editing [`skills/config/routing.json`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/config/routing.json) to declare the new route and updating the `priority` array. The existing [`master-route.sh`](https://github.com/zhaoxuya520/reverse-skill/blob/main/master-route.sh) script automatically recognizes new entries on its next invocation; no engine code changes are necessary.

### How does Reverse‑Skill ensure consistent routing across Windows and Linux?

The project maintains parallel implementations in Bash ([`master-route.sh`](https://github.com/zhaoxuya520/reverse-skill/blob/main/master-route.sh)) and PowerShell, both executing identical Python‑embedded scoring logic. The `verify-routing-coherence.ps1` script validates that priority tables in documentation match the JSON source, catching cross‑platform synchronization errors before deployment.