Skip to content

Course folders from the command line

A course folder is a course written as Markdown and YAML. This page covers every command that works on one: course init, pull, push, diff, status, apply, publish, resolve and absorb-drift talk to an academy (they work with AI switched off), and course validate and course fmt need no server, no login and no network, so they run in an editor, a pre-commit hook and CI. The commands that work on one JSON document instead of a folder (course export, import, approve) are in Build courses from the command line.

The folder is bound to one course made with the course builder. .ulams/base.json records the version the folder was last in step with, so the commands know what you changed, what the server changed, and when a push would overwrite something.

Terminal window
ulams course init ./kubernetes-101 --from-course 12 # write the course as a folder, record the base
cd kubernetes-101
$EDITOR modules/01-basics/01-install.md
ulams course status # local edits, server version, proposal, applied?
ulams course diff # what you changed since the base (no network)
ulams course push --message "Fix the install step" # propose it: nothing changes for learners yet
ulams course apply --approve # a person approves the proposal and applies it
ulams course publish # learners can enrol

A push is always a proposal. It becomes a version of kind import that waits for a decision. Nothing reaches learners until it is approved and applied. A person approves it in the studio (the version review shows the same element diff), or with --approve / --apply on the command line when logged in or using a CLI token they created. Agent tokens and MCP clients can only propose: approving is refused with APPROVAL_REQUIRES_HUMAN (exit 4), and the proposal stays for a person to approve. Tokens of kind ci may approve only when the tenant allows it. The rules are in the Course Builder API.

Command What it does
course init [dir] --from-course <id> [--ci github] Writes the course’s current version as a folder (the folder must be empty; a README and dot files may be there) and records .ulams/base.json. A course that was not made with the builder is refused (NOT_ADOPTED). --ci github also writes the CI workflow (see GitHub Action and Docker image).
course status One request plus the folder: local edits since the base, whether the server moved on (behind), a proposal waiting for approval, whether the current version is applied, drift (elements edited in the LMS since the last apply), open conflicts, and the next command to run. Always exits 0.
course diff Folder against its base: elements added, changed or removed, offline. --remote compares with the server’s current version, field by field (what a push would change). --version <id> shows what a version on the server changes against its parent (or --against <id>). --exit-code exits 13 when there are differences. --from <id> --to <id> compares any two versions or releases instead (see course compare below).
course push [--message] [--approve] [--apply] [--allow-pending] Validates the folder, sends it as a proposed version based on the base, prints the diff. --approve approves it; --apply approves and applies it and waits for the apply (--no-wait returns at once with the run handle). A folder equal to its base sends nothing. While an open Living Course update proposal changes the same elements the push stops with SYNC_CONFLICT (PROPOSAL_PENDING); --allow-pending stores the push anyway.
course sources-connect [dir] [--host] [--branch] [--paths] [--token] Lets Living Course watch the sources/ folder of the repository the course folder lives in (see Git merges and Living Course).
course apply [session] [--approve] [--version <id>] Applies the current version (an unpublished draft). When the folder holds a proposal nobody approved, refuses with CONFIRMATION_REQUIRED (exit 11) unless --approve. Pass a session id to run it outside a folder.
course publish [session] [--acknowledge-warnings] Runs the publish check and publishes. Blocking items stop it (exit 6, error.details.blocking); warnings stop it until you pass --acknowledge-warnings (exit 11, error.details.warnings). The course must be applied first.
course pull Brings the folder up to date with the server, merging your edits with theirs (see below).
course resolve <element> --take local|remote|file Settles one conflict that pull left in .ulams/conflicts/ (see Conflicts).
course releases <course> [--page] [--per-page] Lists the releases of a course, newest first: number, when it went live, what started it (generate, author, chat, update, insights, import, restore), who approved it and what changed since the previous release. Works with AI switched off and needs no folder. A course that was not made with the builder has no releases (NOT_FOUND). --json returns the API payload (Course releases).
course compare <course> --from <id> --to <id> Compares any two versions or releases of a course: elements added, removed, changed, moved and reordered, citations that changed (and the ones repointed to a newer source revision), quiz answer keys with what learners would get, and a plain summary. Works with AI switched off, makes no model call and needs no folder. Swap the two ids for the reverse; a variant course can be compared with its base. --json returns the payload (Compare two versions). The same MCP tool is course_compare (read-only, toolset builder).
course diff --from <id> --to <id> [--course <id>] The same comparison under course diff; the course is the folder’s, or pass --course. --exit-code exits 13 when the two differ. Without --from and --to, diff compares the folder, the server or one version as described below.
course absorb-drift [--preview] Reads edits an admin made in the LMS after the last apply back into a proposed version (see Edits made in the LMS).

