agentleFS
cheyuriycheyuriy/codelabgen/skills/codelabgen-orchestrator/SKILL.md

codelabgen-orchestrator

Skill1 starsChanged 23 days agoMITView on GitHub

Runs and resumes the codelabgen pipeline from the main session — follows `codelabgen state next`, dispatches the worker agents with task tracking, records state through the `codelabgen` CLI, handles verify failures, reviews and rework, and asks the user its review questions inside the session. Load when a /codelabgen command asks for it.

  • Reads credentials

The file

Show its rules and text

We split this skill into the rules it gives an agent

24 rules. About 0 are common, 8 are distinctive, and 16 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈8

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 16

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When the user must decide (the review gates, a version to confirm, a blocked lesson), ask with the AskUserQuestion tool, right there, then …

    line 17
  2. Distinctive:

    Put the information they need in the chat just before the question: a compact summary, not a file to open.

    line 18
  3. Distinctive:

    Treat a free-text answer as a request, act on it, and ask again until the user approves.

    line 21
  4. Distinctive:

    Every worker run is a task:

    line 47
  5. Very specific:

    Before starting the worker: codelabgen state task start <task> [--lesson <id>].

    line 48
  6. Very specific:

    After it succeeds and you have recorded its result: codelabgen state task done <task>.

    line 49
  7. Very specific:

    If it fails: codelabgen state task fail <task> --note "<why>".

    line 50
  8. Distinctive:

    Run tech-scout with the course directory, the topic and the version (if given).

    line 68
  9. Very specific:

    Run one source-hunter per source type (task sources:<type>), in parallel (background agents), each with its skill.

    line 75
  10. Very specific:

    Check that .codelabgen/research/deprecations.md exists.

    line 91
  11. Distinctive:

    Ask (AskUserQuestion), single choice:

    line 98
  12. Very specific:

    Run one topic-extractor per batch (the task key comes from state next), up to parallel_agents at a time in the background.

    line 112
  13. Very specific:

    Run curriculum-architect (task curriculum:architect).

    line 119
  14. Very specific:

    Run runtime-planner (task curriculum:runtime).

    line 120
  15. Distinctive:

    Ask (AskUserQuestion), in one call:

    line 127
  16. Very specific:

    Only when the user approved the plan and every question is answered: codelabgen state phase scaffold --approved, then continue straight on.

    line 134
  17. Very specific:

    If the course needs secrets: list each variable and where to get it (codelabgen env list), tell the user to put them in the course .env …

    line 140
  18. Very specific:

    When the verify fix budget runs out, verify --update-state blocks the lesson by itself ("stage": "blocked" in its output).

    line 161
  19. Very specific:

    After any review, apply the [spec] items yourself: edit .codelabgen/lessons/<id>/spec.yaml so it matches the verified behaviour (usually an …

    line 177
  20. Very specific:

    Every worker in a rework round must read .codelabgen/lessons/<id>/review.md and fix its own tagged items.

    line 179
  21. Very specific:

    When codelabgen state next reports that all lessons are done, continue straight into assembly: follow the assembly procedure in the …

    line 187
  22. Distinctive:

    Ask (AskUserQuestion): "Score two sample lessons now?" with "Yes, quickly", "Later (eval-human.md)" and "No".

    line 193
  23. Very specific:

    gaps: run gap-analyst (task ext<n>:gaps), then codelabgen extend stage research.

    line 202
  24. Very specific:

    Wait for the status JSON at the end of the worker's reply.

    line 229

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

codelabgen orchestrator

You drive course generation from the main session. Only you start subagents, and only you change course state (see the state-protocol skill). Workers do one job each and end with a status JSON.

The phases, in order: init → recon → sources → gate_sources → topics → curriculum → gate_plan → scaffold → lessons → assembly → done. Every command (new, sources, plan, lesson, build, resume) runs the same loop from wherever the course is.

Run to the end, ask in the session

One command runs the whole course: from init to done, then the evaluation. Never end your turn telling the user to run another command, edit a file or "come back when ready".

When the user must decide (the review gates, a version to confirm, a blocked lesson), ask with the AskUserQuestion tool, right there, then continue with the answer:

  • Put the information they need in the chat just before the question: a compact summary, not a file to open.
  • Offer concrete options, with the recommended one first, marked "(Recommended)". The tool adds a free-text "Other" answer by itself; mention it when free text is useful ("Other: paste URLs to add").
  • At most 4 questions per call and 4 options per question. Split bigger choices into several calls.
  • Treat a free-text answer as a request, act on it, and ask again until the user approves.

The only time the user acts outside the chat is for secrets: never ask for API keys in the conversation. Tell them which variables to put in the course .env (full path), then ask a question with the option "Done, the keys are in .env". Check with codelabgen env check, and ask again if anything is still missing.

Before you start

  1. Find the course: the directory from the command's arguments, $CODELABGEN_COURSE, or the current directory. Every CLI call below takes --course <dir>.
  2. codelabgen doctor: stop and tell the user if a required tool is missing. Docker must show ok if any lesson uses services. The github line shows how GitHub research will work (gh, token or anonymous).
  3. codelabgen state show, then codelabgen state next.

The main loop

codelabgen state next is the source of truth for what remains. It reads the state and the files on disk, so it never repeats finished work. Its JSON has:

  • phase: where the course is
  • actions: what to do now, in order. Each has a do:
    • run-agent: start the named worker, with the task key and args (see "Starting a worker")
    • command: a codelabgen command you run yourself
    • ask-user: ask the user in the session (review gates, missing secrets, a version to confirm), then go on
    • advance: move to the next phase (run holds the exact command; --approved only after the user approved)
  • lessons / blocked in the lessons phase: the work items (see "Lesson production")
  • interrupted: tasks whose worker stopped midway in an earlier session

Repeat: run state next, do its actions (independent run-agent actions in parallel, up to budgets.parallel_agents at once, default 4), then run state next again. For ask-user actions, ask in the session (see above) and continue. Stop only when the phase is done and the evaluation is shown, or when the user tells you to stop. The phase sections below say how to do each step well; state next says which steps are left.

Tasks and resuming

Every worker run is a task:

  1. Before starting the worker: codelabgen state task start <task> [--lesson <id>]. It prints the attempt number.
  2. After it succeeds and you have recorded its result: codelabgen state task done <task>.
  3. If it fails: codelabgen state task fail <task> --note "<why>". One retry is allowed; the next task start counts it.

A task that is still running when a session starts was interrupted: the session ended while its worker was busy. state next marks it ("interrupted": true). Its worker may have left partial work: a half-written spec, some of the code, a digest without all its sections, a few sources already added. When you restart such a task, say so in the worker's prompt: "A previous attempt was interrupted. Check what it left in <paths>, keep what is correct, and complete the rest." Never just delete partial work.

Lesson tasks are named lesson:<id>:<stage being produced>, for example lesson:1.2:code for the code-author run. state next gives the key with each lesson.

Research

Phase init: start a course

/codelabgen:new gives you the topic, the target directory and optionally the language, the version and the user's own source URLs.

  1. The target directory must be given explicitly and must be outside the plugin directory. If it is missing, ask for it.
  2. codelabgen init <dir> --topic "<topic>" --lang <lang> [--version <v>] [--source <url> …] [--source-type <type> …] [--sources-per-type N] [--wishes "…"]. If the user states wishes for the course later (scope, size, things to skip), save them: codelabgen config set wishes "…".
  3. codelabgen state phase recon.

Phase recon: what is this technology?

  1. Run tech-scout with the course directory, the topic and the version (if given).
  2. Read .codelabgen/research/overview.md. If the user gave no version, ask (AskUserQuestion) with the proposed version as the recommended option and the previous stable one as an alternative, then record the answer: codelabgen config set version <v>. If the identity of the technology was ambiguous, ask which one is meant in the same call.
  3. codelabgen state phase sources.

Phase sources: find sources

  1. Record the user's own sources first (user_sources in codelabgen config show): for each, codelabgen sources add --json '{"url": …, "type": <best guess>, "roles": [<best guess>], "title": <url or page title>, "score": 1.0, "reason": "Provided by the user", "status": "user"}'.
  2. Run one source-hunter per source type (task sources:<type>), in parallel (background agents), each with its skill. state next lists only the types not done yet:

    Type in the promptSkill
    official-docssource-official-docs
    official-blog and release-notes (also writes deprecations.md)source-official-blog
    package-internalssource-package-internals
    articlesource-articles
    github-reposource-github-repos
    qasource-qa
    paper-specsource-papers-specs
    talk-workshopsource-talks-workshops
    universitysource-university
    book-coursesource-books-courses
  3. As hunters finish, give the user one line each (type, how many, any gap). A hunter that fails gets one retry. If it fails again, report the gap and move on.
  4. Check that .codelabgen/research/deprecations.md exists. If it doesn't, run the official-blog hunter again with only that task.
  5. codelabgen sources render (a record of the list, for later), then codelabgen state phase gate_sources.

Phase gate_sources: the user reviews sources

  1. codelabgen sources overview gives the sources grouped by type, each with default_keep (score 0.6 or more, or added by the user).
  2. In the chat, show per type: how many were found and how many would be kept, and the 1–2 strongest titles with a few words each. Name the gaps (types with nothing good).
  3. Ask (AskUserQuestion), single choice:
    • "Accept the proposed selection (Recommended)": keep what default_keep says
    • "Review by type": go through the types
    • "Add sources first": they type URLs in "Other" (or you ask a follow-up)
  4. Review by type: for each type with sources, ask a multi-select question ("Which <type> sources should the course use?") with one option per source: the label is a short title, the description is the score and the reason. Mention which ones are proposed (the default). Up to 4 options per question and 4 questions per call; split long types into several questions ("official-docs, 1–4", "official-docs, 5–8"). Selected means keep.
  5. Record the decisions: codelabgen sources decide --default for "accept"; for a review, codelabgen sources decide --keep <id> … --drop <id> … covering every reviewed source.
  6. Added URLs (from any "Other" answer): add each with codelabgen sources add ("status": "user", a best-guess type and roles, the URL as title), then run the matching hunter for each to check it and fill in a real title, type and roles (re-adding merges).
  7. Report the result in one line (kept, dropped, added), then codelabgen state phase topics --approved and continue straight on with phase topics.

Curriculum

Phase topics: digests and topics

  1. codelabgen sources batches --size 5: groups of source ids that still need a digest (on a resumed run, only the missing ones).
  2. Run one topic-extractor per batch (the task key comes from state next), up to parallel_agents at a time in the background. When one finishes, start the next batch.
  3. codelabgen sources digests must print all digests present. Give a missing digest one retry. If it fails again, mark the source as dropped in sources.md, run codelabgen sources apply, and tell the user.
  4. codelabgen topics merge and codelabgen sources index. Tell the user in one line how many topics were found.
  5. codelabgen state phase curriculum.

Phase curriculum: plan the course

  1. Run curriculum-architect (task curriculum:architect). Pass on the user's wishes (from state next / the config) and the problems from state next if an earlier draft is invalid.
  2. Run runtime-planner (task curriculum:runtime).
  3. codelabgen curriculum validate, codelabgen sources index (it now shows which lessons use which source), codelabgen curriculum render.
  4. codelabgen state phase gate_plan.

Phase gate_plan: the user reviews the plan

  1. Show the plan in the chat: modules with their lessons, one line each (id, title, what it teaches); the example storyline in one or two lines; services and external services. Mention .codelabgen/plan.md as the full version, but don't require reading it.
  2. Ask (AskUserQuestion), in one call:
    • "Do you approve this plan?": "Approve (Recommended)", "Change the plan" (they describe the change in "Other", or you ask a follow-up)
    • one question per runtime planner question from .codelabgen/research/runtime.md, with its options (for example the LLM providers and models) and the suggested default first. Skip this if there are none.
  3. Handle the answers in rounds, then ask again:
    • Structure changes ("merge 2.3 and 2.4", "add a lesson on streaming", "skip deployment"): codelabgen state task reset curriculum:architect and … curriculum:runtime, run curriculum-architect with the feedback, then runtime-planner, then validate and render again.
    • Small wording changes: edit curriculum.yaml yourself, then validate and render.
    • Answers to the questions: run runtime-planner with the answers. It records them (codelabgen config external add …) and adds the variables to env. Then validate and render.
  4. Only when the user approved the plan and every question is answered: codelabgen state phase scaffold --approved, then continue straight on.

Phase scaffold: prepare the course directory

  1. codelabgen scaffold course. It writes the module workspaces and lesson directories, docker-compose.yml, .env.example and .env, initializes git, and registers the lessons.
  2. codelabgen toc, which writes run.sh and the READMEs.
  3. If the course needs secrets: list each variable and where to get it (codelabgen env list), tell the user to put them in the course .env (full path), and ask (AskUserQuestion) with the option "Done, the keys are in .env". Repeat until codelabgen env check prints ok.
  4. codelabgen state phase lessons, then continue with lesson production.

Lesson production

codelabgen state next returns up to parallel_modules lessons, at most one per module, each with its current stage, the task key of the next step, and whether that step was interrupted. Lessons of one module always run in order, because examples build on each other.

For each lesson, repeat until it is done, blocked, or needs the user:

Current stageDo thisWhen it succeeds
pendingRun example-designercodelabgen state set <id> spec
specRun codelabgen scaffold lesson <id> (copies the earlier lesson's code for an extending example), then code-authorcodelabgen state set <id> code
codeRun codelabgen verify <id> --update-stateVerify itself sets verified, or counts a failed attempt: then run code-fixer with the JSON it printed and verify again
verifiedRun readalong-writercodelabgen state set <id> readalong
readalongRun notes-writercodelabgen state set <id> notes
notesRun lesson-reviewerverdict pass: codelabgen state set <id> reviewed. Verdict revise: see "Rework"
reviewedcodelabgen check snippets <id> must print okcodelabgen state set <id> done

Wrap each worker run in its task (state task start before, state task done after recording the stage). verify is not a worker: run it directly. Before recording a stage, check the worker's status JSON and that its artifacts exist. A worker that reports failed gets one retry with its notes included in the prompt. After that, block the lesson: codelabgen state block <id> --reason "<why>".

When the verify fix budget runs out, verify --update-state blocks the lesson by itself ("stage": "blocked" in its output). Stop working on that lesson.

needs-user from any worker: block the lesson with the worker's reason, tell the user what is needed, and ask (AskUserQuestion) how to go on: for example "Done, retry the lesson" (then codelabgen state unblock <id>), "Skip this lesson for now", or a free-text instruction. Meanwhile, other modules' lessons can continue.

Rework after a review

The reviewer returns rework_from. Move the lesson back so the right workers run again, with the note pointing at review.md:

rework_fromCommandWorkers that run again
codecodelabgen state set <id> spec --note "review round N"code-author (fixes [code] items), verify, readalong-writer, notes-writer, reviewer
readalongcodelabgen state set <id> verified --note "review round N"readalong-writer, notes-writer, reviewer
notescodelabgen state set <id> readalong --note "review round N"notes-writer, reviewer

The CLI refuses once the review budget is used up. Then show the open items from review.md in the chat and ask (AskUserQuestion): "Accept the lesson as it is" (codelabgen state set <id> reviewed, then done) or "Block it for now".

After any review, apply the [spec] items yourself: edit .codelabgen/lessons/<id>/spec.yaml so it matches the verified behaviour (usually an experiment's expected outcome), then codelabgen state log spec-fixed --lesson <id>. Later lessons build on these specs.

Every worker in a rework round must read .codelabgen/lessons/<id>/review.md and fix its own tagged items. Say so in its prompt.

Parallel modules

When state next returns lessons from different modules, run their pipelines side by side: start each lesson's next worker as a background agent, and when one finishes, record its stage and start that lesson's next step. Never run two lessons of the same module at once. When everything returned by state next is done, ask state next again.

Assembly

When codelabgen state next reports that all lessons are done, continue straight into assembly: follow the assembly procedure in the site-assembly skill (glossary, toc, check all, site build, commit, services down, phase done).

Finishing: evaluation

After phase done:

  1. codelabgen report and codelabgen eval --site. Show the overall score, the dimensions, anything missing, and the timings, in a few lines.
  2. Ask (AskUserQuestion): "Score two sample lessons now?" with "Yes, quickly", "Later (eval-human.md)" and "No".
  3. On yes: for each lesson in .codelabgen/eval-human.md, say where to read it (paths, and ./run.sh site serve for the site), then ask the six questions from that file as single-choice 1–5 (two calls of three questions, labels "5 — excellent" … "1 — poor"). Write the scores into eval-human.md (replace each [_] with the digit) and run codelabgen eval again to include them.
  4. End with how to use the course: the course README, ./run.sh <id>, ./run.sh site serve.

Extensions

/codelabgen:extend <dir> "<request>" extends a finished course. state next drives it like everything else: while an extension is before lesson production, it returns extension and that extension's actions.

  1. Start: codelabgen extend start "<request>". It refuses if lessons are unfinished or the course repo has uncommitted changes. Tell the user why and stop.
  2. gaps: run gap-analyst (task ext<n>:gaps), then codelabgen extend stage research.
  3. research: one source-hunter per entry of hunt.yaml (tasks ext<n>:hunt:<type>), passing its focus. Then codelabgen sources keep-proposed --min-score 0.6 and codelabgen extend stage digests.
  4. digests: topic-extractor batches as in phase topics, then topics merge, sources index, and extend stage delta.
  5. delta: curriculum-architect in extend mode (task ext<n>:architect, with the proposal path), then runtime-planner in extend mode (task ext<n>:runtime), then codelabgen extend diff and extend stage gate.
  6. gate: summarize .codelabgen/extensions/<n>/delta.md in the chat (new lessons, rewritten lessons, renamed ones, renumbering, lessons to re-check, sources kept during this extension, new runtime questions) and ask (AskUserQuestion): "Apply (Recommended)", "Change it" (free text, back to the architect with codelabgen state task reset ext<n>:architect); if the delta renumbers lessons, a separate question "Renumber existing lessons?" with "Yes" / "No, place new lessons at the end instead". On approval: codelabgen extend apply, adding --allow-renumber only if they said yes to renumbering. For new secrets, the .env procedure from "Run to the end".
  7. Lessons: the course is back in phase lessons. Produce the new and rewritten lessons as usual.
    • Stale lessons ("stage": "stale" in state next): run codelabgen verify <id>. If it fails, codelabgen state set <id> spec --note "stale: <cause>" and redo from the code. If it passes, run lesson-reviewer with the note "This lesson builds on lesson X, which was rewritten; check that it still agrees". On pass: state set <id> reviewed, then done. On revise: rework as for any review.
  8. Assembly as usual. Commit with a message naming the extension: codelabgen commit -m "Extension <n>: <request>". Then codelabgen extend finish.

Starting a worker

Workers are this plugin's agents (codelabgen:<name>). Give each one everything it needs in its prompt. Get the lesson details from codelabgen curriculum lessons. For research and curriculum workers, pass the course directory, the course language, the technology and version, and the args from state next.

Course directory: <absolute path>
Lesson: <id> "<title>"
Lesson directory: <absolute path>      Module directory: <absolute path>
Runtime: <python-uv | node | go | rust>  Package / project: <package> / <project>
Course language: <language>            Technology: <topic> <version>
Example: <new | extends lesson X>
Lesson sources (digests in .codelabgen/sources/): <the node's sources>
<For rework: Review round N; fix the items tagged [<part>] in .codelabgen/lessons/<id>/review.md>
<For code-fixer: the full JSON printed by codelabgen verify>
<For an interrupted task: A previous attempt was interrupted; check and complete its partial work in …>
Task: <one line, e.g. "Write the lesson spec">

Wait for the status JSON at the end of the worker's reply. If it is missing or malformed, treat the run as failed.

Keeping the user informed

After each step, send one short line: what finished, anything notable. When the work stops (all done, blocked or waiting for the user), summarize with codelabgen state show. At the end of a course, codelabgen report gives the generation summary (timings, verify runs, review rounds, unfinished tasks), and codelabgen eval scores the course against the rubric. Show the user the overall score, the dimensions and anything missing, and point them to .codelabgen/eval-human.md for their own review of two sampled lessons.

Budgets

budgets in .codelabgen/config.yaml: fix_attempts (verify failures before a lesson blocks), review_rounds, parallel_modules (lessons in flight), parallel_agents (agents at once in research and topics), sources_per_type. The CLI enforces the first two. Respect the last three yourself.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.