ワンクリックで
metacognitive-self-mod
// Analyze and improve the improvement process. Use for detecting regressions and meta-optimization.
// Analyze and improve the improvement process. Use for detecting regressions and meta-optimization.
Review plugin quality with tiered checks and dependency scoping. Use for PR and pre-release audits.
Applies client-server architecture for web/mobile apps. Use when designing systems with centralized backend services, trust boundaries, or offline-first sync.
Applies CQRS and Event Sourcing for read/write separation and audit trails. Use when designing systems with complex domain logic or full state-change history.
Applies event-driven async messaging to decouple producers and consumers. Use when designing real-time or multi-subscriber systems needing loose coupling.
Applies Functional Core, Imperative Shell to isolate logic from side effects. Use when business logic is entangled with I/O or unit tests are slow and brittle.
Applies hexagonal architecture isolating domain from infrastructure. Use when designing systems where testability and port/adapter separation are priorities.
| name | metacognitive-self-mod |
| description | Analyze and improve the improvement process. Use for detecting regressions and meta-optimization. |
| alwaysApply | false |
| trigger | metacognitive, self-modification, improve the improver, meta-improvement, improvement effectiveness, regression detected, improvement failed |
| model_hint | standard |
| progressive_loading | true |
| modules | ["modules/trace-capture.md"] |
Analyze the effectiveness of past skill improvements and refine the improvement process itself. This is the core innovation from the Hyperagents paper: not just improving skills, but improving HOW skills are improved.
This skill should be invoked automatically when:
Regression detected: The homeostatic monitor finds
a skill's evaluation window ended in
pending_rollback_review status. The improvement
made things worse — we need to understand why.
Low effectiveness rate: When
ImprovementMemory.get_effective_strategies() vs
get_failed_strategies() shows effectiveness below
50%, the improvement process itself needs refinement.
Degradation despite improvements: When
PerformanceTracker.get_improvement_trend() returns
negative for a skill that was recently improved.
Periodic check: After every 10 improvement cycles (tracked via outcome count in ImprovementMemory).
The homeostatic monitor emits
"improvement_triggered": true when a skill crosses the
flag threshold. At that point, before dispatching the
skill-improver, check if metacognitive analysis is
warranted:
from abstract.improvement_memory import ImprovementMemory
from pathlib import Path
memory = ImprovementMemory(
Path.home() / ".claude/skills/improvement_memory.json"
)
# Check if metacognitive analysis is warranted
effective = memory.get_effective_strategies()
failed = memory.get_failed_strategies()
total = len(effective) + len(failed)
needs_metacognition = False
# Trigger 1: Low effectiveness rate
if total >= 5 and len(effective) / total < 0.5:
needs_metacognition = True
# Trigger 2: Periodic check (every 10 outcomes)
if total > 0 and total % 10 == 0:
needs_metacognition = True
# Trigger 3: Recent regression
if failed and failed[-1].get("outcome_type") == "failure":
needs_metacognition = True
if needs_metacognition:
# Run metacognitive analysis before next improvement
pass # Skill(abstract:metacognitive-self-mod)
Read improvement memory and performance tracker data:
# Check for improvement memory
MEMORY_FILE=~/.claude/skills/improvement_memory.json
TRACKER_FILE=~/.claude/skills/performance_history.json
if [ ! -f "$MEMORY_FILE" ]; then
echo "No improvement memory found."
echo "Run skill-improver first to generate improvement data."
exit 0
fi
Load the JSON files using Python:
from abstract.improvement_memory import ImprovementMemory
from abstract.performance_tracker import PerformanceTracker
from pathlib import Path
memory = ImprovementMemory(Path.home() / ".claude/skills/improvement_memory.json")
tracker = PerformanceTracker(Path.home() / ".claude/skills/performance_history.json")
For each improvement outcome in memory, classify:
after_score - before_score >= 0.1-0.1 < improvement < 0.1after_score < before_scoreeffective = memory.get_effective_strategies()
failed = memory.get_failed_strategies()
# Calculate effectiveness rate
total = len(effective) + len(failed)
if total > 0:
effectiveness_rate = len(effective) / total
Analyze WHAT types of improvements succeed vs fail:
Success patterns to look for:
Failure patterns to look for:
For each pattern found, record as a causal hypothesis:
memory.record_insight(
skill_ref="_meta", # Special ref for meta-insights
category="causal_hypothesis",
insight="Error handling improvements have 85% success rate",
evidence=["skill-A v1.1.0: +0.3", "skill-B v2.1.0: +0.15"]
)
Use PerformanceTracker to identify:
for skill_ref in tracker.get_all_skill_refs():
trend = tracker.get_improvement_trend(skill_ref)
if trend is not None:
if trend > 0.05:
# Sustained improvement - what's working?
pass
elif trend < -0.05:
# Degrading despite improvements - investigate
pass
Based on the meta-analysis, generate recommendations for the skill-improver:
Priority formula adjustments: If certain issue types have higher improvement success rates, weight them higher.
Approach selection: If "add error handling" has 85% success vs "restructure workflow" at 30%, bias toward error handling.
Threshold adjustments: If improvements below priority 3.0 consistently fail, raise the minimum threshold.
Avoidance rules: Document anti-patterns to avoid in future improvements.
Record all findings back into ImprovementMemory under the
special _meta skill ref:
# Record strategy recommendation
memory.record_insight(
skill_ref="_meta",
category="strategy_success",
insight="Recommendation: Prioritize error handling and examples over restructuring",
evidence=[f"Success rate: error_handling={eh_rate:.0%}, restructure={rs_rate:.0%}"]
)
If significant meta-insights are found, propose concrete modifications to the skill-improver agent:
Important: Propose changes, do not auto-apply. The user must approve modifications to the improvement process.
Metacognitive Self-Modification Report
Improvement Data:
Total outcomes analyzed: 15
Effective improvements: 11 (73%)
Regressions: 2 (13%)
Neutral: 2 (13%)
Success Patterns:
1. Error handling additions: 5/6 success (83%)
2. Example additions: 3/3 success (100%)
3. Quiet mode additions: 2/2 success (100%)
Failure Patterns:
1. Workflow restructuring: 1/3 success (33%)
2. Token-heavy additions: 0/1 success (0%)
Performance Trends:
Improving: 8 skills (positive trend)
Stable: 4 skills (no trend)
Degrading: 1 skill (negative trend despite attempts)
Recommendations:
1. Weight error handling improvements 2x in priority
2. Avoid workflow restructuring below priority 8.0
3. Cap additions at 200 tokens to prevent budget overflow
4. Focus next improvement cycle on degrading skill X
Meta-insights stored: 5 new entries in improvement memory
abstract:skill-improver - The agent this skill analyzes
and proposes modifications forabstract:skills-eval - Evaluation framework whose
criteria could be refined by meta-insightsabstract:aggregate-logs - Data source for improvement
metrics