Every command that sends something has --dry-run: push validates the folder and prints the request and the diff, apply and publish print the request, init and pull list the files they would write. Nothing is sent or written.

course pull fetches the current version and compares three things: the base (what the folder was), the folder, and the server.

Folder Server pull does
unchanged unchanged nothing (“already up to date”)
unchanged changed rewrites the files to match and moves the base. Files you renamed keep their names (the number prefixes follow the new order), files of removed lessons are deleted, assets/, sources/ and your own files are never touched.
changed unchanged nothing; your edits stay (diff shows them)
equal to the server changed moves the base only (for example the version you pushed was approved in the studio)
changed changed differently merges element by element, writes a conflict file for each element both sides changed, moves the base to the server’s version, and exits 6 when there are conflicts

The merge works on elements (a block, a lesson, a question, an option, the course settings), matched by id, never by position or by line. Against the version the folder is based on (GET versions/{id}):

Your folder The server Result
unchanged changed the server’s version
changed unchanged yours
changed, identical changed, identical either (no conflict)
changed changed differently conflict (yours stays in the folder until you decide)
removed edited, or something inside it edited conflict
edited, or something inside it edited removed conflict
moved not moved moved
moved elsewhere moved elsewhere conflict
added added (other ids) both are kept

One conflict per element, with no field-level merge: if you changed a lesson’s title and the studio changed its minutes, that lesson is one conflict. Removing an element (a lesson, a quiz) together with everything in it counts as touching it when the other side changed anything inside, and then the whole subtree is one conflict. Order: when only one side reordered a list, its order wins; when both did, the server’s order is kept and your new elements are placed after their neighbours (the report says so). Files the merge does not touch stay byte for byte as you wrote them, comments included; files it changes are written in the canonical form.

After a merge the base is the server’s version, so course diff shows exactly what a push would send on top of it.

Each conflict becomes .ulams/conflicts/<element id>.md: the element as the base, your folder and the server have it, in the folder’s own syntax (a block as a directive, any other element as YAML), a unified diff, and a Resolution section that starts as your version. course status lists the open conflicts, and push and pull refuse while one is open (SYNC_CONFLICT, error.details.code is OPEN_CONFLICTS), so nothing is sent over a decision nobody made. There is no --force.

Terminal window
ulams course pull # exit 6: 1 conflict, .ulams/conflicts/01j9z8aaaa....md
$EDITOR .ulams/conflicts/01j9z8aaaaaaaaaaaaaaaaaaaa.md # optional: combine the two in the Resolution section
ulams course resolve 01j9z8aaaaaaaaaaaaaaaaaaaa --take file
ulams course validate && ulams course push --apply
--take Does
local Keeps your version (the folder already has it) and deletes the conflict file.
remote Replaces the element, and what is inside it, with the server’s version (or removes it, when the server removed it).
file Reads the Resolution section of the conflict file: a block as a directive, any other element as YAML, or the single word (removed). The element’s id cannot change.

resolve validates the folder it would write and refuses with the validator’s report (exit 7) when the resolution breaks it, leaving the conflict in place. --dry-run lists the files that would change.

When the folder’s base is not the server’s current version, the server merges for you. Changes that do not overlap become one proposed version on top of the current one (data.merged lists which elements came from your push and which from the server). Run course pull after it is approved to bring the server’s side into the folder. When the same elements changed on both sides the server stores nothing and answers BASE_OUTDATED; the CLI turns it into SYNC_CONFLICT (exit 6) with error.details.conflicts (element, kind, label, the conflicting fields with base, yours and the server’s value) and without changing a file: run course pull to write them as conflict files.

An admin who edits a title, a lesson’s text or a question in the LMS after an apply changes what learners see but not the blueprint, so the next pull would not show it and the next apply would not know. course status reports such edits (LMS edits: ...), and course absorb-drift reads them back into a proposed version (kind author) that you review and approve like any push. Nothing is applied and nothing is approved on its own.

Terminal window
ulams course absorb-drift --preview # what would be read back, and what cannot be
ulams course absorb-drift # store it as a proposal, remembered in .ulams/proposal.json
ulams course diff --version <id> # review it
ulams course apply --approve # a person approves; the same values are written back
ulams course pull # the folder takes the edits (a merge, like any other)

A field is read back only where the blueprint still holds what was last applied. These come back: the course title, subtitle and description; module and lesson titles and summaries; the Markdown of a lesson (block by block, the blocks become origin: author); question wording, option texts and the explanation. These are listed as unmapped and the blueprint keeps its value: text with HTML from the visual editor, paragraphs added, removed or merged, a changed correct answer, added or removed options, quiz titles, the landing page, and anything the blueprint changed too (resolve those in the studio). Approving a version made this way allows exactly one overwrite: course apply passes overwrite only when every drifted element is one the absorption took its edits from; anything else stays refused until you pass --overwrite yourself.

