Skip to content

Command line

docker compose exec backend python -m app.cli <command>

Eleven commands, and that is all of them — an unknown one prints the list and exits 1.

People

docker compose exec backend python -m app.cli list-users
docker compose exec backend python -m app.cli set-role user@example.com moderator
docker compose exec backend python -m app.cli verify-email user@example.com
docker compose exec backend python -m app.cli delete-user user@example.com   # asks first
docker compose exec backend python -m app.cli export-users > users.csv

set-role takes admin, moderator or user. Note that with SSO role mapping on, a role set here is overwritten at that person's next sign-in — the API endpoints refuse for exactly that reason, and this command does not. Change the group at the provider instead.

Documents

docker compose exec backend python -m app.cli list-docs
docker compose exec backend python -m app.cli fix-stuck-docs
docker compose exec backend python -m app.cli reprocess-doc 32

fix-stuck-docs resets documents that have been processing for more than 30 minutes back to ready. Why they get stuck: if the Celery worker restarts while it is reading a PDF, the task is lost and the document stays at processing for ever, because nothing was watching for the task to come back.

Quizzes

docker compose exec backend python -m app.cli list-quizzes
docker compose exec backend python -m app.cli list-quizzes --all   # including deleted

Maintenance

docker compose exec backend python -m app.cli stats
docker compose exec backend python -m app.cli cleanup-redis
docker compose exec backend python -m app.cli check-links

cleanup-redis removes orphaned keys — quiz progress left with no expiry.

check-links checks every cross-reference, key point, plan block, card and reading link, and exits non-zero if it finds anything, which makes it usable from cron or CI. What it considers broken is in The link checker.

The other script

backend/manage.py is a separate, older helper, used for the extraction and embedding work:

docker compose exec backend python manage.py list-users
docker compose exec backend python manage.py list-sections
docker compose exec backend python manage.py extract 6 --bg
docker compose exec backend python manage.py reembed

It also still carries a reset_password function. It is vestigial: there is no password sign-in, so a password it sets cannot be used for anything.

Management scripts

A number of one-off and periodic jobs live as modules under backend/scripts/ and are run by hand:

docker compose exec backend python -m scripts.classify_unfiled_questions
docker compose exec backend python -m scripts.assign_category_systems
docker compose exec backend python -m scripts.sanitize_tags
docker compose exec backend python -m scripts.generate_articles

generate_articles is the resumable batch article writer — see Drafting with AI. The classification scripts are how tagging is actually run.