| name | skill-iter-tune |
| description | Iterative skill tuning via execute-evaluate-improve feedback loop. Uses maestro delegate Claude to execute skill, Agy to evaluate quality, and Agent to apply improvements. Iterates until quality threshold or max iterations. Triggers on "skill iter tune", "iterative skill tuning", "tune skill". |
| allowed-tools | ["AskUserQuestion","Bash","Edit","Glob","Grep","Read","Skill","Write","teammate","todo"] |
| session-mode | run |
<required_reading>
@~/.maestro/workflows/run-mode.md
</required_reading>
Skill Iter Tune
Iterative skill refinement through execute-evaluate-improve feedback loops. Each iteration runs the skill via Claude, evaluates output via Agy, and applies improvements via Agent.
Architecture Overview
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Skill Iter Tune Orchestrator (SKILL.md) โ
โ โ Parse input โ Setup workspace โ Iteration Loop โ Final Report โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ โ
โโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโ
โ Phase 1 โ โ Iteration Loop (2โ3โ4) โ โ Phase 5 โ
โ Setup โ โ โโโโโโโ โโโโโโโ โโโโโโโ โ โ Report โ
โ โโโโโโโโ โ P2 โโ โ P3 โโ โ P4 โ โโโโโโโ โ
โ Backup + โ โ โExec โ โEval โ โImpr โ โ โ History โ
โ Init โ โ โโโโโโโ โโโโโโโ โโโโโโโ โ โ Summary โ
โโโโโโโโโโโโ โ โ โ โ โโโโโโโโโโโโ
โ โโโโโโโโโโโโโโโโโ โ
โ (if score < threshold โ
โ AND iter < max) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Chain Mode Extension
Chain Mode (execution_mode === "chain"):
Phase 2 runs per-skill in chain_order:
Skill A โ maestro delegate โ artifacts/skill-A/
โ (artifacts as input)
Skill B โ maestro delegate โ artifacts/skill-B/
โ (artifacts as input)
Skill C โ maestro delegate โ artifacts/skill-C/
Phase 3 evaluates entire chain output + per-skill scores
Phase 4 improves weakest skill(s) in chain
Key Design Principles
- Iteration Loop: Phases 2-3-4 repeat until quality threshold, max iterations, or convergence
- Two-Tool Pipeline: Claude (write/execute) + Agy (analyze/evaluate) = complementary perspectives
- Pure Orchestrator: SKILL.md coordinates only โ execution detail lives in phase files
- Progressive Phase Loading: Phase docs read only when that phase executes
- Skill Versioning: Each iteration snapshots skill state before execution
- Convergence Detection: Stop early if score stalls (no improvement in 2 consecutive iterations)
Interactive Preference Collection
const autoYes = /\b(-y|--yes)\b/.test($ARGUMENTS)
if (autoYes) {
workflowPreferences = {
autoYes: true,
maxIterations: 5,
qualityThreshold: 80,
executionMode: 'single'
}
} else {
const prefResponse = AskUserQuestion({
questions: [
{
question: "้ๆฉ่ฟญไปฃ่ฐไผ้
็ฝฎ๏ผ",
header: "Tune Config",
multiSelect: false,
options: [
{ label: "Quick (3 iter, 70)", description: "ๅฟซ้่ฟญไปฃ๏ผ้ๅๅฐๅน
ๆน่ฟ" },
{ label: "Standard (5 iter, 80) (Recommended)", description: "ๅนณ่กกๆนๆก๏ผ้ๅๅคๆฐๅบๆฏ" },
{ label: "Thorough (8 iter, 90)", description: "ๆทฑๅบฆไผๅ๏ผ้ๅ็ไบง็บง skill" }
]
}
]
})
const configMap = {
"Quick": { maxIterations: 3, qualityThreshold: 70 },
"Standard": { maxIterations: 5, qualityThreshold: 80 },
"Thorough": { maxIterations: 8, qualityThreshold: 90 }
}
const selected = Object.keys(configMap).find(k =>
prefResponse["Tune Config"].startsWith(k)
) || "Standard"
workflowPreferences = { autoYes: false, ...configMap[selected] }
const modeResponse = AskUserQuestion({
questions: [{
question: "้ๆฉ่ฐไผๆจกๅผ๏ผ",
header: "Tune Mode",
multiSelect: false,
options: [
{ label: "Single Skill (Recommended)", description: "็ฌ็ซ่ฐไผๆฏไธช skill๏ผ้ๅๅไธ skill ไผๅ" },
{ label: "Skill Chain", description: "ๆ้พๅบๆง่ก๏ผๅไธไธช skill ็ไบงๅบไฝไธบๅไธไธช็่พๅ
ฅ" }
]
}]
});
workflowPreferences.executionMode = modeResponse["Tune Mode"].startsWith("Skill Chain")
? "chain" : "single";
}
Input Processing
$ARGUMENTS โ Parse:
โโ Skill path(s): first arg, comma-separated for multiple
โ e.g., ".claude/skills/my-skill" or "my-skill" (auto-prefixed)
โ Chain mode: order preserved as chain_order
โโ Test scenario: --scenario "description" or remaining text
โโ Flags: --max-iterations=N, --threshold=N, -y/--yes
Execution Flow
โ ๏ธ COMPACT DIRECTIVE: Context compression MUST check todo({ action: "update" }) phase status.
The phase currently marked in_progress is the active execution phase โ preserve its FULL content.
Only compress phases marked completed or pending.
Phase 1: Setup (one-time)
Read and execute: Ref: phases/01-setup.md
- Parse skill paths, validate existence
- Create workspace at
{run_dir}/outputs/skill-iter-tune-{ts}/
- Backup original skill files
- Initialize iteration-state.json
Output: workDir, targetSkills[], testScenario, initialized state
Iteration Loop
while (true) {
state.current_iteration++;
state.iterations.push({
round: state.current_iteration,
status: 'pending',
execution: null,
evaluation: null,
improvement: null
});
todo({ action: "update" })(iterationTask, {
subject: `Iteration ${state.current_iteration}/${state.max_iterations}`,
status: 'in_progress',
activeForm: `Running iteration ${state.current_iteration}`
});
if (shouldTerminate(state)) {
break;
}
}
Phase 2: Execute Skill (per iteration)
Read and execute: Ref: phases/02-execute.md
- Snapshot skill โ
iteration-{N}/skill-snapshot/
- Build execution prompt from skill content + test scenario
- Execute:
maestro delegate "..." --to claude --mode write --cd "${iterDir}/artifacts"
- Collect artifacts
Phase 3: Evaluate Quality (per iteration)
Read and execute: Ref: phases/03-evaluate.md
- Build evaluation prompt with skill + artifacts + criteria + history
- Execute:
maestro delegate "..." --to agy --mode analysis
- Parse 5-dimension score (Clarity, Completeness, Correctness, Effectiveness, Efficiency)
- Write
iteration-{N}-eval.md
- Check termination: score >= threshold | iter >= max | convergence | error limit
Phase 4: Apply Improvements (per iteration, skipped on termination)
Read and execute: Ref: phases/04-improve.md
- Read evaluation suggestions
- Launch general-purpose Agent to apply changes
- Write
iteration-{N}-changes.md
- Update state
Phase 5: Final Report (one-time)
Read and execute: Ref: phases/05-report.md
- Generate comprehensive report with score progression table
- Write
final-report.md
- Display summary to user
Phase Reference Documents (read on-demand when phase executes):
| Phase | Document | Purpose | Compact |
|---|
| 1 | phases/01-setup.md | Initialize workspace and state | todo({ action: "update" }) ้ฉฑๅจ |
| 2 | phases/02-execute.md | Execute skill via maestro delegate Claude | todo({ action: "update" }) ้ฉฑๅจ + ๐ sentinel |
| 3 | phases/03-evaluate.md | Evaluate via maestro delegate Agy | todo({ action: "update" }) ้ฉฑๅจ + ๐ sentinel |
| 4 | phases/04-improve.md | Apply improvements via Agent | todo({ action: "update" }) ้ฉฑๅจ + ๐ sentinel |
| 5 | phases/05-report.md | Generate final report | todo({ action: "update" }) ้ฉฑๅจ |
Compact Rules:
- todo({ action: "update" })
in_progress โ ไฟ็ๅฎๆดๅ
ๅฎน๏ผ็ฆๆญขๅ็ผฉ
- todo({ action: "update" })
completed โ ๅฏๅ็ผฉไธบๆ่ฆ
- ๐ sentinel fallback โ ่ฅ compact ๅไป
ๅญ sentinel ่ๆ ๅฎๆด Step ๅ่ฎฎ๏ผ็ซๅณ
Read() ๆขๅค
Core Rules
- Start Immediately: First action is preference collection โ Phase 1 setup
- Progressive Loading: Read phase doc ONLY when that phase is about to execute
- Snapshot Before Execute: Always snapshot skill state before each iteration
- Background CLI: maestro delegate runs in background, wait for hook callback before proceeding
- Parse Every Output: Extract structured JSON from CLI outputs for state updates
- DO NOT STOP: Continuous iteration until termination condition met
- Single State Source:
iteration-state.json is the only source of truth
Data Flow
User Input (skill paths + test scenario)
โ (+ execution_mode + chain_order if chain mode)
โ
Phase 1: Setup
โ workDir, targetSkills[], testScenario, iteration-state.json
โ
โโโ Phase 2: Execute (maestro delegate claude)
โ โ artifacts/ (skill execution output)
โ โ
โ Phase 3: Evaluate (maestro delegate agy)
โ โ score, dimensions[], suggestions[], iteration-N-eval.md
โ โ
โ [Terminate?]โโโ YES โโโ Phase 5: Report โ final-report.md
โ โ NO
โ โ
โ Phase 4: Improve (Agent)
โ โ modified skill files, iteration-N-changes.md
โ โ
โโโโโ next iteration
todo({ action: "update" }) Pattern
todo({ action: "next" })
if (state.execution_mode === 'chain') {
for (const skillName of state.chain_order) {
todo({ action: "create" })({
subject: `Chain: ${skillName}`,
activeForm: `Tracking ${skillName}`,
description: `Skill chain member position ${state.chain_order.indexOf(skillName) + 1}`
})
}
}
if (state.execution_mode === 'chain') {
todo({ action: "update" })(chainSkillTask, {
subject: `Chain: ${skillName} โ Iter ${N} executed`,
activeForm: `${skillName} iteration ${N}`
})
todo({ action: "update" })(chainSkillTask, {
subject: `Chain: ${skillName} โ Score ${chainScores[skillName]}/100`,
activeForm: `${skillName} scored`
})
} else {
todo({ action: "create" })({
subject: `Iteration ${N}: Score ${score}/100`,
activeForm: `Iteration ${N} complete`,
description: `Strengths: ... | Weaknesses: ... | Suggestions: ${count}`
})
}
todo({ action: "update" })(iterLoop, {
subject: `Iteration Loop (${totalIters} iters, final: ${finalScore})`,
status: 'completed'
})
Termination Logic
function shouldTerminate(state) {
if (state.latest_score >= state.quality_threshold) {
return { terminate: true, reason: 'quality_threshold_met' };
}
if (state.current_iteration >= state.max_iterations) {
return { terminate: true, reason: 'max_iterations_reached' };
}
if (state.score_trend.length >= 3) {
const last3 = state.score_trend.slice(-3);
if (last3[2] - last3[0] <= 2) {
state.converged = true;
return { terminate: true, reason: 'convergence_detected' };
}
}
if (state.error_count >= state.max_errors) {
return { terminate: true, reason: 'error_limit_reached' };
}
return { terminate: false };
}
Error Handling
| Phase | Error | Recovery |
|---|
| 2: Execute | CLI timeout/crash | Retry once with simplified prompt, then skip |
| 3: Evaluate | CLI fails | Retry once, then use score 50 with warning |
| 3: Evaluate | JSON parse fails | Extract score heuristically, save raw output |
| 4: Improve | Agent fails | Rollback from iteration-{N}/skill-snapshot/ |
| Any | 3+ consecutive errors | Terminate with error report |
Error Budget: Each phase gets 1 retry. 3 consecutive failed iterations triggers termination.
Coordinator Checklist
Pre-Phase Actions
Per-Iteration Actions
Post-Workflow Actions