关于 meta-cognition-parallel
实验性分析技能将问题拆分为 Rust 语言机制、设计选择和领域约束三个层面,再综合结果。可并行调用分析 Agent,也可在仅安装技能时顺序执行。
主要功能
- 01三层认知分析
- 02并行调用三个分析 Agent
- 03顺序内联分析模式
- 04跨层综合与建议
适用场景
- 01分析 Rust 所有权错误
- 02比较共享与克隆等设计选择
- 03结合业务约束评估 Rust 实现
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ actionbook/ rust-skills --skill meta-cognition-parallel安装后在 Claude Code 中输入/meta-cognition-parallel确认已加载。
详细介绍
元认知并行分析(实验性)
状态: 实验性 | 版本: 0.2.0 | 上次更新: 2025-01-27
此技能用于测试三层认知分析的并行执行。
概念
此技能不采用顺序分析,而是启动三个并行分析器,每个分析器负责一个认知层,然后综合它们的结果。
User Question
│
▼
┌─────────────────────────────────────────────────────┐
│ meta-cognition-parallel │
│ (Coordinator) │
└─────────────────────────────────────────────────────┘
│
├─── Layer 1 ──► Language Mechanics ──► L1 Result
│
├─── Layer 2 ──► Design Choices ──► L2 Result
│ ├── Parallel (Agent Mode)
│ │ or Sequential (Inline)
└─── Layer 3 ──► Domain Constraints ──► L3 Result
│
▼
┌─────────────────────────────────────────────────────┐
│ Cross-Layer Synthesis │
│ (In main context with all results) │
└─────────────────────────────────────────────────────┘
│
▼
Domain-Correct Architectural Solution
用法
/meta-parallel <your Rust question>
示例:
/meta-parallel 我的交易系统报 E0382 错误,应该用 clone 吗?
执行模式检测
重要:先检查 Agent 文件是否可用,以确定执行模式。
尝试读取各层分析器文件:
../../agents/layer1-analyzer.md../../agents/layer2-analyzer.md../../agents/layer3-analyzer.md
Agent 模式(插件安装)- 并行执行
当 ../../agents/ 下存在所有层分析器文件时:
第 1 步:解析用户查询
从 $ARGUMENTS 中提取:
- 原始问题
- 任意代码片段
- 领域提示(交易、Web、嵌入式等)
第 2 步:启动三个并行 Agent
重要:在同一条消息中启动全部三个 Task,以实现并行执行。
Read agent files, then launch in parallel:
Task(
subagent_type: "general-purpose",
run_in_background: true,
prompt: <content of ../../agents/layer1-analyzer.md>
+ "\n\n## User Query\n" + $ARGUMENTS
)
Task(
subagent_type: "general-purpose",
run_in_background: true,
prompt: <content of ../../agents/layer2-analyzer.md>
+ "\n\n## User Query\n" + $ARGUMENTS
)
Task(
subagent_type: "general-purpose",
run_in_background: true,
prompt: <content of ../../agents/layer3-analyzer.md>
+ "\n\n## User Query\n" + $ARGUMENTS
)
第 3 步:收集结果
等待全部三个 Agent 完成。每个 Agent 都会返回结构化分析。
第 4 步:跨层综合
获取全部三个结果后,按照下方模板进行综合。
内联模式(仅安装技能)- 顺序执行
当层分析器文件不可用时,直接执行分析:
第 1 步:解析用户查询
与 Agent 模式相同:从 $ARGUMENTS 中提取问题、代码和领域提示。
第 2 步:执行第 1 层 - 语言机制
分析涉及的 Rust 语言机制:
## Layer 1: Language Mechanics
**Error/Pattern Identified:**
- Error code: E0XXX (if applicable)
- Pattern: ownership/borrowing/lifetime/etc.
**Root Cause:**
[Explain why this error occurs in terms of Rust's ownership model]
**Language-Level Solutions:**
1. [Solution 1]: description
2. [Solution 2]: description
**Confidence:** HIGH | MEDIUM | LOW
**Reasoning:** [Why this confidence level]
重点领域:
- 所有权规则(移动、复制、借用)
- 生命周期注解
- 借用规则(共享与可变)
- 错误代码及其含义
第 3 步:执行第 2 层 - 设计选择
分析设计模式及其权衡:
## Layer 2: Design Choices
**Design Pattern Context:**
- Current approach: [What pattern is being used]
- Problem: [Why it conflicts with Rust's rules]
**Design Alternatives:**
| Pattern | Pros | Cons | When to Use |
|---------|------|------|-------------|
| Pattern A | ... | ... | ... |
| Pattern B | ... | ... | ... |
**Recommended Pattern:**
[Which pattern fits best and why]
**Confidence:** HIGH | MEDIUM | LOW
**Reasoning:** [Why this confidence level]
重点领域:
- 智能指针选择(Box、Rc、Arc)
- 内部可变性模式(Cell、RefCell、Mutex)
- 所有权转移与共享
- 克隆与引用
第 4 步:执行第 3 层 - 领域约束
分析特定领域的要求:
## Layer 3: Domain Constraints
**Domain Identified:** [trading/fintech | web | CLI | embedded | etc.]
**Domain-Specific Requirements:**
- [ ] Performance: [requirements]
- [ ] Safety: [requirements]
- [ ] Concurrency: [requirements]
- [ ] Auditability: [requirements]
**Domain Best Practices:**
1. [Best practice 1]
2. [Best practice 2]
**Constraints on Solution:**
- MUST: [hard requirements]
- SHOULD: [soft requirements]
- AVOID: [anti-patterns for this domain]
**Confidence:** HIGH | MEDIUM | LOW
**Reasoning:** [Why this confidence level]
重点领域:
- 行业要求(金融科技法规、Web 可扩展性等)
- 性能约束
- 安全性和正确性要求
- 该领域的常见模式
第 5 步:跨层综合
综合全部三个层面:
## Cross-Layer Synthesis
### Layer Results Summary
| Layer | Key Finding | Confidence |
|-------|-------------|------------|
| L1 (Mechanics) | [Summary] | [Level] |
| L2 (Design) | [Summary] | [Level] |
| L3 (Domain) | [Summary] | [Level] |
### Cross-Layer Reasoning
1. **L3 → L2:** [How domain constraints affect design choice]
2. **L2 → L1:** [How design choice determines mechanism]
3. **L1 ← L3:** [Direct domain impact on language features]
### Synthesized Recommendation
**Problem:** [Restated with full context]
**Solution:** [Domain-correct architectural solution]
**Rationale:**
- Domain requires: [L3 constraint]
- Design pattern: [L2 pattern]
- Mechanism: [L1 implementation]
### Confidence Assessment
- **Overall:** HIGH | MEDIUM | LOW
- **Limiting Factor:** [Which layer had lowest confidence]
输出模板
两种模式采用相同的输出格式:
# Three-Layer Meta-Cognition Analysis
> Query: [User's question]
---
## Layer 1: Language Mechanics
[L1 analysis result]
---
## Layer 2: Design Choices
[L2 analysis result]
---
## Layer 3: Domain Constraints
[L3 analysis result]
---
## Cross-Layer Synthesis
### Reasoning Chain
L3 领域:[约束] ↓ 意味着 L2 设计:[模式] ↓ 通过以下方式实现 L1 机制:[特性]
### Final Recommendation
**Do:** [Recommended approach]
**Don't:** [What to avoid]
**Code Pattern:**
```rust
// Recommended implementation
分析由 meta-cognition-parallel v0.2.0(实验性)执行
---
## Test Scenarios
### Test 1: Trading System E0382
/meta-parallel 交易系统报 E0382,trade record 被 move 了
Expected: L3 identifies FinTech constraints → L2 suggests shared immutable → L1 recommends Arc<T>
### Test 2: Web API Concurrency
/meta-parallel Web API 中多个 handler 需要共享数据库连接池
Expected: L3 identifies Web constraints → L2 suggests connection pooling → L1 recommends Arc<Pool>
### Test 3: CLI Tool Config
/meta-parallel CLI 工具如何处理配置文件和命令行参数的优先级
Expected: L3 identifies CLI constraints → L2 suggests config precedence pattern → L1 recommends builder pattern
---
## Error Handling
| Error | Cause | Solution |
|-------|-------|----------|
| Agent files not found | Skills-only install | Use inline mode (sequential) |
| Agent timeout | Complex analysis | Wait longer or use inline mode |
| Incomplete layer result | Agent issue | Fill in with inline analysis |
## Limitations
- **Agent Mode:** Parallel execution, faster but requires plugin install
- **Inline Mode:** Sequential execution, slower but works everywhere
- Cross-layer synthesis quality depends on result structure
- May have higher latency than simple single-layer analysis
## Feedback
This is experimental. Please report issues and suggestions to improve the three-layer analysis approach.