9thlevelsoftware/legion/intent-router

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Interprets --just-* and --skip-* command flags for /legion:build and /legion:review, validates flag combinations against rules, and resolves the matching team template from intent-teams.yaml. Use when the user passes intent flags to build or review commands, asks about flag combinations, or needs to filter agent teams by intent.

Install

npx vskill@latest install 9thlevelsoftware/legion/intent-router

SKILL.md

Intent Router

Interprets semantic intent flags (--just-* and --skip-*) to route execution to specific agent teams and filter criteria. Validates flag combinations, resolves templates from intent-teams.yaml, and produces execution instructions.

Used by /legion:build and /legion:review when intent flags are present.


Section 1: Intent Flag Parsing

Extract and normalize intent flags from command arguments.

parseIntentFlags(arguments)
javascript
/**
* Parse intent flags from command arguments
* @param {string[]} args - Command arguments (e.g., ['--just-harden', '--skip-frontend'])
* @returns {Object} Normalized intent configuration
*
* Returns:
* {
* rawFlags: ['--just-harden', '--skip-frontend'],
* intents: ['harden'],
* filters: {
* skipFrontend: true,
* skipBackend: false
* },
* primaryIntent: 'harden',
* hasConflicts: false
* }
*/

Supported Flags:

FlagIntentDescription
--just-hardenhardenSecurity audit mode
--just-documentdocumentDocumentation-only mode
--just-securitysecurity-onlySecurity review mode (review command only)
--skip-frontendskip-frontendExclude frontend/UI tasks
--skip-backendskip-backendExclude backend/API tasks

