rust-router
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRust Question Router
Rust问题路由工具
Version: 2.0.0 | Last Updated: 2025-01-22v2.0: Context optimized - detailed examples moved to sub-files
版本: 2.0.0 | 最后更新: 2025-01-22v2.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 Signal | Entry Layer | Direction | First Skill |
|---|---|---|---|
| E0xxx error | Layer 1 | Trace UP ↑ | m01-m07 |
| Compile error | Layer 1 | Trace UP ↑ | Error table below |
| "How to design..." | Layer 2 | Check L3, then DOWN ↓ | m09-domain |
| "Building [domain] app" | Layer 3 | Trace DOWN ↓ | domain-* |
| "Best practice..." | Layer 2 | Both directions | m09-m15 |
| Performance issue | Layer 1 → 2 | UP then DOWN | m10-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 Keywords | L1 Skill | L3 Skill |
|---|---|---|
| Web API, HTTP, axum, handler | m07-concurrency | domain-web |
| 交易, 支付, trading, payment | m01-ownership | domain-fintech |
| CLI, terminal, clap | m07-concurrency | domain-cli |
| kubernetes, grpc, microservice | m07-concurrency | domain-cloud-native |
| embedded, no_std, MCU | m02-resource | domain-embedded |
当存在领域关键词时,必须同时加载两个技能:
| 领域关键词 | L1技能 | L3技能 |
|---|---|---|
| Web API、HTTP、axum、handler | m07-concurrency | domain-web |
| 交易、支付、trading、payment | m01-ownership | domain-fintech |
| CLI、terminal、clap | m07-concurrency | domain-cli |
| kubernetes、grpc、microservice | m07-concurrency | domain-cloud-native |
| embedded、no_std、MCU | m02-resource | domain-embedded |
INSTRUCTIONS FOR CLAUDE
给Claude的指令
CRITICAL: Negotiation Protocol Trigger
重要提示:协商协议触发条件
BEFORE answering, check if negotiation is required:
| Query Contains | Action |
|---|---|
| "比较", "对比", "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
undefinedNegotiation 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技能(语言机制)
| Pattern | Route To |
|---|---|
| move, borrow, lifetime, E0382, E0597 | m01-ownership |
| Box, Rc, Arc, RefCell, Cell | m02-resource |
| mut, interior mutability, E0499, E0502, E0596 | m03-mutability |
| generic, trait, inline, monomorphization | m04-zero-cost |
| type state, phantom, newtype | m05-type-driven |
| Result, Error, panic, ?, anyhow, thiserror | m06-error-handling |
| Send, Sync, thread, async, channel | m07-concurrency |
| unsafe, FFI, extern, raw pointer, transmute | unsafe-checker |
| 模式 | 路由至 |
|---|---|
| move、borrow、lifetime、E0382、E0597 | m01-ownership |
| Box、Rc、Arc、RefCell、Cell | m02-resource |
| mut、内部可变性、E0499、E0502、E0596 | m03-mutability |
| 泛型、trait、内联、单态化 | m04-zero-cost |
| 类型状态、phantom、newtype | m05-type-driven |
| Result、Error、panic、?、anyhow、thiserror | m06-error-handling |
| Send、Sync、线程、async、channel | m07-concurrency |
| unsafe、FFI、extern、裸指针、transmute | unsafe-checker |
Layer 2 Skills (Design Choices)
Layer 2技能(设计选择)
| Pattern | Route To |
|---|---|
| domain model, business logic | m09-domain |
| performance, optimization, benchmark | m10-performance |
| integration, interop, bindings | m11-ecosystem |
| resource lifecycle, RAII, Drop | m12-lifecycle |
| domain error, recovery strategy | m13-domain-error |
| mental model, how to think | m14-mental-model |
| anti-pattern, common mistake, pitfall | m15-anti-pattern |
| 模式 | 路由至 |
|---|---|
| 领域模型、业务逻辑 | m09-domain |
| 性能、优化、基准测试 | m10-performance |
| 集成、互操作、绑定 | m11-ecosystem |
| 资源生命周期、RAII、Drop | m12-lifecycle |
| 领域错误、恢复策略 | m13-domain-error |
| 心智模型、思考方式 | m14-mental-model |
| 反模式、常见错误、陷阱 | m15-anti-pattern |
Layer 3 Skills (Domain Constraints)
Layer 3技能(领域约束)
| Domain Keywords | Route To |
|---|---|
| fintech, trading, decimal, currency | domain-fintech |
| ml, tensor, model, inference | domain-ml |
| kubernetes, docker, grpc, microservice | domain-cloud-native |
| embedded, sensor, mqtt, iot | domain-iot |
| web server, HTTP, REST, axum, actix | domain-web |
| CLI, command line, clap, terminal | domain-cli |
| no_std, microcontroller, firmware | domain-embedded |
| 领域关键词 | 路由至 |
|---|---|
| fintech、trading、decimal、currency | domain-fintech |
| ml、tensor、model、inference | domain-ml |
| kubernetes、docker、grpc、microservice | domain-cloud-native |
| embedded、sensor、mqtt、iot | domain-iot |
| web server、HTTP、REST、axum、actix | domain-web |
| CLI、command line、clap、terminal | domain-cli |
| no_std、microcontroller、firmware | domain-embedded |
Error Code Routing
错误码路由
| Error Code | Route To | Common Cause |
|---|---|---|
| E0382 | m01-ownership | Use of moved value |
| E0597 | m01-ownership | Lifetime too short |
| E0506 | m01-ownership | Cannot assign to borrowed |
| E0507 | m01-ownership | Cannot move out of borrowed |
| E0515 | m01-ownership | Return local reference |
| E0716 | m01-ownership | Temporary value dropped |
| E0106 | m01-ownership | Missing lifetime specifier |
| E0596 | m03-mutability | Cannot borrow as mutable |
| E0499 | m03-mutability | Multiple mutable borrows |
| E0502 | m03-mutability | Borrow conflict |
| E0277 | m04/m07 | Trait bound not satisfied |
| E0308 | m04-zero-cost | Type mismatch |
| E0599 | m04-zero-cost | No method found |
| E0038 | m04-zero-cost | Trait not object-safe |
| E0433 | m11-ecosystem | Cannot find crate/module |
| 错误码 | 路由至 | 常见原因 |
|---|---|---|
| E0382 | m01-ownership | 使用了已移动的值 |
| E0597 | m01-ownership | 生命周期过短 |
| E0506 | m01-ownership | 无法赋值给借用的变量 |
| E0507 | m01-ownership | 无法从借用的变量中移出值 |
| E0515 | m01-ownership | 返回局部引用 |
| E0716 | m01-ownership | 临时值已被丢弃 |
| E0106 | m01-ownership | 缺失生命周期标注 |
| E0596 | m03-mutability | 无法可变借用 |
| E0499 | m03-mutability | 多次可变借用 |
| E0502 | m03-mutability | 借用冲突 |
| E0277 | m04/m07 | trait约束未满足 |
| E0308 | m04-zero-cost | 类型不匹配 |
| E0599 | m04-zero-cost | 未找到方法 |
| E0038 | m04-zero-cost | trait不支持对象安全 |
| E0433 | m11-ecosystem | 无法找到crate/模块 |
Functional Routing Table
功能路由表
| Pattern | Route To | Action |
|---|---|---|
| latest version, what's new | rust-learner | Use agents |
| API, docs, documentation | docs-researcher | Use agent |
| code style, naming, clippy | coding-guidelines | Read skill |
| unsafe code, FFI | unsafe-checker | Read skill |
| code review | os-checker | See |
| 模式 | 路由至 | 操作 |
|---|---|---|
| 最新版本、新特性 | rust-learner | 使用agents |
| API、文档、documentation | docs-researcher | 使用agent |
| 代码风格、命名、clippy | coding-guidelines | 阅读技能文档 |
| unsafe代码、FFI | unsafe-checker | 阅读技能文档 |
| 代码审查 | os-checker | 查看 |
Priority Order
优先级顺序
- Identify cognitive layer (L1/L2/L3)
- Load entry skill (m0x/m1x/domain)
- Trace through layers (UP or DOWN)
- Cross-reference skills as indicated in "Trace" sections
- Answer with reasoning chain
- 识别认知层级(L1/L2/L3)
- 加载入口技能(m0x/m1x/领域技能)
- 追溯层级(向上或向下)
- 交叉引用技能 如"追溯"部分所示
- 附带推理链进行回答
Keyword Conflict Resolution
关键词冲突解决
| Keyword | Resolution |
|---|---|
| unsafe-checker (more specific than m11) |
| m06 for general, m13 for domain-specific |
| m12 for design, m01 for implementation |
| rust-learner for version, m11 for integration |
| 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-checker(比m11更具体) |
| 通用错误用m06,领域特定错误用m13 |
| 设计层面用m12,实现层面用m01 |
| 版本相关用rust-learner,集成相关用m11 |
| API相关用tokio-*,概念相关用m07 |
优先级层级:
1. 错误码(E0xxx)→ 直接查找,优先级最高
2. 协商触发词(compare、vs、best practice)→ 启用协商
3. 领域关键词+错误 → 同时加载领域和错误技能
4. 特定crate关键词 → 若存在对应技能则路由至该技能
5. 通用概念关键词 → 路由至元问题技能Sub-Files Reference
子文件参考
| File | Content |
|---|---|
| Negotiation protocol details |
| Workflow examples |
| OS-Checker integration |
| 文件 | 内容 |
|---|---|
| 协商协议详细内容 |
| 工作流示例 |
| OS-Checker集成说明 |