refactor: redesign load-skill-memory to use Skill tool activation

Complete redesign from manual document reading to SKILL activation pattern:

**Before (Manual Loading)**:
- Complex level selection logic (0-3)
- Manual Read operations for each document
- Task-based auto-level selection
- ~200 lines of document loading code

**After (Skill Activation)**:
- Simple two-step: Validate → Activate
- Use Skill(command: "skill_name") tool
- System handles all documentation loading automatically
- ~100 lines simpler, more maintainable

**Key Changes**:

1. **Examples Updated**:
   - From: `/memory:load-skill-memory hydro_generator_module "分析热模型"`
   - To: `Skill(command: "hydro_generator_module")`

2. **Execution Flow Simplified**:
   - Step 1: Validate SKILL.md exists
   - Step 2: Skill(command: "skill_name")
   - System automatically handles progressive loading

3. **Removed Manual Logic**:
   - No explicit --level parameter
   - No manual document reading
   - No level selection algorithm
   - System determines context needs automatically

4. **Added SKILL Trigger Mechanism**:
   - Explains how SKILL description triggers work
   - Keyword matching (domain terms)
   - Action detection (analyzing, modifying, learning)
   - Memory gap detection
   - Path-based triggering

5. **Updated Integration Examples**:
   ```javascript
   Skill(command: "hydro_generator_module")
   SlashCommand(command: "/workflow:plan \"task\"")
   ```

**Benefits**:
- Simpler user experience (just activate SKILL)
- Automatic context optimization
- System handles complexity
- Follows Claude SKILL architecture
- Leverages built-in SKILL trigger patterns

**Philosophy Shift**:
- From: Manual control over documentation loading
- To: Trust SKILL system to load appropriate context
- Aligns with skill-memory.md description optimization

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
catlog22
2025-11-03 21:26:52 +08:00
parent 7b2160d51f
commit 9e0a70150a

View File

