/kmgraph:kmg-init-shared:kmg-ai-model-tier-resolverfrom kmgraph
Resolves a requested model tier or legacy model name to a concrete model via me.md tier mappings, with alias backward compatibility and platform detection.
Claude never picks this command on its own
Its frontmatter has no description. Without a description, Claude Code leaves it out of the list Claude chooses from. Typing /kmgraph:kmg-init-shared:kmg-ai-model-tier-resolver still runs it.
Caller sets these variables before invoking this module:
| Variable | Description |
|---|---|
$requested_tier | A tier label (fast-tier, standard-tier, powerful-tier) or a legacy model name (e.g., Haiku, claude-sonnet-4-6) |
{KG_PATH} | Active KG path (for me.md lookup) |
Check if $requested_tier is a legacy model name rather than a tier label.
Valid tier labels (pass through to R-2 unchanged):
fast-tierstandard-tierpowerful-tierAlias map (match case-insensitively):
| Legacy name pattern | Resolves to |
|---|---|
Haiku, haiku, claude-haiku-* | fast-tier |
Sonnet, sonnet, claude-sonnet-* | standard-tier |
Opus, opus, claude-opus-* | powerful-tier |
Gemini Flash, flash-*, gemini-flash-* | fast-tier |
Gemini Pro, pro-*, gemini-pro-* | standard-tier |
Gemini Ultra, Ultra, ultra-*, gemini-ultra-* | powerful-tier |
If alias matched:
Resolve $requested_tier → tier label (e.g., Haiku → fast-tier)
Emit this message once per day (tracked via /tmp/.kg-tier-alias-warned-$(date +%Y-%m-%d) — one flag file per calendar day; multiple sessions on the same day suppress after the first):
⚠️ Model name
[legacy_name]is deprecated — use tier label[resolved_tier]instead. Update yourme.mdtier_map or dispatcher invocation. Aliases will be removed in v0.6.0.
Continue to R-2 with the resolved tier label.
If no alias matched and $requested_tier is not a valid tier label:
Halt with:
"Unknown tier or model name:
[$requested_tier]. Usefast-tier,standard-tier, orpowerful-tier. Run/kmgraph:kmg-initto configure tier mappings."
Read me.md YAML frontmatter in this order (project overrides user on conflict):
~/.kmgraph/me.md{KG_PATH}/me.md (override layer)Identify the active platform:
claudegeminiollamalm-studio$CLAUDE_CODE_VERSION, $GEMINI_VERSION, etc. (same as init walkthrough)Find the platform entry in platforms[] matching the active platform name.
If no platforms[] block found in either me.md:
Halt with:
"No tier mappings configured. Run
/kmgraph:kmg-init(or/kmgraph:upgrade) to set up tier mappings for your platform."
If active platform not found in platforms[]:
Halt with:
"No tier mapping for platform
[platform_name]. Run/kmgraph:kmg-initto add it."
Look up tier_map[$requested_tier] in the platform entry.
Store result as $mapped_value.
If $mapped_value is non-empty: Continue to R-4 (validation).
If $mapped_value is empty or absent: Apply collapse chain (R-3C).
Direction: downward only. Starting from $requested_tier, try progressively cheaper tiers. Never upgrade (never try a higher tier than what was requested).
If $requested_tier is | Try fallbacks in order |
|---|---|
powerful-tier | standard-tier → fast-tier |
standard-tier | fast-tier only |
fast-tier | (none — halt immediately if empty) |
For each fallback tier:
tier_map[$fallback_tier][$requested_tier] not configured — falling back to [$fallback_tier]." Then set $mapped_value and continue to R-4.If all three tiers are empty:
Halt with:
"No model available. Run
/kmgraph:kmg-initto configure tier mappings."
This gate fires only here — never from file scanning, frontmatter inspection, or grep over arbitrary files.
Validate $mapped_value by applying these checks in order. Fail on the first match:
$mapped_value is fast-tier, standard-tier, or powerful-tier → suspicious (tier label used as model value).$mapped_value case-insensitively matches any key in the R-1 alias map (e.g., Haiku, Sonnet, Opus, Flash, Ultra) → suspicious (alias used as model value).$mapped_value contains no hyphen (-), colon (:), or numeric suffix → suspicious (bare word with no version or type separator).A value that passes all three checks is treated as a valid model ID (e.g., claude-sonnet-4-6, llama3.1:8b, gemini-pro-1.5).
If any check triggers (value is suspicious):
Emit once per day (tracked via /tmp/.kg-model-suspicious-$(date +%Y-%m-%d)):
⚠️ Tier
[$requested_tier]maps to[$mapped_value]which may not be a valid model ID. Check yourme.mdtier_map. Continuing anyway — invocation may fail.
Do NOT halt. Continue with $mapped_value as-is so the user sees the downstream error rather than a silent block.
On success: $resolved_model = $mapped_value
Caller passes this to the subagent:
--model [$resolved_model]
| Condition | Action |
|---|---|
| Unknown tier label, no alias match | Halt with actionable message |
| No platforms[] in me.md | Halt with actionable message |
| Active platform missing from platforms[] | Halt with actionable message |
| All tiers empty (collapse exhausted) | Halt with actionable message |
| Suspicious model ID (validation gate) | Warn once, continue |
| Legacy alias used | Warn once (deprecation), continue |
What the command file sets; muted values are Claude Code's defaults
7-day visitors to each command page
31 commands in this plugin
/kmg-add-category/kmgraph:kmg-add-category — Add Category to Knowledge GraphAdd a new category to the active knowledge graph with optional custom prefix and git strategy./kmg-backfillBackfill Knowledge Graph from Existing Content<!-- Created: 2026-09-04 (ADR-071) -->/kmg-capture-lessonDocument Lessons Learned**Version:** 2.0 (Updated: 2026-03-27)/kmg-check-sensitive/kmgraph:kmg-check-sensitive — Scan for Sensitive DataScan the knowledge graph resolved from the current directory for potentially sensitive information, using regex patterns from config or defaults./kmg-config-sanitization/kmgraph:kmg-config-sanitization — Setup Sanitization HooksInteractive wizard to help users set up pre-commit hooks that scan for potentially sensitive information before committing knowledge graph entries./kmg-create-adrCreate Architecture Decision Record**Purpose:** Create a new Architecture Decision Record (ADR) using the knowledge graph resolved from the current directory. Auto-fills git metadata, auto-increments the ADR number, prompts for decision content, and updates the decisions index.npx claudepluginhub technomensch/knowledge-graph --plugin kmgraph