← Back to registry

tg-cli knowledge

Local-first Telegram sync, search, and export via MTProto

tg is a CLI for Telegram that syncs messages into a local SQLite database via MTProto. Search, analyze, and export your Telegram conversations — all locally and offline-capable.

Features

Install

uv: uv tool install kabi-tg-cli
pipx: pipx install kabi-tg-cli

Commands

CommandSyntaxDescription
refresh tg refresh Refresh all current dialogs
sync tg sync <chat_name> Sync a specific chat's messages
search tg search <keyword> Full-text search across synced messages
recent tg recent --hours 24 --limit 20 View recent messages within a time window
today tg today --sync-first View today's messages with optional sync
export tg export <chat_name> -f yaml -o messages.yaml Export messages to file
send tg send <chat_name> <message> Send a message to a chat

Links

Agent Usage Example

Use cases:

Example workflow:

tg refresh && tg search 'meeting' --hours 48 --yaml