Optimize Skill
Guide for analyzing, editing, and optimizing existing Datus skills based on real usage data.
Step 1: Identify Target Skill
Use load_skill(skill_name="<name>") to load the current SKILL.md content.
Present to the user:
- Current name, description, tags
- Summary of key instruction sections
- Whether it has scripts, references, or other resources
Ask the user what aspect needs improvement (or proceed to analysis if they said "optimize").
Step 2: Find Usage Sessions
Search for sessions where this skill was invoked. Look at the action history and tool call records:
- Search for
load_skill calls with this skill name in recent action histories
- Identify which agent nodes loaded this skill
- Find the corresponding
execute_stream sessions
This gives real-world data on how the skill was actually used.
Step 3: Analyze Tool Call Patterns
From the usage sessions, identify:
- Which tools were called after loading the skill — does the agent follow the skill's instructions?
- What failed — tool errors, retries, dead ends
- Where the agent got stuck — excessive tool calls, circular patterns, repeated queries
- Repeated work patterns — if every session writes similar helper scripts, the skill should bundle them
- Unused instructions — parts of the skill the agent consistently ignores
- Missing guidance — situations where the agent improvises because the skill doesn't cover them
Step 4: Generate Optimization Suggestions
Based on analysis, propose specific changes:
- Improve instructions: Clarify ambiguous guidance that caused agent confusion
- Add missing examples: Where the agent had to guess, add concrete input/output pairs
- Bundle repeated scripts: If the agent keeps creating the same helper, put it in
scripts/
- Remove dead weight: Instructions the agent ignores aren't pulling their weight
- Fix gaps: Add coverage for scenarios where the agent got stuck
Step 5: Rewrite
Generate the improved SKILL.md:
- Show a summary of proposed changes to the user
- Use
ask_user to confirm the changes
- Write the updated file via
write_file (keep the same path returned by load_skill; must stay under .datus/skills/... or ~/.datus/skills/...)
- Call
validate_skill to verify
- Show a before/after comparison of key changes
Step 6: Description Optimization
The description field determines whether the agent invokes a skill. Optimize it:
- Be assertive: "Use whenever X" not "Can be used for X"
- Include trigger contexts: What user phrases should activate this skill
- Adjacent keywords: Related terms the user might use
- Edge cases: Phrases that SHOULD trigger vs phrases that should NOT
- Mental test: "Would the agent correctly decide to use this skill for [scenario]?"
Example transformation:
- Before: "Helps with SQL optimization"
- After: "Analyze and optimize SQL queries for performance. Use whenever the user mentions slow queries, query optimization, EXPLAIN plans, index suggestions, or database performance tuning, even if they don't explicitly ask for optimization."
Improvement Principles
- Generalize from feedback: Skills are used many times across many prompts. Avoid overfitting to specific examples.
- Keep the prompt lean: Remove instructions that aren't pulling their weight. Read transcripts, not just outputs — if the skill makes the agent waste time on unproductive steps, remove those instructions.
- Explain the why: Instead of rigid MUSTs, explain reasoning. Today's LLMs are smart — when given good context they go beyond rote instructions.
- Look for repeated work: If the agent consistently writes similar helper scripts across sessions, bundle them in
scripts/.
- Theory of mind: Try to understand the task from the user's perspective and transmit that understanding into the instructions.
1---2name: optimize-skill3description: Optimize and improve existing Datus skills. Use when users want to edit a skill, improve its instructions, optimize its description for better triggering, or analyze skill performance based on usage sessions. Trigger phrases include "optimize skill", "improve skill", "edit skill", "fix skill", "skill not triggering".4---56# Optimize Skill78Guide for analyzing, editing, and optimizing existing Datus skills based on real usage data.910## Step 1: Identify Target Skill1112Use `load_skill(skill_name="<name>")` to load the current SKILL.md content.1314Present to the user:15- Current name, description, tags16- Summary of key instruction sections17- Whether it has scripts, references, or other resources1819Ask the user what aspect needs improvement (or proceed to analysis if they said "optimize").2021## Step 2: Find Usage Sessions2223Search for sessions where this skill was invoked. Look at the action history and tool call records:2425- Search for `load_skill` calls with this skill name in recent action histories26- Identify which agent nodes loaded this skill27- Find the corresponding `execute_stream` sessions2829This gives real-world data on how the skill was actually used.3031## Step 3: Analyze Tool Call Patterns3233From the usage sessions, identify:3435- **Which tools were called** after loading the skill — does the agent follow the skill's instructions?36- **What failed** — tool errors, retries, dead ends37- **Where the agent got stuck** — excessive tool calls, circular patterns, repeated queries38- **Repeated work patterns** — if every session writes similar helper scripts, the skill should bundle them39- **Unused instructions** — parts of the skill the agent consistently ignores40- **Missing guidance** — situations where the agent improvises because the skill doesn't cover them4142## Step 4: Generate Optimization Suggestions4344Based on analysis, propose specific changes:4546- **Improve instructions**: Clarify ambiguous guidance that caused agent confusion47- **Add missing examples**: Where the agent had to guess, add concrete input/output pairs48- **Bundle repeated scripts**: If the agent keeps creating the same helper, put it in `scripts/`49- **Remove dead weight**: Instructions the agent ignores aren't pulling their weight50- **Fix gaps**: Add coverage for scenarios where the agent got stuck5152## Step 5: Rewrite5354Generate the improved SKILL.md:55561. Show a summary of proposed changes to the user572. Use `ask_user` to confirm the changes583. Write the updated file via `write_file` (keep the same path returned by `load_skill`; must stay under `.datus/skills/...` or `~/.datus/skills/...`)594. Call `validate_skill` to verify605. Show a before/after comparison of key changes6162## Step 6: Description Optimization6364The description field determines whether the agent invokes a skill. Optimize it:6566- **Be assertive**: "Use whenever X" not "Can be used for X"67- **Include trigger contexts**: What user phrases should activate this skill68- **Adjacent keywords**: Related terms the user might use69- **Edge cases**: Phrases that SHOULD trigger vs phrases that should NOT70- **Mental test**: "Would the agent correctly decide to use this skill for [scenario]?"7172Example transformation:73- Before: "Helps with SQL optimization"74- After: "Analyze and optimize SQL queries for performance. Use whenever the user mentions slow queries, query optimization, EXPLAIN plans, index suggestions, or database performance tuning, even if they don't explicitly ask for optimization."7576## Improvement Principles7778- **Generalize from feedback**: Skills are used many times across many prompts. Avoid overfitting to specific examples.79- **Keep the prompt lean**: Remove instructions that aren't pulling their weight. Read transcripts, not just outputs — if the skill makes the agent waste time on unproductive steps, remove those instructions.80- **Explain the why**: Instead of rigid MUSTs, explain reasoning. Today's LLMs are smart — when given good context they go beyond rote instructions.81- **Look for repeated work**: If the agent consistently writes similar helper scripts across sessions, bundle them in `scripts/`.82- **Theory of mind**: Try to understand the task from the user's perspective and transmit that understanding into the instructions.