mot

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

MOT - System Health Check

MOT - 系统健康检查

Run comprehensive health checks on all Claude Code components.
对所有Claude Code组件运行全面的健康检查。

Usage

使用方法

/mot              # Full audit (all categories)
/mot skills       # Just skills
/mot agents       # Just agents
/mot hooks        # Just hooks
/mot memory       # Just memory system
/mot --fix        # Auto-fix simple issues
/mot --quick      # P0 checks only (fast)
/mot              # 完整审计(所有类别)
/mot skills       # 仅检查Skills
/mot agents       # 仅检查Agents
/mot hooks        # 仅检查Hooks
/mot memory       # 仅检查Memory系统
/mot --fix        # 自动修复简单问题
/mot --quick      # 仅运行P0检查(快速)

Audit Process

审计流程

Phase 1: Skills Audit

阶段1:Skills审计

bash
undefined
bash
undefined

Count skills

Count skills

echo "=== SKILLS ===" SKILL_COUNT=$(find .claude/skills -name "SKILL.md" | wc -l | xargs) echo "Found $SKILL_COUNT skill files"
echo "=== SKILLS ===" SKILL_COUNT=$(find .claude/skills -name "SKILL.md" | wc -l | xargs) echo "Found $SKILL_COUNT skill files"

Check frontmatter parsing

Check frontmatter parsing

FAIL=0 for skill in $(find .claude/skills -name "SKILL.md"); do if ! head -1 "$skill" | grep -q "^---$"; then echo "FAIL: No frontmatter: $skill" FAIL=$((FAIL+1)) fi done echo "Frontmatter: $((SKILL_COUNT - FAIL)) pass, $FAIL fail"
FAIL=0 for skill in $(find .claude/skills -name "SKILL.md"); do if ! head -1 "$skill" | grep -q "^---$"; then echo "FAIL: No frontmatter: $skill" FAIL=$((FAIL+1)) fi done echo "Frontmatter: $((SKILL_COUNT - FAIL)) pass, $FAIL fail"

Check name matches directory

Check name matches directory

FAIL=0 for skill in $(find .claude/skills -name "SKILL.md"); do dir=$(basename $(dirname "$skill")) name=$(grep "^name:" "$skill" 2>/dev/null | head -1 | cut -d: -f2 | xargs) if [ -n "$name" ] && [ "$dir" != "$name" ]; then echo "FAIL: Name mismatch $dir vs $name" FAIL=$((FAIL+1)) fi done echo "Name consistency: $((SKILL_COUNT - FAIL)) pass, $FAIL fail"
undefined
FAIL=0 for skill in $(find .claude/skills -name "SKILL.md"); do dir=$(basename $(dirname "$skill")) name=$(grep "^name:" "$skill" 2>/dev/null | head -1 | cut -d: -f2 | xargs) if [ -n "$name" ] && [ "$dir" != "$name" ]; then echo "FAIL: Name mismatch $dir vs $name" FAIL=$((FAIL+1)) fi done echo "Name consistency: $((SKILL_COUNT - FAIL)) pass, $FAIL fail"
undefined

Phase 2: Agents Audit

阶段2:Agents审计

