state-protocol
Skill1 starsChanged 23 days agoMITView on GitHub
How every codelabgen agent reads and changes course state through the `codelabgen` CLI — lesson stages, phases, failures, blocking, the event log, artifact locations and the status message agents return. Load before any work inside a codelabgen course directory.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- urvijain02/claude-autopilottheir own version, first seen Oct 25, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- urvijain02/claude-autopilot★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository24 other files it gives its agents.
- code-authoringSkill
- codelabgen-orchestratorSkill
- course-extensionSkill
- curriculum-designSkill
- diagrammingSkill
- example-designSkill
- lesson-reviewSkill
- notes-writingSkill
- readalong-writingSkill
- runtime-strategySkill
- site-assemblySkill
- source-articlesSkill
- source-books-coursesSkill
- source-digestSkill
- source-evaluationSkill
- source-github-reposSkill
- source-official-blogSkill
- source-official-docsSkill
- source-package-internalsSkill
- source-papers-specsSkill
- source-qaSkill
- source-talks-workshopsSkill
- source-universitySkill
- topic-extractionSkill
The file
Files
codelabgen state protocol
A codelabgen course is a directory with a hidden .codelabgen/ folder. Its progress lives in .codelabgen/state.json, and every change to it goes through the codelabgen CLI. The CLI holds a lock, validates each change and writes an event to .codelabgen/events.jsonl, which is what makes an interrupted run resumable.
Rules
- Never edit
state.jsonorevents.jsonlwith Edit, Write or shell redirection. Use the commands below. - Pass the course explicitly with
--course <dir>(or setCODELABGEN_COURSE), unless the working directory is inside the course. - A non-zero exit is a refusal, not a glitch. Exit code 2 prints
error: …with the reason, for example a skipped stage or a used-up budget. Report it; don't retry the same command or work around it. - Only the orchestrator changes state. Worker agents (example-designer, code-author, …) never run
state set,fail,block,phaseorregister. They do their work, may run read-only commands andstate log, and report through the status JSON at the end. The orchestrator checks the result and moves the stage.
Running the CLI
codelabgen sessions run with the plugin's virtual environment activated, so codelabgen is on PATH. If it is not found, run it through uv instead:
uv run --project ${CLAUDE_PLUGIN_ROOT} codelabgen …Lesson commands need their own environment. The lesson code has its own uv workspace per module. When you run uv for lesson code yourself, drop the plugin's environment first, or uv uses the wrong venv: env -u VIRTUAL_ENV uv run …. codelabgen verify does this for you.
Lesson stages
Each lesson records the last completed stage:
pending → spec → code → verified → readalong → notes → reviewed → done| Stage done | Work that moves it to the next stage | The orchestrator then runs |
pending | example-designer writes lessons/<id>/spec.yaml | codelabgen state set <id> spec |
spec | code-author writes the code and tests | codelabgen state set <id> code |
code | codelabgen verify <id> --update-state passes (code-fixer repairs failures) | nothing: verify sets verified or counts a failure |
verified | readalong-writer | codelabgen state set <id> readalong |
readalong | notes-writer | codelabgen state set <id> notes |
notes | lesson-reviewer, verdict pass | codelabgen state set <id> reviewed |
reviewed | final checks | codelabgen state set <id> done |
codelabgen state stages prints the same table as JSON.
- Forward moves go exactly one stage at a time.
- Rework moves back to any earlier stage:
codelabgen state set <id> readalong --note "reviewer: example 2 unclear". Moving back fromnotesorrevieweduses up one review round, and the CLI refuses once the budget is gone. - Failed verify:
codelabgen state fail <id> --note "<one-line cause>". When the fix budget runs out, the lesson becomesblockedautomatically. - Block for a decision only the user can make:
codelabgen state block <id> --reason "…". The orchestrator unblocks withcodelabgen state unblock <id>. - Stale:
codelabgen state stale <id> --reason "…"marks a done lesson whose upstream changed. It must be redone from an earlier stage.
Phases (orchestrator only)
init → recon → sources → gate_sources → topics → curriculum → gate_plan → scaffold → lessons → assembly → donecodelabgen state phase <next> advances exactly one phase. Leaving a gate (gate_sources, gate_plan) needs --approved, and only after the user approved in the conversation. Entering assembly requires every lesson to be done.
Reading state
codelabgen state show: human summary.--jsongives the full state.codelabgen state next: JSON with what is left in the current phase (actions), the lesson work items in thelessonsphase, andinterruptedtasks. Lessons in one module run in order; separate modules run in parallel up to the budget.codelabgen state task list --open: tasks still running or failed. Tasks (state task start/done/fail/reset) are the orchestrator's record of worker runs; workers don't touch them.codelabgen report: the generation summary in.codelabgen/report.md.codelabgen schema show <name>: JSON Schema of a data file (config,source,topic,curriculum,lesson-spec,run-result,glossary-entry, …).
Logging
Record notable facts that are not state changes, so the final report can use them:
codelabgen state log <kind> --lesson <id> --data key=value --data key=valueWhere artifacts go
Paths are relative to the course root.
| Artifact | Path |
| Research overview, deprecated APIs | .codelabgen/research/overview.md, .codelabgen/research/deprecations.md |
| Source candidates, source digests | .codelabgen/sources.jsonl, .codelabgen/sources/<id>.md |
| Topics | .codelabgen/topics/<source-id>.jsonl |
| Curriculum, plan | .codelabgen/curriculum.yaml, .codelabgen/plan.md |
| Lesson spec, review | .codelabgen/lessons/<id>/spec.yaml, .codelabgen/lessons/<id>/review.md |
| Lesson code and docs | <module>/<id>-<slug>/ (code, docs/notes.md, docs/readalong.md) |
What a worker returns
Finish with a short JSON block and nothing after it, so the orchestrator can parse it:
{"lesson": "1.2", "status": "ok", "stage": "code", "artifacts": ["1-basics/1.2-routing/src/l1_2_routing/graph.py"], "notes": "one line, optional"}status is ok, failed (the work could not be finished; say why in notes) or needs-user (a decision only the user can make). stage is the stage your work completes; the orchestrator decides whether to record it.
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
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.