Parsing Rules:

  1. Equals syntax supported: --just-harden=true or --just-harden
  2. Multiple --just-* flags detected: Flag as conflict (only one primary intent allowed)
  3. Case insensitive: --JUST-HARDEN normalizes to --just-harden
  4. Unknown flags fail fast (strict validation — no silent warning):
  • The authoritative set of valid flags is .planning/config/intent-teams.yaml under intents.* keys (plus the global flags listed in this section's Supported Flags table).
  • If an arg begins with -- and is not in that set:
  • Emit a VALIDATION error, halt the command.
  • Suggest the closest valid flag using a Levenshtein distance ≤ 2 against the union of declared intent flag names. Format: Unknown flag: --just-hardne. Did you mean --just-harden?
  • If no candidate is within distance 2: list the full valid-flag set and exit.
  • Escape hatch: --unsafe-unknown-flags opts into permissive mode (emit an INFO log for each unknown flag and continue). This flag MUST be passed explicitly — it is never the default.
  • Rationale: silent-drop of a typo flag (e.g., --just-hardne → build proceeds without hardening) has been the observed failure mode. Fail fast unless the user has explicitly asked for forward-compat behavior.
  • Cross-reference: validateFlagCombination in Section 2 follows the same fail-fast contract.
  1. Duplicate flags: Deduplicate, use first occurrence

Implementation:

javascript
function parseIntentFlags(args) {
const result = {
rawFlags: [],
intents: [],
filters: {
skipFrontend: false,
skipBackend: false
},
primaryIntent: null,
hasConflicts: false
};
const seenFlags = new Set();
for (const arg of args) {
const flag = arg.toLowerCase().split('=')[0];
if (seenFlags.has(flag)) continue;
seenFlags.add(flag);
switch (flag) {
case '--just-harden':
result.rawFlags.push(flag);
result.intents.push('harden');
result.primaryIntent = 'harden';
break;
case '--just-document':
result.rawFlags.push(flag);
result.intents.push('document');
result.primaryIntent = 'document';
break;
case '--just-security':
result.rawFlags.push(flag);
result.intents.push('security-only');
result.primaryIntent = 'security-only';
break;
case '--skip-frontend':
result.rawFlags.push(flag);
result.filters.skipFrontend = true;
break;
case '--skip-backend':
result.rawFlags.push(flag);
result.filters.skipBackend = true;
break;
default:
if (flag.startsWith('--just-') || flag.startsWith('--skip-')) {
console.warn(`Unknown intent flag: ${arg}`);
}
}
}
// Detect conflicts
if (result.intents.length > 1) {
result.hasConflicts = true;
}
return result;
}

Section 2: Validation Engine

Validate flag combinations against rules from intent-teams.yaml.

validateFlagCombination(intents, command)
javascript
/**
* Validate intent flags against combination rules
* @param {Object} intents - Output from parseIntentFlags()
* @param {string} command - Command context ('build', 'review', 'plan', etc.)
* @returns {Object} Validation result with errors and suggestions
*
* Returns:
* {
* valid: false,
* errors: ['Cannot use --just-harden and --just-document together'],
* suggestions: ['Use --just-harden alone for security audit']
* }
*/

Validation Rules (from intent-teams.yaml):

  1. Mutual Exclusion: Certain flags cannot be combined
  2. Command Context: Some flags only valid for specific commands
  3. Redundancy Detection: Flag combinations that make no sense
  4. Empty Result Detection: Flags that would result in no work

Implementation:

javascript
function validateFlagCombination(intents, command) {
const errors = [];
const suggestions = [];
// Load validation rules from intent-teams.yaml
const rules = loadValidationRules();
// Check mutual exclusion
for (const rule of rules.mutual_exclusion) {
const hasAllFlags = rule.flags.every(flag =>
intents.intents.includes(flag) ||
(flag === 'skip-frontend' && intents.filters.skipFrontend) ||
(flag === 'skip-backend' && intents.filters.skipBackend)
);
if (hasAllFlags) {
errors.push(rule.error);
if (rule.flags.length === 2) {
suggestions.push(`Use only --${rule.flags[0].replace('_', '-')} for this operation`);
}
}
}
// Check command context
for (const rule of rules.requires_command) {
if (intents.intents.includes(rule.flag)) {
if (!rule.commands.includes(command)) {
errors.push(`${rule.error} (used with ${command})`);
if (rule.commands.length === 1) {
suggestions.push(`Use /legion:${rule.commands[0]} instead`);
}
}
}
}
// Check skip-frontend + skip-backend = nothing to build
if (intents.filters.skipFrontend && intents.filters.skipBackend) {
errors.push('Cannot skip both frontend and backend — nothing to build.');
suggestions.push('Remove one skip flag to proceed');
}
// Check document + skip-frontend redundancy
if (intents.intents.includes('document') && intents.filters.skipFrontend) {
errors.push('--just-document already excludes implementation; --skip-frontend is redundant.');
suggestions.push('Use --just-document alone');
}
return {
valid: errors.length === 0,
errors,
suggestions
};
}
Error Message Format
❌ Intent Validation Failed
Errors:
1. Cannot use --just-harden and --just-document together. Choose one intent.
2. --just-harden is only valid for /legion:build (used with review)
Suggestions:
- Use only --just-harden for this operation
- Use /legion:build instead

Section 3: Team Template Resolution

Load and resolve team templates from intent-teams.yaml.

loadIntentTeams()
javascript
/**
* Load and cache intent-teams.yaml configuration
* @returns {Object} Parsed configuration with intents and validation rules
*/
function loadIntentTeams() {
// Preconditions (verified in order):
// 1. Read .planning/config/intent-teams.yaml explicitly via fs.readFileSync.
// 2. ENOENT → graceful degradation (empty config, routing disabled). Intent routing is optional.
// 3. Other read error (EACCES, EISDIR, permission) → emit <escalation severity="blocker" type="infrastructure"> and degrade.
// 4. YAML parse failure → emit <escalation severity="warning" type="infrastructure"> and degrade.
// 5. Schema validation failure → log warning; do NOT block (partial config is acceptable).
const configPath = '.planning/config/intent-teams.yaml';
const emptyConfig = {
intents: {},
nl_patterns: {},
command_routes: {},
context_rules: {}
};
let content;
try {
content = fs.readFileSync(configPath, 'utf8');
} catch (err) {
if (err.code === 'ENOENT') {
// Graceful degradation: no intent config → return empty structure
console.warn(`intent-router: ${configPath} not found. Intent routing disabled.`);
return emptyConfig;
}
// Unexpected I/O error — log and degrade
console.warn(`intent-router: failed to read ${configPath}: ${err.message}. Intent routing disabled.`);
return emptyConfig;
}
let parsed;
try {
parsed = parseYaml(content);
} catch (err) {
console.warn(`intent-router: failed to parse ${configPath}: ${err.message}. Intent routing disabled.`);
return emptyConfig;
}
// Schema validation (if schema file present)
const schemaPath = '.planning/config/intent-teams.schema.json';
try {
if (fs.existsSync(schemaPath)) {
const schema = JSON.parse(fs.readFileSync(schemaPath, 'utf8'));
const validation = validateAgainstSchema(parsed, schema);
if (!validation.valid) {
console.warn(`intent-router: ${configPath} failed schema validation: ${validation.errors.join('; ')}. Using subset that passed.`);
// Return what we have, preserving top-level keys; downstream code must handle gaps.
}
}
} catch (err) {
console.warn(`intent-router: schema validation error: ${err.message}. Continuing with unvalidated config.`);
}
// Ensure top-level keys exist even if YAML omitted them
return {
intents: parsed.intents || {},
nl_patterns: parsed.nl_patterns || {},
command_routes: parsed.command_routes || {},
context_rules: parsed.context_rules || {}
};
}
resolveTeamTemplate(intentName)
javascript
/**
* Resolve team template for an intent
* @param {string} intentName - Intent name (e.g., 'harden', 'document')
* @returns {Object} Team configuration
*
* Returns:
* {
* intent: 'harden',
* description: 'Security audit with Testing + Security divisions',
* mode: 'ad_hoc',
* agents: {
* primary: ['testing-qa-verification-specialist', 'engineering-security-engineer'],
* secondary: ['testing-api-tester', 'testing-qa-verification-specialist']
* },
* domains: ['security', 'owasp', 'stride', 'vulnerability-assessment']
* }
*/
function resolveTeamTemplate(intentName) {
const config = loadIntentTeams();
const intent = config.intents[intentName];
if (!intent) {
throw new Error(`Unknown intent: ${intentName}`);
}
return {
intent: intentName,
description: intent.description,
mode: intent.mode,
agents: intent.agents || { primary: [], secondary: [] },
domains: intent.domains || [],
filters: intent.filter || null
};
}
resolveFilterCriteria(intentName)
javascript
/**
* Get filter predicates for filter_plans or filter_review mode
* @param {string} intentName - Intent name
* @returns {Object} Filter configuration
*
* Returns:
* {
* includeTaskTypes: ['security-audit', 'vulnerability-scan'],
* excludeTaskTypes: ['feature-implementation'],
* excludeAgents: ['engineering-frontend-developer'],
* excludeFilePatterns: ['*.tsx', 'src/frontend/**']
* }
*/
function resolveFilterCriteria(intentName) {
const config = loadIntentTeams();
const intent = config.intents[intentName];
if (!intent || !intent.filter) {
return null;
}
return {
includeTaskTypes: intent.filter.include_task_types || [],
excludeTaskTypes: intent.filter.exclude_task_types || [],
excludeAgents: intent.filter.exclude_agents || [],
excludeFilePatterns: intent.filter.exclude_file_patterns || []
};
}
mapDomainsToAgents(domains)

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
62
Repository forks
7
7-day trend score
21

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/9thlevelsoftware/legion/intent-router/badge)](https://verified-skill.com/skills/9thlevelsoftware/legion/intent-router)

Something wrong with this skill or its page? Tell us.