rust-router

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese


Rust Question Router

Rust问题路由工具

Version: 2.0.0 | Last Updated: 2025-01-22
v2.0: Context optimized - detailed examples moved to sub-files
版本: 2.0.0 | 最后更新: 2025-01-22
v2.0: 上下文优化 - 详细示例已移至子文件

Meta-Cognition Framework

元认知框架

Core Principle

核心原则

Don't answer directly. Trace through the cognitive layers first.
Layer 3: Domain Constraints (WHY)
├── Business rules, regulatory requirements
├── domain-fintech, domain-web, domain-cli, etc.
└── "Why is it designed this way?"

Layer 2: Design Choices (WHAT)
├── Architecture patterns, DDD concepts
├── m09-m15 skills
└── "What pattern should I use?"

Layer 1: Language Mechanics (HOW)
├── Ownership, borrowing, lifetimes, traits
├── m01-m07 skills
└── "How do I implement this in Rust?"
不要直接回答问题。先追溯认知层级。
Layer 3: 领域约束(WHY)
├── 业务规则、监管要求
├── domain-fintech, domain-web, domain-cli, etc.
└── "为什么要这样设计?"

Layer 2: 设计选择(WHAT)
├── 架构模式、DDD概念
├── m09-m15 skills
└── "我应该使用什么模式?"

Layer 1: 语言机制(HOW)
├── 所有权、借用、生命周期、trait
├── m01-m07 skills
└── "如何用Rust实现这个功能?"

Routing by Entry Point

按入口点路由

User SignalEntry LayerDirectionFirst Skill
E0xxx errorLayer 1Trace UP ↑m01-m07
Compile errorLayer 1Trace UP ↑Error table below
"How to design..."Layer 2Check L3, then DOWN ↓m09-domain
"Building [domain] app"Layer 3Trace DOWN ↓domain-*
"Best practice..."Layer 2Both directionsm09-m15
Performance issueLayer 1 → 2UP then DOWNm10-performance
用户信号入口层级方向首个技能
E0xxx错误Layer 1向上追溯 ↑m01-m07
编译错误Layer 1向上追溯 ↑下方错误表
"如何设计..."Layer 2检查L3,然后向下 ↓m09-domain
"构建[领域]应用"Layer 3向下追溯 ↓domain-*
"最佳实践..."Layer 2双向追溯m09-m15
性能问题Layer 1 → 2先上后下m10-performance

CRITICAL: Dual-Skill Loading

重要提示:双技能加载

When domain keywords are present, you MUST load BOTH skills:
Domain KeywordsL1 SkillL3 Skill
Web API, HTTP, axum, handlerm07-concurrencydomain-web
交易, 支付, trading, paymentm01-ownershipdomain-fintech
CLI, terminal, clapm07-concurrencydomain-cli
kubernetes, grpc, microservicem07-concurrencydomain-cloud-native
embedded, no_std, MCUm02-resourcedomain-embedded

当存在领域关键词时,必须同时加载两个技能:
领域关键词L1技能L3技能
Web API、HTTP、axum、handlerm07-concurrencydomain-web
交易、支付、trading、paymentm01-ownershipdomain-fintech
CLI、terminal、clapm07-concurrencydomain-cli
kubernetes、grpc、microservicem07-concurrencydomain-cloud-native
embedded、no_std、MCUm02-resourcedomain-embedded

INSTRUCTIONS FOR CLAUDE

给Claude的指令

CRITICAL: Negotiation Protocol Trigger

重要提示:协商协议触发条件

BEFORE answering, check if negotiation is required:
Query ContainsAction
"比较", "对比", "compare", "vs", "versus"MUST use negotiation
"最佳实践", "best practice"MUST use negotiation
Domain + error (e.g., "交易系统 E0382")MUST use negotiation
Ambiguous scope (e.g., "tokio 性能")SHOULD use negotiation
When negotiation is required, include:
markdown
undefined
回答前,检查是否需要启动协商:
查询包含内容操作
"比较"、"对比"、"compare"、"vs"、"versus"必须使用协商机制
"最佳实践"、"best practice"必须使用协商机制
领域+错误(例如:"交易系统 E0382")必须使用协商机制
模糊范围(例如:"tokio 性能")建议使用协商机制
当需要协商时,需包含以下内容:
markdown
undefined

