agentleFS
cheyuriycheyuriy/codelabgen/skills/code-authoring/SKILL.md

code-authoring

Skill1 starsChanged 23 days agoMITView on GitHub

How to write and fix the code of a codelabgen lesson from its spec — layout, pinned dependencies, teaching-grade comments, region markers for snippets, offline tests, environment variables, and getting `codelabgen verify` to pass — for Python (uv), Node (TypeScript), Go and Rust courses. Used by the code-author and code-fixer agents.

  • Reads credentials

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

10 rules. About 0 are common, 4 are distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Create exactly the files in the spec's files.

    line 27
  2. Very specific:

    Don't touch docs/, README.md or .codelabgen/.

    line 29
  3. Distinctive:

    Every exported function and type gets a doc comment in the language's style.

    line 38
  4. Very specific:

    Configuration through environment variables: Read them with the language's normal API, with a sensible default only for non-secret settings.

    line 41
  5. Distinctive:

    If the formatter moves blank lines around a marker, that's expected.

    line 54
  6. Distinctive:

    Write the tests the spec lists, where the reference says tests live.

    line 58
  7. Distinctive:

    Offline only: no network, no API keys, no LLM, no Docker.

    line 59
  8. Very specific:

    Run codelabgen verify <id> --course <course dir>.

    line 69
  9. Very specific:

    Stop after 5 failed runs and report failed with the cause in notes.

    line 70
  10. Very specific:

    Don't pass --update-state.

    line 72

≈ “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

Writing lesson code

The code is what learners run, read and experiment with. It must work in the pinned version, read like a well-commented teaching example, and pass codelabgen verify.

First: your runtime's reference

The course runtime is runtime.kind in .codelabgen/config.yaml. Read its reference before writing anything. It covers the layout, dependencies, where installed library sources live, comment style, the formatter and linter, and how tests and the live run work:

runtime.kindReference
python-uv${CLAUDE_PLUGIN_ROOT}/skills/code-authoring/references/python.md
node${CLAUDE_PLUGIN_ROOT}/skills/code-authoring/references/node.md
go${CLAUDE_PLUGIN_ROOT}/skills/code-authoring/references/go.md
rust${CLAUDE_PLUGIN_ROOT}/skills/code-authoring/references/rust.md

codelabgen curriculum lessons gives each lesson's directory, package and project names.

Files

  • The lesson directory was created by codelabgen scaffold. Keep its layout.
  • Create exactly the files in the spec's files. If you need another file, say so in the status notes.
  • The scaffold's placeholder (__init__.py docstring, src/main.ts, main.go or src/main.rs with a comment) is yours to replace or keep.
  • Don't touch docs/, README.md or .codelabgen/.

Use only APIs you have seen

Before writing a call, confirm it exists in the installed version. The reference says where the installed sources are; grep them for the function or type and read the signature. Check .codelabgen/research/deprecations.md when it exists, and never use anything listed there. When the docs and the installed source disagree, the installed source wins.

Teaching-grade code

  • Comments in English, more than in production code. Explain why and what the library does here, not what the syntax does. A learner should be able to follow the file without the read-along.
  • Every exported function and type gets a doc comment in the language's style. Every non-obvious line involving the technology gets a comment.
  • Simple over clever. Plain functions, explicit names, no premature abstraction, no metaprogramming. Prefer the library's most common, documented idiom.
  • Types everywhere the language has them.
  • Configuration through environment variables. Read them with the language's normal API, with a sensible default only for non-secret settings. Never hardcode secrets or connection strings. codelabgen verify loads the course and lesson .env files.

Region markers

Wrap every region the spec lists, in the language's line-comment syntax:

# region route        (Python)        // region route        (TypeScript, Go, Rust)
…                                      …
# endregion                            // endregion
  • Names exactly as in the spec's regions. Regions may nest. Markers never appear in the docs.
  • If the formatter moves blank lines around a marker, that's expected; leave it.

Tests

  • Write the tests the spec lists, where the reference says tests live.
  • Offline only: no network, no API keys, no LLM, no Docker. Use fakes and in-memory backends: an in-memory store instead of Postgres, a fake chat model instead of a real one.
  • Fast and deterministic.

The live run

The spec's run_cmd runs the lesson for real: with real services (for example Postgres through POSTGRES_URL) and real keys. It prints clear, readable output showing the concept at work, and exits by itself. Its output is quoted in the read-along, so make it worth reading: short labeled lines, no debug noise.

Finish with a green verify

  1. Format and lint with the commands from the reference.
  2. Run codelabgen verify <id> --course <course dir>. It prints JSON. If it fails, read failed_step and log_tail (the full log is in the course's run_dir), fix, and run it again.
  3. Stop after 5 failed runs and report failed with the cause in notes.

Don't pass --update-state; the orchestrator records the official result.

Fixing failures (code-fixer)

You get the failing verify summary. Work from the evidence:

  • env: a variable is missing. You can't fix it in code: report needs-user and name the variable.
  • services: Docker or the service failed to start. Read the log's diagnosis. A port taken by another course's container, a service not published on its port, or Docker itself being unavailable all need the user: report needs-user with the suggested command.
  • sync: a dependency doesn't resolve. Fix the pins in the lesson's manifest (see the reference).
  • lint / format: run the formatter and the linter's fixer, then fix what remains by hand.
  • offline-tests / live-run: read the error, check the API against the installed source, and fix the code. Never weaken or delete a test to make it pass unless the test itself contradicts the spec, and say so in notes.

Make the smallest change that fixes the cause. Keep regions, comments and the spec's behaviour intact.

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.

Reviews can't be read right now.

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.