Paso 6 de 8 - Unos 40 min
Lab 05 - Promotion
Time: about 40 minutes. You will: find a promotion candidate, follow how it becomes a draft skill inside an OpenSpec change, and see the checks that stop an ungated or unapproved skill from landing.
Why
A memory entry only helps when the agent finds it and opens it. A lesson that keeps coming back should become a procedure the agent follows without searching (a skill) or a principle every change must meet (a constitution rule). The risk runs the other way too: a skill written from one bad day is over-fitted, and a wrong rule constrains every future change. Promotion therefore needs three things: evidence (recurrence across distinct changes), an objective gate (evals), and a human yes.
Concepts
Candidate, then target
flywheel.py candidates lists active observation, feedback, and decision entries whose
distinct sources reach promotion.min_occurrences. The suggested target follows the type:
| Type | Suggested target | Skill |
|---|---|---|
observation |
skill | promote-skill |
feedback |
skill or constitution rule | either, by procedure vs principle |
decision |
skill or constitution rule | either |
A procedure ("how to retry a payment call") is a skill. A principle every change must meet ("plain ASCII punctuation in all copy") is a rule. A single high-impact occurrence does not auto-promote; the skill asks whether you want to author it on purpose.
Draft inside a change, install only on yes
openspec/changes/promote-<skill>/
proposal.md recurrence evidence: entries and their source changes
specs/skill-<skill>/spec.md requirements with scenarios from the real failures
tasks.md
draft/SKILL.md the skill: Trigger, Workflow, Example, Anti-patterns
draft/evals/*.md at least eval.min_evals evalsThe flywheel-promoter agent writes only inside that folder. The evaluate skill runs the gate
on draft/. Only after the gate passes and the user says yes is draft/SKILL.md moved to
.claude/skills/<skill>/, with provenance fields:
promoted_from: [sandbox-timeout-needs-idempotency-key]
approved_by: <who approved>
date: 2026-11-22
eval: {score: 0.9, models: [claude-sonnet-5-5], date: 2026-11-22}Then each source entry is marked promoted with promoted_to naming the skill (or
constitution), which removes it from the index. A rejection is recorded as a decision entry so
the same proposal is not made again.
What the CLI enforces
check rejects a promoted skill (one with promoted_from) without approved_by, date, or
eval; an eval that is not a map; a non-numeric score or one below eval.min_score; an empty
models list; a missing date. set-status ... promoted refuses a skill that does not exist, and
check reports an entry whose promoted_to skill was removed.
Build
.claude/skills/promote-skill/SKILL.mdand.claude/skills/promote-constitution-rule/SKILL.md. The rule version adds a contradiction check againstconstitution.mdand a regression check: the judge reads recently archived changes and says whether accepted work would violate the rule..claude/agents/flywheel-promoter.md- its write boundary..flywheel/bin/flywheel.py-promotion_candidates(),cmd_set_status(), and thepromoted_fromblock incheck_skills().openspec/changes/add-promotion/specs/promotion/spec.md.
Run
This step continues from lab 03, where the entry reached 2 occurrences.
python3 .flywheel/bin/flywheel.py candidatessandbox-timeout-needs-idempotency-key type=observation occurrences=2 target=skill sources=add-checkout-retry,add-refundsNeeds Claude Code and a model: ask Claude Code to "promote sandbox-timeout-needs-idempotency-key
to a skill named idempotent-retries". Watch for the four stops: the promoter writes only inside
openspec/changes/promote-idempotent-retries/; the gate runs on draft/; the agent shows you the
evidence, the draft, and the scores; it asks an explicit yes or no question. Answer no the first
time and look for the decision entry it records.
Offline, you can play the last step by hand to see what the CLI checks. Create
.claude/skills/idempotent-retries/SKILL.md:
---
name: idempotent-retries
description: Use when retrying a payment or refund call after a timeout. Retries only with an idempotency key.
promoted_from: [sandbox-timeout-needs-idempotency-key]
approved_by: learner
date: 2026-11-22
eval: {score: 0.9, models: [claude-sonnet-5-5], date: 2026-11-22}
---
# Idempotent retries
## Trigger
A payment call timed out.
## Workflow
1. Reuse the idempotency key of the first request.python3 .flywheel/bin/flywheel.py check
python3 .flywheel/bin/flywheel.py set-status sandbox-timeout-needs-idempotency-key promoted --promoted-to idempotent-retries
python3 .flywheel/bin/flywheel.py candidatescheck passes, the entry is status: promoted and leaves the index, and candidates prints
no promotion candidates (threshold: 2 distinct changes). Note what check did not catch: there
are no evals in .flywheel/evals/idempotent-retries/. The eval count is the evaluate skill's job,
and the score in the frontmatter is only as honest as the run that produced it. That is why a human
approves.
Break it
Record the gate as a bare number. Set
eval: 0.95:ERROR .claude/skills/idempotent-retries/SKILL.md: eval must be a map: {score: <number>, models: [...], date: YYYY-MM-DD}Set
eval: {score: 0.7, models: [claude-sonnet-5-5], date: 2026-11-22}:eval score 0.7 is below the gate 0.8. Seteval: {score: 0.9}:ERROR .claude/skills/idempotent-retries/SKILL.md: eval.models must list the model(s) the evals ran on ERROR .claude/skills/idempotent-retries/SKILL.md: eval.date must be a date (YYYY-MM-DD)Promote to a skill that is not there.
python3 .flywheel/bin/flywheel.py set-status sandbox-timeout-needs-idempotency-key promoted --promoted-to ghost-skillerror: no skill named 'ghost-skill' in .claude/skills; install the approved skill first, or use --promoted-to constitutionExit code 2. Then move the
idempotent-retriesfolder out of.claude/skills/and runcheck:promoted_to 'idempotent-retries' is not a skill in .claude/skills. Move it back.Undo a promotion.
set-status sandbox-timeout-needs-idempotency-key activeputs the entry back in the index and removespromoted_tofrom its frontmatter, socheckstays clean.
Check
python3 -m unittest tests.test_flywheel.TestSkillsAndEvals.test_promoted_skill_needs_provenance_and_gate tests.test_flywheel.TestSkillsAndEvals.test_promotion_gate_cannot_be_bypassed tests.test_flywheel.TestCommands.test_candidates_threshold tests.test_flywheel.TestCommands.test_set_status_promoted_removes_from_index tests.test_flywheel.TestCommands.test_set_status_promoted_needs_existing_skill -vExercises
- Read
.flywheel/evals/promote-skill/two-feedback-entries-one-skill.mdand its fixtures. Why do two different entries become one skill there? Which particulars of the two entries (file paths, change names) should the draft leave out, according to the rules in.claude/agents/flywheel-promoter.md? - Turn the "no em dashes" feedback from lab 03 into a constitution rule draft with
.flywheel/templates/constitution-rule.md. Which existing rule inconstitution.mddoes it overlap, and what should the contradiction check say? - Set
promotion.min_occurrencesto 3 in.flywheel/config.json. What changes incandidatesand in theadd-sourcemessage? Set it back.
Exam connection
CCA-F - Agentic Architecture & Orchestration (a promoter subagent with a write boundary, human-in-the-loop approval, gates before irreversible steps) and Claude Code Configuration & Workflows (project skills, their descriptions as triggers, and provenance for skills you add). Practice both on CertLabPro.
Previous: Lab 04 - The evaluation gate - Next: Lab 06 - Compaction