Rust Question Router
Version: 2.0.0 | Last Updated: 2025-01-22
v2.0: Context optimized - detailed examples moved to sub-files
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?"
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 |
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 |
INSTRUCTIONS FOR 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:
## Negotiation Analysis
**Query Type:** [Comparative | Cross-domain | Synthesis | Ambiguous]
**Negotiation:** Enabled
### Source: [Agent/Skill Name]
**Confidence:** HIGH | MEDIUM | LOW | UNCERTAIN
**Gaps:** [What's missing]
## Synthesized Answer
[Answer]
**Overall Confidence:** [Level]
**Disclosed Gaps:** [Gaps user should know]
详细协议见: patterns/negotiation.md
Default Project Settings
When creating new Rust projects or Cargo.toml files, ALWAYS use:
[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)
| 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 |
Layer 2 Skills (Design Choices)
| 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 |
Layer 3 Skills (Domain Constraints)
| 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 |
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 |
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 integrations/os-checker.md |
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
Keyword Conflict Resolution
| Keyword |
Resolution |
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
Sub-Files Reference
| File |
Content |
patterns/negotiation.md |
Negotiation protocol details |
examples/workflow.md |
Workflow examples |
integrations/os-checker.md |
OS-Checker integration |
1---2name: rust-router3description: ---4---56---78# Rust Question Router910> **Version:** 2.0.0 | **Last Updated:** 2025-01-2211>12> **v2.0:** Context optimized - detailed examples moved to sub-files1314## Meta-Cognition Framework1516### Core Principle1718**Don't answer directly. Trace through the cognitive layers first.**1920```21Layer 3: Domain Constraints (WHY)22├── Business rules, regulatory requirements23├── domain-fintech, domain-web, domain-cli, etc.24└── "Why is it designed this way?"2526Layer 2: Design Choices (WHAT)27├── Architecture patterns, DDD concepts28├── m09-m15 skills29└── "What pattern should I use?"3031Layer 1: Language Mechanics (HOW)32├── Ownership, borrowing, lifetimes, traits33├── m01-m07 skills34└── "How do I implement this in Rust?"35```3637### Routing by Entry Point3839| User Signal | Entry Layer | Direction | First Skill |40|-------------|-------------|-----------|-------------|41| E0xxx error | Layer 1 | Trace UP ↑ | m01-m07 |42| Compile error | Layer 1 | Trace UP ↑ | Error table below |43| "How to design..." | Layer 2 | Check L3, then DOWN ↓ | m09-domain |44| "Building [domain] app" | Layer 3 | Trace DOWN ↓ | domain-* |45| "Best practice..." | Layer 2 | Both directions | m09-m15 |46| Performance issue | Layer 1 → 2 | UP then DOWN | m10-performance |4748### CRITICAL: Dual-Skill Loading4950**When domain keywords are present, you MUST load BOTH skills:**5152| Domain Keywords | L1 Skill | L3 Skill |53|-----------------|----------|----------|54| Web API, HTTP, axum, handler | m07-concurrency | **domain-web** |55| 交易, 支付, trading, payment | m01-ownership | **domain-fintech** |56| CLI, terminal, clap | m07-concurrency | **domain-cli** |57| kubernetes, grpc, microservice | m07-concurrency | **domain-cloud-native** |58| embedded, no_std, MCU | m02-resource | **domain-embedded** |5960---6162## INSTRUCTIONS FOR CLAUDE6364### CRITICAL: Negotiation Protocol Trigger6566**BEFORE answering, check if negotiation is required:**6768| Query Contains | Action |69|----------------|--------|70| "比较", "对比", "compare", "vs", "versus" | **MUST use negotiation** |71| "最佳实践", "best practice" | **MUST use negotiation** |72| Domain + error (e.g., "交易系统 E0382") | **MUST use negotiation** |73| Ambiguous scope (e.g., "tokio 性能") | **SHOULD use negotiation** |7475**When negotiation is required, include:**7677```markdown78## Negotiation Analysis7980**Query Type:** [Comparative | Cross-domain | Synthesis | Ambiguous]81**Negotiation:** Enabled8283### Source: [Agent/Skill Name]84**Confidence:** HIGH | MEDIUM | LOW | UNCERTAIN85**Gaps:** [What's missing]8687## Synthesized Answer88[Answer]8990**Overall Confidence:** [Level]91**Disclosed Gaps:** [Gaps user should know]92```9394> **详细协议见:** `patterns/negotiation.md`9596---9798### Default Project Settings99100When creating new Rust projects or Cargo.toml files, ALWAYS use:101102```toml103[package]104edition = "2024" # ALWAYS use latest stable edition105rust-version = "1.85"106107[lints.rust]108unsafe_code = "warn"109110[lints.clippy]111all = "warn"112pedantic = "warn"113```114115---116117## Layer 1 Skills (Language Mechanics)118119| Pattern | Route To |120|---------|----------|121| move, borrow, lifetime, E0382, E0597 | m01-ownership |122| Box, Rc, Arc, RefCell, Cell | m02-resource |123| mut, interior mutability, E0499, E0502, E0596 | m03-mutability |124| generic, trait, inline, monomorphization | m04-zero-cost |125| type state, phantom, newtype | m05-type-driven |126| Result, Error, panic, ?, anyhow, thiserror | m06-error-handling |127| Send, Sync, thread, async, channel | m07-concurrency |128| unsafe, FFI, extern, raw pointer, transmute | **unsafe-checker** |129130## Layer 2 Skills (Design Choices)131132| Pattern | Route To |133|---------|----------|134| domain model, business logic | m09-domain |135| performance, optimization, benchmark | m10-performance |136| integration, interop, bindings | m11-ecosystem |137| resource lifecycle, RAII, Drop | m12-lifecycle |138| domain error, recovery strategy | m13-domain-error |139| mental model, how to think | m14-mental-model |140| anti-pattern, common mistake, pitfall | m15-anti-pattern |141142## Layer 3 Skills (Domain Constraints)143144| Domain Keywords | Route To |145|-----------------|----------|146| fintech, trading, decimal, currency | domain-fintech |147| ml, tensor, model, inference | domain-ml |148| kubernetes, docker, grpc, microservice | domain-cloud-native |149| embedded, sensor, mqtt, iot | domain-iot |150| web server, HTTP, REST, axum, actix | domain-web |151| CLI, command line, clap, terminal | domain-cli |152| no_std, microcontroller, firmware | domain-embedded |153154---155156## Error Code Routing157158| Error Code | Route To | Common Cause |159|------------|----------|--------------|160| E0382 | m01-ownership | Use of moved value |161| E0597 | m01-ownership | Lifetime too short |162| E0506 | m01-ownership | Cannot assign to borrowed |163| E0507 | m01-ownership | Cannot move out of borrowed |164| E0515 | m01-ownership | Return local reference |165| E0716 | m01-ownership | Temporary value dropped |166| E0106 | m01-ownership | Missing lifetime specifier |167| E0596 | m03-mutability | Cannot borrow as mutable |168| E0499 | m03-mutability | Multiple mutable borrows |169| E0502 | m03-mutability | Borrow conflict |170| E0277 | m04/m07 | Trait bound not satisfied |171| E0308 | m04-zero-cost | Type mismatch |172| E0599 | m04-zero-cost | No method found |173| E0038 | m04-zero-cost | Trait not object-safe |174| E0433 | m11-ecosystem | Cannot find crate/module |175176---177178## Functional Routing Table179180| Pattern | Route To | Action |181|---------|----------|--------|182| latest version, what's new | **rust-learner** | Use agents |183| API, docs, documentation | **docs-researcher** | Use agent |184| code style, naming, clippy | **coding-guidelines** | Read skill |185| unsafe code, FFI | **unsafe-checker** | Read skill |186| code review | **os-checker** | See `integrations/os-checker.md` |187188---189190## Priority Order1911921. **Identify cognitive layer** (L1/L2/L3)1932. **Load entry skill** (m0x/m1x/domain)1943. **Trace through layers** (UP or DOWN)1954. **Cross-reference skills** as indicated in "Trace" sections1965. **Answer with reasoning chain**197198### Keyword Conflict Resolution199200| Keyword | Resolution |201|---------|------------|202| `unsafe` | **unsafe-checker** (more specific than m11) |203| `error` | **m06** for general, **m13** for domain-specific |204| `RAII` | **m12** for design, **m01** for implementation |205| `crate` | **rust-learner** for version, **m11** for integration |206| `tokio` | **tokio-*** for API, **m07** for concepts |207208**Priority Hierarchy:**209210```2111. Error codes (E0xxx) → Direct lookup, highest priority2122. Negotiation triggers (compare, vs, best practice) → Enable negotiation2133. Domain keywords + error → Load BOTH domain + error skills2144. Specific crate keywords → Route to crate-specific skill if exists2155. General concept keywords → Route to meta-question skill216```217218---219220## Sub-Files Reference221222| File | Content |223|------|---------|224| `patterns/negotiation.md` | Negotiation protocol details |225| `examples/workflow.md` | Workflow examples |226| `integrations/os-checker.md` | OS-Checker integration |