Negotiation Analysis

协商分析

Query Type: [Comparative | Cross-domain | Synthesis | Ambiguous] Negotiation: Enabled
查询类型: [对比型 | 跨领域 | 综合型 | 模糊型] 协商: 已启用

Source: [Agent/Skill Name]

来源: [Agent/技能名称]

Confidence: HIGH | MEDIUM | LOW | UNCERTAIN Gaps: [What's missing]
置信度: 高 | 中 | 低 | 不确定 缺口: [缺失的信息]

Synthesized Answer

综合答案

[Answer]
Overall Confidence: [Level] Disclosed Gaps: [Gaps user should know]

> **详细协议见:** `patterns/negotiation.md`

---
[回答内容]
整体置信度: [等级] 已披露缺口: [用户需要了解的信息缺口]

> **详细协议见:** `patterns/negotiation.md`

---

Default Project Settings

默认项目设置

When creating new Rust projects or Cargo.toml files, ALWAYS use:
toml
[package]
edition = "2024"  # ALWAYS use latest stable edition
rust-version = "1.85"

[lints.rust]
unsafe_code = "warn"

[lints.clippy]
all = "warn"
pedantic = "warn"

创建新Rust项目或Cargo.toml文件时,始终使用以下配置:
toml
[package]
edition = "2024"  # 始终使用最新稳定版
rust-version = "1.85"

[lints.rust]
unsafe_code = "warn"

[lints.clippy]
all = "warn"
pedantic = "warn"

Layer 1 Skills (Language Mechanics)

Layer 1技能(语言机制)

PatternRoute To
move, borrow, lifetime, E0382, E0597m01-ownership
Box, Rc, Arc, RefCell, Cellm02-resource
mut, interior mutability, E0499, E0502, E0596m03-mutability
generic, trait, inline, monomorphizationm04-zero-cost
type state, phantom, newtypem05-type-driven
Result, Error, panic, ?, anyhow, thiserrorm06-error-handling
Send, Sync, thread, async, channelm07-concurrency
unsafe, FFI, extern, raw pointer, transmuteunsafe-checker
模式路由至
move、borrow、lifetime、E0382、E0597m01-ownership
Box、Rc、Arc、RefCell、Cellm02-resource
mut、内部可变性、E0499、E0502、E0596m03-mutability
泛型、trait、内联、单态化m04-zero-cost
类型状态、phantom、newtypem05-type-driven
Result、Error、panic、?、anyhow、thiserrorm06-error-handling
Send、Sync、线程、async、channelm07-concurrency
unsafe、FFI、extern、裸指针、transmuteunsafe-checker

Layer 2 Skills (Design Choices)

Layer 2技能(设计选择)

PatternRoute To
domain model, business logicm09-domain
performance, optimization, benchmarkm10-performance
integration, interop, bindingsm11-ecosystem
resource lifecycle, RAII, Dropm12-lifecycle
domain error, recovery strategym13-domain-error
mental model, how to thinkm14-mental-model
anti-pattern, common mistake, pitfallm15-anti-pattern
模式路由至
领域模型、业务逻辑m09-domain
性能、优化、基准测试m10-performance
集成、互操作、绑定m11-ecosystem
资源生命周期、RAII、Dropm12-lifecycle
领域错误、恢复策略m13-domain-error
心智模型、思考方式m14-mental-model
反模式、常见错误、陷阱m15-anti-pattern

Layer 3 Skills (Domain Constraints)

Layer 3技能(领域约束)

Domain KeywordsRoute To
fintech, trading, decimal, currencydomain-fintech
ml, tensor, model, inferencedomain-ml
kubernetes, docker, grpc, microservicedomain-cloud-native
embedded, sensor, mqtt, iotdomain-iot
web server, HTTP, REST, axum, actixdomain-web
CLI, command line, clap, terminaldomain-cli
no_std, microcontroller, firmwaredomain-embedded

领域关键词路由至
fintech、trading、decimal、currencydomain-fintech
ml、tensor、model、inferencedomain-ml
kubernetes、docker、grpc、microservicedomain-cloud-native
embedded、sensor、mqtt、iotdomain-iot
web server、HTTP、REST、axum、actixdomain-web
CLI、command line、clap、terminaldomain-cli
no_std、microcontroller、firmwaredomain-embedded

Error Code Routing

错误码路由

Error CodeRoute ToCommon Cause
E0382m01-ownershipUse of moved value
E0597m01-ownershipLifetime too short
E0506m01-ownershipCannot assign to borrowed
E0507m01-ownershipCannot move out of borrowed
E0515m01-ownershipReturn local reference
E0716m01-ownershipTemporary value dropped
E0106m01-ownershipMissing lifetime specifier
E0596m03-mutabilityCannot borrow as mutable
E0499m03-mutabilityMultiple mutable borrows
E0502m03-mutabilityBorrow conflict
E0277m04/m07Trait bound not satisfied
E0308m04-zero-costType mismatch
E0599m04-zero-costNo method found
E0038m04-zero-costTrait not object-safe
E0433m11-ecosystemCannot find crate/module

错误码路由至常见原因
E0382m01-ownership使用了已移动的值
E0597m01-ownership生命周期过短
E0506m01-ownership无法赋值给借用的变量
E0507m01-ownership无法从借用的变量中移出值
E0515m01-ownership返回局部引用
E0716m01-ownership临时值已被丢弃
E0106m01-ownership缺失生命周期标注
E0596m03-mutability无法可变借用
E0499m03-mutability多次可变借用
E0502m03-mutability借用冲突
E0277m04/m07trait约束未满足
E0308m04-zero-cost类型不匹配
E0599m04-zero-cost未找到方法
E0038m04-zero-costtrait不支持对象安全
E0433m11-ecosystem无法找到crate/模块

Functional Routing Table

功能路由表

PatternRoute ToAction
latest version, what's newrust-learnerUse agents
API, docs, documentationdocs-researcherUse agent
code style, naming, clippycoding-guidelinesRead skill
unsafe code, FFIunsafe-checkerRead skill
code reviewos-checkerSee
integrations/os-checker.md

模式路由至操作
最新版本、新特性rust-learner使用agents
API、文档、documentationdocs-researcher使用agent
代码风格、命名、clippycoding-guidelines阅读技能文档
unsafe代码、FFIunsafe-checker阅读技能文档
代码审查os-checker查看
integrations/os-checker.md

Priority Order

优先级顺序

  1. Identify cognitive layer (L1/L2/L3)
  2. Load entry skill (m0x/m1x/domain)
  3. Trace through layers (UP or DOWN)
  4. Cross-reference skills as indicated in "Trace" sections
  5. Answer with reasoning chain
  1. 识别认知层级(L1/L2/L3)
  2. 加载入口技能(m0x/m1x/领域技能)
  3. 追溯层级(向上或向下)
  4. 交叉引用技能 如"追溯"部分所示
  5. 附带推理链进行回答

Keyword Conflict Resolution

关键词冲突解决

KeywordResolution
unsafe
unsafe-checker (more specific than m11)
error
m06 for general, m13 for domain-specific
RAII
m12 for design, m01 for implementation
crate
rust-learner for version, m11 for integration
tokio
tokio-* for API, m07 for concepts
Priority Hierarchy:
1. Error codes (E0xxx) → Direct lookup, highest priority
2. Negotiation triggers (compare, vs, best practice) → Enable negotiation
3. Domain keywords + error → Load BOTH domain + error skills
4. Specific crate keywords → Route to crate-specific skill if exists
5. General concept keywords → Route to meta-question skill

关键词解决方式
unsafe
unsafe-checker(比m11更具体)
error
通用错误用m06,领域特定错误用m13
RAII
设计层面用m12,实现层面用m01
crate
版本相关用rust-learner,集成相关用m11
tokio
API相关用tokio-*,概念相关用m07
优先级层级:
1. 错误码(E0xxx)→ 直接查找,优先级最高
2. 协商触发词(compare、vs、best practice)→ 启用协商
3. 领域关键词+错误 → 同时加载领域和错误技能
4. 特定crate关键词 → 若存在对应技能则路由至该技能
5. 通用概念关键词 → 路由至元问题技能

Sub-Files Reference

子文件参考

FileContent
patterns/negotiation.md
Negotiation protocol details
examples/workflow.md
Workflow examples
integrations/os-checker.md
OS-Checker integration
文件内容
patterns/negotiation.md
协商协议详细内容
examples/workflow.md
工作流示例
integrations/os-checker.md
OS-Checker集成说明