@@ -2,44 +2,32 @@
name: load-skill-memory name: load-skill-memory
description: Load SKILL package documentation with progressive levels based on task requirements description: Load SKILL package documentation with progressive levels based on task requirements
argument-hint: "<skill_name> [--level 0|1|2|3] [task description]" argument-hint: "<skill_name> [--level 0|1|2|3] [task description]"
allowed-tools: Bash(*), Read(*), Glob(*) allowed-tools: Bash(*), Read(*), Glob(*), Skill(*)
examples: examples:
- /memory:load-skill-memory hydro_generator_module "分析热模型实现" - Skill(command: "hydro_generator_module")
- /memory:load-skill-memory workflow-system --level 2 "修改任务调度逻辑" - Skill(command: "Claude_dms3")
- /memory:load-skill-memory Claude_dms3 "学习文档生成流程" - Skill(command: "multiphysics_network")
--- ---
# Memory Load SKILL Command (/memory:load-skill-memory) # Memory Load SKILL Command (/memory:load-skill-memory)
## 1. Overview ## 1. Overview
The `memory:load-skill-memory` command loads SKILL package documentation with **progressive levels** (0-3) based on task requirements. It validates SKILL existence and intelligently selects appropriate documentation depth. The `memory:load-skill-memory` command **activates SKILL packages** generated by `/memory:skill-memory`. It validates SKILL existence and uses the `Skill()` tool to load comprehensive documentation context.
**Core Philosophy**: **Core Philosophy**:
- **Two-Step Validation**: Check SKILL existence before loading - **Two-Step Process**: Validate SKILL existence → Activate via Skill tool
- **Progressive Loading**: Load only necessary documentation based on task complexity - **Automatic Context Loading**: SKILL system loads appropriate documentation automatically
- **Token Optimization**: Start with minimal context, expand as needed - **No Manual Reading**: Use Skill tool instead of manual Read operations
- **Task-Driven Selection**: Automatically select level based on task description - **Task-Driven Activation**: System automatically determines required context based on SKILL description triggers
## 2. Parameters ## 2. Parameters
- `<skill_name>` (Required): Name of SKILL package to load - `<skill_name>` (Required): Name of SKILL package to activate
- Example: `hydro_generator_module` - Example: `hydro_generator_module`
- Example: `Claude_dms3` - Example: `Claude_dms3`
- Example: `multiphysics_network` - Example: `multiphysics_network`
- `--level <0|1|2|3>` (Optional): Force specific documentation level
- Level 0: Quick Start (~2K tokens) - Overview only
- Level 1: Core Modules (~10K tokens) - Key module APIs
- Level 2: Complete (~25K tokens) - All modules + architecture
- Level 3: Deep Dive (~40K tokens) - Everything including examples
- Default: Auto-select based on task description
- `[task description]` (Optional): Task context for auto-level selection
- Example: "分析热模型实现"
- Example: "修改builder pattern"
- Example: "学习参数系统设计"
## 3. Two-Step Execution Flow ## 3. Two-Step Execution Flow
### Step 1: Validate SKILL Existence ### Step 1: Validate SKILL Existence
@@ -61,161 +49,144 @@ bash(test -f .claude/skills/{skill_name}/SKILL.md && echo "exists" || echo "not_
❌ SKILL '{skill_name}' not found. ❌ SKILL '{skill_name}' not found.
Available SKILLs: Available SKILLs:
- hydro_generator_module - hydro_generator_module (D:\dongdiankaifa9\hydro_generator_module)
- Claude_dms3 - Claude_dms3 (D:\Claude_dms3)
- multiphysics_network
Use: /memory:load-skill-memory <skill_name> [task description] Use: Skill(command: "skill_name")
Generate new SKILL: /memory:skill-memory [path]
``` ```
### Step 2: Load Documentation by Level ### Step 2: Activate SKILL Package
**Level Selection Logic**: **Use Skill Tool to Activate**:
```javascript
1. **Explicit Level** (--level specified): Use specified level directly Skill(command: "{skill_name}")
2. **Task-Based Auto-Selection**:
- **Level 0** (Quick Start):
- Keywords: "overview", "介绍", "what is", "概述", "快速了解"
- Use case: Initial exploration, understanding basic capabilities
- **Level 1** (Core Modules):
- Keywords: "分析", "analyze", "review", "理解", "understand", "API"
- Use case: Deep analysis of specific modules, API review
- **Level 2** (Complete):
- Keywords: "修改", "modify", "重构", "refactor", "设计", "architecture"
- Use case: Modifying code, understanding system design
- **Level 3** (Deep Dive):
- Keywords: "实现", "implement", "开发", "develop", "示例", "example"
- Use case: New feature implementation, need complete context
3. **Default**: Level 1 if no task description and no --level flag
**Loading Implementation**:
```bash
# Read SKILL.md to get documentation structure
Read(.claude/skills/{skill_name}/SKILL.md)
# Based on selected level, read corresponding files
case $level in
0)
Read(../../../.workflow/docs/{skill_name}/README.md)
;;
1)
Read(../../../.workflow/docs/{skill_name}/README.md)
# Read Core Module README.md files listed in SKILL.md Level 1
;;
2)
# Load all Level 1 docs
Read(../../../.workflow/docs/{skill_name}/ARCHITECTURE.md)
# Read all module README.md + API.md files
;;
3)
# Load all Level 2 docs
Read(../../../.workflow/docs/{skill_name}/EXAMPLES.md)
# Read complete documentation set
;;
esac
``` ```
**What Happens**:
1. Claude's SKILL system reads `.claude/skills/{skill_name}/SKILL.md`
2. Automatically loads appropriate documentation based on:
- SKILL description triggers (analyzing, modifying, learning)
- Current conversation context
- Memory gaps detection
3. Progressive loading levels (0-3) handled automatically by system
4. Context loaded directly into conversation memory
**No Manual Reading Required**: The Skill tool handles all documentation loading automatically based on SKILL.md configuration.
## 4. Output Format ## 4. Output Format
**Success Output**: **Success Output**:
``` ```
Loaded SKILL: {skill_name} (Level {level}) Activated SKILL: {skill_name}
📦 Documentation Loaded: 📦 SKILL Package Information:
- README.md (~2K tokens) - Location: {project_path}
[Level 1+] - Description: {description from SKILL.md}
- analysis/README.md - Documentation: .workflow/docs/{skill_name}/
- builders/README.md
- params/README.md
[Level 2+]
- ARCHITECTURE.md
- Complete module APIs
[Level 3+]
- EXAMPLES.md
💡 Token Budget: ~{token_count}K 💡 Context loaded automatically by SKILL system based on:
- Current task requirements
- Conversation memory gaps
- SKILL description triggers
🎯 Task Context: {task_description} 🎯 Ready for: analyzing, modifying, or learning about {domain_description}
``` ```
## 5. Usage Examples ## 5. Usage Examples
### Example 1: Quick Overview ### Example 1: Activate Hydro Generator Module SKILL
```bash **User Request**: "分析热模型builder pattern实现"
/memory:load-skill-memory hydro_generator_module "快速了解模块功能"
**Command Execution**:
```javascript
// Step 1: Validate
bash(test -f .claude/skills/hydro_generator_module/SKILL.md && echo "exists")
// Output: exists
// Step 2: Activate
Skill(command: "hydro_generator_module")
``` ```
**Auto-Selected Level**: 0 (keyword: "快速了解") **SKILL Activation**:
- System reads `.claude/skills/hydro_generator_module/SKILL.md`
- Description triggers match: "analyzing" + "hydro-generator thermal modeling"
- Automatically loads appropriate documentation (Level 1-2)
- Context available for subsequent analysis
**Loaded Files**: ### Example 2: Activate Workflow System SKILL
- `.workflow/docs/hydro_generator_module/README.md`
**Token Budget**: ~2K **User Request**: "修改文档生成workflow调度逻辑"
### Example 2: Module Analysis **Command Execution**:
```javascript
// Step 1: Validate
bash(test -f .claude/skills/Claude_dms3/SKILL.md && echo "exists")
// Output: exists
```bash // Step 2: Activate
/memory:load-skill-memory hydro_generator_module "分析builder pattern实现" Skill(command: "Claude_dms3")
``` ```
**Auto-Selected Level**: 1 (keyword: "分析") **SKILL Activation**:
- Description triggers match: "modifying" + "workflow management"
- System loads comprehensive documentation (Level 2-3)
- Ready for workflow modification tasks
**Loaded Files**: ### Example 3: Activate Multi-Physics Network SKILL
- README.md
- builders/README.md
- builders/API.md
- interfaces/README.md
- params/README.md
**Token Budget**: ~10K **User Request**: "学习电磁域组件设计模式"
### Example 3: Code Modification **Command Execution**:
```javascript
// Step 1: Validate
bash(test -f .claude/skills/multiphysics_network/SKILL.md && echo "exists")
// Output: exists
```bash // Step 2: Activate
/memory:load-skill-memory Claude_dms3 --level 2 "修改文档生成workflow" Skill(command: "multiphysics_network")
``` ```
**Explicit Level**: 2 **SKILL Activation**:
- Description triggers match: "learning" + "multi-physics"
- System provides overview and core module docs (Level 0-1)
- Context available for exploration
**Loaded Files**: ## 6. SKILL Trigger Mechanism
- README.md
- All module README.md + API.md
- ARCHITECTURE.md
**Token Budget**: ~25K **How SKILL System Determines Context Loading**:
### Example 4: New Feature Implementation The SKILL.md description includes trigger patterns that automatically activate when:
```bash 1. **Keyword Matching**:
/memory:load-skill-memory multiphysics_network "实现新的电磁耦合器" - User mentions domain keywords (e.g., "热模型", "workflow", "多物理场")
``` - Description keywords match task requirements
**Auto-Selected Level**: 3 (keyword: "实现") 2. **Action Detection**:
- "analyzing" triggers for analysis tasks
- "modifying" triggers for code modification
- "learning" triggers for exploration
**Loaded Files**: 3. **Memory Gap Detection**:
- Complete documentation set - "especially when no relevant context exists in memory"
- EXAMPLES.md with 20+ examples - System prioritizes SKILL loading when conversation lacks context
**Token Budget**: ~40K 4. **Path-Based Triggering**:
- User mentions file paths matching SKILL location
- "files under this path" clause activates
## 6. Level Selection Matrix **Progressive Loading (Automatic)**:
- Level 0: ~2K tokens (Quick overview)
- Level 1: ~10K tokens (Core modules)
- Level 2: ~25K tokens (Complete system)
- Level 3: ~40K tokens (Full documentation)
| Task Type | Keywords | Auto Level | Token Budget | System automatically selects appropriate level based on task complexity and context requirements.
|-----------|----------|------------|--------------|
| **Explore** | overview, 介绍, what is, 概述 | 0 | ~2K |
| **Analyze** | 分析, analyze, review, 理解 | 1 | ~10K |
| **Modify** | 修改, modify, 重构, refactor | 2 | ~25K |
| **Implement** | 实现, implement, 开发, develop | 3 | ~40K |
## 7. Implementation Steps ## 7. Implementation Steps
**Pseudo-code**: **Execution Logic**:
```javascript ```javascript
// Step 1: Validate SKILL existence // Step 1: Validate SKILL existence
@@ -225,30 +196,17 @@ if (!exists(skill_path)) {
return error_message return error_message
} }
// Step 2: Determine level // Step 2: Activate SKILL
if (--level specified) { Skill(command: skill_name)
level = specified_level
} else if (task_description) {
level = auto_select_level(task_description)
} else {
level = 1 // Default
}
// Step 3: Read SKILL.md structure // Step 3: System handles automatically
skill_content = Read(skill_path) // - Reads SKILL.md description
doc_structure = parse_progressive_loading(skill_content) // - Matches triggers with task context
// - Loads appropriate documentation level
// - Injects context into conversation memory
// Step 4: Load documentation by level // Step 4: Confirm activation
loaded_docs = [] output_success_message(skill_name, project_path, description)
for (doc in doc_structure[level]) {
loaded_docs.push(Read(doc.path))
}
// Step 5: Calculate token count
token_count = estimate_tokens(loaded_docs)
// Step 6: Output summary
output_success_message(skill_name, level, loaded_docs, token_count, task_description)
``` ```
## 8. Error Handling ## 8. Error Handling
@@ -261,6 +219,7 @@ Available SKILLs:
- hydro_generator_module (D:\dongdiankaifa9\hydro_generator_module) - hydro_generator_module (D:\dongdiankaifa9\hydro_generator_module)
- Claude_dms3 (D:\Claude_dms3) - Claude_dms3 (D:\Claude_dms3)
Activate SKILL: Skill(command: "skill_name")
Generate new SKILL: /memory:skill-memory [path] Generate new SKILL: /memory:skill-memory [path]
``` ```
@@ -274,59 +233,55 @@ Missing files:
Regenerate documentation: /memory:skill-memory --regenerate Regenerate documentation: /memory:skill-memory --regenerate
``` ```
### Invalid Level
```
❌ Invalid level: 4
Valid levels:
- Level 0: Quick Start (~2K)
- Level 1: Core Modules (~10K)
- Level 2: Complete (~25K)
- Level 3: Deep Dive (~40K)
```
## 9. Integration with Other Commands ## 9. Integration with Other Commands
**Workflow Integration**: **Workflow Integration**:
```bash ```javascript
# 1. Load SKILL context // 1. Activate SKILL context
/memory:load-skill-memory hydro_generator_module "修改thermal template" Skill(command: "hydro_generator_module")
# 2. Use loaded context for planning // 2. Use loaded context for planning
/workflow:plan "增强thermal template支持动态阻抗" SlashCommand(command: "/workflow:plan \"增强thermal template支持动态阻抗\"")
# 3. Execute implementation // 3. Execute implementation
/workflow:execute SlashCommand(command: "/workflow:execute")
``` ```
**Memory Refresh**: **Memory Refresh Pattern**:
```bash ```javascript
# Load fresh context after code changes // Refresh SKILL context after code changes
/memory:load-skill-memory hydro_generator_module --level 2 "review recent changes" Skill(command: "hydro_generator_module")
// System automatically detects changes and loads updated documentation
``` ```
## 10. Token Optimization Strategy ## 10. Token Optimization Strategy
**Progressive Loading Pattern**: **Automatic Progressive Loading**:
1. Start with Level 0 for exploration The SKILL system automatically handles token optimization:
2. Escalate to Level 1 for analysis
3. Load Level 2 for modification tasks
4. Use Level 3 only for complex implementations
**Token Budget Guidelines**: 1. **Initial Load**: Starts with minimum required context
- **Simple queries**: Level 0-1 (2-10K) 2. **On-Demand Escalation**: Loads more documentation if needed
- **Code review**: Level 1-2 (10-25K) 3. **Task-Driven**: Adjusts depth based on task complexity
- **Feature development**: Level 2-3 (25-40K) 4. **Memory-Aware**: Avoids loading redundant context
**Reload Strategy**: **Token Budget (Automatic)**:
- Reload with higher level if insufficient context - **Simple queries**: ~2-10K tokens
- Use explicit --level to override auto-selection - **Code analysis**: ~10-25K tokens
- **Implementation**: ~25-40K tokens
**Optimization Benefits**:
- No manual level selection required
- System learns from conversation context
- Efficient memory usage
- Automatic reload when context insufficient
## 11. Notes ## 11. Notes
- **Validation First**: Always checks SKILL existence before activation
- **Automatic Loading**: Skill tool handles all documentation reading
- **Session-Scoped**: Activated SKILL context valid for current session
- **Trigger-Based**: Description patterns drive automatic activation
- **Path-Aware**: Triggers on project path mentions
- **Memory-Smart**: Prioritizes loading when conversation lacks context
- **Read-Only**: Does not modify SKILL files or documentation - **Read-Only**: Does not modify SKILL files or documentation
- **Session-Scoped**: Loaded documentation valid for current session - **Reactivation**: Can re-activate SKILL to refresh context after changes
- **Auto-Selection**: Keywords matched case-insensitively
- **Path Relative**: All documentation paths relative to SKILL.md location
- **Token Aware**: Automatically estimates token consumption
- **Fallback**: Defaults to Level 1 if auto-selection unclear