How the router works
Router mode builds a local SQLite catalog (skill-index.sqlite) from all installed skills under configured roots. When a user prompt arrives, the skill-router skill (automatically installed as the implicit first hop) runs a single skillspec route query against that index. The router uses a BM25-style lexical scoring algorithm over each skill’s name, description, tags, trigger phrases, and skill.spec.yml metadata, then applies an activation-anchor gate to prevent broad skills from winning on generic text overlap.
The route decision is always one of three values:
Router install also writes a visibility manifest and applies native harness controls so routed skills are
manual-only (explicit-only) — the router is the only selection path while it is enabled. The manifest is the rollback boundary; restore always uses recorded file snapshots.
Policy profiles let you layer operator-authored routing rules on top of lexical scoring. The three profile modes are:
route— normal router behavior with optional policy preferencessoft-passthrough— router remains the first hop but the active profile defaults to bypass; only allowlisted skills or matching rules can routenative-passthrough— router steps out of the hot path for high-throughput coding or focus modes; hooks and router skill are made explicit-only while allowlisted skills stay implicit
Install the router
Runskillspec router install once to create the router skill package in every configured skill root, write the visibility manifest, build the initial index, install prompt guard hooks, and write router config to ~/.skillspec/router/config.json.
--roots entries when skills are shared across Codex, Agents, and Claude roots. After a successful install, restart your active harness sessions so they reload skill metadata and hook entries.
skillspec router install creates:
- A SkillSpec-backed
skill-routerskill with aSKILL.mdandskill.spec.ymlin each configured root ~/.skillspec/router/skill-index.sqlite— the SQLite catalog~/.skillspec/router/visibility-manifest.json— the rollback manifest~/.skillspec/router/config.json— router lifecycle state- Managed Codex and Claude
UserPromptSubmitguard hook entries
If you previously used
~/.skillspec/router as a bare SQLite file path, router install will detect the collision and ask for --force. The forced path moves the old file to ~/.skillspec/router/skill-index.sqlite before writing router config.Build the index
The index is built automatically duringrouter install and router enable. You can also build or rebuild it directly with skillspec index:
skill-index.sqlite automatically. When router config exists and is enabled, prefer skillspec router index refresh instead — it reapplies explicit-only visibility controls and checks preparedness after rebuilding.
Route a query
Test routing decisions manually withskillspec route:
decision, selected (skill path when use_skill), candidates with individual base_score and policy_score fields, bypass_reason, and an optional elicitation hint when the user has not yet chosen direct or durable execution mode.
Guard hook
The guard hook runsskillspec router guard before every model turn when the managed hook is installed. It verifies that the router index is fresh and applies repair if visibility or index drift is detected since the last turn.
--hook), the guard reports first_hop_ready, index status before and after any repair, and any visibility repair output:
When emitting harness hook JSON (
--hook), the guard outputs a UserPromptSubmit-compatible block. On success it injects compact context telling the model that router mode is ready and that skill-router must be the first hop. On failure it emits a blocking decision with the concrete repair command. SkillSpec installs managed hook entries into the relevant hooks.json (Codex) or settings.json (Claude Code) for each configured root. It removes only the managed router guard hook entries when disabling or uninstalling — existing user hooks are never touched.Implemented root mapping:<base>/.codex/skills→<base>/.codex/hooks.json<base>/.claude/skills→<base>/.claude/settings.json<base>/.agents/skills→<base>/.codex/hooks.jsonand<base>/.claude/settings.json(when.claudeexists)
Policy profiles
Policy profiles let you tune routing behavior without editing router skill files.1
Create a profile
--active marks this profile as the live profile in skill-index.sqlite. The route command reads the active profile from SQLite at query time — no restart needed.2
Add rules to the profile
--anchor policy lets the exact skill:browser preference satisfy the activation-anchor gate, so the router can select the browser skill even when the query uses only the keyword browse rather than the skill name itself.3
Inspect the policy
policy get or policy show before editing an existing rule so you preserve existing predicates and preferences.4
Explain a routing decision
base_score, policy_score, policy_reason, and which rules matched, so you can audit exactly why a candidate was selected.Available policy commands
Available policy commands
Refresh the index after skill changes
When you add, remove, or change skills outsideskillspec install skill, the router index drifts. Use skillspec router index refresh to repair visibility controls and rebuild the index:
skillspec import-skill for prose-only packages.
Enable and disable
Disable preserves router files, config, index, and manifest — it only removes managed guard hooks, makes the router itself explicit-only, and restores routed skills to implicit/default visibility:skillspec status is read-only. It reports lifecycle state, scanned roots, index freshness, managed hook state, and SkillSpec-backed versus prose-only skills without mutating anything.