# APK and JS Routing Priorities in reverse-skill: How the Engine Selects Reverse Engineering Skills

> Discover APK and JS routing priorities in reverse-skill. Learn how the engine selects reverse engineering skills based on the deterministic hierarchy defined in routing.json. Understand R1 and R3 positions.

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

---

**The reverse-skill repository uses a deterministic priority system defined in [`skills/config/routing.json`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/config/routing.json) where APK reverse engineering (R1) holds the 2nd position and JS frontend reverse (R3) holds the 4th position in the routing hierarchy.**

The routing mechanism determines which reverse engineering skill handles a user query when multiple keywords match. Understanding these specific priorities helps developers predict which skill module—whether APK decompilation or JavaScript analysis—takes precedence during query resolution.

## Understanding the Routing Configuration File

The entire routing logic depends on [`skills/config/routing.json`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/config/routing.json) as the single source of truth. This JSON file contains two critical sections: route definitions that specify matching keywords for each skill, and a **`priority`** array that establishes the precedence order.

When a user submits a query, the engine identifies all routes whose keywords match the input. Instead of arbitrarily selecting a match, the system consults the ordered priority list and selects the first matching route ID as the **primary** route. This ensures consistent, predictable skill selection.

## Specific Routing Priorities for APK and JS Skills

### APK Reverse Engineering (R1)

**APK reverse** corresponds to route ID `R1` and occupies the **2nd position** in the priority array, immediately following `R4` (DSL VM reverse). According to the [[`routing.json`](https://github.com/zhaoxuya520/reverse-skill/blob/main/routing.json)](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/config/routing.json#L14-L19) definition, this route matches keywords related to Android application analysis and decompilation.

Because `R1` precedes `R2` and `R3` in the priority list [`["R4", "R1", "R2", "R3", ...]`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/config/routing.json#L24-L27), any query matching both APK and general mobile reverse criteria will trigger the APK-specific skill. Only `R4` outranks it; all other routes, including JavaScript reverse, yield to `R1` when both match.

### JavaScript Frontend Reverse (R3)

**JS / frontend reverse** maps to route ID `R3` and holds the **4th position** in the priority hierarchy. As defined in [[`routing.json`](https://github.com/zhaoxuya520/reverse-skill/blob/main/routing.json)](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/config/routing.json#L30-L34), this route activates on queries involving obfuscated JavaScript, web parameter decryption, or frontend analysis.

`R3` ranks below `R4` (DSL VM), `R1` (APK), and `R2` (binary/native reverse). Consequently, if a query matches both JavaScript obfuscation patterns and APK decompilation keywords, the engine selects `R1` (2nd position) over `R3` (4th position). The JS reverse skill only becomes the primary route when no higher-priority matches exist.

## How the Routing Engine Evaluates Matches

The routing process follows a deterministic three-step evaluation defined in [`skills/scripts/master-route.sh`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/scripts/master-route.sh):

1. **Load** the [`routing.json`](https://github.com/zhaoxuya520/reverse-skill/blob/main/routing.json) configuration into memory.
2. **Match** the user hint text against each route's keyword arrays.
3. **Resolve** conflicts by iterating through the `priority` array and returning the first matching route ID.

The following Bash commands demonstrate this behavior using the master routing script:

```bash

# Query triggers APK reverse (R1) due to 2nd position priority

bash skills/scripts/master-route.sh --hint "How to unpack an APK with jadx"

# Returns: primary route → R1 → apk-reverse/SKILL.md

# Query triggers JS reverse (R3) when no higher routes match

bash skills/scripts/master-route.sh --hint "Decrypt encrypted JS parameters in a web app"

# Returns: primary route → R3 → js-reverse/SKILL.md

```

## Key Implementation Files

| File | Purpose |
|------|---------|
| [`skills/config/routing.json`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/config/routing.json) | Central routing definition containing route IDs, keywords, and the ordered priority array. |
| [`skills/MASTER-ROUTING.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/MASTER-ROUTING.md) | Human-readable documentation mirroring the JSON priority table for reference. |
| [`skills/scripts/master-route.sh`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/scripts/master-route.sh) | Entry-point bash script that executes the keyword matching and priority resolution logic. |
| `skills/scripts/verify-routing-coherence.ps1` | PowerShell validation script ensuring the markdown documentation remains synchronized with [`routing.json`](https://github.com/zhaoxuya520/reverse-skill/blob/main/routing.json). |

## Summary

- **APK reverse (R1)** holds **2nd priority** in the routing hierarchy, outranking JavaScript reverse but yielding to DSL VM reverse (R4).
- **JS frontend reverse (R3)** occupies **4th position**, evaluated only when routes R4, R1, and R2 fail to match.
- The **`priority`** array in [`skills/config/routing.json`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/config/routing.json) serves as the deterministic arbiter for all routing decisions.
- The [`master-route.sh`](https://github.com/zhaoxuya520/reverse-skill/blob/main/master-route.sh) script implements this logic by selecting the first matching route ID from the ordered priority list.

## Frequently Asked Questions

### How does the reverse-skill router handle multiple matching skills?

When multiple routes match a query's keywords, the engine gathers all matching route IDs then iterates through the `priority` array in [`skills/config/routing.json`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/config/routing.json). It selects the first route ID found in that ordered list as the primary skill, ensuring consistent behavior regardless of how many keyword sets match.

### What determines whether APK reverse or JS reverse is selected?

Selection depends entirely on position within the priority array. **APK reverse (R1)** appears at index 1 (2nd position) while **JS reverse (R3)** appears at index 3 (4th position). If both skills match the query keywords, R1 wins due to its higher precedence in the ordered list `["R4", "R1", "R2", "R3", ...]`.

### Where is the routing priority order defined?

The priority order is explicitly defined in the **`priority`** array within [[`skills/config/routing.json`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/config/routing.json)](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/config/routing.json#L24-L27). This JSON array lists route IDs in descending order of precedence, with earlier entries outranking later ones.

### Can I modify the routing priorities for custom deployments?

Yes. Edit the `priority` array in [`skills/config/routing.json`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/config/routing.json) to reorder route IDs, then run `skills/scripts/verify-routing-coherence.ps1` to validate the changes against [`skills/MASTER-ROUTING.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/MASTER-ROUTING.md). The [`master-route.sh`](https://github.com/zhaoxuya520/reverse-skill/blob/main/master-route.sh) script will automatically respect the new order during the next query routing cycle.