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: 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 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错误 | 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 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" # 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技能(语言机制)
| 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, 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 |
Layer 2 Skills (Design Choices)
L2技能(设计选择)
| 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)
L3技能(领域约束)
| 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 | 使用Agent |
| 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/domain)
- 追溯层级关系 (向上或向下)
- 按"追溯"部分指示交叉引用技能
- 附带推理链作答
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关键词 → 路由至对应crate专属技能(若存在)
5. 通用概念关键词 → 路由至元问题技能Sub-Files Reference
子文件参考
| File | Content |
|---|---|
| Negotiation protocol details |
| Workflow examples |
| OS-Checker integration |
| 文件 | 内容 |
|---|---|
| 协商协议详情 |
| 工作流示例 |
| OS-Checker集成说明 |