English · Русский
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.
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
tgcommands 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_idandapi_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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file telegram_to_agent_skill_cli-0.7.0.tar.gz.
File metadata
- Download URL: telegram_to_agent_skill_cli-0.7.0.tar.gz
- Upload date:
- Size: 558.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9434ed619fcd963794176b812c6c2c7d194692f18c28e974b2fd94a9a3784d70
|
|
| MD5 |
a212b0ad238b8b67acde1c7c829a846e
|
|
| BLAKE2b-256 |
f6befd14eac9d08ddeca1955e2af3e929ed5420bffe53df6f6939fee7c3ecf22
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
telegram_to_agent_skill_cli-0.7.0.tar.gz -
Subject digest:
9434ed619fcd963794176b812c6c2c7d194692f18c28e974b2fd94a9a3784d70 - Sigstore transparency entry: 2495027941
- Sigstore integration time:
-
Permalink:
voftik/telegram-to-agent-skill-cli@8db962105384ad93f4170909d89651c2a97d23f8 -
Branch / Tag:
refs/tags/v0.7.0 - Owner: https://github.com/voftik
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8db962105384ad93f4170909d89651c2a97d23f8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file telegram_to_agent_skill_cli-0.7.0-py3-none-any.whl.
File metadata
- Download URL: telegram_to_agent_skill_cli-0.7.0-py3-none-any.whl
- Upload date:
- Size: 79.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
649ad151f2dc897e82fc391e8958d63e3ed6ecfafa48e2ead3bdda516ea2d41b
|
|
| MD5 |
73a610ac2cf9756352ec1dfd482774ce
|
|
| BLAKE2b-256 |
1121e52bf2aaca323aca242b535e81af89a4c7b83333d9f9a381a8bfd9760af3
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
telegram_to_agent_skill_cli-0.7.0-py3-none-any.whl -
Subject digest:
649ad151f2dc897e82fc391e8958d63e3ed6ecfafa48e2ead3bdda516ea2d41b - Sigstore transparency entry: 2495027978
- Sigstore integration time:
-
Permalink:
voftik/telegram-to-agent-skill-cli@8db962105384ad93f4170909d89651c2a97d23f8 -
Branch / Tag:
refs/tags/v0.7.0 - Owner: https://github.com/voftik
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8db962105384ad93f4170909d89651c2a97d23f8 -
Trigger Event:
push
-
Statement type: