Analyze an existing sub-agent .md file and suggest tightenings — clearer trigger, tighter tool scope, better output-shape contract.
npx mdskills install wshobson/improve-agentRelated
/improve-agent <agent-file>@wshobson? Sign in with GitHub to claim this listing.1# Agent Performance Optimization Workflow23Systematic improvement of existing agents through performance analysis, prompt engineering, and continuous iteration.45[Extended thinking: Agent optimization requires a data-driven approach combining performance metrics, user feedback analysis, and advanced prompt engineering techniques. Success depends on systematic evaluation, targeted improvements, and rigorous testing with rollback capabilities for production safety.]67## Phase 1: Performance Analysis and Baseline Metrics89Comprehensive analysis of agent performance using context-manager for historical data collection.1011### 1.1 Gather Performance Data1213```14Use: context-manager15Command: analyze-agent-performance $ARGUMENTS --days 3016```1718Collect metrics including:1920- Task completion rate (successful vs failed tasks)21- Response accuracy and factual correctness22- Tool usage efficiency (correct tools, call frequency)23- Average response time and token consumption24- User satisfaction indicators (corrections, retries)25- Hallucination incidents and error patterns2627### 1.2 User Feedback Pattern Analysis2829Identify recurring patterns in user interactions:3031- **Correction patterns**: Where users consistently modify outputs32- **Clarification requests**: Common areas of ambiguity33- **Task abandonment**: Points where users give up34- **Follow-up questions**: Indicators of incomplete responses35- **Positive feedback**: Successful patterns to preserve3637### 1.3 Failure Mode Classification3839Categorize failures by root cause:4041- **Instruction misunderstanding**: Role or task confusion42- **Output format errors**: Structure or formatting issues43- **Context loss**: Long conversation degradation44- **Tool misuse**: Incorrect or inefficient tool selection45- **Constraint violations**: Safety or business rule breaches46- **Edge case handling**: Unusual input scenarios4748### 1.4 Baseline Performance Report4950Generate quantitative baseline metrics:5152```53Performance Baseline:54- Task Success Rate: [X%]55- Average Corrections per Task: [Y]56- Tool Call Efficiency: [Z%]57- User Satisfaction Score: [1-10]58- Average Response Latency: [Xms]59- Token Efficiency Ratio: [X:Y]60```6162## Phase 2: Prompt Engineering Improvements6364Apply advanced prompt optimization techniques using prompt-engineer agent.6566### 2.1 Chain-of-Thought Enhancement6768Implement structured reasoning patterns:6970```71Use: prompt-engineer72Technique: chain-of-thought-optimization73```7475- Add explicit reasoning steps: "Let's approach this step-by-step..."76- Include self-verification checkpoints: "Before proceeding, verify that..."77- Implement recursive decomposition for complex tasks78- Add reasoning trace visibility for debugging7980### 2.2 Few-Shot Example Optimization8182Curate high-quality examples from successful interactions:8384- **Select diverse examples** covering common use cases85- **Include edge cases** that previously failed86- **Show both positive and negative examples** with explanations87- **Order examples** from simple to complex88- **Annotate examples** with key decision points8990Example structure:9192```93Good Example:94Input: [User request]95Reasoning: [Step-by-step thought process]96Output: [Successful response]97Why this works: [Key success factors]9899Bad Example:100Input: [Similar request]101Output: [Failed response]102Why this fails: [Specific issues]103Correct approach: [Fixed version]104```105106### 2.3 Role Definition Refinement107108Strengthen agent identity and capabilities:109110- **Core purpose**: Clear, single-sentence mission111- **Expertise domains**: Specific knowledge areas112- **Behavioral traits**: Personality and interaction style113- **Tool proficiency**: Available tools and when to use them114- **Constraints**: What the agent should NOT do115- **Success criteria**: How to measure task completion116117### 2.4 Constitutional AI Integration118119Implement self-correction mechanisms:120121```122Constitutional Principles:1231. Verify factual accuracy before responding1242. Self-check for potential biases or harmful content1253. Validate output format matches requirements1264. Ensure response completeness1275. Maintain consistency with previous responses128```129130Add critique-and-revise loops:131132- Initial response generation133- Self-critique against principles134- Automatic revision if issues detected135- Final validation before output136137### 2.5 Output Format Tuning138139Optimize response structure:140141- **Structured templates** for common tasks142- **Dynamic formatting** based on complexity143- **Progressive disclosure** for detailed information144- **Markdown optimization** for readability145- **Code block formatting** with syntax highlighting146- **Table and list generation** for data presentation147148## Phase 3: Testing and Validation149150Comprehensive testing framework with A/B comparison.151152### 3.1 Test Suite Development153154Create representative test scenarios:155156```157Test Categories:1581. Golden path scenarios (common successful cases)1592. Previously failed tasks (regression testing)1603. Edge cases and corner scenarios1614. Stress tests (complex, multi-step tasks)1625. Adversarial inputs (potential breaking points)1636. Cross-domain tasks (combining capabilities)164```165166### 3.2 A/B Testing Framework167168Compare original vs improved agent:169170```171Use: parallel-test-runner172Config:173 - Agent A: Original version174 - Agent B: Improved version175 - Test set: 100 representative tasks176 - Metrics: Success rate, speed, token usage177 - Evaluation: Blind human review + automated scoring178```179180Statistical significance testing:181182- Minimum sample size: 100 tasks per variant183- Confidence level: 95% (p < 0.05)184- Effect size calculation (Cohen's d)185- Power analysis for future tests186187### 3.3 Evaluation Metrics188189Comprehensive scoring framework:190191**Task-Level Metrics:**192193- Completion rate (binary success/failure)194- Correctness score (0-100% accuracy)195- Efficiency score (steps taken vs optimal)196- Tool usage appropriateness197- Response relevance and completeness198199**Quality Metrics:**200201- Hallucination rate (factual errors per response)202- Consistency score (alignment with previous responses)203- Format compliance (matches specified structure)204- Safety score (constraint adherence)205- User satisfaction prediction206207**Performance Metrics:**208209- Response latency (time to first token)210- Total generation time211- Token consumption (input + output)212- Cost per task (API usage fees)213- Memory/context efficiency214215### 3.4 Human Evaluation Protocol216217Structured human review process:218219- Blind evaluation (evaluators don't know version)220- Standardized rubric with clear criteria221- Multiple evaluators per sample (inter-rater reliability)222- Qualitative feedback collection223- Preference ranking (A vs B comparison)224225## Phase 4: Version Control and Deployment226227Safe rollout with monitoring and rollback capabilities.228229### 4.1 Version Management230231Systematic versioning strategy:232233```234Version Format: agent-name-v[MAJOR].[MINOR].[PATCH]235Example: customer-support-v2.3.1236237MAJOR: Significant capability changes238MINOR: Prompt improvements, new examples239PATCH: Bug fixes, minor adjustments240```241242Maintain version history:243244- Git-based prompt storage245- Changelog with improvement details246- Performance metrics per version247- Rollback procedures documented248249### 4.2 Staged Rollout250251Progressive deployment strategy:2522531. **Alpha testing**: Internal team validation (5% traffic)2542. **Beta testing**: Selected users (20% traffic)2553. **Canary release**: Gradual increase (20% → 50% → 100%)2564. **Full deployment**: After success criteria met2575. **Monitoring period**: 7-day observation window258259### 4.3 Rollback Procedures260261Quick recovery mechanism:262263```264Rollback Triggers:265- Success rate drops >10% from baseline266- Critical errors increase >5%267- User complaints spike268- Cost per task increases >20%269- Safety violations detected270271Rollback Process:2721. Detect issue via monitoring2732. Alert team immediately2743. Switch to previous stable version2754. Analyze root cause2765. Fix and re-test before retry277```278279### 4.4 Continuous Monitoring280281Real-time performance tracking:282283- Dashboard with key metrics284- Anomaly detection alerts285- User feedback collection286- Automated regression testing287- Weekly performance reports288289## Success Criteria290291Agent improvement is successful when:292293- Task success rate improves by ≥15%294- User corrections decrease by ≥25%295- No increase in safety violations296- Response time remains within 10% of baseline297- Cost per task doesn't increase >5%298- Positive user feedback increases299300## Post-Deployment Review301302After 30 days of production use:3033041. Analyze accumulated performance data3052. Compare against baseline and targets3063. Identify new improvement opportunities3074. Document lessons learned3085. Plan next optimization cycle309310## Continuous Improvement Cycle311312Establish regular improvement cadence:313314- **Weekly**: Monitor metrics and collect feedback315- **Monthly**: Analyze patterns and plan improvements316- **Quarterly**: Major version updates with new capabilities317- **Annually**: Strategic review and architecture updates318319Remember: Agent optimization is an iterative process. Each cycle builds upon previous learnings, gradually improving performance while maintaining stability and safety.320
Full transparency — inspect the skill content before installing.