Skip to main content
telegram-to-agent-skill-cli

English · Русский

CI PyPI npm License: Apache-2.0 Python 3.10+

Ask your coding agent "what did the team discuss this week?" and it actually knows.


Half of every project's real context lives in Telegram: decisions made in group chats, specs shared as files, links that never made it to the wiki. This tool gives that context to Claude Code, Codex, or any agent that can run a CLI.

The tg CLI signs in as you (MTProto via Telethon), syncs your chats into a local SQLite index with full-text search, and installs an agent skill that activates itself whenever you mention your chats. Agents read locally: instant, offline, no rate limits. The CLI touches Telegram only to sync, download files, or (after your explicit "yes") send a reply.

Agent session demo

Install

Pick any of the three. Each one ends in the interactive setup wizard, which collects API credentials, signs you in, installs the agent skill and offers the initial sync.

# with uv (recommended)
uv tool install telegram-to-agent-skill-cli && tg setup
# one-shot, no prior install
uvx --from telegram-to-agent-skill-cli tg setup
# via npm, if Node is your home turf
npx telegram-to-agent-skill-cli

Developers clone the repo and run ./install.sh (editable install, same wizard). Details: docs/INSTALL.md.

Claude Code users can also add the repo as a plugin marketplace, which installs the skill without touching the shell:

/plugin marketplace add voftik/telegram-to-agent-skill-cli
/plugin install telegram-context@telegram-to-agent-skill-cli

The CLI itself still comes from PyPI (the skill will tell you the install command if tg is missing).

Update

tg update          # checks PyPI, upgrades, refreshes the agent skill
tg update --check  # just report; agents read update.update_available from `tg status --yaml`

The CLI never phones home on its own in data commands: the passive version hint reads a local cache and prints to stderr only in interactive sessions. Set TG_UPDATE_CHECK=0 to silence it.

Why skill + CLI, not an MCP server

  • Zero context tax. MCP tool schemas eat thousands of tokens in every session. A skill loads on demand; the CLI costs nothing until used.
  • One integration, every agent. The same tg commands work in Claude Code, Codex, and anything else with a shell.
  • No session juggling. MCP servers spawn per agent session and fight over the Telethon session file. Here one sync process writes and any number of agent sessions read.

How it works

flowchart LR
    TG[("Telegram<br/>(your account, MTProto)")]
    subgraph LOCAL["Your machine"]
        SYNC["tg sync / refresh<br/><i>on demand</i>"]
        DB[("SQLite + FTS5<br/>messages · attachments · links · threads")]
        FILES["files/ + extracted text<br/>pdf · docx · xlsx · pptx"]
        QUERY["tg brief · search · thread<br/>links · files · style"]
    end
    subgraph AGENTS["Agents"]
        CC["Claude Code<br/><i>skill auto-activates</i>"]
        CX["Codex<br/><i>via AGENTS.md</i>"]
    end
    TG -->|history| SYNC --> DB
    TG -->|lazy download| FILES
    DB --> QUERY
    QUERY --> CC & CX
    FILES --> CC & CX
    CC & CX -.->|"send only with --confirm<br/>after explicit user yes"| TG

What agents can do with it

Ask in plain language What happens under the hood
"What did we discuss in the project chat?" sync, then brief picks the depth, then recent and a summary with dates and authors
"Find where they shared the pricing doc" tg links --kind gdoc returns the export URL (plain text, not a JS shell)
"Read the spec they sent as a file" tg files --download extracts text next to the file
"Reconstruct that argument about the deadline" tg thread rebuilds the reply chain, even when the root is a poll
"Draft a reply in my voice" tg style gives the agent your own messages; drafts stay dry-run until you say yes
"Digest my work chats since yesterday" the agent loops chats, collects highlights, flags what needs your reaction

Safety model

  • The Telethon session file equals full account access. It lives in a private data dir (0700/0600), never in git, never in cloud-synced folders; every machine signs in separately.
  • Every write to Telegram (send, edit, delete) is a dry-run without --confirm. Confirmed mutations land in a durable journal before the network call.
  • Untrusted attachments face budgets: size checks before download, zip-bomb guards, streaming hashes, private file modes.
  • Use your own api_id and api_hash. The tool syncs politely (delays, jitter, FloodWait handling) and reads locally.

What the fork adds over upstream tg-cli

Area upstream this fork
Attachments not stored indexed at sync, lazy download, text extraction (pdf/docx/xlsx/pptx/csv)
Links not extracted tg links with agent-fetchable fetch_url, structural URL parsing
Threads none tg thread, resilient to unsynced roots, t.me link support
Search LIKE scan FTS5 with Unicode-correct fallback and gap-safe regex paging
Sync integrity best effort gap-safe cursors, tg backfill, honest per-chat reports
Identity bare IDs collide marked peer IDs end-to-end with lazy migration
First sync manual tg bootstrap: survives reboots, removes itself when done
Send safety sends immediately dry-run by default, --confirm, mutation journal
Agent integration a doc file packaged skill, setup wizard, self-update, auto-activation

Credits

A fork of jackwener/tg-cli (Apache-2.0): the clean local-first core is theirs. Built on Telethon. License: Apache-2.0.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

telegram_to_agent_skill_cli-0.7.0.tar.gz (558.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

telegram_to_agent_skill_cli-0.7.0-py3-none-any.whl (79.5 kB view details)

Uploaded Python 3

File details

Details for the file telegram_to_agent_skill_cli-0.7.0.tar.gz.

File metadata

File hashes

Hashes for telegram_to_agent_skill_cli-0.7.0.tar.gz
Algorithm Hash digest
SHA256 9434ed619fcd963794176b812c6c2c7d194692f18c28e974b2fd94a9a3784d70
MD5 a212b0ad238b8b67acde1c7c829a846e
BLAKE2b-256 f6befd14eac9d08ddeca1955e2af3e929ed5420bffe53df6f6939fee7c3ecf22

See more details on using hashes here.

Provenance

The following attestation bundles were made for telegram_to_agent_skill_cli-0.7.0.tar.gz:

Publisher: release.yml on voftik/telegram-to-agent-skill-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file telegram_to_agent_skill_cli-0.7.0-py3-none-any.whl.

File metadata

File hashes

Hashes for telegram_to_agent_skill_cli-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 649ad151f2dc897e82fc391e8958d63e3ed6ecfafa48e2ead3bdda516ea2d41b
MD5 73a610ac2cf9756352ec1dfd482774ce
BLAKE2b-256 1121e52bf2aaca323aca242b535e81af89a4c7b83333d9f9a381a8bfd9760af3

See more details on using hashes here.

Provenance

The following attestation bundles were made for telegram_to_agent_skill_cli-0.7.0-py3-none-any.whl:

Publisher: release.yml on voftik/telegram-to-agent-skill-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.8.0

2 files

This release

0.7.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page