# How to Implement Custom Analysis Decision Frameworks Beyond the Default Precedence Logic

> Learn to implement custom analysis decision frameworks by extending reverse-skill routing. Override default precedence logic with new routes and skill definitions.

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

---

**Extend the reverse-skill routing system by registering new routes in [`routing.json`](https://github.com/zhaoxuya520/reverse-skill/blob/main/routing.json), creating skill definitions, and appending decision rules to [`analysis-decision-framework.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/analysis-decision-framework.md) to override or augment the default R0-R51 precedence logic.**

The reverse-skill repository provides a structured approach to analysis routing through a **single source of truth** defined in [`skills/config/routing.json`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/config/routing.json). By default, the system relies on a precedence array that processes routes R0 through R51 in order, applying decision rules from [`skills/ops/analysis-decision-framework.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/ops/analysis-decision-framework.md). When you need specialized handling for unique analysis scenarios, you must implement a **custom analysis decision framework** that extends both the routing layer and the rule-evaluation engine.

## Understanding the Default Precedence Architecture

The reverse-skill framework routes analysis requests through three coordinated components:

- **[`skills/config/routing.json`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/config/routing.json)** – Contains the `routes` object defining route IDs (R0-R51), their associated skills, keyword triggers, and the `priority` array that determines evaluation order.
- **[`skills/MASTER-ROUTING.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/MASTER-ROUTING.md)** – Maps priority entries to concrete skill directories and provides human-readable documentation of the routing logic.
- **[`skills/ops/analysis-decision-framework.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/ops/analysis-decision-framework.md)** – Catalogs decision rules R1-R51 that agents apply after a skill is selected, including trigger conditions, actions, and evidence requirements.

The `priority` array in [`routing.json`](https://github.com/zhaoxuya520/reverse-skill/blob/main/routing.json) dictates the sequential evaluation order. When `master-route.ps1` processes an analysis request, it iterates through this array until finding a route whose keywords match the input context.

## Step 1: Register a Custom Route

To introduce your custom framework, you must first declare it in the routing configuration.

1. Open [`skills/config/routing.json`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/config/routing.json) and add a new entry under the `"routes"` object using the next available route ID (e.g., R50):

```json
"R50": {
  "label": "Custom-Framework",
  "skill": "custom-framework/SKILL.md",
  "keywords": [
    { "must": "my-custom-framework|custom-analysis|my-framework" }
  ]
}

```

2. Insert the route identifier into the `"priority"` array, positioning it above fallback routes you intend to outrank:

```json
"priority": [
  "R50", "R4", "R1", "R0"
]

```

3. Validate routing coherence by executing the verification script:

```powershell
powershell -NoProfile -ExecutionPolicy Bypass -File skills/scripts/verify-routing-coherence.ps1

```

This script ensures that [`MASTER-ROUTING.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/MASTER-ROUTING.md) remains synchronized with [`routing.json`](https://github.com/zhaoxuya520/reverse-skill/blob/main/routing.json) and that no orphaned routes exist.

## Step 2: Create the Skill Skeleton

Establish the physical directory structure and documentation for your custom framework.

1. Create the directory `skills/custom-framework/`.
2. Add a [`SKILL.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/SKILL.md) file describing the framework's purpose, inputs, and outputs. Copy the template from [`skills/SKILL.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/SKILL.md) to ensure proper formatting.
3. Optionally add a `references/` subdirectory for supporting documentation.

The [`SKILL.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/SKILL.md) serves as the contract between the routing system and the analysis agent, specifying what data the framework expects and what decisions it produces.

## Step 3: Extend the Decision-Rule Set

The core intelligence of your framework resides in [`skills/ops/analysis-decision-framework.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/ops/analysis-decision-framework.md). To add custom evaluation logic:

1. Append a new rule block following the existing R1-R51 pattern, starting with R52 (reserved IDs end at R51):

```markdown

### R52 — Custom-Risk Scoring

| | |
|---|---|
| **Trigger** | Presence of `my-custom-framework` tag in findings |
| **Action** | Compute a risk score (0-100) based on configurable weights |
| **Evidence** | `E-custom-score` |

```

2. Define the new evidence type in the "Evidence IDs" table near the top of the file.
3. Update downstream checklists (such as the "Synthesis checklist") to reference R52 where applicable.

Maintain monotonic numbering without gaps to ensure the decision engine parses rules correctly.

## Step 4: Wire Rules into the Framework

Connect your custom rules to the skill definition so they execute automatically.

In [`skills/custom-framework/SKILL.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/custom-framework/SKILL.md), reference the rule ID in the **Actions** section:

```markdown

## Actions

- When a finding matches the *my-custom-framework* tag → invoke **R52** for risk scoring.

```

Ensure that automation scripts driving the analysis (such as `skills/scripts/master-route.ps1`) invoke the generic decision engine, which will now recognize and process rule R52 when the custom framework is activated.

## Step 5: Verify the End-to-End Flow

Validate that routing and decision logic function correctly through integrated testing.

1. Run the comprehensive smoke test:

```powershell
powershell -NoProfile -ExecutionPolicy Bypass -File skills/scripts/smoke.ps1

```

2. Inspect `work/<case>/route-scope.md` generated by `master-route.ps1` to confirm the router selected R50 when keywords matched your custom framework.
3. Verify that evidence output `E-custom-score` appears in the case timeline, confirming that rule R52 fired during analysis.

## Step 6: Document the Custom Framework

Update [`skills/INDEX.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/INDEX.md) to enable discovery through the repository interface. Include:

- A concise description of the framework's analytical approach.
- A relative link to [`skills/custom-framework/SKILL.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/custom-framework/SKILL.md).
- A list of new rule IDs introduced (R52).

## Summary

Implementing a **custom analysis decision framework** in reverse-skill requires coordination between routing configuration and decision-rule definitions:

- **Register routes** in [`skills/config/routing.json`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/config/routing.json) and position them in the `priority` array to override default precedence.
- **Validate changes** using `verify-routing-coherence.ps1` to maintain consistency with [`MASTER-ROUTING.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/MASTER-ROUTING.md).
- **Create skill definitions** in dedicated subdirectories following the established [`SKILL.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/SKILL.md) template.
- **Extend decision rules** starting at R52 in [`skills/ops/analysis-decision-framework.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/ops/analysis-decision-framework.md), defining triggers, actions, and evidence IDs.
- **Test implementations** using `smoke.ps1` to verify routing selection and evidence generation.

## Frequently Asked Questions

### Where does the default precedence logic live in the reverse-skill repository?

The default precedence logic resides in [`skills/config/routing.json`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/config/routing.json) within the `priority` array, which lists route IDs from highest to lowest precedence. The `master-route.ps1` script processes this array sequentially, matching against the `keywords` defined for each route in the `routes` object. Routes R0-R51 are reserved in the base implementation, with R0 typically serving as the fallback generic analyzer.

### Can I modify existing decision rules R1-R51 instead of creating new ones?

You should not modify rules R1-R51 directly, as these are reserved by the repository's base framework and may be overwritten during updates. Instead, create new rules starting at R52 in [`skills/ops/analysis-decision-framework.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/ops/analysis-decision-framework.md) and override routing precedence through the `priority` array in [`routing.json`](https://github.com/zhaoxuya520/reverse-skill/blob/main/routing.json) to ensure your custom rules evaluate before or alongside default logic.

### How do I ensure my custom framework takes precedence over the generic R0 fallback?

Insert your custom route ID (e.g., R50) into the `priority` array in [`skills/config/routing.json`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/config/routing.json) **before** the R0 entry. The routing engine evaluates the array sequentially from index 0, so entries appearing earlier receive higher precedence. Run `verify-routing-coherence.ps1` after modification to confirm the configuration remains valid.

### What is the purpose of the evidence IDs like E-custom-score?

Evidence IDs serve as standardized references in the decision framework, linking rule actions to concrete output artifacts. When you define `E-custom-score` in [`analysis-decision-framework.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/analysis-decision-framework.md) and reference it in rule R52, you create a contract that automation scripts can detect and extract from case outputs. This enables downstream tools to programmatically consume your custom analysis results.