Management commands
Kosmos's own manage.py commands, grouped by the app that defines
them. Run one with python manage.py <command>, and add --help to
see its arguments.
Which of these an operator needs, and when, is covered in
Background worker.
accounting
| Command |
What it does |
compare_quickbooks |
Compare the ledger's trial balance with a QuickBooks Trial Balance export. |
import_quickbooks |
Import the chart of accounts and the journal from QuickBooks Online exports. |
migrate |
Django's migrate, after relabelling the applied migrations and content types of the Books app as accounting (a no-op once done). |
seed_chart |
Add the default chart of accounts for a law firm. Accounts whose code already exists are left alone, so the command is safe to repeat. |
accounts
| Command |
What it does |
reset_authenticator |
Remove a user's authenticator app, by email address, for when the phone is lost and no administrator can reset it from Settings > Users. The user gets the emailed code at their next sign-in. |
ai
| Command |
What it does |
purge_closed_chats |
Delete AI chat history (conversations, messages and their history rows) for matters closed longer than the retention window. Chats are working notes with no lasting value once a matter closes; the client file lives in the firm's file store and Gmail. Scheduled weekly by setup_schedules. |
calendar
| Command |
What it does |
send_event_reminders |
Sends the event notifications that have come due, by email or ntfy. |
case
| Command |
What it does |
backfill_ocr |
Queue OCR processing for all existing PDF documents that have not been processed |
build_semantic_index |
Embed matter materials for semantic search |
cleanup_orphan_documents |
List document records whose files are missing from storage, and with --apply delete them (and their highlights). Reports only by default. |
dedupe_documents |
Delete duplicate documents (same matter) that have no highlights or references |
fingerprint_documents |
Compute content fingerprints for documents that lack them |
fix_document_paths |
Fix document file paths from old naming format to current convention |
purge_unannotated_documents |
Delete documents that have no highlight, fact, note or promoted email, with their stored files. Dry run unless --apply is given. |
setup_chat_purge_schedule |
Create or update the weekly chat-purge schedule (Sunday 03:00 local): deletes AI chat history for matters closed past the retention window. Superseded by setup_schedules, which installs this with every other schedule. |
update_search_vectors |
Update search vectors for all documents and highlights |
| Command |
What it does |
adopt_google_contacts |
Give the former firm-wide Google Contacts token (GOOGLE_DATA_DIR/contact_tokens.json) and the contacts copied through it to one user. |
intakes
| Command |
What it does |
clean_intake_notes |
List intake notes whose intake is gone, and with --apply delete them. Reports only by default. |
seed_intake_forms |
Create the starter intake form templates: example questionnaires from one firm's practice. Review and edit them before use. |
invoicing
| Command |
What it does |
confido_check |
Read-only pre-flight check for the Confido processor (no charge). |
generate_invoice_pdfs |
Generate and store PDFs for existing invoices |
lawpay_accounts |
List LawPay/AffiniPay merchant deposit accounts (operating vs trust). |
reconcile_pending |
Poll the processor for in-flight online payments and trust deposits and settle, confirm, or reverse them (missed-webhook backstop). |
mail
| Command |
What it does |
adopt_gmail_account |
One-time multi-account migration: turn the legacy shared token file (GOOGLE_DATA_DIR/email_tokens.json) into the given user's GmailAccount, claim all existing Email rows, and backfill Email.message_id (the cross-mailbox dedupe key) from Gmail. Run BEFORE anyone else connects a mailbox. |
link_gmail_labels |
Link Gmail labels to Matter records by setting Matter.gmail_label_name (the cross-mailbox contract). Interactive; suggests matches by name. Labels are read from the first connected mailbox. |
refresh_email_bodies |
Refetch synced emails that have no stored HTML body (one-off backfill after the body_html field was added). Rows whose message genuinely has no HTML part are refetched each run; use --matter to limit scope. |
setup_gmail_sync_schedule |
Create or update the Gmail sync schedules: an incremental history sync every 2 minutes and a weekly full re-list (early Monday) to reconcile drift the history feed can't repair. No env gate: the sync is read-only and no-ops when no Gmail account is connected. Superseded by setup_schedules, which installs these with every other schedule. |
sync_gmail |
Sync labeled Gmail messages onto their mapped matters |
management
| Command |
What it does |
clean_history |
Delete change-history records and failed worker tasks older than specified days (default: 90) |
setup_schedules |
Create or update every recurring Django-Q schedule used by Kosmos. |
tasks
| Command |
What it does |
setup_digest_schedule |
Create or update the daily digest email schedule. Superseded by setup_schedules, which installs this with every other schedule. |