# The learn command

> Courses, lessons, exercises, checks and progress from your terminal, and the tools for authors.

Applies to: the Sypnia engine (open source, self-hosted) and Sypnia Cloud (paid service).  
Source: https://learn.docs.sypnia.com/tools/cli/

For agents: npx @sypnia/learn <command> (learn after npm i -g @sypnia/learn); signed in with the shared session (npx @sypnia/app login; --server for an engine). Learners: courses, course <id>, next, lesson <id> [--level] [--lang], start <lesson> [--project <ref>] [--path <dir>], check [--watch], hint, status, finish --keep|--drop, explain <file[:lines]>|--case|--trace|--problem, progress [--json], progress export|delete. Authors: lint <dir>, preview <lesson> [--level] [--project sample|<ref>] [--lang], courses add <dir> [--org], courses remove <id>. Flags --json, --org. Exit codes: 0 ok, 1 error, 2 usage, 3 not signed in, 4 forbidden, 5 checks failed.

```bash
npx @sypnia/learn next
```

It uses the session of `npx @sypnia/app login`, shared by every Sypnia command line. With your own engine, sign in once with `npx @sypnia/learn login --server <url>`.

## For learners

| Command                                                                         | Does                                                                                                               |
| ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| `learn courses`, `learn course <id>`                                            | the courses, and one course with your progress                                                                     |
| `learn next`                                                                    | the next lesson of your path                                                                                       |
| `learn lesson <id> [--level] [--lang]`                                          | read a lesson in the terminal                                                                                      |
| `learn start <lesson> [--project <ref>] [--path <dir>]`                         | start its exercise: the branch and `LEARN.md`; `--project` defaults to the `project` of the folder's `sypnia.toml` |
| `learn check [--watch]`                                                         | run the checks on your last commit; `--watch` checks on every commit                                               |
| `learn hint`                                                                    | one hint, at your level                                                                                            |
| `learn status`                                                                  | the exercise you are on and its last results                                                                       |
| `learn finish --keep` \| `--drop`                                               | keep the branch with a pull request, or delete it                                                                  |
| `learn explain <file[:lines]>`, `--case <id>`, `--trace <id>`, `--problem <id>` | an explanation at your level                                                                                       |
| `learn progress [--json]`                                                       | what you have done                                                                                                 |
| `learn progress export`, `learn progress delete`                                | download, or delete, all your progress                                                                             |

## For authors

| Command                                                               | Does                                                                                                |
| --------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- |
| `learn lint <dir>`                                                    | check a course folder against [the format](https://learn.docs.sypnia.com/lessons/the-lesson-format) |
| `learn preview <lesson> [--level] [--project sample\|<ref>] [--lang]` | the lesson as one learner would see it                                                              |
| `learn courses add <dir> [--org <org>]`                               | publish a course, or a new version of it                                                            |
| `learn courses remove <id>`                                           | take a course down; learners keep their progress                                                    |

## Exit codes

| Code | Meaning                                 |
| ---- | --------------------------------------- |
| 0    | done                                    |
| 1    | an error                                |
| 2    | wrong use of the command                |
| 3    | not signed in                           |
| 4    | not allowed                             |
| 5    | the checks ran, and at least one failed |