File Commit it? What it holds
ulams.yaml yes The binding: course.id and course.session. Never a token.
.ulams/base.json yes The version the folder is based on and a SHA-256 per element (never a copy of the course text, so it is small and safe to review). push moves it when a version equal to the folder is approved, pull when the server moves.
.ulams/proposal.json no (ignored by .ulams/.gitignore) The version your last push (or absorb-drift) proposed and nobody approved yet, so apply knows what to approve.
.ulams/conflicts/*.md no (they exist only while a merge is unsettled; resolve deletes them) One file per open conflict (see above).

Credentials come from ulams login or ULAMS_URL and ULAMS_TOKEN (in CI), never from the folder.

A course repository can hold the course (modules/, pushed as a course version) and the documents the course is built from (sources/, watched by Living Course). A merged change to sources/ becomes an update proposal; a merged change to modules/ never does.

Terminal window
cd my-course-repo # the clone; the course folder is inside it
ulams course sources-connect course/ # origin remote + default branch -> a Living Course git source on sources/**

The command reads the origin remote and the default branch (github.com and gitlab.com are recognised; pass --host gitlab|gitea for any other server, Forgejo included), connects the repository to the folder’s builder session with paths: ["sources/**"] and prints the webhook address and the webhook secret once. Add both to the repository’s webhook settings (content type JSON, push events). For a private repository pass --token or set ULAMS_SOURCES_TOKEN: a read-only access token, stored encrypted on the server. The repository must already hold a file under sources/ on that branch. --dry-run prints the request with the token masked.

When the push webhook arrives, the revision keeps the head commit, its subject line and the pull request number (read from Merge pull request #123, a squash Title (#123), GitLab’s See merge request group/project!123, Gitea and Forgejo merge messages) and the proposal shows it (“from PR #123: Rename the –namespace flag”). The text is shown as plain text and never sent to the model. A host that cannot reach the academy with a webhook can report the merge from CI instead:

Terminal window
ulams living connections check <connection> --commit "$GITHUB_SHA" # records the commit on the new revision

The loop does not run twice: an applied update proposal is pulled into Git as a pull request; merging it pushes a document equal to the current version, which the server answers with unchanged (no version, no new proposal). A sync pull request never touches sources/.

ulams course init --ci github also writes .github/workflows/ulams.yml at the root of the repository around the folder (it refuses to overwrite one). It uses the course action of this repository, ulams-dev/ulams/actions/course (action.yml and the tested entrypoint entrypoint.mjs), which runs the CLI from the image ghcr.io/ulams-dev/ulams-cli, so the Node version of the runner does not matter. Set the repository secrets ULAMS_URL and ULAMS_TOKEN (a ci token).

Trigger What the workflow does
Pull request validate (SARIF for code scanning, so issues show inline), diff against the server in the job summary, preview: proposes the folder as a version (never approves) and keeps one pull request comment up to date. A fork has no secrets, so only validate runs
Push to the default branch push: proposes the merged course as a version; add apply: true only when the academy lets ci tokens approve (course_as_code.ci_may_approve), otherwise a person approves it in the studio
Hourly, manual, repository_dispatch ulams-course-changed pull-pr: course pull; when files changed, opens or updates the pull request ulams/sync (never stages sources/). A conflict fails the job with the conflict list

The action sets ULAMS_COMMIT and ULAMS_CHANGE_URL, which the CLI sends as X-Ulams-Commit and X-Ulams-Change-Url; the audit event of the import carries them. Studio changes reach Git through the hourly pull; the outgoing webhook course.version_applied (signed, see outgoing webhooks) fires once per release, for a relay you run yourself (GitHub’s repository_dispatch needs a GitHub token in the Authorization header, which a signed webhook cannot carry). Merging the sync pull request pushes the same content back, which the server answers with unchanged.

The image (front/cli/Dockerfile, build the bundle first with yarn workspace ulams build) holds the CLI, git and production dependencies, runs as the non-root user ulams and is about 290 MB (the plan’s 80 MB target was not reached: the MCP SDK and the Node base image dominate). Nothing is published yet; the release workflow (milestone M6-a) pushes it. The repository’s own check is .github/workflows/course-action-test.yml.

Add --json (or ULAMS_OUTPUT=json) for the usual envelope: ok, data, error, warnings. Without it a terminal gets text.

Terminal window
ulams course status --json | jq '.data.next'
ulams course push --message "$GITHUB_SHA" --json # data.version.id, data.counts, data.changes[]
ulams course diff --exit-code --json # exit 13 when the folder drifted from its base
Exit Code When
0 Done (also: nothing to push, already up to date)
2 INPUT_INVALID Not a course folder, no .ulams/base.json, a folder that is not empty for init
3 AUTH_REQUIRED, AUTH_EXPIRED Not logged in, or the token was rejected
4 FORBIDDEN, SCOPE_MISSING Not allowed; approving as an agent token or MCP client (error.details.code is APPROVAL_REQUIRES_HUMAN, and for push error.details.proposed names the version that was proposed)
5 NOT_FOUND Unknown course or version
6 SYNC_CONFLICT, CONFLICT Both sides changed the same elements (BASE_OUTDATED on push, data.conflicts on pull), an open update proposal changes the same elements (PROPOSAL_PENDING, error.details.proposals), conflict files are still open (OPEN_CONFLICTS), the proposal went stale (STALE_PROPOSAL), blocking publish items, a course without a builder session
7 VALIDATION_FAILED The folder has errors (error.details.issues with file, line, column), or the server rejected the course (error.details.errors)
9 NETWORK, SERVER_ERROR The academy is unreachable or failed; nothing in the folder changed
10 TIMEOUT The apply is still running after --timeout; it continues on the server
11 CONFIRMATION_REQUIRED Applying an unapproved proposal without --approve; publish warnings not acknowledged
13 DIFF_FOUND diff --exit-code found differences

Apply finishes asynchronously on the server. The CLI waits by polling the course (appliedVersionId), so it also works with AI switched off; with --no-wait it returns the run handle (meta.operation).

Terminal window
ulams course validate # the folder you are in
ulams course validate ./kubernetes-101 # or give its path
modules/01-basics/01-install.md:17:1 warning UNCITED_AUTHOR_BLOCK This author-written block cites no source.
hint: Living Course cannot keep an uncited block up to date. Add cite="frg_..." when a source exists, or set lint.uncitedAuthorBlocks in ulams.yaml.
modules/01-basics/02-pods.md:23:14 error DIRECTIVE_ATTR_INVALID "frg_nope" is not a fragment id (frg_ and 12 characters a-z, 2-7).
hint: Ids are 26 lowercase letters and digits; cite takes frg_ ids; origin is ai or author.
1 error, 1 warning, 0 notes in 10 files

Every issue has a code, a severity (error, warning or info, shown as a note), the file, the line and the column, and a hint. The codes are listed in the format reference. It checks, in this order:

  1. every YAML file and front matter against its schema, with the position of the offending key;
  2. the directive grammar of the lesson files (unclosed or unknown blocks and attributes, bad ids);
  3. the folder as a Blueprint v3 document, against the course-blueprint/v3.json schema the CLI bundles;
  4. the deterministic checks the server runs (markup, question shape, objectives, id uniqueness, assets and their hashes, the citation rule).

Checks that need a server (do the cited fragments exist?) are not part of this command; course push validates the folder first and the server then checks the citations.

Flag Effect
--strict Warnings fail too.
--fix Applies what course fmt does first (ids, loose Markdown, prefixes, asset hashes), then validates.
--format text The output above. Default in a terminal.
--format json or --json The usual envelope: data.valid, data.summary (errors, warnings, infos), data.issues[]. With errors the envelope is an error (VALIDATION_FAILED) and error.details.issues holds the list.
--format sarif SARIF 2.1.0 on stdout, or in the file given with --out (the terminal then gets the text report).

Exit codes: 0 when there are no errors (and no warnings with --strict), 7 (VALIDATION_FAILED) otherwise, 2 for a usage mistake such as a path that is not a folder.

SARIF lets GitHub show the issues inline on the pull request. A minimal workflow, before the dedicated action ships (it assumes the ulams CLI is installed on the runner: npm install --global ulams once the package is published, a build of front/cli until then):

.github/workflows/course.yml
name: Course
on: pull_request
permissions: { contents: read, security-events: write }
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- run: ulams course validate --format sarif --out ulams.sarif
continue-on-error: true
- uses: github/codeql-action/upload-sarif@v4
with: { sarif_file: ulams.sarif }
- run: ulams course validate --strict
Terminal window
ulams course fmt # rewrite the files in place
ulams course fmt --check # change nothing; exit 13 when files would change

fmt writes the canonical form: YAML keys in a fixed order with comments kept, ids minted for elements that have none, loose Markdown wrapped in author paragraphs, directives printed in one form, module and lesson prefixes renumbered (01-, 02-, …) and asset hashes filled. Running it again changes nothing. It prints the files it changed (data.changed). When a file has a syntax error, fmt writes nothing and reports the error like validate does (exit 7); fix it first.

Use fmt --check in CI to keep a folder formatted, and fmt in a pre-commit hook:

Terminal window
# .husky/pre-commit, or any hook runner
ulams course fmt && git add -A courses/

Adopting a course that was not made with the builder, downloading assets (pull --assets), SCORM, video and file lessons, preview academies are later milestones of the course-as-code plan.