How the AI Routing System Dispatches Security Tasks to Skill Modules

The reverse-skill repository implements a deterministic, data-driven pipeline that maps user security requests to specialized skill modules using regex-based keyword matching, route scoring, and priority resolution defined in routing.json.

The reverse-skill project provides a modular framework for AI-assisted security and reverse-engineering workflows. Its AI routing system dispatches security tasks to skill modules through a declarative configuration that eliminates hard-coded logic, ensuring that the routing matrix remains transparent and easily extensible.

Core Components of the Routing Pipeline

The dispatch mechanism relies on three tightly coupled components that transform a free-form user hint into a concrete skill module selection.

Routing Configuration (routing.json)

The file skills/config/routing.json serves as the single source of truth for all route definitions. Each route entry contains a unique ID, a human-readable label, a relative path to the skill's SKILL.md entry point, and a structured list of regular-expression keyword rules.

The keyword rules support three matching strategies:

  • must – A regex that must match the user hint for the route to be considered
  • mustAll – An optional array of regexes where every pattern must match
  • exclude – A regex that invalidates the match if found (preventing false positives)

The Router Engine (master-route.ps1)

The PowerShell script skills/scripts/master-route.ps1 functions as the routing engine. It ingests the user hint, normalizes it to lowercase while preserving CJK characters, and evaluates every route's keyword rules against the normalized input. The script maintains a scoring dictionary where each successful rule match increments the route's score.

Master Routing Contract (MASTER-ROUTING.md)

The file skills/MASTER-ROUTING.md documents the routing contract that the AI client must follow after selection. It enumerates the ordered priority list used to break ties between equally scored routes and maps every route ID to its corresponding skill folder.

The Dispatch Workflow: From User Hint to Skill Module

When the AI client receives a security task, the routing pipeline executes seven distinct steps to dispatch the request:

  1. Hint ingestion – The system receives a free-form task description (e.g., "scan the target with nmap and look for open ports").

  2. Normalizationmaster-route.ps1 converts the hint to lowercase while preserving any CJK characters to ensure consistent pattern matching.

  3. Keyword evaluation – For each route in routing.json, the script iterates through the keywords array:

    • Validates must regex patterns
    • Checks that all mustAll patterns match when present
    • Disqualifies routes where exclude patterns match
  4. Scoring – Each qualifying match increments the route's score (scores[id] += 1), creating a ranked list of candidates.

  5. Priority resolution – The script traverses the ordered priority array defined in routing.json. The first route with the highest score becomes the PRIMARY route. If multiple routes share the top score, priority order determines the winner. If no route scores, the system defaults to route R0 (general reverse-engineering).

  6. Output generation – The script writes a route-scope.md file containing:

    • primary and primary_label (selected route ID and human-readable name)
    • primary_skill (absolute path to the selected module's SKILL.md)
    • confidence level (high, medium, or low based on match uniqueness)
    • Secondary candidate list
    • Human-readable notes explaining fallback selection when applicable
  7. Task dispatch – The AI client opens the primary_skill file and executes the ACTION REQUIRED block inside that skill's SKILL.md, initiating the concrete workflow for the selected domain.

Route Scoring and Priority Resolution

The scoring algorithm implements a simple accumulation model where multiple keyword matches increase a route's selection probability. However, the priority list in routing.json provides deterministic tie-breaking.

For example, if routes R12 (Web Exploitation) and R15 (API Testing) both score 2 points, the script examines the priority array [R0, R12, R15, ...]. Since R12 appears before R15, it receives the PRIMARY designation regardless of the order in which matches were found.

The fallback route R0 ensures the system remains operational even when user hints contain novel terminology or ambiguous phrasing that fails to trigger specific keyword rules.

Output Generation and Task Dispatch

After selecting the primary route, master-route.ps1 creates a timestamped workspace directory (e.g., work/master-route-20230809-123456/) and writes the route-scope.md file. This artifact serves as the contract between the router and the AI execution environment:


# reverse-skill Master route (PRIMARY)

- hint: enumerate AD users and dump NTLM hashes
- primary: R24
- primary_label: Windows / AD
- primary_skill: skills/windows-ad/SKILL.md
- confidence: high
- secondary: (none)

The AI client then loads the specified SKILL.md file, which contains domain-specific tooling instructions, script references, and sub-task workflows tailored to the security objective.

Extending the System: Adding New Skill Modules

The routing system is fully declarative, requiring no code changes to accommodate new security domains. To add a "container-escape" skill:

First, append the route definition to skills/config/routing.json:

"R41": {
  "label": "Container escape",
  "skill": "container-escape/SKILL.md",
  "keywords": [
    { "must": "container.?escape|docker.?escape|lxc.?escape" }
  ]
}

Then, register the route in skills/MASTER-ROUTING.md by adding it to the priority table:

| **R41** | Container escape | `container-escape/` |

The router automatically incorporates the new route on the next execution, validating that the priority list and JSON definitions remain synchronized (emitting a warning if they diverge).

Summary

  • The routing matrix lives in skills/config/routing.json and defines keyword rules using must, mustAll, and exclude regex patterns.
  • master-route.ps1 normalizes input, scores routes based on rule matches, and resolves ties using the ordered priority list.
  • The system defaults to route R0 when no keywords match, ensuring graceful degradation.
  • Output artifacts in route-scope.md provide the AI client with the exact skill path and confidence metrics required for execution.
  • New skill modules require only declarative entries in JSON and markdown configuration files—no modifications to the routing engine.

Frequently Asked Questions

What happens if the user hint does not match any keywords?

If no route accumulates a score during keyword evaluation, the routing system automatically selects route R0, which corresponds to general reverse-engineering workflows. This fallback ensures the AI assistant can still provide value using generic methodologies when specialized routes fail to trigger.

How does the system resolve conflicts when multiple routes match the same keywords?

When multiple routes achieve identical scores, master-route.ps1 consults the priority array defined in routing.json. The route appearing earliest in this ordered list receives the PRIMARY designation. This deterministic approach prevents non-deterministic dispatch and allows maintainers to explicitly control precedence.

Can I modify the routing behavior without editing the PowerShell script?

Yes. The system is designed to be fully data-driven. You can alter keyword patterns, adjust route priorities, or add new routes by modifying skills/config/routing.json and skills/MASTER-ROUTING.md. The master-route.ps1 script reads these files dynamically and contains no hard-coded route definitions.

What is the purpose of the mustAll keyword rule?

The mustAll rule specifies an array of regex patterns where every pattern must match for the route to score. This is useful for complex scenarios requiring multiple distinct concepts to be present simultaneously—for example, requiring both "jailbreak" and "iOS" to match a mobile security route while excluding matches that contain only one term.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →