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: 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?"

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错误L1向上追溯 ↑m01-m07
编译错误L1向上追溯 ↑下方错误表
"如何设计..."L2检查L3后向下追溯 ↓m09-domain
"构建[领域]应用"L3向下追溯 ↓domain-*
"最佳实践..."L2双向追溯m09-m15
性能问题L1 → 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"  # ALWAYS use latest stable edition
rust-version = "1.85"

[lints.rust]
unsafe_code = "warn"

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

Layer 1 Skills (Language Mechanics)

L1技能(语言机制)

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, 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

Layer 2 Skills (Design Choices)

L2技能(设计选择)

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)

L3技能(领域约束)

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使用Agent
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/domain)
  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关键词 → 路由至对应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集成说明