# How the Routing Mechanism Works in Patent-Disclosure-Skill: Intent-Based Dispatch Explained

> Explore the routing mechanism in handsomestWei/patent-disclosure-skill. Discover how intent-based dispatch maps Chinese keywords to sub-skills with strict isolation and workflow boundaries.

- Repository: [handsomestWei/patent-disclosure-skill](https://github.com/handsomestWei/patent-disclosure-skill)
- Tags: internals
- Published: 2026-09-06

---

**The routing mechanism in `handsomestWei/patent-disclosure-skill` is a declarative intent-classification system defined in the root [`SKILL.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/SKILL.md) that maps Chinese trigger keywords to specific sub-skill entry points while enforcing strict package isolation and workflow boundaries.**

The **patent-disclosure-skill** is a modular suite of six specialized sub-skills designed for patent workflow automation. According to the repository source code, the top-level [`SKILL.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/SKILL.md) acts as a centralized router that parses user input, identifies intent through keyword matching, and dispatches requests to the appropriate sub-skill handler without permitting cross-package tool invocation.

## Intent Recognition and Keyword Mapping

The routing mechanism relies on **hard-coded intent keywords** defined in the routing table of [`SKILL.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/SKILL.md). When a user submits a command, the router scans for specific Chinese trigger words that indicate which patent workflow to initiate.

The recognized intent keywords and their corresponding sub-skill entry points are:

- **交底书** → [`skills/patent-disclosure/SKILL.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/skills/patent-disclosure/SKILL.md)
- **申请文件** → [`skills/patent-application/SKILL.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/skills/patent-application/SKILL.md)
- **著录检索** → [`skills/patent-search/SKILL.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/skills/patent-search/SKILL.md)
- **读专利** → [`skills/patent-reader/SKILL.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/skills/patent-reader/SKILL.md)
- **审查答复** → [`skills/patent-oa/SKILL.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/skills/patent-oa/SKILL.md)
- **政策简报** → [`skills/patent-exam-policy/SKILL.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/skills/patent-exam-policy/SKILL.md)

Each keyword acts as a direct pointer to the sub-skill's configuration file, allowing the Agent-Skills runtime to load the appropriate toolset and prompt definitions.

## Package Isolation Enforcement

A critical guardrail in the routing mechanism is the **prohibition of cross-package calls**. The router enforces strict boundaries between sub-skills to prevent dependency contamination.

If a sub-skill requires a capability that exists in another package, it must use its own isolated copy of that tool. For example, each sub-skill directory contains its own `tools/` subdirectory with redundant scripts rather than importing from sibling packages. This architectural decision ensures that updates to one sub-skill's tooling cannot inadvertently break workflows in another.

## Special Case Routing Logic

The router implements **explicit prioritization rules** for edge cases that deviate from standard keyword matching.

When the input matches a patent number pattern (e.g., `CN202310000000.X`) or ends with a PDF extension, and the user's intent context suggests "读懂" (comprehension), the router bypasses the standard disclosure workflow and immediately dispatches to [`skills/patent-reader/SKILL.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/skills/patent-reader/SKILL.md).

Conversely, the router **never** auto-initiates the policy-brief (`政策简报`), OA reply (`审查答复`), or application (`申请文件`) flows from disclosure or reader contexts. These workflows require explicit user invocation to prevent accidental document generation.

## Workflow Boundary Guardrails

The routing mechanism maintains strict separation between different search capabilities to prevent tool misuse.

During the **disclosure search step**, the router restricts execution to the lightweight "一词一页" (one-term-one-page) search implementation located within the `patent-disclosure` package. When executing a **bibliographic search** (著录检索), the router dispatches to the full-featured `patent-search` package. These two search pipelines are never mixed within a single user request.

## Implementation Example

While the production implementation is driven by YAML declarations in [`SKILL.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/SKILL.md), the routing logic operates conceptually as follows:

```python
def route(user_input: str) -> str:
    # Intent detection via keyword mapping

    intents = {
        "交底书": "skills/patent-disclosure/SKILL.md",
        "申请文件": "skills/patent-application/SKILL.md",
        "著录检索": "skills/patent-search/SKILL.md",
        "读专利":   "skills/patent-reader/SKILL.md",
        "审查答复": "skills/patent-oa/SKILL.md",
        "政策简报": "skills/patent-exam-policy/SKILL.md",
    }

    for kw, entry in intents.items():
        if kw in user_input:
            # Explicit trigger validation for application flow

            if kw == "申请文件" and not _has_disclosure_dir(user_input):
                raise ValueError("Application flow requires a disclosed directory")
            return entry

    # Patent number or PDF detection bypass

    if _looks_like_patent_number(user_input) or _is_pdf(user_input):
        return "skills/patent-reader/SKILL.md"

    raise ValueError("Unable to determine routing")

```

The actual dispatch is handled by the Agent-Skills framework parsing the routing section of the root [`SKILL.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/SKILL.md) file.

## Routing Configuration Reference

The following table summarizes the user commands and their routed destinations:

| User Command | Routed Sub-Skill File | Purpose |
|--------------|----------------------|---------|
| `交底书` | [`skills/patent-disclosure/SKILL.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/skills/patent-disclosure/SKILL.md) | Draft patent disclosure document |
| `申请文件 /path/to/disclosure` | [`skills/patent-application/SKILL.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/skills/patent-application/SKILL.md) | Generate application file set |
| `著录检索` | [`skills/patent-search/SKILL.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/skills/patent-search/SKILL.md) | Search CNIPA bibliographic records |
| `读专利 my_patent.pdf` | [`skills/patent-reader/SKILL.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/skills/patent-reader/SKILL.md) | Parse patent and produce analysis |
| `审查答复` | [`skills/patent-oa/SKILL.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/skills/patent-oa/SKILL.md) | Build office action reply |
| `政策简报` | [`skills/patent-exam-policy/SKILL.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/skills/patent-exam-policy/SKILL.md) | Generate examination policy brief |

## Summary

- The **root [`SKILL.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/SKILL.md)** functions as a declarative router that maps Chinese intent keywords to sub-skill entry points.
- **Six primary intents** are supported: disclosure, application, search, reader, OA reply, and policy brief.
- **Strict package isolation** prevents cross-directory tool sharing; each sub-skill maintains its own `tools/` directory.
- **Patent number and PDF inputs** trigger automatic redirection to the reader sub-skill when comprehension is implied.
- **Explicit invocation** is required for OA, policy, and application workflows to prevent accidental execution.

## Frequently Asked Questions

### What automatically triggers the patent reader sub-skill?

The router automatically dispatches to [`skills/patent-reader/SKILL.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/skills/patent-reader/SKILL.md) when the user input contains a string matching a patent number format (such as `CN2023XXXXXXXX.X`) or references a PDF file, provided the context indicates a goal of reading or comprehension ("读懂"). This bypasses the standard keyword-based routing.

### Can sub-skills share utility scripts or tools?

No. The routing mechanism explicitly prohibits cross-package calls. Each sub-skill must use its own copy of tools located within its respective `tools/` directory. This isolation ensures that modifications to one sub-skill's utilities do not create breaking changes in other workflows.

### What is the difference between disclosure search and bibliographic search?

The **disclosure search** uses a lightweight "一词一页" implementation confined to the `patent-disclosure` package, designed for quick term lookups during disclosure drafting. The **bibliographic search** (`著录检索`) invokes the full-featured `patent-search` package with comprehensive database access. The router strictly separates these to prevent mixing lightweight and heavy search operations.

### Why does the application flow require validation before routing?

When routing to [`skills/patent-application/SKILL.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/skills/patent-application/SKILL.md), the router checks for the presence of a disclosed directory via `_has_disclosure_dir()`. This validation ensures that application file generation only occurs when prerequisite disclosure documents exist, preventing the creation of orphaned application drafts without underlying technical content.