bash
echo "=== AGENTS ==="
AGENT_COUNT=$(ls .claude/agents/*.md 2>/dev/null | wc -l | xargs)
echo "Found $AGENT_COUNT agent files"
bash
echo "=== AGENTS ==="
AGENT_COUNT=$(ls .claude/agents/*.md 2>/dev/null | wc -l | xargs)
echo "Found $AGENT_COUNT agent files"

Check required fields

Check required fields

FAIL=0 for agent in .claude/agents/*.md; do [ -f "$agent" ] || continue

Check name field exists

if ! grep -q "^name:" "$agent"; then echo "FAIL: Missing name: $agent" FAIL=$((FAIL+1)) continue fi

Check model is valid

model=$(grep "^model:" "$agent" | head -1 | cut -d: -f2 | xargs) case "$model" in opus|sonnet|haiku) ;; *) echo "FAIL: Invalid model '$model': $agent"; FAIL=$((FAIL+1)) ;; esac done echo "Agent validation: $((AGENT_COUNT - FAIL)) pass, $FAIL fail"
FAIL=0 for agent in .claude/agents/*.md; do [ -f "$agent" ] || continue

Check name field exists

if ! grep -q "^name:" "$agent"; then echo "FAIL: Missing name: $agent" FAIL=$((FAIL+1)) continue fi

Check model is valid

model=$(grep "^model:" "$agent" | head -1 | cut -d: -f2 | xargs) case "$model" in opus|sonnet|haiku) ;; *) echo "FAIL: Invalid model '$model': $agent"; FAIL=$((FAIL+1)) ;; esac done echo "Agent validation: $((AGENT_COUNT - FAIL)) pass, $FAIL fail"

Check for dangling references (agents that reference non-existent agents)

Check for dangling references (agents that reference non-existent agents)

echo "Checking agent cross-references..." for agent in .claude/agents/*.md; do [ -f "$agent" ] || continue

Find subagent_type references

refs=$(grep -oE 'subagent_type[=:]["''']([a-z-]+)' "$agent" 2>/dev/null | sed 's/.["''']//' | sed 's/["''']$//') for ref in $refs; do if [ ! -f ".claude/agents/$ref.md" ]; then echo "WARN: $agent references non-existent agent: $ref" fi done done
undefined
echo "Checking agent cross-references..." for agent in .claude/agents/*.md; do [ -f "$agent" ] || continue

Find subagent_type references

refs=$(grep -oE 'subagent_type[=:]["''']([a-z-]+)' "$agent" 2>/dev/null | sed 's/.["''']//' | sed 's/["''']$//') for ref in $refs; do if [ ! -f ".claude/agents/$ref.md" ]; then echo "WARN: $agent references non-existent agent: $ref" fi done done
undefined

Phase 3: Hooks Audit

阶段3:Hooks审计

bash
echo "=== HOOKS ==="
bash
echo "=== HOOKS ==="

Check TypeScript source count

Check TypeScript source count

TS_COUNT=$(ls .claude/hooks/src/*.ts 2>/dev/null | wc -l | xargs) echo "Found $TS_COUNT TypeScript source files"
TS_COUNT=$(ls .claude/hooks/src/*.ts 2>/dev/null | wc -l | xargs) echo "Found $TS_COUNT TypeScript source files"

Check bundles exist

Check bundles exist

BUNDLE_COUNT=$(ls .claude/hooks/dist/*.mjs 2>/dev/null | wc -l | xargs) echo "Found $BUNDLE_COUNT built bundles"
BUNDLE_COUNT=$(ls .claude/hooks/dist/*.mjs 2>/dev/null | wc -l | xargs) echo "Found $BUNDLE_COUNT built bundles"

Check shell wrappers are executable

Check shell wrappers are executable

FAIL=0 for sh in .claude/hooks/.sh; do [ -f "$sh" ] || continue if [ ! -x "$sh" ]; then echo "FAIL: Not executable: $sh" FAIL=$((FAIL+1)) fi done SH_COUNT=$(ls .claude/hooks/.sh 2>/dev/null | wc -l | xargs) echo "Shell wrappers: $((SH_COUNT - FAIL)) executable, $FAIL need chmod +x"
FAIL=0 for sh in .claude/hooks/.sh; do [ -f "$sh" ] || continue if [ ! -x "$sh" ]; then echo "FAIL: Not executable: $sh" FAIL=$((FAIL+1)) fi done SH_COUNT=$(ls .claude/hooks/.sh 2>/dev/null | wc -l | xargs) echo "Shell wrappers: $((SH_COUNT - FAIL)) executable, $FAIL need chmod +x"

Check hooks registered in settings.json exist

Check hooks registered in settings.json exist

echo "Checking registered hooks..." FAIL=0
echo "Checking registered hooks..." FAIL=0

Extract hook commands from settings.json and verify files exist

Extract hook commands from settings.json and verify files exist

grep -oE '"command":\s*"[^"].sh"' .claude/settings.json 2>/dev/null |
sed 's/.
"([^"].sh)"./\1/' |
sed 's|$CLAUDE_PROJECT_DIR|.claude|g' |
sed "s|$HOME|$HOME|g" |
sort -u | while read hook; do # Resolve to actual path resolved=$(echo "$hook" | sed 's|^./||') if [ ! -f "$resolved" ] && [ ! -f "./$resolved" ]; then echo "WARN: Registered hook not found: $hook" fi done
undefined
grep -oE '"command":\s*"[^"].sh"' .claude/settings.json 2>/dev/null |
sed 's/.
"([^"].sh)"./\1/' |
sed 's|$CLAUDE_PROJECT_DIR|.claude|g' |
sed "s|$HOME|$HOME|g" |
sort -u | while read hook; do # Resolve to actual path resolved=$(echo "$hook" | sed 's|^./||') if [ ! -f "$resolved" ] && [ ! -f "./$resolved" ]; then echo "WARN: Registered hook not found: $hook" fi done
undefined

Phase 4: Memory Audit

阶段4:Memory审计

bash
echo "=== MEMORY SYSTEM ==="
bash
echo "=== MEMORY SYSTEM ==="

Check DATABASE_URL

Check DATABASE_URL

if [ -z "$DATABASE_URL" ]; then echo "FAIL: DATABASE_URL not set" else echo "PASS: DATABASE_URL is set"

Test connection

if psql "$DATABASE_URL" -c "SELECT 1" > /dev/null 2>&1; then echo "PASS: PostgreSQL reachable"
# Check pgvector
if psql "$DATABASE_URL" -c "SELECT extname FROM pg_extension WHERE extname='vector'" 2>/dev/null | grep -q vector; then
  echo "PASS: pgvector extension installed"
else
  echo "FAIL: pgvector extension not installed"
fi

# Check table exists
if psql "$DATABASE_URL" -c "\d archival_memory" > /dev/null 2>&1; then
  echo "PASS: archival_memory table exists"

  # Count learnings
  COUNT=$(psql "$DATABASE_URL" -t -c "SELECT COUNT(*) FROM archival_memory" 2>/dev/null | xargs)
  echo "INFO: $COUNT learnings stored"
else
  echo "FAIL: archival_memory table missing"
fi
else echo "FAIL: PostgreSQL not reachable" fi fi
if [ -z "$DATABASE_URL" ]; then echo "FAIL: DATABASE_URL not set" else echo "PASS: DATABASE_URL is set"

Test connection

if psql "$DATABASE_URL" -c "SELECT 1" > /dev/null 2>&1; then echo "PASS: PostgreSQL reachable"
# Check pgvector
if psql "$DATABASE_URL" -c "SELECT extname FROM pg_extension WHERE extname='vector'" 2>/dev/null | grep -q vector; then
  echo "PASS: pgvector extension installed"
else
  echo "FAIL: pgvector extension not installed"
fi

# Check table exists
if psql "$DATABASE_URL" -c "\d archival_memory" > /dev/null 2>&1; then
  echo "PASS: archival_memory table exists"

  # Count learnings
  COUNT=$(psql "$DATABASE_URL" -t -c "SELECT COUNT(*) FROM archival_memory" 2>/dev/null | xargs)
  echo "INFO: $COUNT learnings stored"
else
  echo "FAIL: archival_memory table missing"
fi
else echo "FAIL: PostgreSQL not reachable" fi fi

Check Python dependencies

Check Python dependencies

echo "Checking Python dependencies..." (cd opc && uv run python -c "import psycopg2; import pgvector; import sentence_transformers" 2>/dev/null) &&
echo "PASS: Python dependencies available" ||
echo "WARN: Some Python dependencies missing"
undefined
echo "Checking Python dependencies..." (cd opc && uv run python -c "import psycopg2; import pgvector; import sentence_transformers" 2>/dev/null) &&
echo "PASS: Python dependencies available" ||
echo "WARN: Some Python dependencies missing"
undefined

Phase 5: Cross-Reference Audit

阶段5:交叉引用审计

bash
echo "=== CROSS-REFERENCES ==="
bash
echo "=== CROSS-REFERENCES ==="

Check skills reference valid agents

Check skills reference valid agents

echo "Checking skill → agent references..." FAIL=0 for skill in $(find .claude/skills -name "SKILL.md"); do refs=$(grep -oE 'subagent_type[=:]["''']([a-z-]+)' "$skill" 2>/dev/null | sed 's/.["''']//' | sed 's/["''']$//') for ref in $refs; do if [ -n "$ref" ] && [ ! -f ".claude/agents/$ref.md" ]; then echo "FAIL: $skill references missing agent: $ref" FAIL=$((FAIL+1)) fi done done echo "Skill→Agent refs: $FAIL broken"
undefined
echo "Checking skill → agent references..." FAIL=0 for skill in $(find .claude/skills -name "SKILL.md"); do refs=$(grep -oE 'subagent_type[=:]["''']([a-z-]+)' "$skill" 2>/dev/null | sed 's/.["''']//' | sed 's/["''']$//') for ref in $refs; do if [ -n "$ref" ] && [ ! -f ".claude/agents/$ref.md" ]; then echo "FAIL: $skill references missing agent: $ref" FAIL=$((FAIL+1)) fi done done echo "Skill→Agent refs: $FAIL broken"
undefined

Auto-Fix (--fix flag)

自动修复(--fix参数)

If
--fix
is specified, automatically fix:
  1. Make shell wrappers executable
    bash
    chmod +x .claude/hooks/*.sh
  2. Rebuild hooks if TypeScript newer than bundles
    bash
    cd .claude/hooks && npm run build
  3. Create missing cache directories
    bash
    mkdir -p .claude/cache/agents/{scout,kraken,oracle,spark}
    mkdir -p .claude/cache/mot
如果指定了
--fix
参数,将自动修复以下问题:
  1. 设置Shell包装器为可执行权限
    bash
    chmod +x .claude/hooks/*.sh
  2. 若TypeScript源码比打包文件新,则重新构建Hooks
    bash
    cd .claude/hooks && npm run build
  3. 创建缺失的缓存目录
    bash
    mkdir -p .claude/cache/agents/{scout,kraken,oracle,spark}
    mkdir -p .claude/cache/mot

Output Format

输出格式

Write full report to
.claude/cache/mot/report-{timestamp}.md
:
markdown
undefined
将完整报告写入
.claude/cache/mot/report-{timestamp}.md
markdown
undefined

MOT Health Report

MOT 健康报告

Generated: {timestamp}
生成时间:{timestamp}

Summary

摘要

CategoryPassFailWarn
Skills20420
Agents4713
Hooks5821
Memory401
X-Refs002
类别通过失败警告
Skills20420
Agents4713
Hooks5821
Memory401
交叉引用002

Issues Found

发现的问题

P0 - Critical

P0 - 严重

  • [FAIL] Hook build failed: tldr-context-inject.ts
  • [FAIL] Hook构建失败:tldr-context-inject.ts

P1 - High

P1 - 高优先级

  • [FAIL] Agent references missing: scot → scout (typo)
  • [FAIL] Agent引用缺失:scot → scout(拼写错误)

P2 - Medium

P2 - 中优先级

  • [WARN] 3 hooks need rebuild (dist older than src)
  • [WARN] 3个Hooks需要重新构建(dist文件比src文件旧)

P3 - Low

P3 - 低优先级

  • [INFO] VOYAGE_API_KEY not set (using local BGE)
undefined
  • [INFO] 未设置VOYAGE_API_KEY(使用本地BGE模型)
undefined

Exit Codes

退出码

  • 0
    - All P0/P1 checks pass
  • 1
    - Any P0/P1 failure
  • 2
    - Only P2/P3 warnings
  • 0
    - 所有P0/P1检查通过
  • 1
    - 存在任意P0/P1失败项
  • 2
    - 仅存在P2/P3警告项

Quick Mode (--quick)

快速模式(--quick)

Only run P0 checks:
  1. Frontmatter parses
  2. Hooks build
  3. Shell wrappers executable
  4. PostgreSQL reachable
仅运行P0检查:
  1. 前置元数据可正常解析
  2. Hooks构建正常
  3. Shell包装器可执行
  4. PostgreSQL可连接