# What Is routing.json in reverse-skill? The Central Configuration Hub for Task Routing

> Discover how routing.json centralizes task routing in reverse-skill. Learn its role in defining route mappings, keyword rules, and priority for efficient application logic.

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

---

**routing.json serves as the single source of truth for all task-routing decisions in the reverse-skill repository, defining route mappings, keyword matching rules, priority ordering, and fallback behavior in a centralized JSON configuration.**

Located at [`skills/config/routing.json`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/config/routing.json), this file drives the entire routing engine for the reverse-skill platform. It maps textual user inputs to specific reverse-engineering skills through structured keyword rules, enabling automatic selection of the appropriate [`SKILL.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/SKILL.md) documentation based on task descriptions.

## Core Responsibilities of routing.json in reverse-skill

### Defining Routes and Keyword Mappings

Each entry in [`routing.json`](https://github.com/zhaoxuya520/reverse-skill/blob/main/routing.json) (such as `R1`, `R2`, etc.) associates a unique route ID with a **label**, a **skill** markdown file path, and a set of **keyword rules**. These rules contain `must` patterns (required regex matches) and optional `exclude` patterns that disqualify false positives. According to the reverse-skill source code, this structure determines which skill documentation (e.g., [`apk-reverse/SKILL.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/apk-reverse/SKILL.md)) gets invoked for a given task description.

### Scoring Algorithms and Fallback Logic

The **meta** section within [`routing.json`](https://github.com/zhaoxuya520/reverse-skill/blob/main/routing.json) specifies how the routing engine calculates match scores and handles unmatched inputs. When no routes satisfy the keyword criteria, the system falls back to the route ID defined in the `fallbackId` field (typically `R0`). This ensures that even ambiguous or novel task descriptions receive a default skill assignment rather than failing silently.

### Priority-Based Conflict Resolution

When multiple routes achieve identical scores, the **priority** array in [`routing.json`](https://github.com/zhaoxuya520/reverse-skill/blob/main/routing.json) determines the winner. This ordered list of route IDs defines precedence; the first matching ID in the priority list receives the selection, enforcing deterministic behavior during routing conflicts.

## How Routing Scripts Consume routing.json

The PowerShell scripts in `skills/scripts/` rely entirely on [`routing.json`](https://github.com/zhaoxuya520/reverse-skill/blob/main/routing.json) for operational logic. The `master-route.ps1` script reads this configuration to build the routing matrix and execute selected skills, while `verify-routing-coherence.ps1` validates that the JSON priority order aligns with markdown documentation tables.

Here is a practical example showing how a consumer script parses [`routing.json`](https://github.com/zhaoxuya520/reverse-skill/blob/main/routing.json):

```powershell

# Load routing configuration from reverse-skill

$routerPath = Join-Path $PSScriptRoot '..\config\routing.json'
$router = Get-Content $routerPath -Raw | ConvertFrom-Json

# Function: Find the best matching route for user input

function Get-Route {
    param([string]$InputText)

    $matches = @()
    foreach ($id in $router.routes.Keys) {
        $route = $router.routes[$id]
        foreach ($kw in $route.keywords) {
            if ($InputText -match $kw.must) {
                if ($kw.exclude -and $InputText -match $kw.exclude) { continue }
                $matches += [PSCustomObject]@{
                    Id = $id
                    Score = ($kw.must.Split('\|').Count)
                    Note = $kw.note
                }
                break
            }
        }
    }

    if (-not $matches) { return $router.meta.fallbackId }

    # Apply priority ordering from routing.json

    $sorted = $router.priority | Where-Object { $_ -in $matches.Id } |
              ForEach-Object {
                  $matches | Where-Object Id -EQ $_ | 
                  Sort-Object Score -Descending | 
                  Select-Object -First 1
              }
    return $sorted[0].Id
}

```

This implementation mirrors the actual logic found in `master-route.ps1`, demonstrating how the script evaluates `must` regex patterns, respects `exclude` conditions, computes scores, and finally obeys the `priority` list defined in the configuration.

## Integration with the Reverse-Skill Ecosystem

[`routing.json`](https://github.com/zhaoxuya520/reverse-skill/blob/main/routing.json) maintains loose coupling between the routing engine and individual skill implementations. The **skill** field in each route entry points to a specific markdown file (e.g., [`apk-reverse/SKILL.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/apk-reverse/SKILL.md)) containing the actual reverse-engineering procedures. The [`test-routing.sh`](https://github.com/zhaoxuya520/reverse-skill/blob/main/test-routing.sh) automated test harness exercises the routing engine against sample inputs to verify that changes to [`routing.json`](https://github.com/zhaoxuya520/reverse-skill/blob/main/routing.json) correctly map to the intended skill documentation.

Because all routing data lives in this single JSON file, modifications to routing logic—such as adding new reverse-engineering skills, adjusting keyword patterns, or reordering priority—require changes **only** in [`skills/config/routing.json`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/config/routing.json). The surrounding PowerShell and shell scripts regenerate or validate their behavior against this canonical definition, ensuring maintainability across the platform.

## Summary

- [`routing.json`](https://github.com/zhaoxuya520/reverse-skill/blob/main/routing.json) at [`skills/config/routing.json`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/config/routing.json) acts as the single source of truth for task routing in reverse-skill.
- Each route entry combines a skill markdown file with keyword rules containing `must` and `exclude` patterns.
- The **meta** section defines scoring logic and the `fallbackId` (typically `R0`) for unmatched inputs.
- The **priority** array resolves ties by enforcing deterministic route selection order.
- Scripts including `master-route.ps1` and `verify-routing-coherence.ps1` consume this file to execute and validate routing decisions.

## Frequently Asked Questions

### What is the exact file path for routing.json in reverse-skill?

The [`routing.json`](https://github.com/zhaoxuya520/reverse-skill/blob/main/routing.json) configuration file resides at [`skills/config/routing.json`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/config/routing.json) in the repository root. This location is hardcoded into the routing scripts such as `master-route.ps1`, which uses relative paths to load the configuration during execution.

### How does routing.json handle ambiguous routing decisions?

When multiple routes match with identical scores, the **priority** array in [`routing.json`](https://github.com/zhaoxuya520/reverse-skill/blob/main/routing.json) determines the selection. The routing engine processes this ordered list and selects the first route ID that appears both in the priority array and among the matched candidates, ensuring consistent and predictable behavior.

### What happens when no routes match in routing.json?

If no keyword rules satisfy the input criteria, the routing engine returns the route ID specified in the `meta.fallbackId` field (commonly set to `R0`). This fallback mechanism guarantees that every user input maps to at least one skill, preventing routing failures.

### How do I add a new reverse-engineering skill to routing.json?

To add a new skill, append a new route entry to the `routes` object with a unique ID (e.g., `R5`), specify the path to your [`SKILL.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/SKILL.md) file in the **skill** field, define appropriate `must` and `exclude` keyword patterns, and update the **priority** array to include the new route ID in your preferred precedence order. The `verify-routing-coherence.ps1` script will validate your changes against the existing documentation.