Iterative skill tuning via execute-evaluate-improve feedback loop. Uses ccw cli Claude to execute skill, Gemini 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".
78
73%
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Critical
Do not install without reviewing
Optimize this skill with Tessl
npx tessl skill review --optimize ./.claude/skills/skill-iter-tune/SKILL.mdIterative skill refinement through execute-evaluate-improve feedback loops. Each iteration runs the skill via Claude, evaluates output via Gemini, and applies improvements via Agent.
┌──────────────────────────────────────────────────────────────────────────┐
│ 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 (execution_mode === "chain"):
Phase 2 runs per-skill in chain_order:
Skill A → ccw cli → artifacts/skill-A/
↓ (artifacts as input)
Skill B → ccw cli → artifacts/skill-B/
↓ (artifacts as input)
Skill C → ccw cli → artifacts/skill-C/
Phase 3 evaluates entire chain output + per-skill scores
Phase 4 improves weakest skill(s) in chain// ★ Auto mode detection
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] }
// ★ Mode selection: chain vs single
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";
}$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⚠️ COMPACT DIRECTIVE: Context compression MUST check TodoWrite phase status. The phase currently marked
in_progressis the active execution phase — preserve its FULL content. Only compress phases markedcompletedorpending.
Read and execute: Ref: phases/01-setup.md
.workflow/.scratchpad/skill-iter-tune-{ts}/Output: workDir, targetSkills[], testScenario, initialized state
// Orchestrator iteration loop
while (true) {
// Increment iteration
state.current_iteration++;
state.iterations.push({
round: state.current_iteration,
status: 'pending',
execution: null,
evaluation: null,
improvement: null
});
// Update TodoWrite
TaskUpdate(iterationTask, {
subject: `Iteration ${state.current_iteration}/${state.max_iterations}`,
status: 'in_progress',
activeForm: `Running iteration ${state.current_iteration}`
});
// === Phase 2: Execute ===
// Read: phases/02-execute.md
// Single mode: one ccw cli call for all skills
// Chain mode: sequential ccw cli per skill in chain_order, passing artifacts
// Snapshot skill → construct prompt → ccw cli --tool claude --mode write
// Collect artifacts
// === Phase 3: Evaluate ===
// Read: phases/03-evaluate.md
// Construct eval prompt → ccw cli --tool gemini --mode analysis
// Parse score → write iteration-N-eval.md → check termination
// Check termination
if (shouldTerminate(state)) {
break; // → Phase 5
}
// === Phase 4: Improve ===
// Read: phases/04-improve.md
// Agent applies suggestions → write iteration-N-changes.md
// Update TodoWrite with score
// Continue loop
}Read and execute: Ref: phases/02-execute.md
iteration-{N}/skill-snapshot/ccw cli -p "..." --tool claude --mode write --cd "${iterDir}/artifacts"Read and execute: Ref: phases/03-evaluate.md
ccw cli -p "..." --tool gemini --mode analysisiteration-{N}-eval.mdRead and execute: Ref: phases/04-improve.md
iteration-{N}-changes.mdRead and execute: Ref: phases/05-report.md
final-report.mdPhase Reference Documents (read on-demand when phase executes):
| Phase | Document | Purpose | Compact |
|---|---|---|---|
| 1 | phases/01-setup.md | Initialize workspace and state | TodoWrite 驱动 |
| 2 | phases/02-execute.md | Execute skill via ccw cli Claude | TodoWrite 驱动 + 🔄 sentinel |
| 3 | phases/03-evaluate.md | Evaluate via ccw cli Gemini | TodoWrite 驱动 + 🔄 sentinel |
| 4 | phases/04-improve.md | Apply improvements via Agent | TodoWrite 驱动 + 🔄 sentinel |
| 5 | phases/05-report.md | Generate final report | TodoWrite 驱动 |
Compact Rules:
in_progress → 保留完整内容,禁止压缩completed → 可压缩为摘要Read() 恢复iteration-state.json is the only source of truthUser Input (skill paths + test scenario)
↓ (+ execution_mode + chain_order if chain mode)
↓
Phase 1: Setup
↓ workDir, targetSkills[], testScenario, iteration-state.json
↓
┌─→ Phase 2: Execute (ccw cli claude)
│ ↓ artifacts/ (skill execution output)
│ ↓
│ Phase 3: Evaluate (ccw cli gemini)
│ ↓ 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// Initial state
TaskCreate({ subject: "Phase 1: Setup workspace", activeForm: "Setting up workspace" })
TaskCreate({ subject: "Iteration Loop", activeForm: "Running iterations" })
TaskCreate({ subject: "Phase 5: Final Report", activeForm: "Generating report" })
// Chain mode: create per-skill tracking tasks
if (state.execution_mode === 'chain') {
for (const skillName of state.chain_order) {
TaskCreate({
subject: `Chain: ${skillName}`,
activeForm: `Tracking ${skillName}`,
description: `Skill chain member position ${state.chain_order.indexOf(skillName) + 1}`
})
}
}
// During iteration N
// Single mode: one score per iteration (existing behavior)
// Chain mode: per-skill status updates
if (state.execution_mode === 'chain') {
// After each skill executes in Phase 2:
TaskUpdate(chainSkillTask, {
subject: `Chain: ${skillName} — Iter ${N} executed`,
activeForm: `${skillName} iteration ${N}`
})
// After Phase 3 evaluates:
TaskUpdate(chainSkillTask, {
subject: `Chain: ${skillName} — Score ${chainScores[skillName]}/100`,
activeForm: `${skillName} scored`
})
} else {
// Single mode (existing)
TaskCreate({
subject: `Iteration ${N}: Score ${score}/100`,
activeForm: `Iteration ${N} complete`,
description: `Strengths: ... | Weaknesses: ... | Suggestions: ${count}`
})
}
// Completed — collapse
TaskUpdate(iterLoop, {
subject: `Iteration Loop (${totalIters} iters, final: ${finalScore})`,
status: 'completed'
})function shouldTerminate(state) {
// 1. Quality threshold met
if (state.latest_score >= state.quality_threshold) {
return { terminate: true, reason: 'quality_threshold_met' };
}
// 2. Max iterations reached
if (state.current_iteration >= state.max_iterations) {
return { terminate: true, reason: 'max_iterations_reached' };
}
// 3. Convergence: ≤2 points improvement over last 2 iterations
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' };
}
}
// 4. Error limit
if (state.error_count >= state.max_errors) {
return { terminate: true, reason: 'error_limit_reached' };
}
return { terminate: false };
}| 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.
0f8e801
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.